From 8ceca454b16357da36fe3534bb289b9b49d38f15 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 10 Mar 2024 14:56:13 -0400 Subject: [PATCH] Set up a flake command for the l10n-codegen-rust --- Cargo.lock | 4 -- Cargo.nix | 95 +++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 - flake.nix | 15 +++++++- kifu/gtk/build.rs | 7 ++++ l10n/Cargo.toml | 11 ++++-- 6 files changed, 123 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7f342a..f4b3329 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2710,10 +2710,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "kifu-l10n" -version = "0.1.0" - [[package]] name = "kv-log-macro" version = "1.0.7" diff --git a/Cargo.nix b/Cargo.nix index c7b3d96..e64dbbf 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -2249,6 +2249,25 @@ rec { "arbitrary" = [ "dep:arbitrary" ]; }; }; + "convert_case" = rec { + crateName = "convert_case"; + version = "0.6.0"; + edition = "2018"; + sha256 = "1jn1pq6fp3rri88zyw6jlhwwgf6qiyc08d6gjv0qypgkl862n67c"; + authors = [ + "Rutrum " + ]; + dependencies = [ + { + name = "unicode-segmentation"; + packageId = "unicode-segmentation"; + } + ]; + features = { + "rand" = [ "dep:rand" ]; + "random" = [ "rand" ]; + }; + }; "cookie" = rec { crateName = "cookie"; version = "0.17.0"; @@ -8793,6 +8812,18 @@ rec { crateName = "l10n"; version = "0.1.0"; edition = "2021"; + crateBin = [ + { + name = "codegen-rust"; + path = "src/bin/codegen-rust.rs"; + requiredFeatures = [ ]; + } + { + name = "msggen"; + path = "src/bin/msggen.rs"; + requiredFeatures = [ ]; + } + ]; # We can't filter paths with references in Nix 2.4 # See https://github.com/NixOS/nix/issues/5410 src = if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion )) @@ -8807,6 +8838,10 @@ rec { name = "chrono-tz"; packageId = "chrono-tz"; } + { + name = "convert_case"; + packageId = "convert_case"; + } { name = "fixed_decimal"; packageId = "fixed_decimal"; @@ -8816,6 +8851,10 @@ rec { name = "fluent"; packageId = "fluent"; } + { + name = "fluent-ergonomics"; + packageId = "fluent-ergonomics"; + } { name = "icu"; packageId = "icu"; @@ -8828,10 +8867,23 @@ rec { name = "icu_provider"; packageId = "icu_provider"; } + { + name = "serde"; + packageId = "serde 1.0.193"; + features = [ "derive" ]; + } + { + name = "serde_yaml"; + packageId = "serde_yaml"; + } { name = "sys-locale"; packageId = "sys-locale"; } + { + name = "unic-langid"; + packageId = "unic-langid"; + } ]; }; @@ -13177,6 +13229,38 @@ rec { } ]; + }; + "serde_yaml" = rec { + crateName = "serde_yaml"; + version = "0.9.29"; + edition = "2021"; + sha256 = "0aci065jjqjwxn4qm27r4li20w1wfdd6vgx0j34affgrdgv0wpm1"; + authors = [ + "David Tolnay " + ]; + dependencies = [ + { + name = "indexmap"; + packageId = "indexmap"; + } + { + name = "itoa"; + packageId = "itoa"; + } + { + name = "ryu"; + packageId = "ryu"; + } + { + name = "serde"; + packageId = "serde 1.0.193"; + } + { + name = "unsafe-libyaml"; + packageId = "unsafe-libyaml"; + } + ]; + }; "sgf" = rec { crateName = "sgf"; @@ -16157,6 +16241,17 @@ rec { } ]; + }; + "unsafe-libyaml" = rec { + crateName = "unsafe-libyaml"; + version = "0.2.10"; + edition = "2021"; + crateBin = []; + sha256 = "0jsyc1kqc536wpgx1js61lwj86crniqw16lyvh02va4m1f9r0k5b"; + authors = [ + "David Tolnay " + ]; + }; "url 1.7.2" = rec { crateName = "url"; diff --git a/Cargo.toml b/Cargo.toml index fb8c227..b33659e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ members = [ "ifc", "kifu/core", "kifu/gtk", - "kifu/l10n", "l10n", "memorycache", "nom-training", diff --git a/flake.nix b/flake.nix index 11f36ff..7cc2ded 100644 --- a/flake.nix +++ b/flake.nix @@ -86,6 +86,17 @@ file-service = cargo_nix.workspaceMembers.file-service.build; fitnesstrax = cargo_nix.workspaceMembers.fitnesstrax.build; kifu-gtk = cargo_nix.workspaceMembers.kifu-gtk.build; + l10n = cargo_nix.workspaceMembers.l10n.build; + l10n-codegen-rust = pkgs.stdenv.mkDerivation { + name = "l10n-codegen-rust"; + src = ./.; + buildInputs = [ l10n ]; + + installPhase = '' + mkdir -p $out/bin + cp ${l10n}/bin/codegen-rust $out/bin/l10n-codegen-rust + ''; + }; xdg-test = cargo_nix.workspaceMembers.xdg-test.build; all = pkgs.symlinkJoin { @@ -95,7 +106,9 @@ dashboard file-service fitnesstrax - kifu-gtk + # kifu-gtk + l10n + l10n-codegen-rust xdg-test ]; }; diff --git a/kifu/gtk/build.rs b/kifu/gtk/build.rs index 5a48d02..e5636e6 100644 --- a/kifu/gtk/build.rs +++ b/kifu/gtk/build.rs @@ -4,4 +4,11 @@ fn main() { "gresources.xml", "com.luminescent-dreams.kifu-gtk.gresource", ); + + let messages = std::process::Command::new("codegen-rust") + .arg("messages/en.yaml") + .output() + .expect("Failed to execute command"); + + println!("{}", String::from_utf8(messages.stdout).unwrap()); } diff --git a/l10n/Cargo.toml b/l10n/Cargo.toml index 305ae27..40e2d30 100644 --- a/l10n/Cargo.toml +++ b/l10n/Cargo.toml @@ -6,17 +6,20 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chrono = { version = "0.4" } chrono-tz = { version = "0.8" } +chrono = { version = "0.4" } convert_case = { version = "0.6" } fixed_decimal = { version = "0.5.5", features = [ "ryu" ] } -fluent = { version = "0.16" } fluent-ergonomics = { path = "../fluent-ergonomics" } -icu = { version = "1" } +fluent = { version = "0.16" } icu_locid = { version = "1" } icu_provider = { version = "1" } -serde = { version = "1" } +icu = { version = "1" } +serde = { version = "1", features = [ "derive" ] } serde_yaml = { version = "0.9" } sys-locale = { version = "0.3" } unic-langid = { version = "*" } +[[bin]] +name = "codegen-rust" +src = "src/bin/codegen-rust.rs"