[Luau] Add new port to luau (#42101)

This commit is contained in:
Song 2024-11-12 15:31:39 +08:00 committed by GitHub
parent 1b18be18af
commit 2f789860b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 211 additions and 0 deletions

View File

@ -0,0 +1,137 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51fa919e..9854f32c 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}/unofficial-luau-config-version.cmake
+ VERSION "${VERSION}"
+ COMPATIBILITY AnyNewerVersion
+)
+
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/unofficial-luau-config-version.cmake
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/unofficial-luau-config.cmake
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/unofficial-luau
+)
+
+install(
+ TARGETS Luau.Common Luau.Ast Luau.Compiler Luau.Config Luau.Analysis Luau.VM Luau.CLI.lib Luau.EqSat
+ EXPORT unofficial-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 unofficial-luau-targets
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ )
+endif()
+
+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 unofficial-luau-targets
+ NAMESPACE unofficial::luau::
+ DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-luau"
+)
\ No newline at end of file
diff --git a/cmake/unofficial-luau-config.cmake b/cmake/unofficial-luau-config.cmake
new file mode 100644
index 00000000..2680ef31
--- /dev/null
+++ b/cmake/unofficial-luau-config.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/unofficial-luau-targets.cmake)
\ No newline at end of file

39
ports/luau/portfile.cmake Normal file
View File

@ -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 "unofficial-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
ports/luau/vcpkg.json Normal file
View File

@ -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"
}
}
}

View File

@ -5664,6 +5664,10 @@
"baseline": "3.1.0", "baseline": "3.1.0",
"port-version": 1 "port-version": 1
}, },
"luau": {
"baseline": "0.651",
"port-version": 0
},
"luminoengine": { "luminoengine": {
"baseline": "0.10.1", "baseline": "0.10.1",
"port-version": 1 "port-version": 1

9
versions/l-/luau.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": [
{
"version": "0.651",
"port-version": 0,
"git-tree": "b24888fd538d5e53526c0a7b6f37646f9aec0556"
}
]
}