From 70efb0b0ba381e5a723a58eeba38ebf732fd1c82 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Sat, 28 Mar 2026 14:17:43 +0100 Subject: [PATCH] add cargo build system --- .gitignore | 6 ++++++ Cargo.lock | 14 ++++++++++++++ Cargo.toml | 7 +++++++ application/Cargo.toml | 7 +++++++ application/build.rs | 33 +++++++++++++++++++++++++++++++++ application/src/main.rs | 4 ++++ ui-rs/Cargo.toml | 7 +++++++ ui-rs/build.rs | 3 +++ ui-rs/src/lib.rs | 0 9 files changed, 81 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 application/Cargo.toml create mode 100644 application/build.rs create mode 100644 application/src/main.rs create mode 100644 ui-rs/Cargo.toml create mode 100644 ui-rs/build.rs create mode 100644 ui-rs/src/lib.rs diff --git a/.gitignore b/.gitignore index 6a50135..0f391ad 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,10 @@ make/vs/vcpkg_installed ui/winui/winui.vcxproj.user ui/winui/Generated Files gmon.out +.idea + + +# Added by cargo + +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..3697568 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,14 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "note" +version = "0.1.0" +dependencies = [ + "ui-rs", +] + +[[package]] +name = "ui-rs" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e4cdb20 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[workspace] +members = [ + "ui-rs", + "application" +] + +resolver = "2" diff --git a/application/Cargo.toml b/application/Cargo.toml new file mode 100644 index 0000000..75d4ac4 --- /dev/null +++ b/application/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "note" +version = "0.1.0" +edition = "2021" + +[dependencies] +ui-rs = { path = "../ui-rs" } diff --git a/application/build.rs b/application/build.rs new file mode 100644 index 0000000..55af0b4 --- /dev/null +++ b/application/build.rs @@ -0,0 +1,33 @@ +use std::path::Path; +use std::fs; + +fn main() { + let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + let lib_dir = Path::new(&manifest_dir).join("../build/lib"); + let config_mk = Path::new(&manifest_dir).join("../config.mk"); + + println!("cargo:rustc-link-search=native={}", lib_dir.display()); + println!("cargo:rustc-link-lib=static=uitk"); + println!("cargo:rustc-link-lib=static=ucx"); + + let content = fs::read_to_string(&config_mk) + .expect(&format!("Failed to read {}", config_mk.display())); + for line in content.lines() { + if line.starts_with("TK_LDFLAGS") { + let parts: Vec<&str> = line.split_whitespace().collect(); + for token in &parts[2..] { + if let Some(lib) = token.strip_prefix("-l") { + println!("cargo:rustc-link-lib={}", lib); + } else if token.starts_with("-L") { + let path = &token[2..]; + println!("cargo:rustc-link-search=native={}", path); + } else if token.starts_with("-R") { + let path = &token[2..]; + println!("cargo:rustc-link-arg=-Wl,-rpath,{}", path); + } else { + println!("cargo:rustc-link-arg={}", token); + } + } + } + } +} diff --git a/application/src/main.rs b/application/src/main.rs new file mode 100644 index 0000000..3033f62 --- /dev/null +++ b/application/src/main.rs @@ -0,0 +1,4 @@ + +fn main() { + +} diff --git a/ui-rs/Cargo.toml b/ui-rs/Cargo.toml new file mode 100644 index 0000000..ab578f0 --- /dev/null +++ b/ui-rs/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "ui-rs" +version = "0.1.0" +edition = "2021" + +[dependencies] + diff --git a/ui-rs/build.rs b/ui-rs/build.rs new file mode 100644 index 0000000..cf74f49 --- /dev/null +++ b/ui-rs/build.rs @@ -0,0 +1,3 @@ +fn main() { + +} \ No newline at end of file diff --git a/ui-rs/src/lib.rs b/ui-rs/src/lib.rs new file mode 100644 index 0000000..e69de29 -- 2.47.3