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

[luajit] Use common build functions #30608

Merged
merged 12 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 0 additions & 139 deletions ports/luajit/004-fix-build-path-and-crt-linkage.patch

This file was deleted.

20 changes: 20 additions & 0 deletions ports/luajit/Makefile.nmake
Original file line number Diff line number Diff line change
@@ -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 changes: 86 additions & 0 deletions ports/luajit/configure
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion ports/luajit/luajit.pc.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
31 changes: 31 additions & 0 deletions ports/luajit/msvcbuild.patch
Original file line number Diff line number Diff line change
@@ -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
Loading