From f3e4ee86598a48926abd2c0fc46325390844dbea Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 8 Nov 2024 23:06:54 +0100 Subject: [PATCH 01/11] gitignore: Ignore `.bob` output dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 759ac43..52aaca3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ bin *.core .testfiles *.sw[op] +.bob From e295b07e7779e685fc3f05d15fa44292237d3b8b Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 8 Nov 2024 23:07:15 +0100 Subject: [PATCH 02/11] build: `build.wren` -> `build.fl` --- build.fl | 36 ++++++++++++++++++++++++++++++ build.wren | 64 ------------------------------------------------------ 2 files changed, 36 insertions(+), 64 deletions(-) create mode 100644 build.fl delete mode 100644 build.wren diff --git a/build.fl b/build.fl new file mode 100644 index 0000000..e612226 --- /dev/null +++ b/build.fl @@ -0,0 +1,36 @@ +# This Source Form is subject to the terms of the AQUA Software License, +# v. 1.0. Copyright (c) 2024 Aymeric Wibo + +import bob + +# C compilation. + +let lib_src = Fs.list("src/lib").where(|path| path.endswith(".c")) +let cmd_src = Fs.list("src/cmd").where(|path| path.endswith(".c")) + +let cc = Cc(["-Isrc", "-fPIC", "-std=c99", "-Wall", "-Wextra", "-Werror"]) + +# TODO Check that the lib and cmd sources are actually being compiled in parallel. + +let lib_obj = cc.compile(lib_src) +let cmd_obj = cc.compile(cmd_src) + +# Create static & dynamic libraries and command-line frontend executable. + +let lib_linker = Linker([]) +let archive = Linker([]).archive(lib_obj) +let dyn_lib = Linker(["-shared"]).link(lib_obj) +let cmd = Linker(["-liar"]).link(cmd_obj) + +# Installation map. + +install = { + cmd: "bin/iar", + archive: "lib/libiar.a", + dyn_lib: "lib/libiar.so", + "src/iar.h": "include/iar.h", +} + +# Default runner. + +run = ["iar"] diff --git a/build.wren b/build.wren deleted file mode 100644 index d2e22cf..0000000 --- a/build.wren +++ /dev/null @@ -1,64 +0,0 @@ -// C compilation - -var cc = CC.new() - -cc.add_opt("-I/usr/local/include") -cc.add_opt("-Isrc") -cc.add_opt("-fPIC") -cc.add_opt("-std=c99") -cc.add_opt("-Wall") -cc.add_opt("-Wextra") -cc.add_opt("-Werror") - -var lib_src = File.list("src/lib") - .where { |path| path.endsWith(".c") } - -var cmd_src = File.list("src/cmd") - .where { |path| path.endsWith(".c") } - -var src = lib_src.toList + cmd_src.toList - -src - .each { |path| cc.compile(path) } - -// create static & dynamic libraries - -var linker = Linker.new() - -linker.archive(lib_src.toList, "libiar.a") -linker.link(lib_src.toList, [], "libiar.so", true) - -// create command-line frontend - -linker.link(cmd_src.toList, ["iar"], "iar") - -// copy over headers - -File.list("src") - .where { |path| path.endsWith(".h") } - .each { |path| Resources.install(path) } - -// running - -class Runner { - static run(args) { File.exec("iar", args) } -} - -// installation map - -var install = { - "iar": "bin/iar", - "libiar.a": "lib/libiar.a", - "libiar.so": "lib/libiar.so", - "iar.h": "include/iar.h", -} - -// testing - -class Tests { - static version { File.exec("iar", ["--version"]) } - static pack { File.exec("test.sh") } - static json { File.exec("test.sh") } -} - -var tests = ["version", "pack", "json"] From 2ac90aa85653e04aa47e9b1e3fdd763c2a078ffe Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 8 Nov 2024 23:17:07 +0100 Subject: [PATCH 03/11] ci: Use latest Bob --- .cirrus.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 1383a0a..6282305 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,7 +4,7 @@ task: env: CLICOLOR_FORCE: bob_script: - - git clone https://github.com/inobulles/bob --depth 1 --branch v0.1.0 + - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh build.sh && sh-bin/bob install ) build_script: - bob test install @@ -17,7 +17,7 @@ task: env: CLICOLOR_FORCE: bob_script: - - git clone https://github.com/inobulles/bob --depth 1 --branch v0.1.0 + - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh build.sh && sh-bin/bob install ) build_script: - bob test install From 2475c2b69cc4768f2528465efef6f7f6ef8d6468 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Fri, 8 Nov 2024 23:17:37 +0100 Subject: [PATCH 04/11] readme: Can use latest version of Bob --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9eaecb4..b5f5735 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The source code for the IAR (Inobulles ARchive) file format library and command- ## Building -With [Bob the Builder v0.1.0](https://github.com/inobulles/bob) installed: +With [Bob the Builder](https://github.com/inobulles/bob) installed: ```console bob test install From 7bdcb7ca754ca2b892c50f5d18cab018b3148d42 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 01:52:59 +0100 Subject: [PATCH 05/11] build: Remove useless variable --- build.fl | 1 - 1 file changed, 1 deletion(-) diff --git a/build.fl b/build.fl index e612226..40fb006 100644 --- a/build.fl +++ b/build.fl @@ -17,7 +17,6 @@ let cmd_obj = cc.compile(cmd_src) # Create static & dynamic libraries and command-line frontend executable. -let lib_linker = Linker([]) let archive = Linker([]).archive(lib_obj) let dyn_lib = Linker(["-shared"]).link(lib_obj) let cmd = Linker(["-liar"]).link(cmd_obj) From 98ff6705e8dd02ed6fcfe9f40c8db656d0a4d481 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 01:53:37 +0100 Subject: [PATCH 06/11] printf: Use `PRI{x,d}64` --- src/cmd/main.c | 3 ++- src/lib/libiar.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd/main.c b/src/cmd/main.c index 36618a4..287d874 100755 --- a/src/cmd/main.c +++ b/src/cmd/main.c @@ -1,5 +1,6 @@ #include +#include #include #include @@ -44,7 +45,7 @@ int main(int argc, char** argv) { page_bytes = atoll(argv[++i]); if (page_bytes < 1) { - fprintf(stderr, "ERROR Provided page size (%lu) is too small\n", page_bytes); + fprintf(stderr, "ERROR Provided page size (%" PRId64 ") is too small\n", page_bytes); return -1; } } diff --git a/src/lib/libiar.c b/src/lib/libiar.c index 5babd22..6ec96df 100644 --- a/src/lib/libiar.c +++ b/src/lib/libiar.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -40,12 +41,12 @@ int iar_open_read(iar_file_t* self, const char* path) { pread(self->fd, &self->header, sizeof(self->header), 0); // read the iar header if (self->header.magic != IAR_MAGIC) { - fprintf(stderr, "ERROR '%s' is not a valid IAR file (magic = 0x%lx)\n", path, self->header.magic); + fprintf(stderr, "ERROR '%s' is not a valid IAR file (magic = 0x%" PRIx64 ")\n", path, self->header.magic); goto error; } if (self->header.version > IAR_VERSION) { - fprintf(stderr, "ERROR '%s' is of an unsupported version (%lu) (latest supported version is %lu)\n", path, self->header.version, IAR_VERSION); + fprintf(stderr, "ERROR '%s' is of an unsupported version (%" PRId64 ") (latest supported version is %lu)\n", path, self->header.version, IAR_VERSION); goto error; } From bb44e278a68492e0db1e4e09dec7e575e53a528a Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 01:55:08 +0100 Subject: [PATCH 07/11] ci: Update with Bob's `bootstrap.sh` --- .cirrus.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 6282305..0980376 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -5,9 +5,11 @@ task: CLICOLOR_FORCE: bob_script: - git clone https://github.com/inobulles/bob --depth 1 --branch main - - ( cd bob && sh build.sh && sh-bin/bob install ) + - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob test install + - bob install + test_script: + - iar --version amd64_artifacts: path: "bin/*" @@ -18,8 +20,10 @@ task: CLICOLOR_FORCE: bob_script: - git clone https://github.com/inobulles/bob --depth 1 --branch main - - ( cd bob && sh build.sh && sh-bin/bob install ) + - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob test install + - bob install + test_script: + - iar --version arm64_artifacts: path: "bin/*" From a2520261c9d6665195d247801bf4e32137d70fcf Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 01:56:51 +0100 Subject: [PATCH 08/11] ci: `ASAN_OPTIONS=detect_leaks=0` --- .cirrus.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index 0980376..23e885c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,6 +3,7 @@ task: image: gcc:latest env: CLICOLOR_FORCE: + ASAN_OPTIONS: detect_leaks=0 bob_script: - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) @@ -18,6 +19,7 @@ task: image: gcc:latest env: CLICOLOR_FORCE: + ASAN_OPTIONS: detect_leaks=0 bob_script: - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) From 3f67b2da63d3636f9e38a125ad985c83c850916a Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 01:59:12 +0100 Subject: [PATCH 09/11] ci: Change install prefix to `/usr` --- .cirrus.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 23e885c..23c2f1a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,7 +8,7 @@ task: - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob install + - bob -o /usr install test_script: - iar --version amd64_artifacts: @@ -24,7 +24,7 @@ task: - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob install + - bob -o /usr install test_script: - iar --version arm64_artifacts: From a87d0cd8527b3c8ad112b543944428dfe786e6d6 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 02:01:02 +0100 Subject: [PATCH 10/11] ci: Okay this is annoying me --- .cirrus.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 23c2f1a..0144385 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,11 +4,13 @@ task: env: CLICOLOR_FORCE: ASAN_OPTIONS: detect_leaks=0 + LD_LIBRARY_PATH: /usr/local/lib bob_script: - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob -o /usr install + - bob install + - find /usr/local test_script: - iar --version amd64_artifacts: @@ -20,11 +22,13 @@ task: env: CLICOLOR_FORCE: ASAN_OPTIONS: detect_leaks=0 + LD_LIBRARY_PATH: /usr/local/lib bob_script: - git clone https://github.com/inobulles/bob --depth 1 --branch main - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob -o /usr install + - bob install + - find /usr/local test_script: - iar --version arm64_artifacts: From 9a8ba8f9848c7e30c40d9641673893f3f33826ff Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sun, 10 Nov 2024 02:05:08 +0100 Subject: [PATCH 11/11] ci: Pin to Bob v0.2.2 --- .cirrus.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 0144385..d973b17 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -6,7 +6,7 @@ task: ASAN_OPTIONS: detect_leaks=0 LD_LIBRARY_PATH: /usr/local/lib bob_script: - - git clone https://github.com/inobulles/bob --depth 1 --branch main + - git clone https://github.com/inobulles/bob --depth 1 --branch v0.2.2 - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - bob install @@ -24,7 +24,7 @@ task: ASAN_OPTIONS: detect_leaks=0 LD_LIBRARY_PATH: /usr/local/lib bob_script: - - git clone https://github.com/inobulles/bob --depth 1 --branch main + - git clone https://github.com/inobulles/bob --depth 1 --branch v0.2.2 - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - bob install