Commit 0523aaa3 authored by Günther Wagner's avatar Günther Wagner
Browse files

meson-templates: add Rust CLI project and Empty project

parent c9bb42ef
Pipeline #169759 passed with stage
in 31 minutes and 11 seconds
......@@ -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>
......
......@@ -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'
[package]
name = "{{name}}"
version = "0.1.0"
edition = "2018"
fn main() {
println!("Hello World");
}
......@@ -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}}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment