-
Notifications
You must be signed in to change notification settings - Fork 93
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
[WIP] Add Cargo buildsystem #564
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1515,8 +1515,10 @@ builder_module_build_helper (BuilderModule *self, | |
const char *make_cmd = NULL; | ||
const char *test_arg = NULL; | ||
|
||
gboolean autotools = FALSE, cmake = FALSE, cmake_ninja = FALSE, meson = FALSE, simple = FALSE, qmake = FALSE; | ||
gboolean autotools = FALSE, cmake = FALSE, cmake_ninja = FALSE, meson = FALSE, simple = FALSE, qmake = FALSE, cargo = FALSE; | ||
g_autoptr(GFile) configure_file = NULL; | ||
g_autoptr(GFile) cargo_file = NULL; | ||
g_autoptr(GFile) cargo_lock_file = NULL; | ||
g_autoptr(GFile) build_dir = NULL; | ||
g_autofree char *build_dir_relative = NULL; | ||
gboolean has_configure = FALSE; | ||
|
@@ -1585,6 +1587,8 @@ builder_module_build_helper (BuilderModule *self, | |
simple = TRUE; | ||
else if (!strcmp (self->buildsystem, "qmake")) | ||
qmake = TRUE; | ||
else if (!strcmp (self->buildsystem, "cargo")) | ||
cargo = TRUE; | ||
else | ||
{ | ||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module %s: Invalid buildsystem: \"%s\"", | ||
|
@@ -1634,6 +1638,22 @@ builder_module_build_helper (BuilderModule *self, | |
return FALSE; | ||
} | ||
} | ||
else if (cargo) | ||
{ | ||
cargo_file = find_file_with_extension (source_subdir, "Cargo.toml"); | ||
TingPing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (cargo_file == NULL) | ||
{ | ||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module: %s: Can't find Cargo.toml", self->name); | ||
return FALSE; | ||
} | ||
|
||
cargo_lock_file = find_file_with_extension (source_subdir, "Cargo.lock"); | ||
if (cargo_lock_file == NULL) | ||
{ | ||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "module: %s: Can't find Cargo.lock", self->name); | ||
return FALSE; | ||
} | ||
} | ||
else if (autotools) | ||
{ | ||
configure_file = g_file_get_child (source_subdir, "configure"); | ||
|
@@ -1741,6 +1761,10 @@ builder_module_build_helper (BuilderModule *self, | |
configure_cmd = "meson"; | ||
configure_final_arg = g_strdup (".."); | ||
} | ||
else if (cargo) | ||
{ | ||
// nothing to do - Cargo does not have a configure step | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so how do you select features? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Just to be more specific about this, do you mean switches like:
|
||
} | ||
else | ||
{ | ||
configure_cmd = "../configure"; | ||
|
@@ -1872,6 +1896,11 @@ builder_module_build_helper (BuilderModule *self, | |
} | ||
else if (simple) | ||
make_cmd = NULL; | ||
else if (cargo) | ||
{ | ||
make_cmd = "cargo"; | ||
test_arg = "check"; | ||
} | ||
else | ||
{ | ||
make_cmd = "make"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "hello_cargo" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# test-cargo-without-lockfile | ||
|
||
This is an example of a Cargo project with no Cargo.lock file. | ||
|
||
In this case, flatpak-builder should fail, and tell the user to generate the Cargo.lock file first. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "hello_cargo" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# test-cargo | ||
|
||
This is an example of a valid Cargo project (with a Cargo.lock file). | ||
|
||
In this case, flatpak-builder should succeed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
app-id: example | ||
runtime: org.test.Platform | ||
sdk: org.test.Sdk | ||
command: test-cargo | ||
modules: | ||
- name: app | ||
buildsystem: cargo | ||
sources: | ||
- type: dir | ||
path: . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will need to be documented. See
data/flatpak-manifest.schema.json
anddoc/flatpak-manifest.xml