From e5aafad60d6d18e426e7e816a98c9e45e8d34667 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 9 Oct 2023 18:27:58 +0800 Subject: [PATCH] force cargo to use our copy of zynq-rs --- .gitignore | 8 ++++++++ README.md | 1 - flake.nix | 18 +++++++++--------- src/Cargo.lock | 7 +------ src/Makefile | 13 ++++++++++--- .../{Cargo.toml => Cargo.toml.tpl} | 10 +++++----- src/libc/{Cargo.toml => Cargo.toml.tpl} | 2 +- src/libdyld/{Cargo.toml => Cargo.toml.tpl} | 2 +- src/libio/{Cargo.toml => Cargo.toml.tpl} | 2 +- src/libksupport/{Cargo.toml => Cargo.toml.tpl} | 14 +++++++------- src/runtime/{Cargo.toml => Cargo.toml.tpl} | 12 ++++++------ src/satman/{Cargo.toml => Cargo.toml.tpl} | 12 ++++++------ 12 files changed, 55 insertions(+), 46 deletions(-) rename src/libboard_artiq/{Cargo.toml => Cargo.toml.tpl} (65%) rename src/libc/{Cargo.toml => Cargo.toml.tpl} (70%) rename src/libdyld/{Cargo.toml => Cargo.toml.tpl} (62%) rename src/libio/{Cargo.toml => Cargo.toml.tpl} (68%) rename src/libksupport/{Cargo.toml => Cargo.toml.tpl} (55%) rename src/runtime/{Cargo.toml => Cargo.toml.tpl} (68%) rename src/satman/{Cargo.toml => Cargo.toml.tpl} (62%) diff --git a/.gitignore b/.gitignore index f704879..12283e7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,11 @@ examples/*.elf __pycache__ build + +src/libboard_artiq/Cargo.toml +src/libc/Cargo.toml +src/libdyld/Cargo.toml +src/libio/Cargo.toml +src/libksupport/Cargo.toml +src/runtime/Cargo.toml +src/satman/Cargo.toml diff --git a/README.md b/README.md index 8dfe618..12e5194 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,6 @@ Notes: - When calling make, you need to specify both the variant and firmware type. - Firmware type must be either ``runtime`` for DRTIO-less or DRTIO master variants, or ``satman`` for DRTIO satellite. - If the board is connected to the local machine, use the ``local_run.sh`` script. -- To update ``zynq-rs``, update the cargo files as per usual for Rust projects, but also keep ``flake.lock`` in sync. License ------- diff --git a/flake.nix b/flake.nix index 73e5f80..df4f03a 100644 --- a/flake.nix +++ b/flake.nix @@ -122,9 +122,6 @@ src = ./src; cargoLock = { lockFile = src/Cargo.lock; - outputHashes = { - "libasync-0.0.0" = "sha256-MppR7yxs3cjG7tQc82vX0MhyN71CJL2QWkM65F5hrFU="; - }; }; nativeBuildInputs = [ @@ -138,6 +135,7 @@ export XARGO_RUST_SRC="${rust}/lib/rustlib/src/rust/library" export CLANG_EXTRA_INCLUDE_DIR="${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include" export CARGO_HOME=$(mktemp -d cargo-home.XXX) + export ZYNQ_RS=${zynq-rs} make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" ${fwtype} ''; @@ -251,18 +249,19 @@ ''; }; - fmt-check = pkgs.stdenv.mkDerivation { + fmt-check = pkgs.stdenvNoCC.mkDerivation { name = "fmt-check"; - nativeBuildInputs = [ - rust - ]; + src = ./src; - phases = [ "buildPhase" ]; + nativeBuildInputs = [ rust pkgs.gnumake ]; + + phases = [ "unpackPhase" "buildPhase" ]; buildPhase = '' - cd ${self}/src + export ZYNQ_RS=${zynq-rs} + make manifests cargo fmt -- --check touch $out ''; @@ -381,6 +380,7 @@ ]; XARGO_RUST_SRC = "${rust}/lib/rustlib/src/rust/library"; CLANG_EXTRA_INCLUDE_DIR = "${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include"; + ZYNQ_RS = "${zynq-rs}"; OPENOCD_ZYNQ = "${zynq-rs}/openocd"; SZL = "${zynqpkgs.szl}"; }; diff --git a/src/Cargo.lock b/src/Cargo.lock index 3666b3e..0d1f74e 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -242,13 +242,13 @@ dependencies = [ "log_buffer", "nb 0.1.3", "unwind", + "vcell", "void", ] [[package]] name = "libasync" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#c15b54f92b3d4e125ae47a0dce7abe4b2bc9e054" dependencies = [ "embedded-hal", "libcortex_a9", @@ -280,7 +280,6 @@ dependencies = [ [[package]] name = "libboard_zynq" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#c15b54f92b3d4e125ae47a0dce7abe4b2bc9e054" dependencies = [ "bit_field", "embedded-hal", @@ -305,7 +304,6 @@ dependencies = [ [[package]] name = "libconfig" version = "0.1.0" -source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#c15b54f92b3d4e125ae47a0dce7abe4b2bc9e054" dependencies = [ "core_io", "fatfs", @@ -316,7 +314,6 @@ dependencies = [ [[package]] name = "libcortex_a9" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#c15b54f92b3d4e125ae47a0dce7abe4b2bc9e054" dependencies = [ "bit_field", "libregister", @@ -332,7 +329,6 @@ checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "libregister" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#c15b54f92b3d4e125ae47a0dce7abe4b2bc9e054" dependencies = [ "bit_field", "vcell", @@ -342,7 +338,6 @@ dependencies = [ [[package]] name = "libsupport_zynq" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zynq-rs.git#c15b54f92b3d4e125ae47a0dce7abe4b2bc9e054" dependencies = [ "cc", "compiler_builtins", diff --git a/src/Makefile b/src/Makefile index f12fb29..f167a6a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,11 +9,18 @@ satman: ../build/satman.bin .PHONY: all runtime_target satman_target +manifests = libboard_artiq/Cargo.toml libc/Cargo.toml libdyld/Cargo.toml libio/Cargo.toml libksupport/Cargo.toml runtime/Cargo.toml satman/Cargo.toml + +$(manifests): %.toml: %.toml.tpl + sed s+@@ZYNQ_RS@@+$(ZYNQ_RS)+g $< > $@ + +manifests: $(manifests) + ../build/pl.rs ../build/rustc-cfg ../build/mem.rs: gateware/* mkdir -p ../build python gateware/$(TARGET).py -r ../build/pl.rs -c ../build/rustc-cfg -m ../build/mem.rs $(GWARGS) -../build/firmware/armv7-none-eabihf/release/runtime: ../build/pl.rs ../build/rustc-cfg ../build/mem.rs $(shell find . -type f -print) +../build/firmware/armv7-none-eabihf/release/runtime: ../build/pl.rs ../build/rustc-cfg ../build/mem.rs $(manifests) $(shell find . -type f -not -name Cargo.toml -print) cd runtime && \ XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \ cargo xbuild --release \ @@ -23,7 +30,7 @@ satman: ../build/satman.bin ../build/runtime.bin: ../build/firmware/armv7-none-eabihf/release/runtime llvm-objcopy -O binary ../build/firmware/armv7-none-eabihf/release/runtime ../build/runtime.bin -../build/firmware/armv7-none-eabihf/release/satman: ../build/pl.rs ../build/rustc-cfg ../build/mem.rs $(shell find . -type f -print) +../build/firmware/armv7-none-eabihf/release/satman: ../build/pl.rs ../build/rustc-cfg ../build/mem.rs $(manifests) $(shell find . -type f -not -name Cargo.toml -print) cd satman && \ XBUILD_SYSROOT_PATH=`pwd`/../../build/sysroot \ cargo xbuild --release \ @@ -31,4 +38,4 @@ satman: ../build/satman.bin --no-default-features --features=target_$(TARGET) ../build/satman.bin: ../build/firmware/armv7-none-eabihf/release/satman - llvm-objcopy -O binary ../build/firmware/armv7-none-eabihf/release/satman ../build/satman.bin \ No newline at end of file + llvm-objcopy -O binary ../build/firmware/armv7-none-eabihf/release/satman ../build/satman.bin diff --git a/src/libboard_artiq/Cargo.toml b/src/libboard_artiq/Cargo.toml.tpl similarity index 65% rename from src/libboard_artiq/Cargo.toml rename to src/libboard_artiq/Cargo.toml.tpl index e5ccf34..3fc8809 100644 --- a/src/libboard_artiq/Cargo.toml +++ b/src/libboard_artiq/Cargo.toml.tpl @@ -24,8 +24,8 @@ nb = "1.0" void = { version = "1", default-features = false } io = { path = "../libio", features = ["byteorder"] } -libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git"} -libregister = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libconfig = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["fat_lfn"] } -libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libasync = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } \ No newline at end of file +libboard_zynq = { path = "@@ZYNQ_RS@@/libboard_zynq" } +libregister = { path = "@@ZYNQ_RS@@/libregister" } +libconfig = { path = "@@ZYNQ_RS@@/libconfig", features = ["fat_lfn"] } +libcortex_a9 = { path = "@@ZYNQ_RS@@/libcortex_a9" } +libasync = { path = "@@ZYNQ_RS@@/libasync" } diff --git a/src/libc/Cargo.toml b/src/libc/Cargo.toml.tpl similarity index 70% rename from src/libc/Cargo.toml rename to src/libc/Cargo.toml.tpl index 006d80b..89c75c4 100644 --- a/src/libc/Cargo.toml +++ b/src/libc/Cargo.toml.tpl @@ -6,7 +6,7 @@ edition = "2018" build = "build.rs" [dependencies] -libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } +libboard_zynq = { path = "@@ZYNQ_RS@@/libboard_zynq" } [build-dependencies] cc = { version = "1.0.1" } diff --git a/src/libdyld/Cargo.toml b/src/libdyld/Cargo.toml.tpl similarity index 62% rename from src/libdyld/Cargo.toml rename to src/libdyld/Cargo.toml.tpl index 97da8db..481c14f 100644 --- a/src/libdyld/Cargo.toml +++ b/src/libdyld/Cargo.toml.tpl @@ -8,4 +8,4 @@ name = "dyld" [dependencies] log = "0.4" -libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } +libcortex_a9 = { path = "@@ZYNQ_RS@@/libcortex_a9" } diff --git a/src/libio/Cargo.toml b/src/libio/Cargo.toml.tpl similarity index 68% rename from src/libio/Cargo.toml rename to src/libio/Cargo.toml.tpl index c02f08a..f6bd041 100644 --- a/src/libio/Cargo.toml +++ b/src/libio/Cargo.toml.tpl @@ -11,7 +11,7 @@ path = "lib.rs" core_io = { version = "0.1", features = ["collections"] } byteorder = { version = "1.0", default-features = false, optional = true } -libsupport_zynq = { default-features = false, features = ["alloc_core"], git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } +libsupport_zynq = { path = "@@ZYNQ_RS@@/libsupport_zynq", default-features = false, features = ["alloc_core"] } [features] alloc = [] diff --git a/src/libksupport/Cargo.toml b/src/libksupport/Cargo.toml.tpl similarity index 55% rename from src/libksupport/Cargo.toml rename to src/libksupport/Cargo.toml.tpl index 9f49b53..7e26bd5 100644 --- a/src/libksupport/Cargo.toml +++ b/src/libksupport/Cargo.toml.tpl @@ -19,16 +19,16 @@ log_buffer = { version = "1.2" } libm = { version = "0.2", features = ["unstable"] } vcell = "0.1" -libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["ipv6"]} -libsupport_zynq = { default-features = false, features = ["alloc_core"], git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libasync = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libregister = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libconfig = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["fat_lfn", "ipv6"] } +libboard_zynq = { path = "@@ZYNQ_RS@@/libboard_zynq", features = ["ipv6"]} +libsupport_zynq = { path = "@@ZYNQ_RS@@/libsupport_zynq", default-features = false, features = ["alloc_core"] } +libcortex_a9 = { path = "@@ZYNQ_RS@@/libcortex_a9" } +libasync = { path = "@@ZYNQ_RS@@/libasync" } +libregister = { path = "@@ZYNQ_RS@@/libregister" } +libconfig = { path = "@@ZYNQ_RS@@/libconfig", features = ["fat_lfn", "ipv6"] } dyld = { path = "../libdyld" } dwarf = { path = "../libdwarf" } unwind = { path = "../libunwind" } libc = { path = "../libc" } io = { path = "../libio" } -libboard_artiq = { path = "../libboard_artiq" } \ No newline at end of file +libboard_artiq = { path = "../libboard_artiq" } diff --git a/src/runtime/Cargo.toml b/src/runtime/Cargo.toml.tpl similarity index 68% rename from src/runtime/Cargo.toml rename to src/runtime/Cargo.toml.tpl index ea6c32c..a0c7fa7 100644 --- a/src/runtime/Cargo.toml +++ b/src/runtime/Cargo.toml.tpl @@ -27,12 +27,12 @@ async-recursion = "0.3" log_buffer = { version = "1.2" } vcell = "0.1" -libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["ipv6"]} -libsupport_zynq = { default-features = false, features = ["alloc_core"], git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libasync = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libregister = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libconfig = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["fat_lfn", "ipv6"] } +libboard_zynq = { path = "@@ZYNQ_RS@@/libboard_zynq", features = ["ipv6"]} +libsupport_zynq = { path = "@@ZYNQ_RS@@/libsupport_zynq", default-features = false, features = ["alloc_core"] } +libcortex_a9 = { path = "@@ZYNQ_RS@@/libcortex_a9" } +libasync = { path = "@@ZYNQ_RS@@/libasync" } +libregister = { path = "@@ZYNQ_RS@@/libregister" } +libconfig = { path = "@@ZYNQ_RS@@/libconfig", features = ["fat_lfn", "ipv6"] } dyld = { path = "../libdyld" } dwarf = { path = "../libdwarf" } diff --git a/src/satman/Cargo.toml b/src/satman/Cargo.toml.tpl similarity index 62% rename from src/satman/Cargo.toml rename to src/satman/Cargo.toml.tpl index 36914d3..d9cff61 100644 --- a/src/satman/Cargo.toml +++ b/src/satman/Cargo.toml.tpl @@ -18,12 +18,12 @@ core_io = { version = "0.1", features = ["collections"] } cslice = "0.3" embedded-hal = "0.2" -libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["ipv6"]} -libsupport_zynq = { default-features = false, features = ["alloc_core"], git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libasync = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libregister = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git" } -libconfig = { git = "https://git.m-labs.hk/M-Labs/zynq-rs.git", features = ["fat_lfn", "ipv6"] } +libboard_zynq = { path = "@@ZYNQ_RS@@/libboard_zynq", features = ["ipv6"]} +libsupport_zynq = { path = "@@ZYNQ_RS@@/libsupport_zynq", default-features = false, features = ["alloc_core"] } +libcortex_a9 = { path = "@@ZYNQ_RS@@/libcortex_a9" } +libasync = { path = "@@ZYNQ_RS@@/libasync" } +libregister = { path = "@@ZYNQ_RS@@/libregister" } +libconfig = { path = "@@ZYNQ_RS@@/libconfig", features = ["fat_lfn", "ipv6"] } libboard_artiq = { path = "../libboard_artiq" } unwind = { path = "../libunwind" }