Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/ports/contrib/lua.py
4154 views
1
# Copyright 2025 The Emscripten Authors. All rights reserved.
2
# Emscripten is available under two separate licenses, the MIT license and the
3
# University of Illinois/NCSA Open Source License. Both these licenses can be
4
# found in the LICENSE file.
5
6
import os
7
8
TAG = '5.4.7'
9
HASH = '98c5c8978dfdf867e37e9eb3b3ec83dee92d199243b5119505da83895e33f10d43c841be6a7d3b106daba8a0b2bd25fe099ebff8f87831dcc55c79c78b97d8b8'
10
11
# contrib port information (required)
12
URL = 'https://www.lua.org/'
13
DESCRIPTION = 'Lua is a powerful, efficient, lightweight, embeddable scripting language'
14
LICENSE = 'MIT License'
15
16
port_name = 'contrib.lua'
17
lib_name = 'liblua.a'
18
19
20
def get(ports, settings, shared):
21
# get the port
22
ports.fetch_project(port_name, f'https://www.lua.org/ftp/lua-{TAG}.tar.gz', sha512hash=HASH)
23
24
def create(final):
25
root_path = os.path.join(ports.get_dir(), port_name, f'lua-{TAG}')
26
source_path = os.path.join(root_path, 'src')
27
28
# install headers
29
includes = ['lua.h', 'lua.hpp', 'luaconf.h', 'lauxlib.h', 'lualib.h']
30
for f in includes:
31
ports.install_headers(source_path, pattern=f)
32
33
srcs = '''
34
lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c
35
lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lcorolib.c
36
ldblib.c liolib.c lmathlib.c loadlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c linit.c
37
'''.split()
38
39
flags = ['-DLUA_COMPAT_5_3']
40
41
ports.build_port(source_path, final, port_name, srcs=srcs, flags=flags)
42
43
return [shared.cache.get_lib(lib_name, create, what='port')]
44
45
46
def clear(ports, settings, shared):
47
shared.cache.erase_lib(lib_name)
48
49