Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start using blueprints in kcshot #34

Merged
merged 10 commits into from
Jul 19, 2023
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
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
name: CI

env:
KCSHOT_UBUNTU_DEPS: libdbus-1-dev pkg-config libgtk-4-dev libcairo-gobject2 libcairo2-dev
KCSHOT_UBUNTU_DEPS: libdbus-1-dev pkg-config libgtk-4-dev libcairo-gobject2 libcairo2-dev meson ninja-build desktop-file-utils

permissions:
contents: read
Expand Down Expand Up @@ -69,10 +69,14 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ steps.toolchain-install.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock')}}-lint
- run: cargo cranky -h &>/dev/null || cargo install cargo-cranky
subprojects/blueprint-compiler/
builddir/
key: ${{ runner.os }}-${{ steps.toolchain-install.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock')}}-${{ hashFiles('subprojects/blueprint-compiler.wrap') }}-lint
- run: cargo cranky -h &>/dev/null || cargo install --locked cargo-cranky
- name: Configure meson
run: meson setup builddir
- name: cranky
run: cargo cranky -- -D warnings
run: KCSHOT_LINTING=1 meson devenv -C builddir cargo cranky --manifest-path=../Cargo.toml -- -D warnings
test:
runs-on: ubuntu-22.04
steps:
Expand All @@ -91,6 +95,10 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ steps.toolchain-install.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock')}}-test
subprojects/blueprint-compiler/
builddir/
key: ${{ runner.os }}-${{ steps.toolchain-install.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock')}}-${{ hashFiles('subprojects/blueprint-compiler.wrap') }}-test
- name: Configure meson
run: meson setup builddir
- name: test
run: cargo test
run: meson test --verbose -C builddir
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
screenshot*
*.db
heaptrack.kcshot-rs.*
builddir/
/subprojects/blueprint-compiler
47 changes: 23 additions & 24 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "kcshot-rs"
name = "kcshot"
version = "0.1.0"
authors = ["Mițca Dumitru <dumitru0mitca@gmail.com>"]
edition = "2021"
Expand All @@ -12,7 +12,7 @@ members = ["kcshot-data", "kcshot-screenshot"]

[workspace.dependencies]
cairo = { package = "cairo-rs", version = "0.17.0", features = ["png"] }
gtk4 = "0.6.0"
gtk4 = { version = "0.6.6", features = ["blueprint"] }
once_cell = "1.13.1"
tokio = { version = "1.25.0", features = ["rt-multi-thread"] }
tracing = "0.1.23"
Expand Down Expand Up @@ -49,7 +49,7 @@ tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
thiserror = "1.0.30"

[build-dependencies]
glib-build-tools = "0.16.0"
glib-build-tools = "0.17.0"

[features]
default = ["xdg-paths"]
Expand Down
22 changes: 4 additions & 18 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,17 @@ url="https://github.com/RealKC/$pkgname"
arch=('x86_64')
license=('custom:EUPL-1.2')
depends=('gtk4' 'sqlite' 'xdg-utils')
makedepends=('cargo' 'glib2')
makedepends=('cargo' 'glib2' 'meson')
optdepends=('xdg-desktop-portal: Wayland support')
source=("git+https://github.com/RealKC/$pkgname")
sha256sums=(SKIP)

prepare() {
cd "$srcdir/$pkgname"

cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
cd "$srcdir/$pkgname"

export RUSTUP_TOOLCHAIN=stable
cargo build --frozen --features xdg-paths --release --target-dir target
arch-meson "$pkgname-v$pkgver" build
meson compile -C build
}

package() {
cd "$srcdir/$pkgname"

install -Dm755 target/release/kcshot-rs "$pkgdir/usr/bin/kcshot"

install -Dm644 resources/logo/kcshot_logo_dark.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/kcshot.svg"
install -Dm644 resources/kc.kcshot.gschema.xml "$pkgdir/usr/share/glib-2.0/schemas/kc.kcshot.gschema.xml"

install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
meson install -C build --destdir "$pkgdir"
}
6 changes: 5 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ fn main() {
// See: https://docs.rs/diesel_migrations/2.0.0-rc.1/diesel_migrations/macro.embed_migrations.html#automatic-rebuilds
println!("cargo:rerun-if-changed=migrations/");

if std::option_env!("KCSHOT_LINTING").is_some() {
println!("cargo:rustc-cfg=kcshot_linting");
}

glib_build_tools::compile_resources(
"resources",
&["resources"],
"resources/resources.gresource.xml",
"compiled.gresource",
);
Expand Down
2 changes: 1 addition & 1 deletion kcshot-screenshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ashpd = { version = "0.4.0-alpha.3", default-features = false, features = [
"tokio",
"tracing",
] }
xcb = { version = "1.2.0", features = [
xcb = { git = "https://github.com/rust-x-bindings/rust-xcb/", features = [
"debug_atom_names",
"shape",
"xfixes",
Expand Down
78 changes: 78 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
project('kcshot', 'rust', license: 'EUPL-1.2')

gnome = import('gnome')

dependency('sqlite3', version: '>= 3.37')
dependency('glib-2.0', version: '>= 2.66')
dependency('gio-2.0', version: '>= 2.66')
dependency('gtk4', version: '>= 4.0.0')

subproject('blueprint-compiler')

cargo = find_program('cargo', required: true)
glib_compile_resources = find_program('glib-compile-resources', required: true)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)

cargo_options = ['--manifest-path', meson.project_source_root() / 'Cargo.toml']
cargo_options += ['--target-dir', meson.project_build_root() / 'src']

prefix = get_option('prefix')
bindir = prefix / get_option('bindir')

if get_option('profile') == 'default'
cargo_options += ['--release']
rust_target = 'release'
message('Building in release mode')
else
rust_target = 'debug'
message('Building in debug mode')
endif

message(
'blueprint-compiler is: ' + find_program('blueprint-compiler').full_path(),
)

fs = import('fs')
env = environment()
env.append('PATH', fs.parent(find_program('blueprint-compiler').full_path()))
env.set('CARGO_HOME', meson.project_build_root() / 'cargo-home')
meson.add_devenv(env)

cargo_build = custom_target(
'cargo-build',
build_by_default: true,
build_always_stale: true,
output: meson.project_name(),
console: true,
install: true,
install_dir: bindir,
env: env,
command: [
'sh',
'-c', cargo,
'build',
cargo_options,
'&&',
'cp',
'src' / rust_target / meson.project_name(),
'@OUTPUT@',
],
)

test(
'cargo-test',
cargo,
args: [
'test',
'--manifest-path=@0@/Cargo.toml'.format(meson.global_source_root()),
],
env: env,
timeout: 3000,
)

gnome.post_install(
gtk_update_icon_cache: true,
glib_compile_schemas: true,
update_desktop_database: true,
)

7 changes: 7 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
option(
'profile',
type: 'combo',
choices: ['default', 'development'],
value: 'default',
description: 'The build profile for GTK Rust Template. One of "default" or "development".',
)
2 changes: 2 additions & 0 deletions resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
<file>editor/tool-text.png</file>
<file>editor/tool-pencil.png</file>
<file>editor/tool-colourpicker.png</file>

<!-- UI files generated from blueprints in build.rs -->
</gresource>
</gresources>
Loading