Skip to content

Commit

Permalink
Cross build with host tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Apr 13, 2023
1 parent 949f2d5 commit 05ccc15
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 11 deletions.
39 changes: 33 additions & 6 deletions ports/luajit/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -e

LJARCH=
LUAJIT_BUILDMODE=
LUAJIT_BUILDVM_X=
LUAJIT_DASM_ARCHS=
LUAJIT_PREFIX=
for OPTION; do
case "${OPTION}" in
Expand All @@ -13,6 +15,12 @@ for OPTION; do
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=}"
;;
Expand All @@ -33,22 +41,41 @@ BUILD_OPTIONS += 'LDFLAGS=${LDFLAGS}'
BUILD_OPTIONS += 'LIBS=${LIBS}'
ifeq (${LJARCH},)
INSTALL_BUILDVM = yes
# 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=buildvm'
BUILD_OPTIONS += 'BUILDVM_X=${LUAJIT_BUILDVM_X}'
endif
# used by src/Makefile, best effort from manual `$(CC) -E src/lj_arch.h -dM`
TARGET_TESTARCH_COMMON_64 += LJ_ARCH_BITS 64 LJ_ARCH_HASFPU 1 LJ_LE 1 LJ_HASJIT 1
TARGET_TESTARCH_COMMON_64 += LJ_HASFFI 1 LJ_ARCH_HASFPU 1 LJ_ABI_SOFTFP 0 LJ_TARGET_GC64 1
TARGET_TESTARCH_arm64 = \$(TARGET_TESTARCH_COMMON_64) LJ_TARGET_ARM64 LJ_ARCH_VERSION 80
TARGET_TESTARCH_x64 = \$(TARGET_TESTARCH_COMMON_64) LJ_TARGET_X64 LJ_DUALNUM 1 LJ_FR2 1
all:
\$(MAKE) clean \$(COMMON_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 \\
arm64) TARGET_TESTARCH="\$(TARGET_TESTARCH_arm64)" ;; \\
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) --trace install \$(COMMON_OPTIONS)
ifeq (${LJARCH},)
mkdir -p "\$\${DESTDIR}${LUAJIT_PREFIX}/manual-tools/luajit"
install -m 0755 "src/host/buildvm\$(EXECUTABLE_SUFFIX)" "\$\${DESTDIR}${LUAJIT_PREFIX}/manual-tools/luajit/buildvm\$(EXECUTABLE_SUFFIX)"
endif
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
22 changes: 20 additions & 2 deletions ports/luajit/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ vcpkg_from_github(
${extra_patches}
)

vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")

vcpkg_list(SET options)
if(VCPKG_CROSSCOMPILING)
list(APPEND options "LJARCH=${VCPKG_TARGET_ARCHITECTURE}")
vcpkg_host_path_list(PREPEND ENV{PATH} "${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}")
set(host_path "${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}")
list(APPEND options
"LJARCH=${VCPKG_TARGET_ARCHITECTURE}"
"BUILDVM_X=${host_path}/buildvm-${VCPKG_TARGET_ARCHITECTURE}${VCPKG_HOST_EXECUTABLE_SUFFIX}"
)
endif()

if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
Expand Down Expand Up @@ -68,17 +74,29 @@ else()
vcpkg_list(APPEND make_options "TARGET_SYS=Windows")
endif()

set(dasm_archs "")
if("buildvm-arm64" IN_LIST FEATURES)
string(APPEND dasm_archs " arm64")
endif()
if("buildvm-x64" IN_LIST FEATURES)
string(APPEND dasm_archs " 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}"
)
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
Expand Down
30 changes: 28 additions & 2 deletions ports/luajit/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
"dependencies": [
{
"name": "luajit",
"host": true
"host": true,
"features": [
"buildvm-x64"
],
"platform": "x64 & (!windows | mingw) & !native"
},
{
"name": "luajit",
"host": true,
"features": [
"buildvm-arm64"
],
"platform": "arm64 & (!windows | mingw) & !native"
},
{
"name": "vcpkg-cmake",
Expand All @@ -18,6 +30,20 @@
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "vcpkg-cmake-get-vars",
"host": true
}
],
"features": {
"buildvm-arm64": {
"description": "Install host tools for arm64 targets",
"supports": "native & (!windows | mingw)"
},
"buildvm-x64": {
"description": "Install host tools for x64 targets",
"supports": "native & (!windows | mingw)"
}
]
}
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4886,7 +4886,7 @@
},
"luajit": {
"baseline": "2023-01-04",
"port-version": 0
"port-version": 1
},
"luasec": {
"baseline": "1.1.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/luajit.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b8b55de760f43b0c564225d1b31a11ab0cd04fa7",
"version-date": "2023-01-04",
"port-version": 1
},
{
"git-tree": "3c7f639efd41b49e93c61ae54fd99bb332d80bf9",
"version-date": "2023-01-04",
Expand Down

0 comments on commit 05ccc15

Please sign in to comment.