From c1064e4ee88d1bac569f7e65a36a801017476f31 Mon Sep 17 00:00:00 2001 From: ppvan Date: Mon, 17 Feb 2025 21:35:21 +0700 Subject: [PATCH 1/2] fix: ignore .vscode file --- .gitignore | 2 ++ .vscode/launch.json | 17 ----------------- .vscode/tasks.json | 18 ------------------ 3 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index afb9e55..a3ce7c5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ subprojects/* *.flatpak *.dot io.github.ppvan.tarug.flatpak + +.vscode/* diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 664e7a4..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - // Debug with CoreLLDB extension - "version": "0.2.0", - "configurations": [ - { - "type": "lldb", - "request": "launch", - "name": "Launch", - "program": "${workspaceFolder}/build/src/${workspaceFolderBasename}", - "cwd": "${workspaceFolder}", - "preLaunchTask": "Compile" - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 51dc160..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "Meson (Flatpak): Run Unit test", - "type": "shell", - "options": { - // Match meson buildPath - "cwd": "${workspaceFolder}/_build" - }, - "group": "test", - // mesonbuild.mesonPath - "command": "${workspaceFolder}/.flatpak/meson.sh test", - } - ] -} \ No newline at end of file From f3e9b2f24a2cb3d0fa8a02edeeeff23c3973a260 Mon Sep 17 00:00:00 2001 From: ppvan Date: Wed, 19 Feb 2025 23:54:14 +0700 Subject: [PATCH 2/2] feat: stop rely on vscode extension, just good old cli --- CONTRIBUTING.md | 38 +++--------- Makefile | 116 +++++++++++++++++++++++++++++++++++ scripts/blueprint-compiler | 5 ++ scripts/meson | 5 ++ scripts/vala-language-server | 7 +++ 5 files changed, 140 insertions(+), 31 deletions(-) create mode 100644 Makefile create mode 100755 scripts/blueprint-compiler create mode 100755 scripts/meson create mode 100755 scripts/vala-language-server diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7eb1e65..82c7155 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,40 +24,16 @@ I often use the dvdrental sample db when develop and test tarug. ### 3. Build Tarug -- Install Flatpak Intergration for VScode [extension](https://github.com/bilelmoussaoui/flatpak-vscode) -- Open VScode commmand prompt (Ctr+Shift+P/Cmd+Shift+P) type: "Flatpak: Select or change manifest", make sure it's io.github.ppvan.tarug -- Open the prompt again and type "Flatpak: Build and Run" -- Start patching!! - - -### 4. Trouble shooting - -If you got error something like: `org.gnome.Sdk/*unspecified*/47 not installed`. Install required runtime and sdk. - -```sh -flatpak install flathub org.gnome.Platform//47 org.gnome.Sdk//47 org.freedesktop.Sdk.Extension.vala//24.08 ``` - -If you do not see syntax hightlight or meson error, check your local .vscode setting:: `.vscode/settings.json`. It should be update by the flatpak extension to something like: - -```json -{ - "mesonbuild.configureOnOpen": false, - "files.watcherExclude": { - "**/.git/objects/**": true, - "**/.git/subtree-cache/**": true, - "**/.hg/store/**": true, - ".flatpak/**": true, - "_build/**": true - }, - "mesonbuild.mesonPath": "${workspaceFolder}/.flatpak/meson.sh", - "vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh", - "mesonbuild.buildFolder": "_build", - "C_Cpp.default.compileCommands": "/home/ppvan/Documents/code/github/tarug/_build/compile_commands.json", - "C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild" -} +make build run ``` +> If you got error something like: `org.gnome.Sdk/*unspecified*/47 not installed`. Install required runtime and sdk. + ```sh + flatpak install flathub org.gnome.Platform//47 org.gnome.Sdk//47 org.freedesktop.Sdk.Extension.vala//24.08 + ``` + +Try edit `resources/gtk/connection-view.blp:200` label from "Connect with Tarug" to "Hello world". Build the project again to see the change ## Project structure diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a4339fe --- /dev/null +++ b/Makefile @@ -0,0 +1,116 @@ +# Directories +FLATPAK_DIR := .flatpak +BUILD_DIR := build +REPO_DIR := $(FLATPAK_DIR)/repo +STATE_DIR := $(FLATPAK_DIR)/flatpak-builder +BUNDLE_DIR := $(FLATPAK_DIR)/finalized-repo + +# Application info +APP_ID := io.github.ppvan.tarug +MANIFEST := pkgs/flatpak/$(APP_ID).yml +SDK := org.gnome.Sdk +PLATFORM := org.gnome.Platform +VERSION := 47 + +# Common builder flags +BUILDER_FLAGS := --ccache \ + --force-clean \ + --disable-updates \ + --state-dir=$(STATE_DIR) \ + --stop-at=tarug + + +# Run flatpak app without install, a lot of hack since flatpak not realy support this (wtf?) +# Reference: https://github.com/flatpak/flatpak/issues/408 +RUNNER_FLAGS := --with-appdir \ + --allow=devel \ + --env=AT_SPI_BUS_ADDRESS=unix:path=/run/flatpak/at-spi-bus \ + --env=DESKTOP_SESSION=$(DESKTOP_SESSION) \ + --env=LANG=$(LANG) \ + --env=WAYLAND_DISPLAY=$(WAYLAND_DISPLAY) \ + --env=XDG_CURRENT_DESKTOP=$(XDG_CURRENT_DESKTOP) \ + --env=XDG_SESSION_DESKTOP=$(XDG_SESSION_DESKTOP) \ + --env=XDG_SESSION_TYPE=$(XDG_SESSION_TYPE) \ + --bind-mount=/run/host/fonts=/usr/share/fonts \ + --bind-mount=/run/host/fonts-cache=/var/cache/fontconfig \ + --bind-mount=/run/host/user-fonts-cache=$(HOME)/.cache/fontconfig \ + --bind-mount=/run/host/font-dirs.xml=$(HOME)/.cache/font-dirs.xml \ + --bind-mount=/run/flatpak/at-spi-bus=/run/user/1000/at-spi/bus \ + --filesystem=$(HOME)/.local/share/fonts:ro \ + --filesystem=$(HOME)/.cache/fontconfig:ro \ + --share=network \ + --share=ipc \ + --socket=fallback-x11 \ + --socket=wayland \ + --talk-name="org.freedesktop.portal.*" \ + --talk-name=org.a11y.Bus \ + --device=dri + +init: + flatpak build-init $(REPO_DIR) $(APP_ID) $(SDK) $(PLATFORM) $(VERSION) + +download: + flatpak-builder \ + $(BUILDER_FLAGS) \ + --download-only \ + $(REPO_DIR) \ + $(MANIFEST) + +build-deps: download + flatpak-builder \ + $(BUILDER_FLAGS) \ + --disable-download \ + --build-only \ + --keep-build-dirs \ + $(REPO_DIR) \ + $(MANIFEST) + +configure: build-deps + flatpak build \ + --share=network \ + --filesystem=$(PWD) \ + --filesystem=$(PWD)/$(REPO_DIR) \ + --filesystem=$(PWD)/$(BUILD_DIR) \ + $(REPO_DIR) \ + meson setup $(BUILD_DIR) + +build: configure + flatpak build \ + --share=network \ + --filesystem=$(PWD) \ + --filesystem=$(PWD)/$(REPO_DIR) \ + --filesystem=$(PWD)/$(BUILD_DIR) \ + $(REPO_DIR) \ + ninja -C $(BUILD_DIR) + +install: build + flatpak build \ + --share=network \ + --filesystem=$(PWD) \ + --filesystem=$(PWD)/$(REPO_DIR) \ + --filesystem=$(PWD)/$(BUILD_DIR) \ + $(REPO_DIR) \ + ninja -C $(BUILD_DIR) install + +run: install + flatpak build \ + $(RUNNER_FLAGS) \ + $(REPO_DIR) tarug + +bundle: build + cp -r $(REPO_DIR) $(BUNDLE_DIR) + flatpak build-export $(FLATPAK_DIR)/ostree-repo $(BUNDLE_DIR) + flatpak build-bundle $(FLATPAK_DIR)/ostree-repo $(APP_ID).flatpak $(APP_ID) + +lsp: + flatpak build $(RUNNER_FLAGS) $(REPO_DIR) /usr/lib/sdk/vala/bin/vala-language-server + +meson: + flatpak build $(RUNNER_FLAGS) $(REPO_DIR) /usr/bin/meson + +test: + flatpak build $(RUNNER_FLAGS) $(REPO_DIR) /usr/bin/meson test -C $(BUILD_DIR) + +clean: + rm -rf $(BUILD_DIR) + rm -rf $(REPO_DIR) \ No newline at end of file diff --git a/scripts/blueprint-compiler b/scripts/blueprint-compiler new file mode 100755 index 0000000..83ef388 --- /dev/null +++ b/scripts/blueprint-compiler @@ -0,0 +1,5 @@ +#!/usr/bin/bash + +SCRIPT_PATH="$(dirname -- "${BASH_SOURCE[0]}")" + +flatpak build --with-appdir --allow=devel "${SCRIPT_PATH}"/../.flatpak/repo /app/bin/blueprint-compiler "$@" \ No newline at end of file diff --git a/scripts/meson b/scripts/meson new file mode 100755 index 0000000..844b657 --- /dev/null +++ b/scripts/meson @@ -0,0 +1,5 @@ +#!/usr/bin/bash + +SCRIPT_PATH="$(dirname -- "${BASH_SOURCE[0]}")" + +flatpak build --with-appdir --allow=devel "${SCRIPT_PATH}"/../.flatpak/repo /usr/bin/meson "$@" \ No newline at end of file diff --git a/scripts/vala-language-server b/scripts/vala-language-server new file mode 100755 index 0000000..5bde7a0 --- /dev/null +++ b/scripts/vala-language-server @@ -0,0 +1,7 @@ +#!/usr/bin/bash + +# Change your editor language-server-path to this script to get better intellisense. + +SCRIPT_PATH="$(dirname -- "${BASH_SOURCE[0]}")" + +flatpak build --with-appdir --allow=devel "${SCRIPT_PATH}"/../.flatpak/repo /usr/lib/sdk/vala/bin/vala-language-server "$@" \ No newline at end of file