Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 7 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
116 changes: 116 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions scripts/blueprint-compiler
Original file line number Diff line number Diff line change
@@ -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 "$@"
5 changes: 5 additions & 0 deletions scripts/meson
Original file line number Diff line number Diff line change
@@ -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 "$@"
7 changes: 7 additions & 0 deletions scripts/vala-language-server
Original file line number Diff line number Diff line change
@@ -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 "$@"