Skip to content
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
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,7 @@ def test_external_ports(self):
''', stdout)

@requires_network
@also_with_pthreads
def test_port_contrib_lua(self):
self.do_runf('other/test_port_contrib_lua.c', 'hello world\nHELLO WORLD\nsqrt(16)=4\n', cflags=['--use-port=contrib.lua'])

Expand Down
15 changes: 11 additions & 4 deletions tools/ports/contrib/lua.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
LICENSE = 'MIT License'

port_name = 'contrib.lua'
lib_name = 'liblua.a'
variants = {'contrib.lua-mt': {'PTHREADS': 1}}

def get_lib_name(settings):
return 'liblua' + ('-mt' if settings.PTHREADS else '') + '.a'

def get(ports, settings, shared):
# get the port
Expand All @@ -36,10 +38,15 @@ def create(final):
ldblib.c liolib.c lmathlib.c loadlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c linit.c
'''.split()

ports.build_port(source_path, final, port_name, srcs=srcs)
flags=[]

return [shared.cache.get_lib(lib_name, create, what='port')]
if settings.PTHREADS:
flags += ['-pthread']

ports.build_port(source_path, final, port_name, srcs=srcs, flags=flags)

return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]


def clear(ports, settings, shared):
shared.cache.erase_lib(lib_name)
shared.cache.erase_lib(get_lib_name(settings))