diff --git a/build/luau-head/docker/Dockerfile b/build/luau-head/docker/Dockerfile new file mode 100644 index 00000000..4724eda7 --- /dev/null +++ b/build/luau-head/docker/Dockerfile @@ -0,0 +1,29 @@ +FROM ubuntu:16.04 + +MAINTAINER melpon + +RUN apt-get update && \ + apt-get install -y software-properties-common && \ + add-apt-repository ppa:ubuntu-toolchain-r/test && \ + apt-get update && \ + apt-get install -y --allow-unauthenticated \ + g++-9 \ + git \ + make \ + wget && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV CMAKE_VERSION="3.16.3" \ + CMAKE_SHA256="3e15dadfec8d54eda39c2f266fc1e571c1b88bf32f9d221c8a039b07234206fa" + +ENV CMAKE_PREFIX="/usr/local/wandbox/camke-${CMAKE_VERSION}" + +RUN cd ~/ && \ + wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz && \ + echo "${CMAKE_SHA256} *cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" | sha256sum -c && \ + tar xf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz && \ + mkdir -p /usr/local/wandbox/ && \ + mv cmake-${CMAKE_VERSION}-Linux-x86_64 $CMAKE_PREFIX diff --git a/build/luau-head/install.sh b/build/luau-head/install.sh new file mode 100755 index 00000000..85322957 --- /dev/null +++ b/build/luau-head/install.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +. ../init.sh + +PREFIX=/opt/wandbox/luau-head +CMAKE=/usr/local/wandbox/camke-3.16.3/bin/cmake + +# get sources + +cd ~/ + +git clone https://github.com/Roblox/luau.git +cd luau + +# build + +mkdir cmake && cd cmake +$CMAKE .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DCMAKE_EXE_LINKER_FLAGS="-static" \ + -DCMAKE_CXX_FLAGS="-Wno-unused-variable" +$CMAKE --build . --target Luau.Repl.CLI --config Release +$CMAKE --build . --target Luau.Analyze.CLI --config Release + +mkdir $PREFIX || true + +mkdir $PREFIX/bin || true +cp luau* $PREFIX/bin/ + +# mkdir $PREFIX/lib || true +# cp *.a $PREFIX/lib/ + +cd .. +git rev-parse HEAD > $PREFIX/bin/VERSION + +cp $BASE_DIR/resources/run-luau-analyze.sh.in $PREFIX/bin/run-luau-analyze.sh +sed -i "s#@prefix@#$PREFIX#g" $PREFIX/bin/run-luau-analyze.sh +chmod +x $PREFIX/bin/run-luau-analyze.sh + +rm -r ~/* diff --git a/build/luau-head/resources/run-luau-analyze.sh.in b/build/luau-head/resources/run-luau-analyze.sh.in new file mode 100644 index 00000000..c1fcd73b --- /dev/null +++ b/build/luau-head/resources/run-luau-analyze.sh.in @@ -0,0 +1,3 @@ +#!/bin/bash + +@prefix@/bin/luau-analyze "$@" && echo "" diff --git a/build/luau-head/resources/test.lua b/build/luau-head/resources/test.lua new file mode 100644 index 00000000..11b15b1a --- /dev/null +++ b/build/luau-head/resources/test.lua @@ -0,0 +1 @@ +print("hello") diff --git a/build/luau-head/test.sh b/build/luau-head/test.sh new file mode 100755 index 00000000..3aee5197 --- /dev/null +++ b/build/luau-head/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +. ../init.sh + +PREFIX=/opt/wandbox/luau-head + +test "`$PREFIX/bin/luau $BASE_DIR/resources/test.lua`" = "hello" +test "`$PREFIX/bin/run-luau-analyze.sh $BASE_DIR/resources/test.lua`" = "" diff --git a/build/luau/VERSIONS b/build/luau/VERSIONS new file mode 100644 index 00000000..3995e432 --- /dev/null +++ b/build/luau/VERSIONS @@ -0,0 +1 @@ +0.504 diff --git a/build/luau/docker/Dockerfile b/build/luau/docker/Dockerfile new file mode 100644 index 00000000..4724eda7 --- /dev/null +++ b/build/luau/docker/Dockerfile @@ -0,0 +1,29 @@ +FROM ubuntu:16.04 + +MAINTAINER melpon + +RUN apt-get update && \ + apt-get install -y software-properties-common && \ + add-apt-repository ppa:ubuntu-toolchain-r/test && \ + apt-get update && \ + apt-get install -y --allow-unauthenticated \ + g++-9 \ + git \ + make \ + wget && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV CMAKE_VERSION="3.16.3" \ + CMAKE_SHA256="3e15dadfec8d54eda39c2f266fc1e571c1b88bf32f9d221c8a039b07234206fa" + +ENV CMAKE_PREFIX="/usr/local/wandbox/camke-${CMAKE_VERSION}" + +RUN cd ~/ && \ + wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz && \ + echo "${CMAKE_SHA256} *cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" | sha256sum -c && \ + tar xf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz && \ + mkdir -p /usr/local/wandbox/ && \ + mv cmake-${CMAKE_VERSION}-Linux-x86_64 $CMAKE_PREFIX diff --git a/build/luau/install.sh b/build/luau/install.sh new file mode 100755 index 00000000..029dd918 --- /dev/null +++ b/build/luau/install.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +. ../init.sh + +if [ $# -lt 1 ]; then + echo "$0 " + exit 0 +fi + +VERSION=$1 +PREFIX=/opt/wandbox/luau-$VERSION +CMAKE=/usr/local/wandbox/camke-3.16.3/bin/cmake + +# get sources + +cd ~/ + +git clone https://github.com/Roblox/luau.git -b $VERSION +cd luau + +# build + +mkdir cmake && cd cmake +$CMAKE .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$PREFIX \ + -DCMAKE_EXE_LINKER_FLAGS="-static" \ + -DCMAKE_CXX_FLAGS="-Wno-unused-variable" +$CMAKE --build . --target Luau.Repl.CLI --config Release +$CMAKE --build . --target Luau.Analyze.CLI --config Release + +mkdir $PREFIX || true + +mkdir $PREFIX/bin || true +cp luau* $PREFIX/bin/ + +mkdir $PREFIX/lib || true +cp *.a $PREFIX/lib/ + +cp $BASE_DIR/resources/run-luau-analyze.sh.in $PREFIX/bin/run-luau-analyze.sh +sed -i "s#@prefix@#$PREFIX#g" $PREFIX/bin/run-luau-analyze.sh +chmod +x $PREFIX/bin/run-luau-analyze.sh + +rm -r ~/* diff --git a/build/luau/resources/run-luau-analyze.sh.in b/build/luau/resources/run-luau-analyze.sh.in new file mode 100644 index 00000000..c1fcd73b --- /dev/null +++ b/build/luau/resources/run-luau-analyze.sh.in @@ -0,0 +1,3 @@ +#!/bin/bash + +@prefix@/bin/luau-analyze "$@" && echo "" diff --git a/build/luau/resources/test.lua b/build/luau/resources/test.lua new file mode 100644 index 00000000..11b15b1a --- /dev/null +++ b/build/luau/resources/test.lua @@ -0,0 +1 @@ +print("hello") diff --git a/build/luau/test.sh b/build/luau/test.sh new file mode 100755 index 00000000..5aa8d393 --- /dev/null +++ b/build/luau/test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +. ../init.sh + +if [ $# -lt 1 ]; then + echo "$0 " + exit 0 +fi + +VERSION=$1 +PREFIX=/opt/wandbox/luau-$VERSION + +test "`$PREFIX/bin/luau $BASE_DIR/resources/test.lua`" = "hello" +test "`$PREFIX/bin/run-luau-analyze.sh $BASE_DIR/resources/test.lua`" = "" diff --git a/cattleshed-conf/compilers.py b/cattleshed-conf/compilers.py index a605678e..97fe1f22 100644 --- a/cattleshed-conf/compilers.py +++ b/cattleshed-conf/compilers.py @@ -1747,6 +1747,72 @@ def make_luajit(self): }, cv=cv)) return compilers + def make_luau(self): + luau_vers = get_generic_versions('luau', with_head=True) + compilers = [] + for cv in luau_vers: + if cv == 'head': + display_name = 'Luau HEAD' + else: + display_name = 'Luau' + + if cv == 'head': + version_command = ['/bin/cat', '/opt/wandbox/luau-{cv}/bin/VERSION'] + else: + version_command = ['/bin/echo', '{cv}'] + + compilers.append(format_value({ + 'name': 'luau-{cv}', + 'displayable': True, + 'language': 'Lua', + 'output-file': 'prog.lua', + 'compiler-option-raw': False, + 'compile-command': ['/bin/true'], + 'version-command': version_command, + 'switches': [], + 'initial-checked': [], + 'display-name': display_name, + 'display-compile-command': 'luau prog.lua', + 'run-command': ['/opt/wandbox/luau-{cv}/bin/luau', 'prog.lua'], + 'runtime-option-raw': True, + 'jail-name': 'melpon2-default', + 'templates': ['luau'], + }, cv=cv)) + return compilers + + def make_luau_analyze(self): + luau_vers = get_generic_versions('luau', with_head=True) + compilers = [] + for cv in luau_vers: + if cv == 'head': + display_name = 'Luau analyze HEAD' + else: + display_name = 'Luau analyze' + + if cv == 'head': + version_command = ['/bin/cat', '/opt/wandbox/luau-{cv}/bin/VERSION'] + else: + version_command = ['/bin/echo', '{cv}'] + + compilers.append(format_value({ + 'name': 'luau-analyze-{cv}', + 'displayable': True, + 'language': 'Lua', + 'output-file': 'prog.lua', + 'compiler-option-raw': False, + 'compile-command': ['/bin/true'], + 'version-command': version_command, + 'switches': [], + 'initial-checked': [], + 'display-name': display_name, + 'display-compile-command': 'luau-analyze prog.lua', + 'run-command': ['/opt/wandbox/luau-{cv}/bin/run-luau-analyze.sh', 'prog.lua'], + 'runtime-option-raw': True, + 'jail-name': 'melpon2-default', + 'templates': ['luau-analyze'], + }, cv=cv)) + return compilers + def make_sqlite(self): sqlite_vers = get_generic_versions('sqlite', with_head=True) compilers = [] @@ -2398,6 +2464,8 @@ def make(self): self.make_php() + self.make_lua() + self.make_luajit() + + self.make_luau() + + self.make_luau_analyze() + self.make_sqlite() + self.make_fpc() + self.make_clisp() + diff --git a/cattleshed-conf/templates/luau-analyze/prog.lua b/cattleshed-conf/templates/luau-analyze/prog.lua new file mode 100644 index 00000000..addefc3f --- /dev/null +++ b/cattleshed-conf/templates/luau-analyze/prog.lua @@ -0,0 +1,12 @@ +--!strict +-- This file is a "Hello, world!" in Lua language for wandbox. + +-- TypeError: Unknown global 'HelloWandbox' +HelloWandbox = "!" + +-- Lua language references: +-- https://www.lua.org/ +-- Luau language references: +-- https://luau-lang.org/ +-- Luau analyze references: +-- https://luau-lang.org/typecheck diff --git a/cattleshed-conf/templates/luau/prog.lua b/cattleshed-conf/templates/luau/prog.lua new file mode 100644 index 00000000..63a5e767 --- /dev/null +++ b/cattleshed-conf/templates/luau/prog.lua @@ -0,0 +1,8 @@ +-- This file is a "Hello, world!" in Lua language for wandbox. + +print "Hello, Wandbox!" + +-- Lua language references: +-- https://www.lua.org/ +-- Luau language references: +-- https://luau-lang.org/ diff --git a/test/run.py b/test/run.py index 3890c6f7..0f1f8941 100644 --- a/test/run.py +++ b/test/run.py @@ -221,6 +221,13 @@ def test_gdc_head(): add_test(compiler, lambda: run(compiler, code, 'hello\n')) +def test_luau_analyze(): + code = codecs.open('../build/luau-head/resources/test.lua', 'r', 'utf-8').read() + for cv in get_generic_versions("luau", with_head=True): + compiler = 'luau-analyze-{cv}'.format(cv=cv) + add_test(compiler, lambda compiler=compiler: run(compiler, code, "\n", stderr=False)) + + def test_lazyk(): compiler = 'lazyk' code = codecs.open('../build/lazyk/resources/test.lazy', 'r', 'utf-8').read() @@ -272,6 +279,8 @@ def register(): test_generic(name='php', test_file='test.php', expected='hello\n', with_head=True) test_generic(name='lua', test_file='test.lua', expected='hello\n', with_head=False) test_generic(name='luajit', test_file='test.lua', expected='hello\n', with_head=True) + test_generic(name='luau', test_file='test.lua', expected='hello\n', with_head=True) + test_luau_analyze() test_generic(name='sqlite', test_file='test.sql', expected='hello\n', with_head=True) test_generic(name='fpc', test_file='test.pas', expected='hello\n', with_head=True) test_generic(name='clisp', test_file='test.lisp', expected='hello\n', with_head=False)