Set up bash scripts that can be used as a build environment #52

Merged
savanni merged 4 commits from ci-cd into main 2023-08-07 19:23:27 +00:00
10 changed files with 1893 additions and 60 deletions

1766
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

8
Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[workspace]
members = [
"dashboard",
"fluent-ergonomics",
"geo-types",
"ifc",
"memorycache",
]

30
build.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail
RUST_ALL_TARGETS="dashboard ifc memorycache geo-types fluent-ergonomics"
build_rust_targets() {
local CMD=$1
local TARGETS=${@/$CMD}
for target in $TARGETS; do
MODULE=$target CMD=$CMD ./builders/rust.sh
done
}
export CARGO=`which cargo`
if [ -z "${TARGET-}" ]; then
TARGET="all"
fi
if [ -z "${CMD-}" ]; then
CMD="release"
fi
if [ "${TARGET}" == "all" ]; then
build_rust_targets $CMD $RUST_ALL_TARGETS
else
build_rust_targets $CMD $TARGET
fi

33
builders/rust.sh Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
if [ ! -z "$MODULE" ]; then
MODULE="-p $MODULE"
fi
if [ -z "${PARAMS-}" ]; then
PARAMS=""
fi
case $CMD in
build)
$CARGO build $MODULE $PARAMS
;;
test)
$CARGO test $MODULE $PARAMS
;;
release)
$CARGO build --release $MODULE $PARAMS
;;
clean)
$CARGO clean $MODULE
;;
"")
echo "No command specified. Use build | test | release | clean"
;;
*)
echo "$CMD is unknown. Use build | test | release | clean"
;;
esac

View File

@ -15,7 +15,7 @@ lazy_static = { version = "1.4" }
unic-langid = { version = "0.9" }
horrorshow = { version = "0.8" }
http = { version = "*" }
international-fixed-calendar = { path = "../ifc/" }
ifc = { path = "../ifc/" }
memorycache = { path = "../memory_cache" }
reqwest = { version = "0.11", features = ["json"] }
serde_derive = { version = "1" }

View File

@ -10,7 +10,7 @@ use fluent::{FluentArgs, FluentValue};
use geo_types::{Latitude, Longitude};
use horrorshow::helper::doctype;
use horrorshow::prelude::*;
use international_fixed_calendar as IFC;
use ifc;
use std::{
borrow::Cow,
net::{IpAddr, Ipv4Addr, SocketAddr},
@ -58,7 +58,7 @@ autumn_equinox = Aŭtuna Ekvinokso
winter_solstice = Vintra Solstico
";
fn date(fluent: Arc<fluent_ergonomics::FluentErgo>, today: IFC::IFC) -> impl Render {
fn date(fluent: Arc<fluent_ergonomics::FluentErgo>, today: ifc::IFC) -> impl Render {
let mut day_args = FluentArgs::new();
day_args.set(
"day",
@ -126,7 +126,7 @@ fn astronomia_eventa_desegno(
/*
fn page_template(
fluent: Arc<fluent_ergonomics::FluentErgo>,
today: IFC::IFC,
today: ifc::IFC,
sun_moon: SunMoon,
event: Option<solstices::Event>,
) -> String {
@ -156,7 +156,7 @@ async fn page(
longitude: Longitude,
) -> Result<Html<String>, Rejection> {
let now = Utc::now();
let d = IFC::IFC::from(now.with_timezone(&New_York).date());
let d = ifc::IFC::from(now.with_timezone(&New_York).date());
let sun_moon = solar_client
.request(latitude, longitude, now.with_timezone(&New_York).date())
.await;
@ -170,7 +170,7 @@ async fn page(
#[tokio::main]
pub async fn main() {
let now = Local::now();
let ifc = IFC::IFC::from(now.date_naive().with_year(12023).unwrap());
let ifc = ifc::IFC::from(now.date_naive().with_year(12023).unwrap());
let next_event = EVENTS.next_event(now.with_timezone(&Utc)).unwrap();
println!(

View File

@ -46,56 +46,52 @@
];
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;
};
hydraJobs = {
inherit (self) packages;
};
# 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 +1,5 @@
[package]
name = "international-fixed-calendar"
name = "ifc"
description = "chrono-compatible-ish date objects for the International Fixed Calendar"
version = "0.1.0"
authors = ["Savanni D'Gerinel <savanni@luminescent-dreams.com>"]

View File

@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with Lum
extern crate chrono;
extern crate chrono_tz;
extern crate international_fixed_calendar as IFC;
extern crate ifc as IFC;
use chrono::{Datelike, Utc};

View File

@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with Lum
*/
use chrono::{Datelike, Utc};
use international_fixed_calendar as IFC;
use ifc as IFC;
use iron::headers;
use iron::middleware::Handler;
use iron::modifiers::Header;