CMakeLists.txt: Add a vercel_pkg CMake target to package the JavaScript output into executables for macOS when using emscripten and yarn (or npm)
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
e7df484db0
commit
022a0c6b62
|
@ -14,7 +14,8 @@ set(EXEDESC "Transpiler for the yerbacon language.")
|
||||||
string(TIMESTAMP SHORT_BUILD_TIMESTAMP "%Y%m")
|
string(TIMESTAMP SHORT_BUILD_TIMESTAMP "%Y%m")
|
||||||
string(SUBSTRING ${SHORT_BUILD_TIMESTAMP} 2 4 SHORT_BUILD_TIMESTAMP)
|
string(SUBSTRING ${SHORT_BUILD_TIMESTAMP} 2 4 SHORT_BUILD_TIMESTAMP)
|
||||||
string(ASCII 169 CopyrightCharacter)
|
string(ASCII 169 CopyrightCharacter)
|
||||||
string(TIMESTAMP LEGAL-COPYRIGHT "Copyright ${CopyrightCharacter} 2020-%Y. Available under the MPL-2.0 license.")
|
set(CPACK_RPM_PACKAGE_LICENSE "MPL-2.0")
|
||||||
|
string(TIMESTAMP LEGAL-COPYRIGHT "Copyright ${CopyrightCharacter} 2020-%Y. Available under the ${CPACK_RPM_PACKAGE_LICENSE} license.")
|
||||||
file(COPY "resources/${PROJECT_NAME}.ico" DESTINATION "processed")
|
file(COPY "resources/${PROJECT_NAME}.ico" DESTINATION "processed")
|
||||||
configure_file("resources/${PROJECT_NAME}.manifest" "processed/${PROJECT_NAME}.manifest" @ONLY)
|
configure_file("resources/${PROJECT_NAME}.manifest" "processed/${PROJECT_NAME}.manifest" @ONLY)
|
||||||
configure_file("resources/${PROJECT_NAME}.rc" "processed/${PROJECT_NAME}.rc" @ONLY)
|
configure_file("resources/${PROJECT_NAME}.rc" "processed/${PROJECT_NAME}.rc" @ONLY)
|
||||||
|
@ -200,7 +201,26 @@ if (NOT (UPPERCASE_BUILD_TYPE STREQUAL "DEBUG" OR UPPERCASE_BUILD_TYPE STREQUAL
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX AND NOT (MINGW OR CMAKE_HOST_WIN32))
|
if (EMSCRIPTEN)
|
||||||
|
find_program(NPM_PRESENT npm)
|
||||||
|
find_program(YARN_PRESENT yarn)
|
||||||
|
if (YARN_PRESENT)
|
||||||
|
set(NODE_PACKAGE_PROGRAM "${YARN_PRESENT}")
|
||||||
|
elseif(NPM_PRESENT)
|
||||||
|
set(NODE_PACKAGE_PROGRAM "${NPM_PRESENT}")
|
||||||
|
endif()
|
||||||
|
if (DEFINED NODE_PACKAGE_PROGRAM)
|
||||||
|
configure_file("resources/package.json" "processed/package.json" @ONLY)
|
||||||
|
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/processed/package.json" DESTINATION ".")
|
||||||
|
file(COPY "resources/.npmrc" DESTINATION ".")
|
||||||
|
add_custom_target(vercel_pkg COMMAND ${NODE_PACKAGE_PROGRAM} install)
|
||||||
|
add_dependencies(vercel_pkg ${EXENAME})
|
||||||
|
# Warning: https://github.com/sbingner/ldid has to be on the PATH, before packaging, for the arm64 macOS executable to work
|
||||||
|
add_custom_command(TARGET vercel_pkg POST_BUILD COMMAND node_modules/.bin/pkg --config processed/package.json -C Brotli $<TARGET_FILE:${EXENAME}> --no-bytecode --public-packages "\"*\"" --public --output "${EXENAME}-mac" VERBATIM)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (UNIX AND NOT (MINGW OR CMAKE_HOST_WIN32 OR EMSCRIPTEN))
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
set(CMAKE_INSTALL_PREFIX "/usr")
|
set(CMAKE_INSTALL_PREFIX "/usr")
|
||||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
@ -214,7 +234,6 @@ if (UNIX AND NOT (MINGW OR CMAKE_HOST_WIN32))
|
||||||
set(CPACK_RPM_COMPRESSION_TYPE ${CPACK_DEBIAN_COMPRESSION_TYPE})
|
set(CPACK_RPM_COMPRESSION_TYPE ${CPACK_DEBIAN_COMPRESSION_TYPE})
|
||||||
set(CPACK_RPM_PACKAGE_AUTOREQ YES)
|
set(CPACK_RPM_PACKAGE_AUTOREQ YES)
|
||||||
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
||||||
set(CPACK_RPM_PACKAGE_LICENSE "MPL-2.0")
|
|
||||||
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog")
|
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog")
|
||||||
if (CMAKE_VERSION STREQUAL "3.21.1")
|
if (CMAKE_VERSION STREQUAL "3.21.1")
|
||||||
message(WARNING "CPack ${CMAKE_VERSION} has a bug which causes rpm scripts to be unusable; please update or downgrade")
|
message(WARNING "CPack ${CMAKE_VERSION} has a bug which causes rpm scripts to be unusable; please update or downgrade")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
|
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
|
||||||
def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: false, notFailBuild: true, skipWhenFailed: false) }
|
def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: false, notFailBuild: true, skipWhenFailed: false) }
|
||||||
|
boolean use_yarn_or_npm() { return fileExists('/usr/bin/yarn') || fileExists('/usr/bin/npm') }
|
||||||
|
|
||||||
/* Required Plugins:
|
/* Required Plugins:
|
||||||
- CMake
|
- CMake
|
||||||
|
@ -13,6 +14,8 @@ def clean_workspace() { cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disa
|
||||||
Optional Tools:
|
Optional Tools:
|
||||||
- Ninja
|
- Ninja
|
||||||
- UPX (d61edc9 or higher)
|
- UPX (d61edc9 or higher)
|
||||||
|
- Vercel PKG (https://github.com/vercel/pkg)
|
||||||
|
- LDID (https://github.com/sbingner/ldid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
@ -67,7 +70,7 @@ pipeline {
|
||||||
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
|
||||||
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${path}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCXX_TARGET=\"${use_toolchain ? 'noarch' : debArch}\" -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCMAKE_SYSTEM_PROCESSOR=\"${path.substring(0, path.indexOf('-'))}\" -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ -DCMAKE_LINKER=${fileExists("${linker}.gold") ? "${linker}.gold" : linker} -DCMAKE_AR=/usr/bin/${path}-ar -DCMAKE_RC_COMPILER=/usr/bin/${path}-windres -DCMAKE_EXE_LINKER_FLAGS=-static"} -DNO_SELF_PACKER=${!(not_packer_compatible || use_toolchain) ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON -DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON${path.endsWith('armv7-w64-mingw32') ? ' -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=NO' : ''}",
|
cmakeArgs: "--no-warn-unused-cli ${use_toolchain ? "-DCMAKE_TOOLCHAIN_FILE=${path}" : "-DCMAKE_SYSTEM_NAME=\"${system_name}\" -DCXX_TARGET=\"${use_toolchain ? 'noarch' : debArch}\" -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCMAKE_SYSTEM_PROCESSOR=\"${path.substring(0, path.indexOf('-'))}\" -DCMAKE_C_COMPILER=/usr/bin/${path}-gcc -DCMAKE_CXX_COMPILER=/usr/bin/${path}-g++ -DCMAKE_LINKER=${fileExists("${linker}.gold") ? "${linker}.gold" : linker} -DCMAKE_AR=/usr/bin/${path}-ar -DCMAKE_RC_COMPILER=/usr/bin/${path}-windres -DCMAKE_EXE_LINKER_FLAGS=-static"} -DNO_SELF_PACKER=${!(not_packer_compatible || use_toolchain) ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON -DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON${path.endsWith('armv7-w64-mingw32') ? ' -DCMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE=NO' : ''}",
|
||||||
generator: cmake_generator()
|
generator: cmake_generator()
|
||||||
cmake arguments: "--build ./$build_directory --target ybcon", installation: 'Latest'
|
cmake arguments: "--build ./$build_directory --target ${!("${TARGET}".endsWith('Emscripten.cmake') && use_yarn_or_npm()) ? 'ybcon' : 'vercel_pkg'}", installation: 'Latest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +89,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
echo 'Deploying....'
|
echo 'Deploying....'
|
||||||
catchError(buildResult: "${TARGET}".endsWith('.cmake') ? 'FAILURE' : 'UNSTABLE', stageResult: 'FAILURE') {
|
catchError(buildResult: "${TARGET}".endsWith('.cmake') ? 'FAILURE' : 'UNSTABLE', stageResult: 'FAILURE') {
|
||||||
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-*/*.js, cmake-build-*/*.*.exe, cmake-build-*/*.zip', fingerprint: false
|
archiveArtifacts artifacts: "cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-*/*.js,${use_yarn_or_npm() ? 'cmake-build-*/*-mac-*,' : ''} cmake-build-*/*.*.exe, cmake-build-*/*.zip", fingerprint: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package-lock=false
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "@EXENAME@",
|
||||||
|
"bin": "@EXENAME@.js",
|
||||||
|
"license": "@CPACK_RPM_PACKAGE_LICENSE@",
|
||||||
|
"devDependencies": { "pkg": "^5.8.0" },
|
||||||
|
"pkg": {
|
||||||
|
"assets": "../@EXENAME@.worker.js",
|
||||||
|
"targets": [
|
||||||
|
"latest-macos-x64",
|
||||||
|
"latest-macos-arm64"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue