Skip to content

Commit e3e56fe

Browse files
committed
Add "Zig" lang
Fixes #290
1 parent d444a49 commit e3e56fe

File tree

10 files changed

+63
-5
lines changed

10 files changed

+63
-5
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ COPY --from=codegolf/lang-ruby / /langs/ruby/rootfs/
4040
COPY --from=codegolf/lang-rust / /langs/rust/rootfs/
4141
COPY --from=codegolf/lang-sql / /langs/sql/rootfs/
4242
COPY --from=codegolf/lang-swift / /langs/swift/rootfs/
43+
COPY --from=codegolf/lang-zig / /langs/zig/rootfs/
4344

4445
COPY --from=0 /go/code-golf /
4546
COPY /*.toml /

Dockerfile.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ COPY --from=codegolf/lang-ruby / /langs/ruby/rootfs/
3030
COPY --from=codegolf/lang-rust / /langs/rust/rootfs/
3131
COPY --from=codegolf/lang-sql / /langs/sql/rootfs/
3232
COPY --from=codegolf/lang-swift / /langs/swift/rootfs/
33+
COPY --from=codegolf/lang-zig / /langs/zig/rootfs/
3334

3435
COPY run-lang.c ./
3536

db/a-schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CREATE TYPE lang AS ENUM (
2121
'bash', 'brainfuck', 'c', 'c-sharp', 'cobol', 'f-sharp', 'fortran', 'go',
2222
'haskell', 'j', 'java', 'javascript', 'julia', 'lisp', 'lua', 'nim',
2323
'perl', 'php', 'powershell', 'python', 'raku', 'ruby', 'rust', 'sql',
24-
'swift'
24+
'swift', 'zig'
2525
);
2626

2727
CREATE TYPE scoring AS ENUM ('bytes', 'chars');

hole/play.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ func Play(ctx context.Context, holeID, langID, code string) (score Scorecard) {
113113
}
114114
case "nim":
115115
cmd.Args = []string{"/usr/bin/nim", "-o:/tmp/code", "-r", "c", "-"}
116+
case "zig":
117+
cmd.Args = []string{"/usr/bin/" + langID}
116118
default:
117119
cmd.Args = []string{"/usr/bin/" + langID, "-"}
118120
}

langs.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ website = '//sqlite.org/index.html'
122122
size = '852 MiB'
123123
version = '5.3'
124124
website = '//swift.org'
125+
126+
[Zig]
127+
size = '242 MiB'
128+
version = '0.6.0'
129+
website = '//ziglang.org'

langs/zig/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM alpine:3.12 as builder
2+
3+
RUN mkdir /empty
4+
5+
RUN apk add --no-cache binutils curl
6+
7+
RUN curl https://ziglang.org/builds/zig-linux-x86_64-0.6.0+1e13e8e81.tar.xz \
8+
| tar -xJf -
9+
10+
RUN strip /zig-linux-x86_64-0.6.0+1e13e8e81/zig
11+
12+
FROM scratch
13+
14+
COPY --from=0 /bin/cat /bin/rm /bin/sh /bin/
15+
COPY --from=0 /lib/ld-musl-x86_64.so.1 /lib/
16+
COPY --from=0 /empty /proc
17+
COPY --from=0 /empty /tmp
18+
COPY --from=0 /zig-linux-x86_64-0.6.0+1e13e8e81/zig /usr/local/bin/
19+
COPY --from=0 /zig-linux-x86_64-0.6.0+1e13e8e81/lib /usr/local/lib/
20+
21+
COPY zig /usr/bin/
22+
23+
ENTRYPOINT ["/usr/local/bin/zig", "version"]

langs/zig/zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh -e
2+
3+
chdir /tmp
4+
5+
cat - > code.zig
6+
7+
/usr/local/bin/zig build-exe --global-cache-dir . code.zig
8+
9+
rm code.zig
10+
11+
exec ./code "$@"

t/args.t

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,26 @@ rust
148148
}
149149
}
150150
151+
sql
152+
153+
SELECT * FROM argv
154+
151155
swift
152156
153157
for a in CommandLine.arguments[1...] {
154158
print(a)
155159
}
156160
157-
sql
161+
zig
158162
159-
SELECT * FROM argv
163+
const std = @import("std");
164+
165+
pub fn main() !void {
166+
var args = std.process.args();
167+
168+
_ = args.skip();
169+
170+
while (args.next(std.testing.allocator)) |arg|
171+
try std.io.getStdOut().outStream().print("{}\n", .{arg});
172+
}
160173
=end pod

views/css/golfer/holes.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ input.raku:not(:checked) ~ .raku,
5454
input.ruby:not(:checked) ~ .ruby,
5555
input.rust:not(:checked) ~ .rust,
5656
input.sql:not(:checked) ~ .sql,
57-
input.swift:not(:checked) ~ .swift { display: none }
57+
input.swift:not(:checked) ~ .swift,
58+
input.zig:not(:checked) ~ .zig { display: none }
5859

5960
input:checked + label {
6061
background: var(--color);
@@ -79,7 +80,7 @@ main svg:nth-of-type(2) {
7980

8081
@media (min-width: 1280px) {
8182
/* Increase this number when adding a language. */
82-
main { grid-template-columns: 4fr repeat(25, 1fr) }
83+
main { grid-template-columns: 4fr repeat(26, 1fr) }
8384

8485
main a { height: 1.9rem }
8586

views/svg/zig.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)