[gnome-builder/gnome-builder-3-36] meson-templates: add Rust CLI project and Empty project
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-36] meson-templates: add Rust CLI project and Empty project
- Date: Mon, 13 Apr 2020 16:45:14 +0000 (UTC)
commit 2de7256a7d69d41bbbf97a35c8aa0572b7c7b0e4
Author: Günther Wagner <info gunibert de>
Date: Mon Apr 13 16:01:07 2020 +0200
meson-templates: add Rust CLI project and Empty project
.../meson-templates/meson-templates.gresource.xml | 2 ++
src/plugins/meson-templates/meson_templates.py | 11 ++++++--
.../meson-templates/resources/src/Cargo-cli.toml | 4 +++
.../meson-templates/resources/src/main-cli.rs | 3 +++
.../meson-templates/resources/src/meson-cli.build | 29 ++++++++++++++++++++--
5 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/meson-templates/meson-templates.gresource.xml
b/src/plugins/meson-templates/meson-templates.gresource.xml
index 78c87d33b..367b89b2e 100644
--- a/src/plugins/meson-templates/meson-templates.gresource.xml
+++ b/src/plugins/meson-templates/meson-templates.gresource.xml
@@ -33,9 +33,11 @@
<file compressed="true">resources/src/hello.py.in</file>
<file compressed="true">resources/src/main.py</file>
<file compressed="true">resources/src/main.rs</file>
+ <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.toml</file>
+ <file compressed="true">resources/src/Cargo-cli.toml</file>
<file compressed="true">resources/src/meson-cs.build</file>
<file compressed="true">resources/build-aux/cargo.sh</file>
<file compressed="true">resources/build-aux/meson/postinstall.py</file>
diff --git a/src/plugins/meson-templates/meson_templates.py b/src/plugins/meson-templates/meson_templates.py
index bc7e78b1e..2e03e4943 100644
--- a/src/plugins/meson-templates/meson_templates.py
+++ b/src/plugins/meson-templates/meson_templates.py
@@ -343,13 +343,16 @@ class EmptyProjectTemplate(MesonTemplate):
_('Empty Project'),
'pattern-cli',
_('Create a new empty project'),
- ['C', 'C++', 'C♯', 'JavaScript', 'Python', 'Vala'],
+ ['C', 'C++', 'C♯', 'JavaScript', 'Python', 'Vala', 'Rust'],
200
)
def prepare_files(self, files):
files['resources/src/meson-empty.build'] = 'src/meson.build'
+ if self.language == 'rust':
+ files['resources/src/Cargo-cli.toml'] = 'Cargo.toml'
+
class CLIProjectTemplate(MesonTemplate):
def __init__(self):
@@ -358,7 +361,7 @@ class CLIProjectTemplate(MesonTemplate):
_('Command Line Tool'),
'pattern-cli',
_('Create a new command line project'),
- ['C', 'Vala'],
+ ['C', 'Vala', 'Rust'],
200
)
@@ -369,3 +372,7 @@ class CLIProjectTemplate(MesonTemplate):
files['resources/src/main-cli.c'] = 'src/main.c'
elif self.language == 'vala':
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-cli.toml'] = 'Cargo.toml'
+ files['resources/build-aux/cargo.sh'] = 'build-aux/cargo.sh'
diff --git a/src/plugins/meson-templates/resources/src/Cargo-cli.toml
b/src/plugins/meson-templates/resources/src/Cargo-cli.toml
new file mode 100644
index 000000000..4bccb97fd
--- /dev/null
+++ b/src/plugins/meson-templates/resources/src/Cargo-cli.toml
@@ -0,0 +1,4 @@
+[package]
+name = "{{name}}"
+version = "0.1.0"
+edition = "2018"
diff --git a/src/plugins/meson-templates/resources/src/main-cli.rs
b/src/plugins/meson-templates/resources/src/main-cli.rs
new file mode 100644
index 000000000..f6320bcb0
--- /dev/null
+++ b/src/plugins/meson-templates/resources/src/main-cli.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello World");
+}
diff --git a/src/plugins/meson-templates/resources/src/meson-cli.build
b/src/plugins/meson-templates/resources/src/meson-cli.build
index a62ee9efb..6a59cc7b9 100644
--- a/src/plugins/meson-templates/resources/src/meson-cli.build
+++ b/src/plugins/meson-templates/resources/src/meson-cli.build
@@ -3,18 +3,43 @@
'main.c',
{{else if language == "vala"}}
'main.vala',
+{{else if language == "rust"}}
+ 'main.rs',
{{end}}
]
{{name_}}_deps = [
+{{if language == "c"}}
+ dependency('glib-2.0'),
+{{else if language == "vala"}}
dependency('glib-2.0'),
-{{if language == "vala"}}
dependency('gobject-2.0'),
{{end}}
]
+{{if language != "rust"}}
executable('{{name}}', {{name_}}_sources,
{{if language == "vala"}} vala_args: '--target-glib=2.58',{{end}}
dependencies: {{name_}}_deps,
install: true,
-)
\ No newline at end of file
+)
+{{else}}
+cargo_script = find_program(join_paths(meson.source_root(), 'build-aux/cargo.sh'))
+cargo_release = custom_target(
+ 'cargo-build',
+ build_by_default: true,
+ input: {{name_}}_sources,
+ output: meson.project_name(),
+ console: true,
+ install: true,
+ install_dir: get_option('bindir'),
+ command: [
+ cargo_script,
+ meson.build_root(),
+ meson.source_root(),
+ '@OUTPUT@',
+ get_option('buildtype'),
+ meson.project_name(),
+ ]
+)
+{{end}}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]