[gnome-builder] meson-templates: Add cargo files to source files for rust
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] meson-templates: Add cargo files to source files for rust
- Date: Fri, 16 Oct 2020 02:51:15 +0000 (UTC)
commit f5356c60487c359127d4bf7d7823364180534907
Author: Christopher Davis <brainblasted disroot org>
Date: Thu Oct 15 18:41:22 2020 -0700
meson-templates: Add cargo files to source files for rust
Adds Cargo.toml and Cargo.lock as source files for
rust projects. These files list dependencies
and the versions chosen for the projects. When they
change, generally the user wants to rebuild.
src/plugins/meson-templates/meson-templates.gresource.xml | 1 +
src/plugins/meson-templates/meson_templates.py | 3 +++
src/plugins/meson-templates/resources/meson.build | 7 +++++++
src/plugins/meson-templates/resources/src/Cargo.lock | 0
src/plugins/meson-templates/resources/src/meson-cli.build | 1 +
src/plugins/meson-templates/resources/src/meson-rs.build | 4 +++-
6 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/meson-templates/meson-templates.gresource.xml
b/src/plugins/meson-templates/meson-templates.gresource.xml
index 367b89b2e..a2d2a0d30 100644
--- a/src/plugins/meson-templates/meson-templates.gresource.xml
+++ b/src/plugins/meson-templates/meson-templates.gresource.xml
@@ -36,6 +36,7 @@
<file compressed="true">resources/src/main-cli.rs</file>
<file compressed="true">resources/src/application.in</file>
<file compressed="true">resources/src/main.cs</file>
+ <file compressed="true">resources/src/Cargo.lock</file>
<file compressed="true">resources/src/Cargo.toml</file>
<file compressed="true">resources/src/Cargo-cli.toml</file>
<file compressed="true">resources/src/meson-cs.build</file>
diff --git a/src/plugins/meson-templates/meson_templates.py b/src/plugins/meson-templates/meson_templates.py
index 2e03e4943..e3e522984 100644
--- a/src/plugins/meson-templates/meson_templates.py
+++ b/src/plugins/meson-templates/meson_templates.py
@@ -305,6 +305,7 @@ class GnomeProjectTemplate(MesonTemplate):
files['resources/src/config.rs.in'] = 'src/config.rs.in'
files['resources/src/main.rs'] = 'src/main.rs'
files['resources/src/window.rs'] = 'src/window.rs'
+ files['resources/src/Cargo.lock'] = 'Cargo.lock'
files['resources/src/Cargo.toml'] = 'Cargo.toml'
files['resources/build-aux/cargo.sh'] = 'build-aux/cargo.sh'
meson_file = 'resources/src/meson-rs.build'
@@ -351,6 +352,7 @@ class EmptyProjectTemplate(MesonTemplate):
files['resources/src/meson-empty.build'] = 'src/meson.build'
if self.language == 'rust':
+ files['resources/src/Cargo.lock'] = 'Cargo.lock'
files['resources/src/Cargo-cli.toml'] = 'Cargo.toml'
@@ -374,5 +376,6 @@ class CLIProjectTemplate(MesonTemplate):
files['resources/src/main-cli.vala'] = 'src/main.vala'
elif self.language == 'rust':
files['resources/src/main-cli.rs'] = 'src/main.rs'
+ files['resources/src/Cargo.lock'] = 'Cargo.lock'
files['resources/src/Cargo-cli.toml'] = 'Cargo.toml'
files['resources/build-aux/cargo.sh'] = 'build-aux/cargo.sh'
diff --git a/src/plugins/meson-templates/resources/meson.build
b/src/plugins/meson-templates/resources/meson.build
index ec9e69cbb..67f028012 100644
--- a/src/plugins/meson-templates/resources/meson.build
+++ b/src/plugins/meson-templates/resources/meson.build
@@ -31,6 +31,13 @@ add_project_arguments([
], language: 'c')
{{end}}
+{{if language == "rust"}}
+cargo_sources = files(
+ 'Cargo.toml',
+ 'Cargo.lock',
+)
+{{end}}
+
{{if enable_gnome}}
subdir('data')
{{end}}
diff --git a/src/plugins/meson-templates/resources/src/Cargo.lock
b/src/plugins/meson-templates/resources/src/Cargo.lock
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/plugins/meson-templates/resources/src/meson-cli.build
b/src/plugins/meson-templates/resources/src/meson-cli.build
index 6a59cc7b9..f9defad53 100644
--- a/src/plugins/meson-templates/resources/src/meson-cli.build
+++ b/src/plugins/meson-templates/resources/src/meson-cli.build
@@ -4,6 +4,7 @@
{{else if language == "vala"}}
'main.vala',
{{else if language == "rust"}}
+ cargo_sources,
'main.rs',
{{end}}
]
diff --git a/src/plugins/meson-templates/resources/src/meson-rs.build
b/src/plugins/meson-templates/resources/src/meson-rs.build
index f7d105d37..a29405ba4 100644
--- a/src/plugins/meson-templates/resources/src/meson-rs.build
+++ b/src/plugins/meson-templates/resources/src/meson-rs.build
@@ -27,12 +27,14 @@ run_command(
check: true
)
-sources = files(
+rust_sources = files(
'config.rs',
'main.rs',
'window.rs',
)
+sources = [cargo_sources, rust_sources]
+
cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.sh'))
cargo_release = custom_target(
'cargo-build',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]