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

[Luau] Add new port to luau #42101

Merged
merged 12 commits into from
Nov 12, 2024
137 changes: 137 additions & 0 deletions ports/luau/cmake-config-export.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51fa919e..d25cca2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,30 +65,30 @@ add_library(Luau.VM.Internals INTERFACE)

include(Sources.cmake)

-target_include_directories(Luau.Common INTERFACE Common/include)
+target_include_directories(Luau.Common INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common/include> $<INSTALL_INTERFACE:include/luau>)

target_compile_features(Luau.CLI.lib PUBLIC cxx_std_17)
target_link_libraries(Luau.CLI.lib PRIVATE Luau.Common)

target_compile_features(Luau.Ast PUBLIC cxx_std_17)
-target_include_directories(Luau.Ast PUBLIC Ast/include)
+target_include_directories(Luau.Ast PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Ast/include> $<INSTALL_INTERFACE:include/luau>)
target_link_libraries(Luau.Ast PUBLIC Luau.Common Luau.CLI.lib)

target_compile_features(Luau.Compiler PUBLIC cxx_std_17)
-target_include_directories(Luau.Compiler PUBLIC Compiler/include)
+target_include_directories(Luau.Compiler PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Compiler/include> $<INSTALL_INTERFACE:include/luau>)
target_link_libraries(Luau.Compiler PUBLIC Luau.Ast)

target_compile_features(Luau.Config PUBLIC cxx_std_17)
-target_include_directories(Luau.Config PUBLIC Config/include)
+target_include_directories(Luau.Config PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Config/include> $<INSTALL_INTERFACE:include/luau>)
target_link_libraries(Luau.Config PUBLIC Luau.Ast)

target_compile_features(Luau.Analysis PUBLIC cxx_std_17)
-target_include_directories(Luau.Analysis PUBLIC Analysis/include)
+target_include_directories(Luau.Analysis PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Analysis/include> $<INSTALL_INTERFACE:include/luau>)
target_link_libraries(Luau.Analysis PUBLIC Luau.Ast Luau.EqSat Luau.Config)
target_link_libraries(Luau.Analysis PRIVATE Luau.Compiler Luau.VM)

target_compile_features(Luau.EqSat PUBLIC cxx_std_17)
-target_include_directories(Luau.EqSat PUBLIC EqSat/include)
+target_include_directories(Luau.EqSat PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/EqSat/include> $<INSTALL_INTERFACE:include/luau>)
target_link_libraries(Luau.EqSat PUBLIC Luau.Common)

target_compile_features(Luau.CodeGen PRIVATE cxx_std_17)
@@ -97,7 +97,7 @@ target_link_libraries(Luau.CodeGen PRIVATE Luau.VM Luau.VM.Internals) # Code gen
target_link_libraries(Luau.CodeGen PUBLIC Luau.Common)

target_compile_features(Luau.VM PRIVATE cxx_std_11)
-target_include_directories(Luau.VM PUBLIC VM/include)
+target_include_directories(Luau.VM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/VM/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(Luau.VM PUBLIC Luau.Common)

target_include_directories(isocline PUBLIC extern/isocline/include)
@@ -182,22 +182,6 @@ if(MSVC AND LUAU_BUILD_CLI)
set_target_properties(Luau.Repl.CLI PROPERTIES LINK_FLAGS_DEBUG /STACK:2097152)
endif()

-# embed .natvis inside the library debug information
-if(MSVC)
- target_link_options(Luau.Ast INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/Ast.natvis)
- target_link_options(Luau.Analysis INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/Analysis.natvis)
- target_link_options(Luau.CodeGen INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/CodeGen.natvis)
- target_link_options(Luau.VM INTERFACE /NATVIS:${CMAKE_CURRENT_SOURCE_DIR}/tools/natvis/VM.natvis)
-endif()
-
-# make .natvis visible inside the solution
-if(MSVC_IDE)
- target_sources(Luau.Ast PRIVATE tools/natvis/Ast.natvis)
- target_sources(Luau.Analysis PRIVATE tools/natvis/Analysis.natvis)
- target_sources(Luau.CodeGen PRIVATE tools/natvis/CodeGen.natvis)
- target_sources(Luau.VM PRIVATE tools/natvis/VM.natvis)
-endif()
-
# On Windows and Android threads are provided, on Linux/Mac/iOS we use pthreads
add_library(osthreads INTERFACE)
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin|iOS")
@@ -287,3 +271,54 @@ foreach(LIB Luau.Ast Luau.Compiler Luau.Config Luau.Analysis Luau.EqSat Luau.Cod
endif()
endif()
endforeach()
+
+# luau package
+include(GNUInstallDirs)
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/luau-config-version.cmake
+ VERSION "${VERSION}"
+ COMPATIBILITY AnyNewerVersion
+)
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/luau-config-version.cmake
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/luau-config.cmake
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/luau
+)
+
+install(
+ TARGETS Luau.Common Luau.Ast Luau.Compiler Luau.Config Luau.Analysis Luau.VM Luau.CLI.lib Luau.EqSat
+ EXPORT luau-targets
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+)
+
+if (LUAU_BUILD_CLI)
+ install(
+ TARGETS Luau.Repl.CLI
+ EXPORT luau-targets
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ )
+endif()
sssooonnnggg marked this conversation as resolved.
Show resolved Hide resolved
+
+install(
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Common/include/"
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Ast/include/"
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Compiler/include/"
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Config/include/"
+ DIRECTORY "${CMAKE_SOURCE_DIR}/Analysis/include/"
+ DIRECTORY "${CMAKE_SOURCE_DIR}/VM/include/"
+ DIRECTORY "${CMAKE_SOURCE_DIR}/VM/src/"
+ DESTINATION "include/luau"
+ FILES_MATCHING
+ PATTERN "*.h"
+)
+
+install(
+ EXPORT luau-targets
+ NAMESPACE luau::
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/luau"
+)
\ No newline at end of file
diff --git a/cmake/luau-config.cmake b/cmake/luau-config.cmake
new file mode 100644
index 00000000..fd681158
--- /dev/null
+++ b/cmake/luau-config.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/luau-targets.cmake)
\ No newline at end of file
39 changes: 39 additions & 0 deletions ports/luau/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO luau-lang/luau
REF ${VERSION}
SHA512 a3be52f7958d364693c0bc2541b08082852917b53a80cc4fbdde3167c9068b269f8476882592eafac4c4d674ed6d51ba25a52eaa3b2b6d4dce4603f6aad73f6b
HEAD_REF master
PATCHES
cmake-config-export.patch
)

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tool LUAU_BUILD_CLI
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DVERSION=${VERSION}
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DLUAU_BUILD_CLI=OFF
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(PACKAGE_NAME "luau")

if("tool" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES luau AUTO_CLEAN)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
22 changes: 22 additions & 0 deletions ports/luau/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "luau",
"version": "0.651",
"description": "A fast, small, safe, gradually typed embeddable scripting language derived from Lua",
"homepage": "https://github.com/luau-lang/luau",
"license": "MIT",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"tool": {
"description": "Builds luau executable"
}
}
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5652,6 +5652,10 @@
"baseline": "3.1.0",
"port-version": 1
},
"luau": {
"baseline": "0.651",
"port-version": 0
},
"luminoengine": {
"baseline": "0.10.1",
"port-version": 1
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/luau.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"version": "0.651",
"port-version": 0,
"git-tree": "ea1bcb7db02b46fd51b187ba76532c766f23e9cb"
}
]
}