Skip to content

Commit 447121b

Browse files
committed
Add Julia lang
Fixes #58
1 parent 27cdbb6 commit 447121b

File tree

12 files changed

+89
-13
lines changed

12 files changed

+89
-13
lines changed

assets/common.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ tr.me { background: #5cf }
206206
.haskell { background: svg(haskell#000) center right 7px / 26px no-repeat }
207207
.j { background: svg(j#000) center right 7px / 26px no-repeat }
208208
.javascript { background: svg(javascript#000) center right 7px / 26px no-repeat }
209+
.julia { background: svg(julia#000) center right 7px / 26px no-repeat }
209210
.lisp { background: svg(lisp#000) center right 7px / 26px no-repeat }
210211
.lua { background: svg(lua#000) center right 7px / 26px no-repeat }
211212
.perl { background: svg(perl#000) center right 7px / 26px no-repeat }

assets/hole.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ h3 {
147147
#tabs {
148148
clear: both;
149149
display: grid;
150-
grid-template-columns: repeat(11, 1fr);
150+
grid-template-columns: repeat(12, 1fr);
151151
margin-top: 10px;
152152
position: relative;
153153
-moz-user-select: none;
@@ -177,8 +177,9 @@ h3 {
177177

178178
#tabs a[href="#bash"] { background-image: svg(bash#fff) }
179179
#tabs a[href="#haskell"] { background-image: svg(haskell#fff) }
180-
#tabs a[href="#j"] { background-image: svg(j#fff) }
180+
#tabs a[href="#j"] { background-image: svg(j#fff) }
181181
#tabs a[href="#javascript"] { background-image: svg(javascript#fff) }
182+
#tabs a[href="#julia"] { background-image: svg(julia#fff) }
182183
#tabs a[href="#lisp"] { background-image: svg(lisp#fff) }
183184
#tabs a[href="#lua"] { background-image: svg(lua#fff) }
184185
#tabs a[href="#perl"] { background-image: svg(perl#fff) }

assets/hole.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ onload = function() {
2424
let editors = [];
2525

2626
for (let langName of [
27-
'Bash', 'Haskell', 'J', 'JavaScript', 'Lisp',
27+
'Bash', 'Haskell', 'J', 'JavaScript', 'Julia', 'Lisp',
2828
'Lua', 'Perl', 'Perl 6', 'PHP', 'Python', 'Ruby',
2929
]) {
3030
let lang = langName.replace(/ /, '').toLowerCase();
@@ -70,7 +70,7 @@ onload = function() {
7070

7171
( onhashchange = function() {
7272
// Kick 'em to Perl 6 if we don't know the chosen language.
73-
if (!/^#(?:bash|haskell|j|javascript|lisp|lua|perl6?|php|python|ruby)$/.exec(location.hash))
73+
if (!/^#(?:bash|haskell|j|javascript|julia|lisp|lua|perl6?|php|python|ruby)$/.exec(location.hash))
7474
location.hash = 'perl6';
7575

7676
let lang = location.hash.slice(1);

assets/includes/julia.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/user.css

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ tr {
104104
#matrix tr:first-child th:nth-child(3) { background-image: svg(haskell#222) }
105105
#matrix tr:first-child th:nth-child(4) { background-image: svg(j#222) }
106106
#matrix tr:first-child th:nth-child(5) { background-image: svg(javascript#222) }
107-
#matrix tr:first-child th:nth-child(6) { background-image: svg(lisp#222) }
108-
#matrix tr:first-child th:nth-child(7) { background-image: svg(lua#222) }
109-
#matrix tr:first-child th:nth-child(8) { background-image: svg(perl#222) }
110-
#matrix tr:first-child th:nth-child(9) { background-image: svg(perl6#222) }
111-
#matrix tr:first-child th:nth-child(10) { background-image: svg(php#222) }
112-
#matrix tr:first-child th:nth-child(11) { background-image: svg(python#222) }
113-
#matrix tr:first-child th:nth-child(12) { background-image: svg(ruby#222) }
107+
#matrix tr:first-child th:nth-child(6) { background-image: svg(julia#222) }
108+
#matrix tr:first-child th:nth-child(7) { background-image: svg(lisp#222) }
109+
#matrix tr:first-child th:nth-child(8) { background-image: svg(lua#222) }
110+
#matrix tr:first-child th:nth-child(9) { background-image: svg(perl#222) }
111+
#matrix tr:first-child th:nth-child(10) { background-image: svg(perl6#222) }
112+
#matrix tr:first-child th:nth-child(11) { background-image: svg(php#222) }
113+
#matrix tr:first-child th:nth-child(12) { background-image: svg(python#222) }
114+
#matrix tr:first-child th:nth-child(13) { background-image: svg(ruby#222) }

build-langs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ docker pull alpine:edge
44

55
cd containers
66

7-
for name in Bash Haskell J JavaScript Lisp Lua Perl Perl\ 6 PHP Python Ruby; do
7+
for name in Bash Haskell J JavaScript Julia Lisp Lua Perl Perl\ 6 PHP Python Ruby; do
88
lang=${name,,} # lowercase
99
lang=${lang// /} # trim space
1010

@@ -20,7 +20,7 @@ for name in Bash Haskell J JavaScript Lisp Lua Perl Perl\ 6 PHP Python Ruby; do
2020
docker build -t code-golf-$lang $lang
2121

2222
if [ $lang = j ]; then
23-
ver=`echo echo JLIB | docker run --rm --tmpfs /tmp -i code-golf-$lang`
23+
ver=`echo echo JLIB | docker run --rm --tmpfs /tmp -i code-golf-j`
2424
else
2525
ver=`docker run --rm code-golf-$lang`
2626
fi

containers/julia/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!/julia.c

containers/julia/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM alpine:edge as builder
2+
3+
RUN apk add --no-cache cmake curl g++ gfortran libexecinfo-dev \
4+
linux-headers m4 make musl-dev patch perl python3 tar xz
5+
6+
RUN curl -L https://github.com/JuliaLang/julia/releases/download/v1.0.0/julia-1.0.0.tar.gz | tar xzf -
7+
8+
RUN make -C julia prefix=/usr MARCH=x86-64 install \
9+
&& strip -s /usr/bin/julia /usr/lib/julia/*.so \
10+
&& rm -r julia
11+
12+
COPY julia.c /
13+
14+
RUN gcc -s -o run-julia julia.c
15+
16+
FROM scratch
17+
18+
COPY --from=0 /lib/ld-musl-x86_64.so.1 /lib/
19+
COPY --from=0 /run-julia /usr/bin/julia /usr/bin/
20+
COPY --from=0 /usr/lib/julia/sys.so /usr/lib/julia/
21+
COPY --from=0 /usr/lib/julia/libamd.so \
22+
/usr/lib/julia/libcamd.so \
23+
/usr/lib/julia/libccolamd.so \
24+
/usr/lib/julia/libcholmod.so \
25+
/usr/lib/julia/libcolamd.so \
26+
/usr/lib/julia/libdSFMT.so \
27+
/usr/lib/julia/libgmp.so \
28+
/usr/lib/julia/libgmp.so.10 \
29+
/usr/lib/julia/libLLVM-6.0.so \
30+
/usr/lib/julia/libmpfr.so \
31+
/usr/lib/julia/libopenblas64_.so \
32+
/usr/lib/julia/libopenblas64_.so.0 \
33+
/usr/lib/julia/libpcre2-8.so \
34+
/usr/lib/julia/libsuitesparse_wrapper.so \
35+
/usr/lib/julia/libsuitesparseconfig.so \
36+
/usr/lib/libexecinfo.so.1 \
37+
/usr/lib/libgcc_s.so.1 \
38+
/usr/lib/libgfortran.so.3 \
39+
/usr/lib/libjulia.so.1 \
40+
/usr/lib/libquadmath.so.0 \
41+
/usr/lib/libstdc++.so.6 /usr/lib/
42+
43+
ENTRYPOINT ["/usr/bin/julia", "-e", "println(VERSION)"]

containers/julia/julia.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <unistd.h>
4+
5+
int main (int argc, char *argv[]) {
6+
char buffer[4096];
7+
ssize_t nbytes;
8+
FILE *fp = fopen("/tmp/code.jl", "w");
9+
10+
if (fp == 0)
11+
return 1;
12+
13+
while ((nbytes = fread(buffer, sizeof(char), sizeof(buffer), stdin)) > 0)
14+
if (fwrite(buffer, sizeof(char), nbytes, fp) != nbytes)
15+
return 2;
16+
17+
fclose(fp);
18+
19+
putenv("HOME=/");
20+
21+
execv("/usr/bin/julia", argv);
22+
perror("execv");
23+
}

db.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ CREATE TYPE public.lang AS ENUM (
7777
'haskell',
7878
'j',
7979
'javascript',
80+
'julia',
8081
'lisp',
8182
'lua',
8283
'perl',

0 commit comments

Comments
 (0)