Skip to content

Commit

Permalink
Add V lang
Browse files Browse the repository at this point in the history
  • Loading branch information
JRaspass committed Dec 24, 2020
1 parent 0e18bfa commit 74bbb70
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 4 deletions.
2 changes: 1 addition & 1 deletion db/a-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CREATE TYPE lang AS ENUM (
'bash', 'brainfuck', 'c', 'c-sharp', 'cobol', 'f-sharp', 'fish',
'fortran', 'go', 'haskell', 'j', 'java', 'javascript', 'julia', 'lisp',
'lua', 'nim', 'perl', 'php', 'powershell', 'python', 'raku', 'ruby',
'rust', 'sql', 'swift', 'zig'
'rust', 'sql', 'swift', 'v', 'zig'
);

CREATE TYPE scoring AS ENUM ('bytes', 'chars');
Expand Down
1 change: 1 addition & 0 deletions docker/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 185 M
COPY --from=codegolf/lang-c-sharp ["/", "/langs/c-sharp/rootfs/" ] # 128 MiB
COPY --from=codegolf/lang-go ["/", "/langs/go/rootfs/" ] # 110 MiB
COPY --from=codegolf/lang-f-sharp ["/", "/langs/f-sharp/rootfs/" ] # 108 MiB
COPY --from=codegolf/lang-v ["/", "/langs/v/rootfs/" ] # 97.1 MiB
COPY --from=codegolf/lang-java ["/", "/langs/java/rootfs/" ] # 68.7 MiB
COPY --from=codegolf/lang-raku ["/", "/langs/raku/rootfs/" ] # 50.6 MiB
COPY --from=codegolf/lang-lisp ["/", "/langs/lisp/rootfs/" ] # 35.4 MiB
Expand Down
1 change: 1 addition & 0 deletions docker/live.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ COPY --from=codegolf/lang-powershell ["/", "/langs/powershell/rootfs/"] # 185 M
COPY --from=codegolf/lang-c-sharp ["/", "/langs/c-sharp/rootfs/" ] # 128 MiB
COPY --from=codegolf/lang-go ["/", "/langs/go/rootfs/" ] # 110 MiB
COPY --from=codegolf/lang-f-sharp ["/", "/langs/f-sharp/rootfs/" ] # 108 MiB
COPY --from=codegolf/lang-v ["/", "/langs/v/rootfs/" ] # 97.1 MiB
COPY --from=codegolf/lang-java ["/", "/langs/java/rootfs/" ] # 68.7 MiB
COPY --from=codegolf/lang-raku ["/", "/langs/raku/rootfs/" ] # 50.6 MiB
COPY --from=codegolf/lang-lisp ["/", "/langs/lisp/rootfs/" ] # 35.4 MiB
Expand Down
25 changes: 23 additions & 2 deletions langs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ example = '''
print("Hello, World!")
// Looping
for n in 0...9 {
print(n)
for i in 0...9 {
print(i)
}
// Accessing arguments
Expand All @@ -420,6 +420,27 @@ for arg in CommandLine.arguments[1...] {
}
'''

[V]
size = '97.1 MiB'
version = '0.2'
website = '//vlang.io'
example = '''
import os
// Printing
println('Hello, World!')
// Looping
for i in 0..10 {
println(i)
}
// Accessing arguments
for arg in os.args[1..] {
println(arg)
}
'''

[Zig]
size = '216 MiB'
version = '0.7.0'
Expand Down
31 changes: 31 additions & 0 deletions langs/v/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM debian:buster-slim as builder

RUN mkdir /empty

RUN apt-get update && apt-get install -y gcc git make

RUN git clone -b 0.2 git://github.com/vlang/v /opt/v

RUN cd /opt/v && make

FROM debian:buster-slim

RUN apt-get update && apt-get install -y libc-dev

COPY --from=0 /opt/v/thirdparty/tcc /opt/v/thirdparty/tcc
COPY --from=0 /opt/v/v /opt/v/v
COPY --from=0 /opt/v/vlib /opt/v/vlib

FROM scratch

COPY --from=1 /bin /bin
COPY --from=1 /lib /lib
COPY --from=1 /lib64 /lib64
COPY --from=1 /opt/v /opt/v
COPY --from=0 /empty /proc
COPY --from=0 /empty /tmp
COPY --from=1 /usr /usr

COPY v /usr/bin/

CMD ["/opt/v/v", "version"]
16 changes: 16 additions & 0 deletions langs/v/v
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -e

# FIXME Setting VVV=/opt/v doesn't prevent the need to cd.
cd /opt/v

# FIXME "v run -" writes the code to the cwd first, which fails under r/o.
# V panic: Failed to create temporary file 01ETADWV0J7NFKFRH587599FQQ.v

# Compile
cat - > /tmp/code.v
./v /tmp/code.v
rm /tmp/code.v

# Execute
shift
exec /tmp/code "$@"
8 changes: 8 additions & 0 deletions t/args.t
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ swift
print(a)
}
v
import os
for a in os.args[1..] {
println(a)
}
zig
const std = @import("std");
Expand Down
3 changes: 2 additions & 1 deletion views/css/golfer/holes.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ input.ruby:not(:checked) ~ .ruby,
input.rust:not(:checked) ~ .rust,
input.sql:not(:checked) ~ .sql,
input.swift:not(:checked) ~ .swift,
input.v:not(:checked) ~ .v,
input.zig:not(:checked) ~ .zig { display: none }

input:checked + label {
Expand All @@ -84,7 +85,7 @@ main svg:nth-of-type(2) {

@media (min-width: 1280px) {
/* Increase this number when adding a language. */
main { grid-template-columns: 4fr repeat(27, 1fr) }
main { grid-template-columns: 4fr repeat(28, 1fr) }

main a { height: 1.9rem }

Expand Down
1 change: 1 addition & 0 deletions views/svg/v.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 74bbb70

Please sign in to comment.