Skip to content

Commit 2f78986

Browse files
authored
[Luau] Add new port to luau (microsoft#42101)
1 parent 1b18be1 commit 2f78986

File tree

5 files changed

+211
-0
lines changed

5 files changed

+211
-0
lines changed

ports/luau/cmake-config-export.patch

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 51fa919e..9854f32c 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -65,30 +65,30 @@ add_library(Luau.VM.Internals INTERFACE)
6+
7+
include(Sources.cmake)
8+
9+
-target_include_directories(Luau.Common INTERFACE Common/include)
10+
+target_include_directories(Luau.Common INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common/include> $<INSTALL_INTERFACE:include/luau>)
11+
12+
target_compile_features(Luau.CLI.lib PUBLIC cxx_std_17)
13+
target_link_libraries(Luau.CLI.lib PRIVATE Luau.Common)
14+
15+
target_compile_features(Luau.Ast PUBLIC cxx_std_17)
16+
-target_include_directories(Luau.Ast PUBLIC Ast/include)
17+
+target_include_directories(Luau.Ast PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Ast/include> $<INSTALL_INTERFACE:include/luau>)
18+
target_link_libraries(Luau.Ast PUBLIC Luau.Common Luau.CLI.lib)
19+
20+
target_compile_features(Luau.Compiler PUBLIC cxx_std_17)
21+
-target_include_directories(Luau.Compiler PUBLIC Compiler/include)
22+
+target_include_directories(Luau.Compiler PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/include> $<INSTALL_INTERFACE:include/luau>)
23+
target_link_libraries(Luau.Compiler PUBLIC Luau.Ast)
24+
25+
target_compile_features(Luau.Config PUBLIC cxx_std_17)
26+
-target_include_directories(Luau.Config PUBLIC Config/include)
27+
+target_include_directories(Luau.Config PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Config/include> $<INSTALL_INTERFACE:include/luau>)
28+
target_link_libraries(Luau.Config PUBLIC Luau.Ast)
29+
30+
target_compile_features(Luau.Analysis PUBLIC cxx_std_17)
31+
-target_include_directories(Luau.Analysis PUBLIC Analysis/include)
32+
+target_include_directories(Luau.Analysis PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Analysis/include> $<INSTALL_INTERFACE:include/luau>)
33+
target_link_libraries(Luau.Analysis PUBLIC Luau.Ast Luau.EqSat Luau.Config)
34+
target_link_libraries(Luau.Analysis PRIVATE Luau.Compiler Luau.VM)
35+
36+
target_compile_features(Luau.EqSat PUBLIC cxx_std_17)
37+
-target_include_directories(Luau.EqSat PUBLIC EqSat/include)
38+
+target_include_directories(Luau.EqSat PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/EqSat/include> $<INSTALL_INTERFACE:include/luau>)
39+
target_link_libraries(Luau.EqSat PUBLIC Luau.Common)
40+
41+
target_compile_features(Luau.CodeGen PRIVATE cxx_std_17)
42+
@@ -97,7 +97,7 @@ target_link_libraries(Luau.CodeGen PRIVATE Luau.VM Luau.VM.Internals) # Code gen
43+
target_link_libraries(Luau.CodeGen PUBLIC Luau.Common)
44+
45+
target_compile_features(Luau.VM PRIVATE cxx_std_11)
46+
-target_include_directories(Luau.VM PUBLIC VM/include)
47+
+target_include_directories(Luau.VM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/VM/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
48+
target_link_libraries(Luau.VM PUBLIC Luau.Common)
49+
50+
target_include_directories(isocline PUBLIC extern/isocline/include)
51+
@@ -182,22 +182,6 @@ if(MSVC AND LUAU_BUILD_CLI)
52+
set_target_properties(Luau.Repl.CLI PROPERTIES LINK_FLAGS_DEBUG /STACK:2097152)
53+
endif()
54+
55+
-# embed .natvis inside the library debug information
56+
-if(MSVC)
57+
- target_link_options(Luau.Ast INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/Ast.natvis)
58+
- target_link_options(Luau.Analysis INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/Analysis.natvis)
59+
- target_link_options(Luau.CodeGen INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/CodeGen.natvis)
60+
- target_link_options(Luau.VM INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/VM.natvis)
61+
-endif()
62+
-
63+
-# make .natvis visible inside the solution
64+
-if(MSVC_IDE)
65+
- target_sources(Luau.Ast PRIVATE tools/natvis/Ast.natvis)
66+
- target_sources(Luau.Analysis PRIVATE tools/natvis/Analysis.natvis)
67+
- target_sources(Luau.CodeGen PRIVATE tools/natvis/CodeGen.natvis)
68+
- target_sources(Luau.VM PRIVATE tools/natvis/VM.natvis)
69+
-endif()
70+
-
71+
# On Windows and Android threads are provided, on Linux/Mac/iOS we use pthreads
72+
add_library(osthreads INTERFACE)
73+
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin|iOS")
74+
@@ -287,3 +271,54 @@ foreach(LIB Luau.Ast Luau.Compiler Luau.Config Luau.Analysis Luau.EqSat Luau.Cod
75+
endif()
76+
endif()
77+
endforeach()
78+
+
79+
+# luau package
80+
+include(GNUInstallDirs)
81+
+include(CMakePackageConfigHelpers)
82+
+
83+
+write_basic_package_version_file(
84+
+ ${CMAKE_CURRENT_BINARY_DIR}/unofficial-luau-config-version.cmake
85+
+ VERSION "${VERSION}"
86+
+ COMPATIBILITY AnyNewerVersion
87+
+)
88+
+
89+
+install(FILES
90+
+ ${CMAKE_CURRENT_BINARY_DIR}/unofficial-luau-config-version.cmake
91+
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/unofficial-luau-config.cmake
92+
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/unofficial-luau
93+
+)
94+
+
95+
+install(
96+
+ TARGETS Luau.Common Luau.Ast Luau.Compiler Luau.Config Luau.Analysis Luau.VM Luau.CLI.lib Luau.EqSat
97+
+ EXPORT unofficial-luau-targets
98+
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
99+
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
100+
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
101+
+)
102+
+
103+
+if (LUAU_BUILD_CLI)
104+
+ install(
105+
+ TARGETS Luau.Repl.CLI
106+
+ EXPORT unofficial-luau-targets
107+
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
108+
+ )
109+
+endif()
110+
+
111+
+install(
112+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Common/include/"
113+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Ast/include/"
114+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Compiler/include/"
115+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Config/include/"
116+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Analysis/include/"
117+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/VM/include/"
118+
+ DIRECTORY "${CMAKE_SOURCE_DIR}/VM/src/"
119+
+ DESTINATION "include/luau"
120+
+ FILES_MATCHING
121+
+ PATTERN "*.h"
122+
+)
123+
+
124+
+install(
125+
+ EXPORT unofficial-luau-targets
126+
+ NAMESPACE unofficial::luau::
127+
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-luau"
128+
+)
129+
\ No newline at end of file
130+
diff --git a/cmake/unofficial-luau-config.cmake b/cmake/unofficial-luau-config.cmake
131+
new file mode 100644
132+
index 00000000..2680ef31
133+
--- /dev/null
134+
+++ b/cmake/unofficial-luau-config.cmake
135+
@@ -0,0 +1 @@
136+
+include(${CMAKE_CURRENT_LIST_DIR}/unofficial-luau-targets.cmake)
137+
\ No newline at end of file

ports/luau/portfile.cmake

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
2+
3+
vcpkg_from_github(
4+
OUT_SOURCE_PATH SOURCE_PATH
5+
REPO luau-lang/luau
6+
REF ${VERSION}
7+
SHA512 a3be52f7958d364693c0bc2541b08082852917b53a80cc4fbdde3167c9068b269f8476882592eafac4c4d674ed6d51ba25a52eaa3b2b6d4dce4603f6aad73f6b
8+
HEAD_REF master
9+
PATCHES
10+
cmake-config-export.patch
11+
)
12+
13+
vcpkg_check_features(
14+
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
15+
FEATURES
16+
tool LUAU_BUILD_CLI
17+
)
18+
19+
vcpkg_cmake_configure(
20+
SOURCE_PATH "${SOURCE_PATH}"
21+
OPTIONS
22+
-DVERSION=${VERSION}
23+
${FEATURE_OPTIONS}
24+
OPTIONS_DEBUG
25+
-DLUAU_BUILD_CLI=OFF
26+
)
27+
28+
vcpkg_cmake_install()
29+
30+
vcpkg_cmake_config_fixup(PACKAGE_NAME "unofficial-luau")
31+
32+
if("tool" IN_LIST FEATURES)
33+
vcpkg_copy_tools(TOOL_NAMES luau AUTO_CLEAN)
34+
endif()
35+
36+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
37+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
38+
39+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")

ports/luau/vcpkg.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "luau",
3+
"version": "0.651",
4+
"description": "A fast, small, safe, gradually typed embeddable scripting language derived from Lua",
5+
"homepage": "https://github.com/luau-lang/luau",
6+
"license": "MIT",
7+
"dependencies": [
8+
{
9+
"name": "vcpkg-cmake",
10+
"host": true
11+
},
12+
{
13+
"name": "vcpkg-cmake-config",
14+
"host": true
15+
}
16+
],
17+
"features": {
18+
"tool": {
19+
"description": "Builds luau executable"
20+
}
21+
}
22+
}

versions/baseline.json

+4
Original file line numberDiff line numberDiff line change
@@ -5664,6 +5664,10 @@
56645664
"baseline": "3.1.0",
56655665
"port-version": 1
56665666
},
5667+
"luau": {
5668+
"baseline": "0.651",
5669+
"port-version": 0
5670+
},
56675671
"luminoengine": {
56685672
"baseline": "0.10.1",
56695673
"port-version": 1

versions/l-/luau.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"versions": [
3+
{
4+
"version": "0.651",
5+
"port-version": 0,
6+
"git-tree": "b24888fd538d5e53526c0a7b6f37646f9aec0556"
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)