Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bob 2 #4

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"

Expand All @@ -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/*"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin
*.core
.testfiles
*.sw[op]
.bob
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions build.fl
Original file line number Diff line number Diff line change
@@ -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"]
64 changes: 0 additions & 64 deletions build.wren

This file was deleted.

3 changes: 2 additions & 1 deletion src/cmd/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iar.h>

#include <inttypes.h>
#include <string.h>
#include <stdlib.h>

Expand Down Expand Up @@ -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;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/libiar.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <errno.h>
#include <dirent.h>
Expand Down Expand Up @@ -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;
}

Expand Down