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
4 changes: 2 additions & 2 deletions rust-relm4/.github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
Expand All @@ -24,7 +24,7 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
Expand Down
2 changes: 1 addition & 1 deletion rust-relm4/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/vendor
/.vscode
.flatpak-builder/
.direnv
.direnv
22 changes: 11 additions & 11 deletions rust-relm4/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rust-relm4/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "gtk-rust-template"
name = "#project-name#"
version = "0.1.0"
edition = "2024"
license = "MIT OR Apache-2.0"
Expand All @@ -18,4 +18,3 @@ relm4 = { version = "0.10.0", features = ["libadwaita", "gnome_48"] }
relm4-components = "0.10.0"
tracing = "0.1.41"
tracing-subscriber = "0.3"

22 changes: 1 addition & 21 deletions rust-relm4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,6 @@ by [Bleur Stack] developers.
- Gitlab CI to produce flatpak nightlies
- i18n support

## How to init a project ?

> Remove python bootstrap in favor of cli bleur tool.

The template ships a simple python script to init a project easily. It asks you a few questions and replaces & renames all the necessary files.

If you clone this repository, you can run it with:

```shell
➜ python create-project.py
Welcome to GTK Rust Template
Name: Contrast
Project Name: contrast
Application ID (e.g. org.domain.MyAwesomeApp, see: https://developer.gnome.org/ChooseApplicationID/): org.gnome.design.Contrast
Author: Bleur Developers
Email: support@bleur.net
```

A new directory named `contrast` containing the generated project

## Building the project

There are basically 2 ways of building this project.
Expand All @@ -67,7 +47,7 @@ nix build
Make sure you have `flatpak` and `flatpak-builder` installed. Then run the commands below. Replace `<application_id>` with the value you entered during project creation. Please note that these commands are just for demonstration purposes. Normally this would be handled by your IDE, such as GNOME Builder or VS Code with the Flatpak extension.

```shell
flatpak install --user org.gnome.Sdk//46 org.gnome.Platform//46 org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.llvm16//23.08
flatpak install --user org.gnome.Sdk//49 org.gnome.Platform//49 org.freedesktop.Sdk.Extension.rust-stable//25.08 org.freedesktop.Sdk.Extension.llvm21//25.08
flatpak-builder --user flatpak_app build-aux/<application_id>.Devel.json
```

Expand Down
162 changes: 162 additions & 0 deletions rust-relm4/bleur.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ name = "rust-relm4"

## Variables

[[variable]]
variable = "project-name"
default = "my-awesome-app"
message = "Project name (e.g my-awesome-app)"
pattern = "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"
pattern_error = "Project name must be kebab-case (e.g. my-awesome-app)."

[[variable]]
variable = "application-id"
default = "uz.bleur.MyAwesomeApp"
message = "Application ID (e.g. uz.bleur.MyAwesomeApp)"
pattern = "^(?:[A-Za-z][A-Za-z0-9_]*\\.)+[A-Za-z][A-Za-z0-9_-]*$"
pattern_error = "Application ID must look like org.example.MyApp (hyphens only in the last segment)."

[[variable]]
variable = "application-name"
default = "My Awesome App"
message = "Application name (e.g. My Awesome App)"

[[variable]]
variable = "website"
default = "https://bleur.uz"
Expand All @@ -25,11 +44,71 @@ message = "Who's going to be author?"

# File changes

[[change]]
placeholder = "#project-name#"
source = "Cargo.toml"
value = "@project-name@"

[[change]]
placeholder = "#project-name#"
source = "Cargo.lock"
value = "@project-name@"

[[change]]
placeholder = "#project-name#"
source = "meson.build"
value = "@project-name@"

[[change]]
placeholder = "#project-name#"
source = "data/#application-id#.desktop.in.in"
value = "@project-name@"

[[change]]
placeholder = "#project-name#"
source = "build-aux/#application-id#.Devel.json"
value = "@project-name@"

[[change]]
placeholder = "#application-name#"
source = "data/#application-id#.desktop.in.in"
value = "@application-name@"

[[change]]
placeholder = "#application-name#"
source = "data/#application-id#.metainfo.xml.in.in"
value = "@application-name@"

[[change]]
placeholder = "#application-name#"
source = "src/main.rs"
value = "@application-name@"

[[change]]
placeholder = "#application-name#"
source = "src/app.rs"
value = "@application-name@"

[[change]]
placeholder = "#application-name#"
source = "src/modals/about.rs"
value = "@application-name@"

[[change]]
placeholder = "#website#"
source = "Cargo.toml"
value = "@website@"

[[change]]
placeholder = "#website#"
source = "data/#application-id#.metainfo.xml.in.in"
value = "@website@"

[[change]]
placeholder = "#website#"
source = "src/modals/about.rs"
value = "@website@"

[[change]]
placeholder = "#author#"
source = "Cargo.toml"
Expand All @@ -40,7 +119,90 @@ placeholder = "#repository#"
source = "Cargo.toml"
value = "@repository@"

[[change]]
placeholder = "#repository#"
source = "data/#application-id#.metainfo.xml.in.in"
value = "@repository@"

[[change]]
placeholder = "#repository#"
source = "src/modals/about.rs"
value = "@repository@"

[[change]]
placeholder = "#description#"
source = "Cargo.toml"
value = "@description@"

[[change]]
placeholder = "#application-id#"
source = "meson.build"
value = "@application-id@"

[[change]]
placeholder = "#application-id#"
source = "build-aux/#application-id#.Devel.json"
value = "@application-id@"

[[change]]
placeholder = "#application-id#"
source = "po/POTFILES.in"
value = "@application-id@"

[[change]]
placeholder = "#application-path#"
source = "data/resources/resources.gresource.xml"
value = "/@application-id@/"
apply = "replaceAll:.->/"

[[change]]
placeholder = "#application-path#"
source = "data/#application-id#.gschema.xml.in"
value = "/@application-id@/"
apply = "replaceAll:.->/"

[[change]]
placeholder = "#application-path#"
source = "src/main.rs"
value = "/@application-id@/"
apply = "replaceAll:.->/"

[[change]]
placeholder = "#application-path#"
source = "src/app.rs"
value = "/@application-id@/"
apply = "replaceAll:.->/"

[[change]]
placeholder = "#project-name-alt#"
source = "build-aux/#application-id#.Devel.json"
value = "@project-name@"
apply = "replaceAll:-->_"

[[replace]]
from = "build-aux/#application-id#.Devel.json"
to = "build-aux/@application-id@.Devel.json"

[[replace]]
from = "data/icons/#application-id#-symbolic.svg"
to = "data/icons/@application-id@-symbolic.svg"

[[replace]]
from = "data/icons/#application-id#.svg"
to = "data/icons/@application-id@.svg"

[[replace]]
from = "data/icons/#application-id#.Devel.svg"
to = "data/icons/@application-id@.Devel.svg"

[[replace]]
from = "data/#application-id#.desktop.in.in"
to = "data/@application-id@.desktop.in.in"

[[replace]]
from = "data/#application-id#.gschema.xml.in"
to = "data/@application-id@.gschema.xml.in"

[[replace]]
from = "data/#application-id#.metainfo.xml.in.in"
to = "data/@application-id@.metainfo.xml.in.in"
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"id": "net.bleur.GtkRustTemplate.Devel",
"id": "#application-id#.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "47",
"runtime-version": "49",
"sdk": "org.gnome.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.rust-stable",
"org.freedesktop.Sdk.Extension.llvm18"
"org.freedesktop.Sdk.Extension.llvm21"
],
"command": "gtk-rust-template",
"command": "#project-name#",
"finish-args": [
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--device=dri",
"--env=RUST_LOG=gtk_rust_template=debug",
"--env=RUST_LOG=#project-name-alt#=debug",
"--env=G_MESSAGES_DEBUG=none",
"--env=RUST_BACKTRACE=1"
],
"build-options": {
"append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm18/bin",
"append-path": "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm21/bin",
"build-args": [
"--share=network"
],
Expand All @@ -36,7 +36,7 @@
},
"modules": [
{
"name": "gtk-rust-template",
"name": "#project-name#",
"buildsystem": "meson",
"run-tests": true,
"config-opts": [
Expand Down
26 changes: 17 additions & 9 deletions rust-relm4/build-aux/dist-vendor.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
#!/bin/sh
# Since Meson invokes this script as
# "/bin/sh .../dist-vendor.sh DIST SOURCE_ROOT" we can't rely on bash features
# "/bin/sh .../dist-vendor.sh ARG" we can't rely on bash features
set -eu
export DIST="$1"
export SOURCE_ROOT="$2"
export CARGO_HOME="$1"
export CARGO_TARGET_DIR="$2"

cd "$SOURCE_ROOT"
mkdir "$DIST"/.cargo
cd "$MESON_SOURCE_ROOT"
mkdir "$MESON_DIST_ROOT"/.cargo
# cargo-vendor-filterer can be found at https://github.com/coreos/cargo-vendor-filterer
# It is also part of the Rust SDK extension.
cargo vendor-filterer --platform=x86_64-unknown-linux-gnu --platform=aarch64-unknown-linux-gnu > "$DIST"/.cargo/config
rm -f vendor/gettext-sys/gettext-*.tar.*
cargo vendor-filterer --all-features --platform=x86_64-unknown-linux-gnu --platform=aarch64-unknown-linux-gnu > "$MESON_DIST_ROOT"/.cargo/config.toml
set -- vendor/gettext-sys/gettext-*.tar.*
TARBALL_PATH=$1
TARBALL_NAME=$(basename "$TARBALL_PATH")
rm -f "$TARBALL_PATH"
# remove the tarball from checksums
cargo_checksum='vendor/gettext-sys/.cargo-checksum.json'
tmp_f=$(mktemp --tmpdir='vendor/gettext-sys' -t)
jq -c "del(.files[\"$TARBALL_NAME\"])" "$cargo_checksum" > "$tmp_f"
mv -f "$tmp_f" "$cargo_checksum"
# Don't combine the previous and this line with a pipe because we can't catch
# errors with "set -o pipefail"
sed -i 's/^directory = ".*"/directory = "vendor"/g' "$DIST/.cargo/config"
sed -i 's/^directory = ".*"/directory = "vendor"/g' "$MESON_DIST_ROOT/.cargo/config.toml"
# Move vendor into dist tarball directory
mv vendor "$DIST"
mv vendor "$MESON_DIST_ROOT"
Loading
Loading