Add the rest of the Rust projects to the build tool #53

Merged
savanni merged 13 commits from add-projects-to-build-tool into main 2023-08-07 22:42:23 +00:00
25 changed files with 1247 additions and 15199 deletions

1196
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,16 @@
[workspace] [workspace]
members = [ members = [
"cyberpunk-splash",
"dashboard", "dashboard",
"fluent-ergonomics", "fluent-ergonomics",
"geo-types", "geo-types",
"ifc", "ifc",
"memorycache", "memorycache",
"screenplay",
"emseries",
"coordinates",
"flow",
"sgf",
"changeset",
"hex-grid",
] ]

View File

@ -5,42 +5,6 @@ test: kifu-core/test-oneshot sgf/test-oneshot
bin: kifu-gtk bin: kifu-gtk
changeset-dev:
cd changeset && make dev
changeset-test:
cd changeset && make test
coordinates-dev:
cd coordinates && make dev
coordinates-test:
cd coordinates && make test
emseries-dev:
cd emseries && make dev
emseries-test:
cd emseries && make test
flow-dev:
cd flow && make dev
flow-test:
cd flow && make test
fluent-ergonomics-dev:
cd fluent-ergonomics && make dev
fluent-ergonomics-test:
cd fluent-ergonomics && make test
ifc-dev:
cd ifc && make dev
ifc-test:
cd ifc && make test
kifu-core/dev: kifu-core/dev:
cd kifu/core && make test cd kifu/core && make test
@ -64,9 +28,3 @@ kifu-pwa/dev:
kifu-pwa/server: kifu-pwa/server:
pushd kifu/pwa && make server pushd kifu/pwa && make server
sgf/test:
pushd sgf && make test
sgf/test-oneshot:
pushd sgf && make test-oneshot

View File

@ -2,7 +2,21 @@
set -euo pipefail set -euo pipefail
RUST_ALL_TARGETS="dashboard ifc memorycache geo-types fluent-ergonomics" RUST_ALL_TARGETS=(
"dashboard"
"ifc"
"memorycache"
"geo-types"
"fluent-ergonomics"
"cyberpunk-splash"
"screenplay"
"emseries"
"coordinates"
"flow"
"sgf"
"changeset"
"hex-grid"
)
build_rust_targets() { build_rust_targets() {
local CMD=$1 local CMD=$1
@ -20,11 +34,18 @@ if [ -z "${TARGET-}" ]; then
fi fi
if [ -z "${CMD-}" ]; then if [ -z "${CMD-}" ]; then
CMD="release" CMD="test release"
fi fi
if [ "${TARGET}" == "all" ]; then if [ "${CMD}" == "clean" ]; then
build_rust_targets $CMD $RUST_ALL_TARGETS cargo clean
else exit 0
build_rust_targets $CMD $TARGET
fi fi
for cmd in $CMD; do
if [ "${TARGET}" == "all" ]; then
build_rust_targets $cmd ${RUST_ALL_TARGETS[*]}
else
build_rust_targets $cmd $TARGET
fi
done

View File

@ -17,6 +17,9 @@ case $CMD in
test) test)
$CARGO test $MODULE $PARAMS $CARGO test $MODULE $PARAMS
;; ;;
run)
$CARGO run $MODULE $PARAMS
;;
release) release)
$CARGO build --release $MODULE $PARAMS $CARGO build --release $MODULE $PARAMS
;; ;;
@ -24,10 +27,10 @@ case $CMD in
$CARGO clean $MODULE $CARGO clean $MODULE
;; ;;
"") "")
echo "No command specified. Use build | test | release | clean" echo "No command specified. Use build | test | run | release | clean"
;; ;;
*) *)
echo "$CMD is unknown. Use build | test | release | clean" echo "$CMD is unknown. Use build | test | run | release | clean"
;; ;;
esac esac

View File

@ -1,9 +0,0 @@
dev:
cargo watch -x build
test:
cargo watch -x test
test-once:
cargo test

View File

@ -3,7 +3,6 @@ name = "coordinates"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
license = "GPL-3.0-only" license = "GPL-3.0-only"
license-file = "../COPYING"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,9 +0,0 @@
dev:
cargo watch -x build
test:
cargo watch -x test
test-once:
cargo test

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ unic-langid = { version = "0.9" }
horrorshow = { version = "0.8" } horrorshow = { version = "0.8" }
http = { version = "*" } http = { version = "*" }
ifc = { path = "../ifc/" } ifc = { path = "../ifc/" }
memorycache = { path = "../memory_cache" } memorycache = { path = "../memorycache" }
reqwest = { version = "0.11", features = ["json"] } reqwest = { version = "0.11", features = ["json"] }
serde_derive = { version = "1" } serde_derive = { version = "1" }
serde_json = { version = "1" } serde_json = { version = "1" }

View File

@ -1,9 +0,0 @@
dev:
cargo watch -x build
test:
cargo watch -x test
test-once:
cargo test

View File

@ -46,52 +46,5 @@
]; ];
LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
}; };
# packages."x86_64-linux" =
# let
# pkgs = import nixpkgs { system = "x86_64-linux"; };
# standardOverride = attrs: {
# nativeBuildInputs = [
# pkgs.pkg-config
# pkgs.gtk4
# ];
# verbose = true;
# };
# customBuildInfo = pkgs: pkgs.buildRustCrate.override {
# defaultCrateOverrides = pkgs.defaultCrateOverrides // {
# cairo-sys-rs = standardOverride;
# graphene-sys = standardOverride;
# gobject-sys = standardOverride;
# pango-sys = standardOverride;
# gio-sys = standardOverride;
# gdk-pixbuf-sys = standardOverride;
# gdk4-sys = standardOverride;
# gsk4-sys = standardOverride;
# gtk4-sys = standardOverride;
# kifu-gtk = attrs: {
# nativeBuildInputs = [
# pkgs.glib
# ];
# };
# };
# };
# in {
# # gobject-sys = pkgs.buildRustCrate cargo.internal.crates.gobject-sys;
# kifu-gtk = (import ./kifu/kifu-gtk/Cargo.nix {
# inherit pkgs;
# buildRustCrateForPkgs = customBuildInfo;
# rootFeatures = [ "screenplay" ];
# release = true;
# }).rootCrate.build;
# cyberpunk-splash = (import ./cyberpunk-splash/Cargo.nix {
# inherit pkgs;
# buildRustCrateForPkgs = customBuildInfo;
# release = true;
# }).rootCrate.build;
#
# dashboard = (import ./dashboard/Cargo.nix {
# inherit pkgs;
# release = true;
# }).rootCrate.build;
# };
}; };
} }

View File

@ -1,5 +0,0 @@
dev:
cargo watch -x build
test:
cargo watch -x test

View File

@ -19,6 +19,7 @@ include = [
] ]
[dependencies] [dependencies]
fluent = "0.16" fluent-bundle = "0.15"
unic-langid = "0.9" unic-langid = "0.9"
fluent-syntax = "0.11" fluent-syntax = "0.11"
intl-memoizer = "*"

View File

@ -1,9 +0,0 @@
dev:
cargo watch -x build
test:
cargo watch -x test
test-once:
cargo test

View File

@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with Lum
//! The Fluent class makes it easier to load translation bundles with language fallbacks and to go //! The Fluent class makes it easier to load translation bundles with language fallbacks and to go
//! through the most common steps of translating a message. //! through the most common steps of translating a message.
//! //!
use fluent::{FluentArgs, FluentBundle, FluentError, FluentResource}; use fluent_bundle::{bundle::FluentBundle, FluentArgs, FluentError, FluentResource};
use fluent_syntax::parser::ParserError; use fluent_syntax::parser::ParserError;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::collections::HashMap; use std::collections::HashMap;
@ -103,7 +103,14 @@ impl From<FromUtf8Error> for Error {
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct FluentErgo { pub struct FluentErgo {
languages: Vec<LanguageIdentifier>, languages: Vec<LanguageIdentifier>,
bundles: Arc<RwLock<HashMap<LanguageIdentifier, FluentBundle<FluentResource>>>>, bundles: Arc<
RwLock<
HashMap<
LanguageIdentifier,
FluentBundle<FluentResource, intl_memoizer::concurrent::IntlLangMemoizer>,
>,
>,
>,
} }
impl fmt::Debug for FluentErgo { impl fmt::Debug for FluentErgo {
@ -167,7 +174,10 @@ impl FluentErgo {
bundle.add_resource(res).map_err(|err| Error::from(err)) bundle.add_resource(res).map_err(|err| Error::from(err))
} }
Entry::Vacant(e) => { Entry::Vacant(e) => {
let mut bundle = FluentBundle::new(vec![lang]); let mut bundle: FluentBundle<
FluentResource,
intl_memoizer::concurrent::IntlLangMemoizer,
> = FluentBundle::new_concurrent(vec![lang]);
bundle.add_resource(res).map_err(|err| Error::from(err))?; bundle.add_resource(res).map_err(|err| Error::from(err))?;
e.insert(bundle); e.insert(bundle);
Ok(()) Ok(())
@ -220,14 +230,14 @@ impl FluentErgo {
/// A typical call with arguments would look like this: /// A typical call with arguments would look like this:
/// ///
/// ``` /// ```
/// use fluent::{FluentArgs, FluentValue}; /// use fluent_bundle::{FluentArgs, FluentValue};
/// ///
/// let eo_id = "eo".parse::<unic_langid::LanguageIdentifier>().unwrap(); /// let eo_id = "eo".parse::<unic_langid::LanguageIdentifier>().unwrap();
/// let en_id = "en-US".parse::<unic_langid::LanguageIdentifier>().unwrap(); /// let en_id = "en-US".parse::<unic_langid::LanguageIdentifier>().unwrap();
/// ///
/// let mut fluent = fluent_ergonomics::FluentErgo::new(&[eo_id, en_id]); /// let mut fluent = fluent_ergonomics::FluentErgo::new(&[eo_id, en_id]);
/// let mut args = FluentArgs::new(); /// let mut args = FluentArgs::new();
/// args.insert("value", FluentValue::from("15")); /// args.set("value", FluentValue::from("15"));
/// let r = fluent.tr("length-without-label", Some(&args)); /// let r = fluent.tr("length-without-label", Some(&args));
/// ``` /// ```
/// ///
@ -257,7 +267,7 @@ impl FluentErgo {
fn tr_( fn tr_(
&self, &self,
bundle: &FluentBundle<FluentResource>, bundle: &FluentBundle<FluentResource, intl_memoizer::concurrent::IntlLangMemoizer>,
msgid: &str, msgid: &str,
args: Option<&FluentArgs>, args: Option<&FluentArgs>,
) -> Option<String> { ) -> Option<String> {
@ -287,7 +297,7 @@ impl FluentErgo {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::FluentErgo; use super::FluentErgo;
use fluent::{FluentArgs, FluentValue}; use fluent_bundle::{FluentArgs, FluentValue};
use unic_langid::LanguageIdentifier; use unic_langid::LanguageIdentifier;
const EN_TRANSLATIONS: &'static str = " const EN_TRANSLATIONS: &'static str = "

View File

@ -3,15 +3,14 @@ name = "hex-grid"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
license = "GPL-3.0-only" license = "GPL-3.0-only"
license-file = "../COPYING"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
cairo-rs = "0.16" cairo-rs = "0.17"
gio = "0.16" gio = "0.17"
glib = "0.16" glib = "0.17"
gtk = { version = "0.5", package = "gtk4" } gtk = { version = "0.6", package = "gtk4" }
coordinates = { path = "../coordinates" } coordinates = { path = "../coordinates" }
image = { version = "0.24" } image = { version = "0.24" }

View File

@ -228,7 +228,7 @@ impl ObjectImpl for HexGridWindowPrivate {
} }
}); });
} }
self.drawing_area.add_controller(&motion_controller); self.drawing_area.add_controller(motion_controller);
} }
} }

View File

@ -1,9 +0,0 @@
dev:
cargo watch -x build
test:
cargo watch -x test
test-once:
cargo test

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
test:
cargo watch -x 'nextest run'
test-oneshot:
cargo nextest run