From 2f789860b78f4ffe4f1ea305689d18fcf21c399f Mon Sep 17 00:00:00 2001 From: Song Date: Tue, 12 Nov 2024 15:31:39 +0800 Subject: [PATCH] [Luau] Add new port to luau (#42101) --- ports/luau/cmake-config-export.patch | 137 +++++++++++++++++++++++++++ ports/luau/portfile.cmake | 39 ++++++++ ports/luau/vcpkg.json | 22 +++++ versions/baseline.json | 4 + versions/l-/luau.json | 9 ++ 5 files changed, 211 insertions(+) create mode 100644 ports/luau/cmake-config-export.patch create mode 100644 ports/luau/portfile.cmake create mode 100644 ports/luau/vcpkg.json create mode 100644 versions/l-/luau.json diff --git a/ports/luau/cmake-config-export.patch b/ports/luau/cmake-config-export.patch new file mode 100644 index 0000000000..eb59a87021 --- /dev/null +++ b/ports/luau/cmake-config-export.patch @@ -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 $ $) + + 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 $ $) + 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 $ $) + 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 $ $) + 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 $ $) + 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 $ $) + 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 $ $) + 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 diff --git a/ports/luau/portfile.cmake b/ports/luau/portfile.cmake new file mode 100644 index 0000000000..2d730827bb --- /dev/null +++ b/ports/luau/portfile.cmake @@ -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") \ No newline at end of file diff --git a/ports/luau/vcpkg.json b/ports/luau/vcpkg.json new file mode 100644 index 0000000000..b090db08b8 --- /dev/null +++ b/ports/luau/vcpkg.json @@ -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" + } + } +} diff --git a/versions/baseline.json b/versions/baseline.json index 007e7b3909..db7f611b66 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5664,6 +5664,10 @@ "baseline": "3.1.0", "port-version": 1 }, + "luau": { + "baseline": "0.651", + "port-version": 0 + }, "luminoengine": { "baseline": "0.10.1", "port-version": 1 diff --git a/versions/l-/luau.json b/versions/l-/luau.json new file mode 100644 index 0000000000..cf06853b4d --- /dev/null +++ b/versions/l-/luau.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "version": "0.651", + "port-version": 0, + "git-tree": "b24888fd538d5e53526c0a7b6f37646f9aec0556" + } + ] +} \ No newline at end of file