From fcc4e82b194b231cad68ee3cb4d7f34edf16fa9a Mon Sep 17 00:00:00 2001 From: Andre Riesco Date: Fri, 8 Nov 2024 15:20:52 -0300 Subject: [PATCH] zigConsole: Apply patch to bump it to zig v.13.0 Related-to: #274 --- zigConsole/.gitignore | 5 +++-- zigConsole/Dockerfile | 16 ++++++++-------- zigConsole/Dockerfile.debug | 2 +- zigConsole/Dockerfile.sdk | 2 +- zigConsole/build.zig | 8 +++++--- zigConsole/src/main.zig | 4 ++-- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/zigConsole/.gitignore b/zigConsole/.gitignore index a1e689d43..22be77941 100644 --- a/zigConsole/.gitignore +++ b/zigConsole/.gitignore @@ -1,3 +1,4 @@ -zig-*/ +.zig-cache/ +zig-out/ -executable-* \ No newline at end of file +executable-* diff --git a/zigConsole/Dockerfile b/zigConsole/Dockerfile index 8971c81f9..a41eced16 100644 --- a/zigConsole/Dockerfile +++ b/zigConsole/Dockerfile @@ -2,8 +2,8 @@ ## # Base container version ## -ARG SDK_BASE_VERSION=4.0.0 -ARG BASE_VERSION=4.0.0 +ARG SDK_BASE_VERSION=4.2.0 +ARG BASE_VERSION=4.2.0 ## # Board architecture @@ -22,7 +22,7 @@ FROM torizon/cross-toolchain-${IMAGE_ARCH}:${SDK_BASE_VERSION} AS build ARG IMAGE_ARCH ARG COMPILER_ARCH ARG APP_ROOT -ENV ZIG_PATH /zig/0.11.0/files +ENV ZIG_PATH /zig/0.13.0/files # __deps__ RUN apt-get -q -y update && \ @@ -37,22 +37,22 @@ RUN apt-get -q -y update && \ rm -rf /var/lib/apt/lists/* # __deps__ -# Install Zig 0.11.0 (uses LLVM-16.0.6) +# Install Zig 0.13.0 (uses LLVM-18.1.6) RUN if [ "$IMAGE_ARCH" = "arm64" ] ; then \ wget -q https://github.com/kassane/zigup/releases/download/2023_09_29/zigup.ubuntu-latest-aarch64.zip && \ unzip zigup.ubuntu-latest-aarch64.zip -d /usr/bin && \ chmod +x /usr/bin/zigup && \ - zigup --install-dir /zig 0.11.0 ; \ - elif [ "$IMAGE_ARCH" = "armhf" ] ; then \ + zigup --install-dir /zig 0.13.0 ; \ + elif [ "$IMAGE_ARCH" = "arm" ] ; then \ wget -q https://github.com/kassane/zigup/releases/download/2023_09_29/zigup.ubuntu-latest-armv7a.zip && \ unzip zigup.ubuntu-latest-armv7a.zip -d /usr/bin && \ chmod +x /usr/bin/zigup && \ - zigup --install-dir /zig 0.11.0 ; \ + zigup --install-dir /zig 0.13.0 ; \ elif [ "$IMAGE_ARCH" = "amd64" ] ; then \ wget -q https://github.com/kassane/zigup/releases/download/2023_09_29/zigup.ubuntu-latest-x86_64.zip && \ unzip zigup.ubuntu-latest-x86_64.zip -d /usr/bin && \ chmod +x /usr/bin/zigup && \ - zigup --install-dir /zig 0.11.0; \ + zigup --install-dir /zig 0.13.0; \ fi RUN chmod +x ${ZIG_PATH}/zig diff --git a/zigConsole/Dockerfile.debug b/zigConsole/Dockerfile.debug index b2dbdf43a..6ea954903 100644 --- a/zigConsole/Dockerfile.debug +++ b/zigConsole/Dockerfile.debug @@ -7,7 +7,7 @@ ARG IMAGE_ARCH= ## # Base container version ## -ARG BASE_VERSION=4.0.0 +ARG BASE_VERSION=4.2.0 ## # Directory of the application inside container diff --git a/zigConsole/Dockerfile.sdk b/zigConsole/Dockerfile.sdk index 6e9fce78f..d92ddcc0f 100644 --- a/zigConsole/Dockerfile.sdk +++ b/zigConsole/Dockerfile.sdk @@ -7,7 +7,7 @@ ARG IMAGE_ARCH= ## # Base container version ## -ARG SDK_BASE_VERSION=0.11.0 +ARG SDK_BASE_VERSION=0.13.0 ## # Directory of the application inside container diff --git a/zigConsole/build.zig b/zigConsole/build.zig index 307763639..d62018f8f 100644 --- a/zigConsole/build.zig +++ b/zigConsole/build.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const Path = std.Build.LazyPath; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); @@ -7,7 +6,7 @@ pub fn build(b: *std.Build) void { const binary = b.addExecutable(.{ .name = "__change__", - .root_source_file = Path.relative("src/main.zig"), + .root_source_file = b.path("src/main.zig"), // or (implicit LazyPath struct, w/ path field) // .root_source_file = .{ .path = "src/main.zig" }, .target = target, @@ -34,7 +33,10 @@ pub fn build(b: *std.Build) void { b.installArtifact(binary); // overwrite default output - b.resolveInstallPrefix(b.fmt("zig-out/{s}/{s}", .{ @tagName(target.getCpuArch()), @tagName(optimize) }), .{}); + b.resolveInstallPrefix(b.fmt("zig-out/{s}/{s}", .{ + @tagName(binary.rootModuleTarget().cpu.arch), + @tagName(optimize), + }), .{}); // This *creates* a Run step in the build graph, to be executed when another // step is evaluated that depends on it. The next line below will establish diff --git a/zigConsole/src/main.zig b/zigConsole/src/main.zig index 86bb580bd..7afb02e64 100644 --- a/zigConsole/src/main.zig +++ b/zigConsole/src/main.zig @@ -2,8 +2,8 @@ const std = @import("std"); const log = std.log.scoped(.toradex); // override the std implementation -pub const std_options = struct { - pub const log_level = .info; +pub const std_options = .{ + .log_level = .info, }; pub fn main() void { log.info("Hello {s}!", .{"Torizon"});