Skip to content

Commit

Permalink
Switch to primo's ><>
Browse files Browse the repository at this point in the history
  • Loading branch information
JRaspass committed Nov 17, 2020
1 parent 0f4c022 commit d060bba
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 36 deletions.
53 changes: 29 additions & 24 deletions build-langs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ for %langs{ @langs || * }:p.sort -> (:key($name), :value(%lang)) {
if $id eq 'javascript';

# Tag the builder stage so "docker system prune" won't remove it.
run «docker build --pull --target builder -t "{$img}-builder" "langs/$id"»
if $id ne 'fish';
run «docker build --pull --target builder -t "{$img}-builder" "langs/$id"»;

run «docker build -t $img "langs/$id"»;
run «docker push $img» unless $no-push;
Expand All @@ -37,30 +36,36 @@ for %langs{ @langs || * }:p.sort -> (:key($name), :value(%lang)) {
%lang<size> = $proc.out.slurp(:close).chomp.subst: /(.)B$/, {" {$0.uc}iB"};

# Version.
( $proc = run «docker run --rm --tmpfs /tmp $img», :out ).sink;

my $ver = $proc.out.slurp(:close).chomp.trans: "\n" => ' ';

given $name {
my $digits = $ver ~~ / <[\d.]>+ \d+ /;

when 'C#'
| 'F#'
| 'PowerShell' { }
when 'C' { $ver = "Tiny C Compiler $digits" }
when 'COBOL' { $ver = "GnuCOBOL $digits" }
when 'Fortran' { $ver = "GNU Fortran $digits" }
when 'Haskell' { $ver = "Glasgow Haskell Compiler $digits" }
when 'JavaScript' { $ver = "V8 $digits" }
when 'Lisp' { $ver = "GNU CLISP $digits" }
when 'Raku' {
$ver ~~ m:g/ v (\S+) '.' /;
$ver = "Raku $1[0] on Rakudo $0[0]";
}
default { $ver = $digits }
if $id eq 'fish' {
"langs/$id/Dockerfile".IO.slurp ~~ / ' VERSION=' (\S+) /;
%lang<version> = $0;
}
else {
( my $proc = run «docker run --rm --tmpfs /tmp $img», :out ).sink;

my $ver = $proc.out.slurp(:close).chomp.trans: "\n" => ' ';

given $name {
my $digits = $ver ~~ / <[\d.]>+ \d+ /;

when 'C#'
| 'F#'
| 'PowerShell' { }
when 'C' { $ver = "Tiny C Compiler $digits" }
when 'COBOL' { $ver = "GnuCOBOL $digits" }
when 'Fortran' { $ver = "GNU Fortran $digits" }
when 'Haskell' { $ver = "Glasgow Haskell Compiler $digits" }
when 'JavaScript' { $ver = "V8 $digits" }
when 'Lisp' { $ver = "GNU CLISP $digits" }
when 'Raku' {
$ver ~~ m:g/ v (\S+) '.' /;
$ver = "Raku $1[0] on Rakudo $0[0]";
}
default { $ver = $digits }
}

%lang<version> = $ver;
%lang<version> = $ver;
}
}

spurt 'langs.toml', to-toml %langs;
Expand Down
2 changes: 1 addition & 1 deletion docker/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ COPY --from=codegolf/lang-fortran ["/", "/langs/fortran/rootfs/" ] # 410 M
COPY --from=codegolf/lang-haskell ["/", "/langs/haskell/rootfs/" ] # 332 MiB
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 279 MiB
COPY --from=codegolf/lang-zig ["/", "/langs/zig/rootfs/" ] # 216 MiB
COPY --from=codegolf/lang-fish ["/", "/langs/fish/rootfs/" ] # 206 MiB
COPY --from=codegolf/lang-python ["/", "/langs/python/rootfs/" ] # 206 MiB
COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 185 MiB
COPY --from=codegolf/lang-c-sharp ["/", "/langs/c-sharp/rootfs/" ] # 141 MiB
Expand All @@ -31,6 +30,7 @@ COPY --from=codegolf/lang-brainfuck ["/", "/langs/brainfuck/rootfs/" ] # 1.59 M
COPY --from=codegolf/lang-c ["/", "/langs/c/rootfs/" ] # 1.58 MiB
COPY --from=codegolf/lang-bash ["/", "/langs/bash/rootfs/" ] # 1.15 MiB
COPY --from=codegolf/lang-sql ["/", "/langs/sql/rootfs/" ] # 1.02 MiB
COPY --from=codegolf/lang-fish ["/", "/langs/fish/rootfs/" ] # 579 KiB
COPY --from=codegolf/lang-lua ["/", "/langs/lua/rootfs/" ] # 314 KiB

COPY run-lang.c ./
Expand Down
2 changes: 1 addition & 1 deletion docker/live.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ COPY --from=codegolf/lang-fortran ["/", "/langs/fortran/rootfs/" ] # 410 M
COPY --from=codegolf/lang-haskell ["/", "/langs/haskell/rootfs/" ] # 332 MiB
COPY --from=codegolf/lang-julia ["/", "/langs/julia/rootfs/" ] # 279 MiB
COPY --from=codegolf/lang-zig ["/", "/langs/zig/rootfs/" ] # 216 MiB
COPY --from=codegolf/lang-fish ["/", "/langs/fish/rootfs/" ] # 206 MiB
COPY --from=codegolf/lang-python ["/", "/langs/python/rootfs/" ] # 206 MiB
COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 185 MiB
COPY --from=codegolf/lang-c-sharp ["/", "/langs/c-sharp/rootfs/" ] # 141 MiB
Expand All @@ -41,6 +40,7 @@ COPY --from=codegolf/lang-brainfuck ["/", "/langs/brainfuck/rootfs/" ] # 1.59 M
COPY --from=codegolf/lang-c ["/", "/langs/c/rootfs/" ] # 1.58 MiB
COPY --from=codegolf/lang-bash ["/", "/langs/bash/rootfs/" ] # 1.15 MiB
COPY --from=codegolf/lang-sql ["/", "/langs/sql/rootfs/" ] # 1.02 MiB
COPY --from=codegolf/lang-fish ["/", "/langs/fish/rootfs/" ] # 579 KiB
COPY --from=codegolf/lang-lua ["/", "/langs/lua/rootfs/" ] # 314 KiB

COPY --from=0 /go/code-golf /
Expand Down
6 changes: 3 additions & 3 deletions langs.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
['><>']
size = '206 MiB'
version = '1.0'
website = '//esolangs.org/wiki/fish'
size = '579 KiB'
version = 'bde83aa'
website = '//github.com/primo-ppcg/fish-jit'
example = '''
\ printing
> "!dlroW ,olleH" ooooooooooooo ao 03.
Expand Down
18 changes: 11 additions & 7 deletions langs/fish/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM alpine:3.12 as builder

RUN mkdir /empty

ENV PY_VERSION=3.7-v7.3.2 VERSION=bde83aa

RUN apk add --no-cache curl gcc linux-headers make musl-dev python2

RUN curl https://downloads.python.org/pypy/pypy3.7-v7.3.2-src.tar.bz2 \
RUN curl https://downloads.python.org/pypy/pypy$PY_VERSION-src.tar.bz2 \
| tar xj

RUN curl -L https://github.com/primo-ppcg/fish-jit/tarball/cee89b7 \
RUN curl -L https://github.com/primo-ppcg/fish-jit/tarball/$VERSION \
| tar xz

RUN LDFLAGS=-static python pypy3.7-v7.3.2-src/rpython/bin/rpython \
--lto primo-ppcg-fish-jit-cee89b7/fish-jit.py \
RUN LDFLAGS=-static python pypy$PY_VERSION-src/rpython/bin/rpython \
--lto primo-ppcg-fish-jit-$VERSION/fish-jit.py \
&& strip fish-jit-c

FROM scratch

COPY --from=0 fish-jit-c /usr/bin/fish

ENTRYPOINT ["/usr/bin/fish", "-c", "1n'.'o0n;"]
COPY --from=0 /empty /proc
COPY --from=0 /empty /tmp
COPY --from=0 /fish-jit-c /usr/bin/fish

0 comments on commit d060bba

Please sign in to comment.