diff --git a/.cirrus.yml b/.cirrus.yml index 1383a0a..d973b17 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,11 +3,16 @@ task: image: gcc:latest 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 v0.1.0 - - ( cd bob && sh build.sh && sh-bin/bob install ) + - git clone https://github.com/inobulles/bob --depth 1 --branch v0.2.2 + - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob test install + - bob install + - find /usr/local + test_script: + - iar --version amd64_artifacts: path: "bin/*" @@ -16,10 +21,15 @@ task: image: gcc:latest 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 v0.1.0 - - ( cd bob && sh build.sh && sh-bin/bob install ) + - git clone https://github.com/inobulles/bob --depth 1 --branch v0.2.2 + - ( cd bob && sh bootstrap.sh && .bootstrap/bob install ) build_script: - - bob test install + - bob install + - find /usr/local + test_script: + - iar --version arm64_artifacts: path: "bin/*" diff --git a/.gitignore b/.gitignore index 759ac43..52aaca3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ bin *.core .testfiles *.sw[op] +.bob 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 diff --git a/build.fl b/build.fl new file mode 100644 index 0000000..40fb006 --- /dev/null +++ b/build.fl @@ -0,0 +1,35 @@ +# 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 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"] 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; }