-
Notifications
You must be signed in to change notification settings - Fork 30
[sqlite] CC-1935: Upgrade Zig to v0.15 #144
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
|
||
set -e # Exit on failure | ||
|
||
exec $(dirname $0)/zig-out/bin/main "$@" | ||
exec "$(dirname "$0")"/zig-out/bin/main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM debian:bookworm | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y xz-utils=5.4.1-1 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Download and install Zig | ||
RUN curl -O https://ziglang.org/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz \ | ||
&& tar -xf zig-x86_64-linux-0.15.1.tar.xz \ | ||
&& mv zig-x86_64-linux-0.15.1 /usr/local/zig \ | ||
&& rm zig-x86_64-linux-0.15.1.tar.xz | ||
|
||
# Add Zig to PATH | ||
ENV PATH="/usr/local/zig:${PATH}" | ||
|
||
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon" | ||
|
||
WORKDIR /app | ||
|
||
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses | ||
COPY --exclude=.git --exclude=README.md . /app | ||
|
||
# This runs zig build | ||
RUN .codecrafters/compile.sh | ||
|
||
# Cache build directory | ||
RUN mkdir -p /app-cached | ||
RUN mv /app/.zig-cache /app-cached/.zig-cache || true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
|
||
set -e # Exit on failure | ||
|
||
exec $(dirname $0)/zig-out/bin/main "$@" | ||
exec "$(dirname "$0")"/zig-out/bin/main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,13 @@ pub fn main() !void { | |
const args = try std.process.argsAlloc(allocator); | ||
defer std.process.argsFree(allocator, args); | ||
|
||
var stdout_buffer: [1024]u8 = undefined; | ||
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer); | ||
const stdout = &stdout_writer.interface; | ||
|
||
if (args.len < 3) { | ||
try std.io.getStdErr().writer().print("Usage: {s} <database_file_path> <command>\n", .{args[0]}); | ||
try stdout.print("Usage: {s} <database_file_path> <command>\n", .{args[0]}); | ||
try stdout.flush(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Invalid API Usage Causes Compilation ErrorsThe Additional Locations (2) |
||
return; | ||
} | ||
|
||
|
@@ -24,6 +29,7 @@ pub fn main() !void { | |
_ = try file.seekTo(16); | ||
_ = try file.read(&buf); | ||
const page_size = std.mem.readInt(u16, &buf, .big); | ||
try std.io.getStdOut().writer().print("database page size: {}\n", .{page_size}); | ||
try stdout.print("database page size: {}\n", .{page_size}); | ||
try stdout.flush(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
|
||
set -e # Exit on failure | ||
|
||
exec $(dirname $0)/zig-out/bin/main "$@" | ||
exec "$(dirname "$0")"/zig-out/bin/main "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,13 @@ pub fn main() !void { | |
const args = try std.process.argsAlloc(allocator); | ||
defer std.process.argsFree(allocator, args); | ||
|
||
var stdout_buffer: [1024]u8 = undefined; | ||
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer); | ||
const stdout = &stdout_writer.interface; | ||
|
||
if (args.len < 3) { | ||
try std.io.getStdErr().writer().print("Usage: {s} <database_file_path> <command>\n", .{args[0]}); | ||
try stdout.print("Usage: {s} <database_file_path> <command>\n", .{args[0]}); | ||
try stdout.flush(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Unix Conventions Violated: Error Messages RedirectedUsage error messages are now printed to stdout instead of stderr. This change breaks standard Unix conventions for command-line tools, affecting script handling and output redirection. Additional Locations (1) |
||
return; | ||
} | ||
|
||
|
@@ -28,6 +33,7 @@ pub fn main() !void { | |
// _ = try file.seekTo(16); | ||
// _ = try file.read(&buf); | ||
// const page_size = std.mem.readInt(u16, &buf, .big); | ||
// try std.io.getStdOut().writer().print("database page size: {}\n", .{page_size}); | ||
// try stdout.print("database page size: {}\n", .{page_size}); | ||
// try stdout.flush(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
attributes: | ||
required_executable: zig (0.14) | ||
required_executable: zig (0.15) | ||
user_editable_file: src/main.zig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Build Configuration Locks Target and Optimization
The
build.zig
configuration hardcodes the build target tob.graph.host
and removes the optimization option. This change eliminates the ability to cross-compile or specify optimization levels viazig build
command-line arguments, reducing build flexibility.Additional Locations (1)
starter_templates/zig/code/build.zig#L6-L10