Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Luau #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions build/luau-head/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:16.04

MAINTAINER melpon <shigemasa7watanabe+docker@gmail.com>

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
41 changes: 41 additions & 0 deletions build/luau-head/install.sh
Original file line number Diff line number Diff line change
@@ -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 ~/*
3 changes: 3 additions & 0 deletions build/luau-head/resources/run-luau-analyze.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

@prefix@/bin/luau-analyze "$@" && echo ""
1 change: 1 addition & 0 deletions build/luau-head/resources/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("hello")
8 changes: 8 additions & 0 deletions build/luau-head/test.sh
Original file line number Diff line number Diff line change
@@ -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`" = ""
1 change: 1 addition & 0 deletions build/luau/VERSIONS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.504
29 changes: 29 additions & 0 deletions build/luau/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:16.04

MAINTAINER melpon <shigemasa7watanabe+docker@gmail.com>

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
44 changes: 44 additions & 0 deletions build/luau/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

. ../init.sh

if [ $# -lt 1 ]; then
echo "$0 <version>"
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 ~/*
3 changes: 3 additions & 0 deletions build/luau/resources/run-luau-analyze.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

@prefix@/bin/luau-analyze "$@" && echo ""
1 change: 1 addition & 0 deletions build/luau/resources/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("hello")
14 changes: 14 additions & 0 deletions build/luau/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

. ../init.sh

if [ $# -lt 1 ]; then
echo "$0 <version>"
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`" = ""
68 changes: 68 additions & 0 deletions cattleshed-conf/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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() +
Expand Down
12 changes: 12 additions & 0 deletions cattleshed-conf/templates/luau-analyze/prog.lua
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions cattleshed-conf/templates/luau/prog.lua
Original file line number Diff line number Diff line change
@@ -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/
9 changes: 9 additions & 0 deletions test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down