From 0f42691db80f12dbb607b0de0bc12e76eba14110 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 15 Dec 2024 21:27:29 -0800 Subject: [PATCH] Initfs makefile --- .gitignore | 1 - .gitmodules | 3 +++ components/Makefile | 2 +- make/filesystem | 22 ++++++++++++++-------- tools/.gitignore | 1 + tools/Makefile | 14 ++++++++++++++ tools/initfs | 1 + 7 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 tools/.gitignore create mode 100644 tools/Makefile create mode 160000 tools/initfs diff --git a/.gitignore b/.gitignore index 342f695..a17545d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ /build **/target -/tools *.ignore diff --git a/.gitmodules b/.gitmodules index 8d7aac3..2f687c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "components/sources/zerod"] path = components/sources/zerod url = https://gitlab.redox-os.org/redox-os/zerod.git +[submodule "tools/initfs"] + path = tools/initfs + url = https://gitlab.redox-os.org/redox-os/redox-initfs.git diff --git a/components/Makefile b/components/Makefile index b326f5f..a3e7fa7 100644 --- a/components/Makefile +++ b/components/Makefile @@ -1,6 +1,6 @@ BUILD=./build -TOOLCHAIN = $(CURDIR)/../tools/x86_64-unknown-redox/toolchain +TOOLCHAIN = $(CURDIR)/../tools/bin/x86_64-unknown-redox/toolchain CARGO = $(TOOLCHAIN)/bin/cargo PATH := $(TOOLCHAIN)/bin:$(PATH) diff --git a/make/filesystem b/make/filesystem index 176905c..b495d3f 100644 --- a/make/filesystem +++ b/make/filesystem @@ -1,13 +1,19 @@ -$(BUILD_DIR)/filesystem: - @mkdir -p $(BUILD_DIR) - rm -f $@.partial - mkdir $@.partial - fallocate -l 1MiB $@.partial/kernel - mv $@.partial $@ +$(BUILD_DIR)/filesystem/boot/initfs: $(shell find ./components -type f -not -path "*/target/*") + @mkdir -p $(BUILD_DIR)/filesystem/boot + rm -f $@ + make -C tools + make -C components + ./tools/bin/redox-initfs-ar --output $@ ./components/build -$(BUILD_DIR)/filesystem.img: $(BUILD_DIR)/filesystem +$(BUILD_DIR)/filesystem/boot/kernel: + @mkdir -p $(BUILD_DIR)/filesystem/boot + rm -f $@ + fallocate -l 1MiB $(BUILD_DIR)/filesystem/boot/kernel + + +$(BUILD_DIR)/filesystem.img: $(BUILD_DIR)/filesystem/boot/kernel $(BUILD_DIR)/filesystem/boot/initfs @mkdir -p $(BUILD_DIR) rm -f $@.partial fallocate -l 254MiB $@.partial - redoxfs-ar $@.partial $< + redoxfs-ar $@.partial $(BUILD_DIR)/filesystem mv $@.partial $@ \ No newline at end of file diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000..ba077a4 --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1 @@ +bin diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 0000000..1cedd54 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,14 @@ +.PHONY: all +all: bin/redox-initfs-ar bin/redox-initfs-dump + +bin/redox-initfs-ar: $(shell find ./initfs -type f -not -path "*/target/*") + @mkdir -p bin + cd initfs/tools && \ + cargo build --release --bin redox-initfs-ar + cp initfs/target/release/redox-initfs-ar $@ + +bin/redox-initfs-dump: $(shell find ./initfs -type f -not -path "*/target/*") + @mkdir -p bin + cd initfs/tools && \ + cargo build --release --bin redox-initfs-dump + cp initfs/target/release/redox-initfs-dump $@ \ No newline at end of file diff --git a/tools/initfs b/tools/initfs new file mode 160000 index 0000000..d080223 --- /dev/null +++ b/tools/initfs @@ -0,0 +1 @@ +Subproject commit d0802237d7894881df7ddd338dfc64220d0646ff