Automated building
This commit is contained in:
parent
d4aad0e8cd
commit
5f34f078db
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -4,3 +4,6 @@
|
||||||
[submodule "firmware2/spectre-api-c"]
|
[submodule "firmware2/spectre-api-c"]
|
||||||
path = firmware/spectre-api-c
|
path = firmware/spectre-api-c
|
||||||
url = https://github.com/Limeth/spectre-api.git
|
url = https://github.com/Limeth/spectre-api.git
|
||||||
|
[submodule "firmware/libsodium"]
|
||||||
|
path = firmware/libsodium
|
||||||
|
url = https://github.com/jedisct1/libsodium
|
||||||
|
|
|
||||||
13
firmware/Cargo.lock
generated
13
firmware/Cargo.lock
generated
|
|
@ -62,7 +62,7 @@ dependencies = [
|
||||||
"spectre-api-sys",
|
"spectre-api-sys",
|
||||||
"static_cell",
|
"static_cell",
|
||||||
"tinyvec",
|
"tinyvec",
|
||||||
"xkbcommon 0.9.0 (git+https://github.com/Limeth/xkbcommon-rs?branch=esp32s3)",
|
"xkbcommon 0.9.0 (git+https://github.com/Limeth/xkbcommon-rs?rev=d91705a7211e294c09abae5e3e64f1df158bc2c5)",
|
||||||
"xz2",
|
"xz2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -3834,7 +3834,7 @@ dependencies = [
|
||||||
"input",
|
"input",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"nix",
|
"nix",
|
||||||
"xkbcommon 0.9.0",
|
"xkbcommon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -6141,6 +6141,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rmk"
|
name = "rmk"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
source = "git+https://github.com/Limeth/rmk?rev=1661c55f5c21e7d80ea3f93255df483302c74b84#1661c55f5c21e7d80ea3f93255df483302c74b84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitfield-struct",
|
"bitfield-struct",
|
||||||
"bt-hci",
|
"bt-hci",
|
||||||
|
|
@ -6185,6 +6186,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rmk-config"
|
name = "rmk-config"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
|
source = "git+https://github.com/Limeth/rmk?rev=1661c55f5c21e7d80ea3f93255df483302c74b84#1661c55f5c21e7d80ea3f93255df483302c74b84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
"config",
|
"config",
|
||||||
|
|
@ -6201,6 +6203,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rmk-macro"
|
name = "rmk-macro"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
source = "git+https://github.com/Limeth/rmk?rev=1661c55f5c21e7d80ea3f93255df483302c74b84#1661c55f5c21e7d80ea3f93255df483302c74b84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
"darling 0.20.11",
|
"darling 0.20.11",
|
||||||
|
|
@ -6222,6 +6225,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rmk-types"
|
name = "rmk-types"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
source = "git+https://github.com/Limeth/rmk?rev=1661c55f5c21e7d80ea3f93255df483302c74b84#1661c55f5c21e7d80ea3f93255df483302c74b84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitfield-struct",
|
"bitfield-struct",
|
||||||
"postcard",
|
"postcard",
|
||||||
|
|
@ -6849,6 +6853,7 @@ checksum = "a0f368519fc6c85fc1afdb769fb5a51123f6158013e143656e25a3485a0d401c"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spectre-api-sys"
|
name = "spectre-api-sys"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/Limeth/spectre-api-sys#9e844eb056c3dfee8286ac21ec40fa689a8b8aa2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
|
|
@ -8392,6 +8397,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xkbcommon"
|
name = "xkbcommon"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
|
|
@ -8401,7 +8408,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xkbcommon"
|
name = "xkbcommon"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "git+https://github.com/Limeth/xkbcommon-rs?branch=esp32s3#d91705a7211e294c09abae5e3e64f1df158bc2c5"
|
source = "git+https://github.com/Limeth/xkbcommon-rs?rev=d91705a7211e294c09abae5e3e64f1df158bc2c5#d91705a7211e294c09abae5e3e64f1df158bc2c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"xkeysym",
|
"xkeysym",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,12 @@ rustflags = [
|
||||||
|
|
||||||
[env] # These must be kept in sync with /.zed/settings.json
|
[env] # These must be kept in sync with /.zed/settings.json
|
||||||
EXPLICITLY_INCLUDE_DEFAULT_DIRS = "true"
|
EXPLICITLY_INCLUDE_DEFAULT_DIRS = "true"
|
||||||
LIBXKBCOMMON_BUILD_DIR = "../libxkbcommon/build"
|
XKBCOMMON_BUILD_DIR = "../libxkbcommon/build-esp32s3"
|
||||||
SPECTRE_API_BUILD_DIR = "../spectre-api-c/build-esp32s3"
|
SPECTRE_API_BUILD_DIR = "../spectre-api-c/build-esp32s3"
|
||||||
|
SODIUM_INSTALL_DIR = "../libsodium/install"
|
||||||
|
XKBCOMMON_BUILD_DIR_NAME = "build-esp32s3"
|
||||||
|
SPECTRE_API_BUILD_DIR_NAME = "build-esp32s3"
|
||||||
|
SODIUM_INSTALL_DIR_NAME = "install"
|
||||||
SPECTRE_API_SYS_CC = "xtensa-esp32s3-elf-cc.exe"
|
SPECTRE_API_SYS_CC = "xtensa-esp32s3-elf-cc.exe"
|
||||||
ESP_LOG = "warn"
|
ESP_LOG = "warn"
|
||||||
ESP_BACKTRACE_CONFIG_BACKTRACE_FRAMES = "20"
|
ESP_BACKTRACE_CONFIG_BACKTRACE_FRAMES = "20"
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ probe = ["limit-fps", "rtt-log", "no-usb", "ble"]
|
||||||
format-db = []
|
format-db = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rmk = { version = "0.8.2", default-features = false, features = [
|
rmk = { version = "0.8.2", git = "https://github.com/Limeth/rmk", rev = "1661c55f5c21e7d80ea3f93255df483302c74b84", default-features = false, features = [
|
||||||
"log",
|
"log",
|
||||||
"storage",
|
"storage",
|
||||||
"vial",
|
"vial",
|
||||||
|
|
@ -68,7 +68,7 @@ itertools = { version = "0.14.0", default-features = false }
|
||||||
bytemuck = "1.24.0"
|
bytemuck = "1.24.0"
|
||||||
critical-section = "1.2.0"
|
critical-section = "1.2.0"
|
||||||
cfg-if = "1.0.4"
|
cfg-if = "1.0.4"
|
||||||
xkbcommon = { git = "https://github.com/Limeth/xkbcommon-rs", branch = "esp32s3", default-features = false, features = ["c-lib-wrap"] }
|
xkbcommon = { git = "https://github.com/Limeth/xkbcommon-rs", rev = "d91705a7211e294c09abae5e3e64f1df158bc2c5", default-features = false, features = ["c-lib-wrap"] }
|
||||||
rtt-target = { version = "0.6.2", features = ["log"], optional = true }
|
rtt-target = { version = "0.6.2", features = ["log"], optional = true }
|
||||||
panic-rtt-target = { version = "0.2.0", optional = true }
|
panic-rtt-target = { version = "0.2.0", optional = true }
|
||||||
enumset = "1.1.10"
|
enumset = "1.1.10"
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ This replaces the debugging symbols with paths that will be available when debug
|
||||||
|
|
||||||
Then compile the firmware with:
|
Then compile the firmware with:
|
||||||
```ps1
|
```ps1
|
||||||
$env:LIBXKBCOMMON_BUILD_DIR="libxkbcommon/build-debug"; cargo build
|
$env:XKBCOMMON_BUILD_DIR="libxkbcommon/build-debug"; cargo build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Creating keymaps
|
### Creating keymaps
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,40 @@ use std::io::{Read, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use const_gen::*;
|
use const_gen::*;
|
||||||
|
use embuild::cmd;
|
||||||
use indoc::{formatdoc, writedoc};
|
use indoc::{formatdoc, writedoc};
|
||||||
use json::JsonValue;
|
use json::JsonValue;
|
||||||
use slint_build::{CompilerConfiguration, EmbedResourcesKind};
|
use slint_build::{CompilerConfiguration, EmbedResourcesKind};
|
||||||
use xz2::read::XzEncoder;
|
use xz2::read::XzEncoder;
|
||||||
|
|
||||||
|
fn build_xkbcommon() {
|
||||||
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
|
let build_script = manifest_dir.join("../libxkbcommon-compile.sh");
|
||||||
|
let build_dir_name = env::var("XKBCOMMON_BUILD_DIR_NAME").unwrap();
|
||||||
|
cmd!(build_script, build_dir_name)
|
||||||
|
.run()
|
||||||
|
.expect("Failed to compile xkbcommon.");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_sodium() {
|
||||||
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
|
let build_script = manifest_dir.join("../libsodium-compile.sh");
|
||||||
|
let install_dir_name = env::var("SODIUM_INSTALL_DIR_NAME").unwrap();
|
||||||
|
cmd!(build_script, install_dir_name)
|
||||||
|
.run()
|
||||||
|
.expect("Failed to compile sodium.");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_spectre() {
|
||||||
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
|
let build_script = manifest_dir.join("../spectre-api-compile.sh");
|
||||||
|
let build_dir_name = env::var("SPECTRE_API_BUILD_DIR_NAME").unwrap();
|
||||||
|
let sodium_install_dir = env::var("SODIUM_INSTALL_DIR").unwrap();
|
||||||
|
cmd!(build_script, build_dir_name, sodium_install_dir)
|
||||||
|
.run()
|
||||||
|
.expect("Failed to compile the Spectre API.");
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
if let Ok(repo) = gix::discover(&manifest_dir) {
|
if let Ok(repo) = gix::discover(&manifest_dir) {
|
||||||
|
|
@ -32,37 +61,56 @@ fn main() {
|
||||||
// Set the extra linker script from defmt
|
// Set the extra linker script from defmt
|
||||||
// println!("cargo:rustc-link-arg=-Tdefmt.x");
|
// println!("cargo:rustc-link-arg=-Tdefmt.x");
|
||||||
|
|
||||||
// TODO: Make it a submodule and use relative paths.
|
#[derive(Debug)]
|
||||||
|
struct NotBuilt {
|
||||||
|
lib_build_dir: String,
|
||||||
|
}
|
||||||
|
|
||||||
fn link_static_lib(env_var: &str, library: &str) {
|
fn link_static_lib(env_var: &str, library: &str) -> Result<(), NotBuilt> {
|
||||||
let lib_build_dir = env::var(env_var)
|
let lib_build_dir_str = env::var(env_var)
|
||||||
.unwrap_or_else(|error| panic!("The build directory of lib{library} must be specified using the `{env_var}` environment variable: {error}"));
|
.unwrap_or_else(|error| panic!("The build directory of lib{library} must be specified using the `{env_var}` environment variable: {error}"));
|
||||||
let lib_build_dir = PathBuf::from(&lib_build_dir).canonicalize().unwrap();
|
let lib_build_dir = PathBuf::from(&lib_build_dir_str)
|
||||||
|
.canonicalize()
|
||||||
|
.map_err(|_| NotBuilt {
|
||||||
|
lib_build_dir: lib_build_dir_str.clone(),
|
||||||
|
})?;
|
||||||
let lib_library_path = lib_build_dir
|
let lib_library_path = lib_build_dir
|
||||||
.join(format!("lib{library}.a"))
|
.join(format!("lib{library}.a"))
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.unwrap();
|
.map_err(|_| NotBuilt {
|
||||||
|
lib_build_dir: lib_build_dir_str.clone(),
|
||||||
|
})?;
|
||||||
let lib_build_dir = lib_build_dir.display();
|
let lib_build_dir = lib_build_dir.display();
|
||||||
|
|
||||||
if !lib_library_path.is_file() {
|
if !lib_library_path.is_file() {
|
||||||
panic!(
|
return Err(NotBuilt {
|
||||||
"{}",
|
lib_build_dir: lib_build_dir_str,
|
||||||
formatdoc! {"
|
});
|
||||||
The compiled lib{library} library was not found at path {lib_library_path:?}.
|
|
||||||
Most likely, the library was not compiled. See the `README.md` for compilation instructions.
|
|
||||||
If the `{env_var}` environment variable is not set to the build directory you want to use, change it.
|
|
||||||
Currently, `{env_var}` is set to: {lib_build_dir}
|
|
||||||
"}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-search=native={lib_build_dir}");
|
println!("cargo:rustc-link-search=native={lib_build_dir}");
|
||||||
println!("cargo:rustc-link-lib=static={library}");
|
println!("cargo:rustc-link-lib=static={library}");
|
||||||
println!("cargo:rerun-if-changed={lib_build_dir}/lib{library}.a");
|
println!("cargo:rerun-if-changed={lib_build_dir}/lib{library}.a");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
link_static_lib("LIBXKBCOMMON_BUILD_DIR", "xkbcommon");
|
fn link_static_lib_or_build(env_var: &str, library: &str, build: impl FnOnce()) {
|
||||||
link_static_lib("SPECTRE_API_BUILD_DIR", "spectre");
|
if link_static_lib(env_var, library).is_err() {
|
||||||
|
(build)();
|
||||||
|
link_static_lib(env_var, library)
|
||||||
|
.unwrap_or_else(|err| panic!("Failed to link library after building it: {err:?}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
link_static_lib_or_build("XKBCOMMON_BUILD_DIR", "xkbcommon", || {
|
||||||
|
build_xkbcommon();
|
||||||
|
});
|
||||||
|
|
||||||
|
link_static_lib_or_build("SPECTRE_API_BUILD_DIR", "spectre", || {
|
||||||
|
build_sodium();
|
||||||
|
build_spectre();
|
||||||
|
});
|
||||||
|
|
||||||
// Slint config and compilation
|
// Slint config and compilation
|
||||||
{
|
{
|
||||||
|
|
|
||||||
1
firmware/libsodium
Submodule
1
firmware/libsodium
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit d24faf56214469b354b01c8ba36257e04737101e
|
||||||
|
|
@ -1,2 +1,22 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
env CC=xtensa-esp32s3-elf-gcc CFLAGS="-ffreestanding -fno-builtin -mlongcalls" LDFLAGS="-nostdlib -static" ./configure --host xtensa-esp32s3 --disable-shared --enable-static --prefix="$PWD/install"
|
if [ "$#" -lt 1 ]; then
|
||||||
|
echo "Usage: $0 <installation-directory-name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
REPO_DIR="$SCRIPT_DIR/libsodium"
|
||||||
|
INSTALL_DIR_NAME="$REPO_DIR/$1"
|
||||||
|
|
||||||
|
pushd "$REPO_DIR" >/dev/null
|
||||||
|
env CC=xtensa-esp32s3-elf-gcc \
|
||||||
|
CFLAGS="-ffreestanding -fno-builtin -mlongcalls" \
|
||||||
|
LDFLAGS="-nostdlib -static" \
|
||||||
|
./configure \
|
||||||
|
--host xtensa-esp32s3 \
|
||||||
|
--disable-shared \
|
||||||
|
--enable-static \
|
||||||
|
--prefix="$INSTALL_DIR_NAME"
|
||||||
|
make -j
|
||||||
|
make install
|
||||||
|
popd >/dev/null
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,8 @@ BUILD_DIR_NAME="$LIBXKBCOMMON_DIR/$1"
|
||||||
STATIC_LIB_PATH="$BUILD_DIR_NAME/libxkbcommon.a"
|
STATIC_LIB_PATH="$BUILD_DIR_NAME/libxkbcommon.a"
|
||||||
SETUP_ARGS=${@:2}
|
SETUP_ARGS=${@:2}
|
||||||
|
|
||||||
git submodule update --init --recursive
|
|
||||||
pushd "$LIBXKBCOMMON_DIR" >/dev/null
|
pushd "$LIBXKBCOMMON_DIR" >/dev/null
|
||||||
meson setup "$BUILD_DIR_NAME" \
|
meson setup "$BUILD_DIR_NAME" \
|
||||||
--wipe \
|
|
||||||
--cross-file "$SCRIPT_DIR/cross-esp32s3.txt" \
|
--cross-file "$SCRIPT_DIR/cross-esp32s3.txt" \
|
||||||
-Denable-x11=false \
|
-Denable-x11=false \
|
||||||
-Denable-wayland=false \
|
-Denable-wayland=false \
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,16 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
if [ "$#" -lt 2 ]; then
|
||||||
|
echo "Usage: $0 <build-directory-name> <sodium-install-dir>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
meson setup build --wipe --cross-file "$SCRIPT_DIR/cross-esp32s3.txt" -Dlibsodium-install-dir="$LIBSODIUM_INSTALL_DIR"
|
REPO_DIR="$SCRIPT_DIR/spectre-api-c"
|
||||||
meson compile -C build
|
BUILD_DIR_NAME="$REPO_DIR/$1"
|
||||||
|
STATIC_LIB_PATH="$BUILD_DIR_NAME/libspectre.a"
|
||||||
|
|
||||||
|
pushd "$REPO_DIR" >/dev/null
|
||||||
|
meson setup "$BUILD_DIR_NAME" --cross-file "$SCRIPT_DIR/cross-esp32s3.txt" -Dlibsodium-install-dir="$2"
|
||||||
|
meson compile -C "$BUILD_DIR_NAME"
|
||||||
|
$SCRIPT_DIR/redefine-syms.sh "__spre_" "$STATIC_LIB_PATH" "$STATIC_LIB_PATH"
|
||||||
|
popd >/dev/null
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue