Skip to content

Commit

Permalink
zigConsole: Apply patch to bump it to zig v.13.0
Browse files Browse the repository at this point in the history
Related-to: torizon#274
  • Loading branch information
andreriesco committed Dec 11, 2024
1 parent f648dd6 commit 490b883
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
5 changes: 3 additions & 2 deletions zigConsole/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
zig-*/
.zig-cache/
zig-out/

executable-*
executable-*
16 changes: 8 additions & 8 deletions zigConsole/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 && \
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zigConsole/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zigConsole/Dockerfile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions zigConsole/build.zig
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const std = @import("std");
const Path = std.Build.LazyPath;

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions zigConsole/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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"});
Expand Down

0 comments on commit 490b883

Please sign in to comment.