[luajit] Use common build functions (#30608)

* [luajit] Use nmake build setup [skip actions]

* [luajit] Use vcpkg_configure/install_make [skip actions]

* Cross build with host tools

* Host tools must match target bitness

* Cleanup

* WIP

* Don't touch CI baseline now

* Less osx quirks

* Move msvc header installation to nmake

* Simplify MSVC

* Add arm and x86 cross build support
This commit is contained in:
Kai Pastor 2023-05-10 01:57:10 +02:00 committed by GitHub
parent e7250fea9f
commit f35ba0c785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 253 additions and 249 deletions

View File

@ -1,139 +0,0 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index d323d8d..6e61150 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -15,19 +15,20 @@
@setlocal
@rem Add more debug flags here, e.g. DEBUGCFLAGS=/DLUA_USE_APICHECK
@set DEBUGCFLAGS=
-@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline
+@set SOURCEDIR=%1
+@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_STDIO_INLINE=__declspec(dllexport)__inline /I%SOURCEDIR%
@set LJLINK=link /nologo
@set LJMT=mt /nologo
@set LJLIB=lib /nologo /nodefaultlib
-@set DASMDIR=..\dynasm
+@set DASMDIR=%SOURCEDIR%\..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
-@set DASC=vm_x64.dasc
+@set DASC=%SOURCEDIR%\vm_x64.dasc
@set LJDLLNAME=lua51.dll
@set LJLIBNAME=lua51.lib
@set BUILDTYPE=release
-@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c lib_buffer.c
+@set ALL_LIB=%SOURCEDIR%\lib_base.c %SOURCEDIR%\lib_math.c %SOURCEDIR%\lib_bit.c %SOURCEDIR%\lib_string.c %SOURCEDIR%\lib_table.c %SOURCEDIR%\lib_io.c %SOURCEDIR%\lib_os.c %SOURCEDIR%\lib_package.c %SOURCEDIR%\lib_debug.c %SOURCEDIR%\lib_jit.c %SOURCEDIR%\lib_ffi.c %SOURCEDIR%\lib_buffer.c
-%LJCOMPILE% host\minilua.c
+%LJCOMPILE% %SOURCEDIR%\host\minilua.c /Fdminilua.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:minilua.exe minilua.obj
@if errorlevel 1 goto :BAD
@@ -38,20 +39,20 @@ if exist minilua.exe.manifest^
@set LJARCH=x64
@minilua
@if errorlevel 8 goto :X64
-@set DASC=vm_x86.dasc
+@set DASC=%SOURCEDIR%\vm_x86.dasc
@set DASMFLAGS=-D WIN -D JIT -D FFI
@set LJARCH=x86
@set LJCOMPILE=%LJCOMPILE% /arch:SSE2
:X64
@if "%1" neq "nogc64" goto :GC64
@shift
-@set DASC=vm_x86.dasc
+@set DASC=%SOURCEDIR%\vm_x86.dasc
@set LJCOMPILE=%LJCOMPILE% /DLUAJIT_DISABLE_GC64
:GC64
-minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h %DASC%
+minilua %DASM% -LN %DASMFLAGS% -o %SOURCEDIR%\host\buildvm_arch.h %DASC%
@if errorlevel 1 goto :BAD
-%LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c
+%LJCOMPILE% /I "." /I %DASMDIR% %SOURCEDIR%\host\buildvm*.c /Fdbuildvm.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:buildvm.exe buildvm*.obj
@if errorlevel 1 goto :BAD
@@ -60,41 +61,44 @@ if exist buildvm.exe.manifest^
buildvm -m peobj -o lj_vm.obj
@if errorlevel 1 goto :BAD
-buildvm -m bcdef -o lj_bcdef.h %ALL_LIB%
+buildvm -m bcdef -o %SOURCEDIR%\lj_bcdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m ffdef -o lj_ffdef.h %ALL_LIB%
+buildvm -m ffdef -o %SOURCEDIR%\lj_ffdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m libdef -o lj_libdef.h %ALL_LIB%
+buildvm -m libdef -o %SOURCEDIR%\lj_libdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m recdef -o lj_recdef.h %ALL_LIB%
+buildvm -m recdef -o %SOURCEDIR%\lj_recdef.h %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m vmdef -o jit\vmdef.lua %ALL_LIB%
+buildvm -m vmdef -o %SOURCEDIR%\jit\vmdef.lua %ALL_LIB%
@if errorlevel 1 goto :BAD
-buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
+buildvm -m folddef -o %SOURCEDIR%\lj_folddef.h %SOURCEDIR%\lj_opt_fold.c
@if errorlevel 1 goto :BAD
-@if "%1" neq "debug" goto :NODEBUG
+@if "%2"=="static" set CRT_LINKAGE=/MT
+@if "%2"=="dynamic" set CRT_LINKAGE=/MD
+@set LJLINK=%LJLINK% /debug
+@if "%3" neq "debug" goto :NODEBUG
@shift
@set BUILDTYPE=debug
@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS%
-@set LJLINK=%LJLINK% /opt:ref /opt:icf /incremental:no
+@set CRT_LINKAGE=%CRT_LINKAGE%d
:NODEBUG
@set LJLINK=%LJLINK% /%BUILDTYPE%
-@if "%1"=="amalg" goto :AMALGDLL
-@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+@if "%3"=="amalg" goto :AMALGDLL
+@if "%3"=="static" goto :STATIC
+%LJCOMPILE% %CRT_LINKAGE% /DLUA_BUILD_AS_DLL %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:STATIC
-%LJCOMPILE% lj_*.c lib_*.c
+%LJCOMPILE% %CRT_LINKAGE% %SOURCEDIR%\lj_*.c %SOURCEDIR%\lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:AMALGDLL
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL %SOURCEDIR%\ljamalg.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD
@@ -102,7 +106,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
-%LJCOMPILE% luajit.c
+%LJCOMPILE% %CRT_LINKAGE% %SOURCEDIR%\luajit.c /Fdluajit.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD
@@ -110,8 +114,8 @@ if exist luajit.exe.manifest^
%LJMT% -manifest luajit.exe.manifest -outputresource:luajit.exe
@del *.obj *.manifest minilua.exe buildvm.exe
-@del host\buildvm_arch.h
-@del lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h
+@del %SOURCEDIR%\host\buildvm_arch.h
+@del %SOURCEDIR%\lj_bcdef.h %SOURCEDIR%\lj_ffdef.h %SOURCEDIR%\lj_libdef.h %SOURCEDIR%\lj_recdef.h %SOURCEDIR%\lj_folddef.h
@echo.
@echo === Successfully built LuaJIT for Windows/%LJARCH% ===
@@ -124,4 +128,5 @@ if exist luajit.exe.manifest^
@goto :END
:FAIL
@echo You must open a "Visual Studio Command Prompt" to run this script
+exit 1
:END

View File

@ -0,0 +1,20 @@
all:
@echo _CL_ = $(_CL_)
@echo _LINK_ = $(_LINK_)
cd src && .\msvcbuild.bat $(MSVCBUILD_OPTIONS)
install: src/luajit.exe
-mkdir "$(INSTALLDIR)"
-mkdir "$(INSTALLDIR)\bin"
copy src\luajit.exe "$(INSTALLDIR)\bin\"
if exist src\lua51.dll copy src\lua51.dll "$(INSTALLDIR)\bin\"
-mkdir "$(INSTALLDIR)\lib"
copy src\lua51.lib "$(INSTALLDIR)\lib\"
-mkdir "$(INSTALLDIR)\include"
-mkdir "$(INSTALLDIR)\include\luajit"
copy src/lua.h "$(INSTALLDIR)\include\luajit\"
copy src/luajit.h "$(INSTALLDIR)\include\luajit\"
copy src/luaconf.h "$(INSTALLDIR)\include\luajit\"
copy src/lualib.h "$(INSTALLDIR)\include\luajit\"
copy src/lauxlib.h "$(INSTALLDIR)\include\luajit\"
copy src/lua.hpp "$(INSTALLDIR)\include\luajit\"

86
ports/luajit/configure vendored Executable file
View File

@ -0,0 +1,86 @@
#!/bin/sh
set -e
LJARCH=
LUAJIT_BUILDMODE=
LUAJIT_BUILDVM_X=
LUAJIT_DASM_ARCHS=
LUAJIT_PREFIX=
for OPTION; do
case "${OPTION}" in
--prefix=*)
LUAJIT_PREFIX="${OPTION#--prefix=}"
;;
BUILDMODE=*)
LUAJIT_BUILDMODE="${OPTION#BUILDMODE=}"
;;
BUILDVM_X=*)
LUAJIT_BUILDVM_X="${OPTION#BUILDVM_X=}"
;;
DASM_ARCHS=*)
LUAJIT_DASM_ARCHS="${OPTION#DASM_ARCHS=}"
;;
LJARCH=*)
LJARCH="${OPTION#LJARCH=}"
;;
esac
done
cat > Makefile.vcpkg <<END_MAKEFILE ;
COMMON_OPTIONS += 'E=@:' 'Q='
COMMON_OPTIONS += 'BUILDMODE=${LUAJIT_BUILDMODE}'
COMMON_OPTIONS += 'PREFIX=${LUAJIT_PREFIX}'
COMMON_OPTIONS += 'INSTALL_TNAME=luajit'
BUILD_OPTIONS += 'CC=${CC}'
BUILD_OPTIONS += 'CCDEBUG='
BUILD_OPTIONS += 'CFLAGS=${CPPFLAGS} ${CFLAGS}'
BUILD_OPTIONS += 'LDFLAGS=${LDFLAGS}'
BUILD_OPTIONS += 'LIBS=${LIBS}'
ifeq (${LJARCH},)
# native
BUILDVM_PREFIX = ${LUAJIT_PREFIX}/manual-tools/luajit
DASM_ARCHS = ${LUAJIT_DASM_ARCHS}
else
# cross
BUILD_OPTIONS += 'HOST_CC=:'
BUILD_OPTIONS += 'BUILDVM_T='
BUILD_OPTIONS += 'BUILDVM_X=${LUAJIT_BUILDVM_X}'
endif
# used by src/Makefile, best effort from manual '<CC> [-m32] -E src/lj_arch.h -dM'
TARGET_TESTARCH_COMMON += 'LJ_LE 1' 'LJ_HASJIT 1' 'LJ_HASFFI 1' 'LJ_ARCH_HASFPU 1' 'LJ_ABI_SOFTFP 0'
TARGET_TESTARCH_COMMON_32 += \$(TARGET_TESTARCH_COMMON) 'LJ_ARCH_BITS 32'
TARGET_TESTARCH_COMMON_64 += \$(TARGET_TESTARCH_COMMON) 'LJ_ARCH_BITS 64' 'LJ_TARGET_GC64 1'
TARGET_TESTARCH_arm = \$(TARGET_TESTARCH_COMMON_32) LJ_TARGET_ARM
TARGET_TESTARCH_arm64 = \$(TARGET_TESTARCH_COMMON_64) LJ_TARGET_ARM64 'LJ_ARCH_VERSION 80'
TARGET_TESTARCH_x86 = \$(TARGET_TESTARCH_COMMON_32) LJ_TARGET_X86
TARGET_TESTARCH_x64 = \$(TARGET_TESTARCH_COMMON_64) LJ_TARGET_X64 'LJ_DUALNUM 1' 'LJ_FR2 1'
all:
\$(MAKE) clean \$(COMMON_OPTIONS) \$(BUILD_OPTIONS)
\$(MAKE) all \$(COMMON_OPTIONS) \$(BUILD_OPTIONS)
for DA in \$(DASM_ARCHS); do \\
rm -f src/host/buildvm_arch.h src/host/*.o; \\
case "\$\$DA" in \\
arm) TARGET_TESTARCH="\$(TARGET_TESTARCH_arm)" ;; \\
arm64) TARGET_TESTARCH="\$(TARGET_TESTARCH_arm64)" ;; \\
x86) TARGET_TESTARCH="\$(TARGET_TESTARCH_x86)" ;; \\
x64) TARGET_TESTARCH="\$(TARGET_TESTARCH_x64)" ;; \\
esac ; \\
\$(MAKE) -C src host/buildvm-\$\$DA\$(EXECUTABLE_SUFFIX) \$(COMMON_OPTIONS) \$(BUILD_OPTIONS) \\
BUILDVM_T=host/buildvm-\$\$DA\$(EXECUTABLE_SUFFIX) "TARGET_TESTARCH=\$\${TARGET_TESTARCH}" \\
|| exit 1; \\
done
install:
\$(MAKE) install \$(COMMON_OPTIONS)
for DA in \$(DASM_ARCHS); do \\
mkdir -p "\$\${DESTDIR}\$(BUILDVM_PREFIX)"; \\
install -m 0755 "src/host/buildvm-\$\$DA\$(EXECUTABLE_SUFFIX)" "\$\${DESTDIR}\$(BUILDVM_PREFIX)/buildvm-\$\$DA\$(EXECUTABLE_SUFFIX)" || exit 1 ; \\
done
END_MAKEFILE

View File

@ -6,7 +6,7 @@ version=${majver}.${minver}.${relver}-beta3
abiver=51
prefix=@PREFIX@
multilib=@LJIT_LIBDIR@
multilib=lib
exec_prefix=${prefix}
libdir=${exec_prefix}/${multilib}
libname=lua${abiver}

View File

@ -0,0 +1,31 @@
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat
index aab4ef1..e92c486 100644
--- a/src/msvcbuild.bat
+++ b/src/msvcbuild.bat
@@ -79,10 +79,9 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
@set LJCOMPILE=%LJCOMPILE% /Zi %DEBUGCFLAGS%
@set LJLINK=%LJLINK% /opt:ref /opt:icf /incremental:no
:NODEBUG
-@set LJLINK=%LJLINK% /%BUILDTYPE%
@if "%1"=="amalg" goto :AMALGDLL
@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c /Fdlua51.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@@ -102,7 +101,7 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
if exist %LJDLLNAME%.manifest^
%LJMT% -manifest %LJDLLNAME%.manifest -outputresource:%LJDLLNAME%;2
-%LJCOMPILE% luajit.c
+%LJCOMPILE% luajit.c /Fdluajit.pdb
@if errorlevel 1 goto :BAD
%LJLINK% /out:luajit.exe luajit.obj %LJLIBNAME%
@if errorlevel 1 goto :BAD
@@ -124,4 +123,5 @@ if exist luajit.exe.manifest^
@goto :END
:FAIL
@echo You must open a "Visual Studio Command Prompt" to run this script
+@exit 1
:END

View File

@ -1,7 +1,6 @@
set(extra_patches "")
if (VCPKG_TARGET_IS_OSX)
set (LJIT_PATCHES 005-do-not-pass-ld-e-macosx.patch)
else()
set (LJIT_PATCHES "")
list(APPEND extra_patches 005-do-not-pass-ld-e-macosx.patch)
endif()
vcpkg_from_github(
@ -11,124 +10,95 @@ vcpkg_from_github(
SHA512 e4111b2d7eeb05676c62d69da13a380a51d98f082c0be575a414c09ee27ff17d101b5b4a95e1b8a1bad14d55a4d2b305718a11878fbf36e0d3d48e62ba03407f
HEAD_REF master
PATCHES
msvcbuild.patch
003-do-not-set-macosx-deployment-target.patch
004-fix-build-path-and-crt-linkage.patch
${LJIT_PATCHES}
${extra_patches}
)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set (LJIT_STATIC "")
set (LJIT_MSVC_PC_CFLAGS "/DLUA_BUILD_AS_DLL=1")
else()
set (LJIT_STATIC "static")
set (LJIT_MSVC_PC_CFLAGS "")
endif()
vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")
if(VCPKG_TARGET_IS_OSX)
set(MACOSX_DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=${VCPKG_OSX_DEPLOYMENT_TARGET}")
set(TARGET_ARCHITECTURE "${VCPKG_TARGET_ARCHITECTURE}")
if(TARGET_ARCHITECTURE STREQUAL x64)
set(TARGET_ARCHITECTURE x86_64)
if(VCPKG_DETECTED_MSVC)
# Due to lack of better MSVC cross-build support, just always build the host
# minilua tool with the target toolchain. This will work for native builds and
# for targeting x86 from x64 hosts. (UWP and ARM64 is unsupported.)
vcpkg_list(SET options)
set(PKGCONFIG_CFLAGS "")
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
list(APPEND options "MSVCBUILD_OPTIONS=static")
else()
set(PKGCONFIG_CFLAGS "/DLUA_BUILD_AS_DLL=1")
endif()
list(APPEND MACOSX_ARCHITECTURES "TARGET_CFLAGS=--target=${TARGET_ARCHITECTURE}-apple-darwin")
list(APPEND MACOSX_ARCHITECTURES "TARGET_LDFLAGS=--target=${TARGET_ARCHITECTURE}-apple-darwin")
endif()
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL debug)
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
vcpkg_install_nmake(SOURCE_PATH "${SOURCE_PATH}"
PROJECT_NAME "${CMAKE_CURRENT_LIST_DIR}/Makefile.nmake"
OPTIONS
${options}
)
if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
vcpkg_execute_required_process_repeat(
COUNT 1
COMMAND "${SOURCE_PATH}/src/msvcbuild.bat" ${SOURCE_PATH}/src ${VCPKG_CRT_LINKAGE} debug ${LJIT_STATIC}
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
LOGNAME build-${TARGET_TRIPLET}-dbg
)
# Note that luajit's build system responds to failure by producing no output; in particular a likely outcome is
# only 'minilua.exe' being produced. This resulted in:
# https://github.com/microsoft/vcpkg/pull/25856#issuecomment-1214285736
# Please ensure luajit.exe is actually produced when making future changes.
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/luajit.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/tools")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/lua51.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
set(LJIT_LIBDIR "debug/lib")
configure_file("${CMAKE_CURRENT_LIST_DIR}/luajit.pc.win.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/luajit.pc" @ONLY)
if(NOT VCPKG_BUILD_TYPE)
configure_file("${CMAKE_CURRENT_LIST_DIR}/luajit.pc.win.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/luajit.pc" @ONLY)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/lua51.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(COPY "${CURRENT_PACKAGES_DIR}/debug/bin/lua51.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/tools")
endif()
vcpkg_copy_pdbs()
else()
vcpkg_execute_build_process(
COMMAND make -j${VCPKG_CONCURRENCY} -f ${SOURCE_PATH}/Makefile ${MACOSX_DEPLOYMENT_TARGET} clean
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME clean-${TARGET_TRIPLET}-debug
)
vcpkg_execute_build_process(
COMMAND make -j${VCPKG_CONCURRENCY} -f ${SOURCE_PATH}/Makefile ${MACOSX_DEPLOYMENT_TARGET} ${MACOSX_ARCHITECTURES} PREFIX=${CURRENT_PACKAGES_DIR}/debug CCDEBUG=-g3 CFLAGS=-O0 BUILDMODE=${VCPKG_LIBRARY_LINKAGE} install
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-debug
)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/lua")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/luajit.pc" "multilib=lib" "multilib=debug/lib")
endif()
endif()
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL release)
message(STATUS "Building ${TARGET_TRIPLET}-rel")
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
vcpkg_execute_required_process_repeat(
COUNT 1
COMMAND "${SOURCE_PATH}/src/msvcbuild.bat" ${SOURCE_PATH}/src ${VCPKG_CRT_LINKAGE} ${LJIT_STATIC}
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
LOGNAME build-${TARGET_TRIPLET}-rel
vcpkg_copy_pdbs()
else()
vcpkg_list(SET options)
if(VCPKG_CROSSCOMPILING)
list(APPEND options
"LJARCH=${VCPKG_TARGET_ARCHITECTURE}"
"BUILDVM_X=${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}/buildvm-${VCPKG_TARGET_ARCHITECTURE}${VCPKG_HOST_EXECUTABLE_SUFFIX}"
)
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/luajit.exe" DESTINATION "${CURRENT_PACKAGES_DIR}/tools")
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/lua51.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
set(LJIT_LIBDIR "lib")
configure_file("${CMAKE_CURRENT_LIST_DIR}/luajit.pc.win.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/luajit.pc" @ONLY)
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/lua51.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
vcpkg_copy_tools(TOOL_NAMES luajit SEARCH_DIR ${CURRENT_PACKAGES_DIR}/tools AUTO_CLEAN)
endif()
vcpkg_copy_pdbs()
else()
vcpkg_execute_build_process(
COMMAND make -j${VCPKG_CONCURRENCY} -f ${SOURCE_PATH}/Makefile ${MACOSX_DEPLOYMENT_TARGET} clean
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME clean-${TARGET_TRIPLET}-rel
)
vcpkg_execute_build_process(
COMMAND make -j${VCPKG_CONCURRENCY} -f ${SOURCE_PATH}/Makefile ${MACOSX_DEPLOYMENT_TARGET} ${MACOSX_ARCHITECTURES} PREFIX=${CURRENT_PACKAGES_DIR} CCDEBUG= BUILDMODE=${VCPKG_LIBRARY_LINKAGE} install
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-rel
)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/lua" "${CURRENT_PACKAGES_DIR}/lib/lua")
endif()
vcpkg_list(SET make_options "EXECUTABLE_SUFFIX=${VCPKG_TARGET_EXECUTABLE_SUFFIX}")
if(VCPKG_TARGET_IS_OSX)
vcpkg_list(APPEND make_options "TARGET_SYS=Darwin")
elseif(VCPKG_TARGET_IS_IOS)
vcpkg_list(APPEND make_options "TARGET_SYS=iOS")
elseif(VCPKG_TARGET_IS_LINUX)
vcpkg_list(APPEND make_options "TARGET_SYS=Linux")
elseif(VCPKG_TARGET_IS_WINDOWS)
vcpkg_list(APPEND make_options "TARGET_SYS=Windows")
endif()
set(dasm_archs "")
if("buildvm-32" IN_LIST FEATURES)
string(APPEND dasm_archs " arm x86")
endif()
if("buildvm-64" IN_LIST FEATURES)
string(APPEND dasm_archs " arm64 x64")
endif()
file(COPY "${CMAKE_CURRENT_LIST_DIR}/configure" DESTINATION "${SOURCE_PATH}")
vcpkg_configure_make(SOURCE_PATH "${SOURCE_PATH}"
COPY_SOURCE
OPTIONS
"BUILDMODE=${VCPKG_LIBRARY_LINKAGE}"
${options}
OPTIONS_RELEASE
"DASM_ARCHS=${dasm_archs}"
)
vcpkg_install_make(
MAKEFILE "Makefile.vcpkg"
OPTIONS
${make_options}
"TARGET_AR=${VCPKG_DETECTED_CMAKE_AR} rcus"
"TARGET_STRIP=${VCPKG_DETECTED_CMAKE_STRIP}"
)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/lib/lua"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/lib/lua"
"${CURRENT_PACKAGES_DIR}/share/lua"
"${CURRENT_PACKAGES_DIR}/share/man"
)
file(INSTALL "${SOURCE_PATH}/src/lua.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}")
file(INSTALL "${SOURCE_PATH}/src/luajit.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}")
file(INSTALL "${SOURCE_PATH}/src/luaconf.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}")
file(INSTALL "${SOURCE_PATH}/src/lualib.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}")
file(INSTALL "${SOURCE_PATH}/src/lauxlib.h" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}")
file(INSTALL "${SOURCE_PATH}/src/lua.hpp" DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}")
vcpkg_copy_tools(TOOL_NAMES luajit AUTO_CLEAN)
vcpkg_fixup_pkgconfig()
file(INSTALL "${SOURCE_PATH}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYRIGHT")

View File

@ -1,11 +1,28 @@
{
"name": "luajit",
"version-date": "2023-01-04",
"port-version": 1,
"description": "LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.",
"homepage": "https://github.com/LuaJIT/LuaJIT",
"license": "MIT",
"supports": "!uwp",
"supports": "!uwp & !(arm64 & windows)",
"dependencies": [
{
"name": "luajit",
"host": true,
"features": [
"buildvm-64"
],
"platform": "!native & (arm64 | x64) & (!windows | mingw)"
},
{
"name": "luajit",
"host": true,
"features": [
"buildvm-32"
],
"platform": "!native & ((arm & !arm64) | x86) & (!windows | mingw)"
},
{
"name": "vcpkg-cmake",
"host": true
@ -13,6 +30,20 @@
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "vcpkg-cmake-get-vars",
"host": true
}
]
],
"features": {
"buildvm-32": {
"description": "Install host tools for 32 bit targets",
"supports": "native & ((arm & !arm64) | x86) & (!windows | mingw)"
},
"buildvm-64": {
"description": "Install host tools for 64 bit targets",
"supports": "native & (arm64 | x64) & (!windows | mingw)"
}
}
}

View File

@ -4954,7 +4954,7 @@
},
"luajit": {
"baseline": "2023-01-04",
"port-version": 0
"port-version": 1
},
"luasec": {
"baseline": "1.3.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "5a564decc9569af8e940353cab9623b6f93f3a4b",
"version-date": "2023-01-04",
"port-version": 1
},
{
"git-tree": "3c7f639efd41b49e93c61ae54fd99bb332d80bf9",
"version-date": "2023-01-04",