CMakeLists.txt: Remove PNAME + CXX_TARGET, set CPACK_PACKAGE_FILE_NAME only once and let rpmbuild and the CPack Deb generator decide what file name to use

Jenkinsfile: Remove the buildTarget function's architecture-related parameters
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-08-24 00:25:14 +02:00
parent 0fbe69ba91
commit 7846634165
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 20 additions and 26 deletions

View File

@ -34,6 +34,9 @@ if (CMAKE_CXX_LINK_PIE_SUPPORTED)
elseif(USER_DEFINED_PIE AND CMAKE_POSITION_INDEPENDENT_CODE)
message(NOTICE "-- Could NOT manually enable Position-Independent Code (PIC) because it is not supported by the current toolchain")
endif()
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "")
set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_COLOR_DIAGNOSTICS ON)
@ -150,7 +153,7 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_CONTACT "Username404 <w.iron.zombie@gmail.com>")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${TIME}")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CODENAME}-${TIME}_${CMAKE_SYSTEM_NAME}.${CMAKE_SYSTEM_PROCESSOR}")
include_directories(${CMAKE_CURRENT_LIST_DIR})
add_executable(${EXENAME} src/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/processed/${PROJECT_NAME}.rc src/etc/filefuncs.cpp src/etc/lexer.cpp src/headers/lex.hpp src/headers/misc.hpp src/headers/parsing/ParseComponents.hpp src/headers/transpiler/Target.hpp src/headers/transpiler/implementations/Lua.hpp src/headers/transpiler/implementations/Js.hpp src/headers/transpiler/implementations/Py.hpp src/headers/parsing/Parser.hpp src/headers/arguments.hpp src/headers/parsing/ReservedIdentifiers.hpp)
@ -181,21 +184,20 @@ if (NOT (UPPERCASE_BUILD_TYPE STREQUAL "DEBUG" OR UPPERCASE_BUILD_TYPE STREQUAL
endif()
endif()
# lpkg = linux package, wpkg = windows package
set(PNAME ${PROJECT_NAME}-${CODENAME}-${TIME})
if (UNIX AND NOT (MINGW OR CMAKE_HOST_WIN32))
include(GNUInstallDirs)
set(CMAKE_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(CPACK_PACKAGE_FILE_NAME "${PNAME}_lpkg")
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst" "processed/postinst" @ONLY)
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/processed/postinst")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE})
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_COMPRESSION_TYPE xz)
set(CPACK_RPM_COMPRESSION_TYPE ${CPACK_DEBIAN_COMPRESSION_TYPE})
set(CPACK_RPM_PACKAGE_AUTOREQ YES)
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")
if (CMAKE_VERSION STREQUAL "3.21.1")
@ -248,7 +250,6 @@ elseif(MINGW OR MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ -static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CPACK_PACKAGE_FILE_NAME "${PNAME}_wpkg")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
set(CPACK_NSIS_MANIFEST_DPI_AWARE TRUE)
set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME} ${CODENAME}-${PROJECT_VERSION}")
@ -271,8 +272,4 @@ elseif(MINGW OR MSVC)
set(CPACK_GENERATOR ZIP;NSIS)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXENAME}.exe DESTINATION bin)
endif()
if (NOT DEFINED CXX_TARGET)
set(CXX_TARGET ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.${CXX_TARGET}")
include(CPack)

31
Jenkinsfile vendored
View File

@ -1,22 +1,19 @@
String cmake_generator() { return fileExists('/usr/bin/ninja') ? 'Ninja' : 'Unix Makefiles' }
String no_compilation_cache_flags() { return '-DNO_CCACHE=ON -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON' }
def buildTarget(String path, String rpmArch = 'noarch', String debArch = 'noarch', boolean isPackageArchDeb = true, String suffix = '') {
final String packageArch = isPackageArchDeb ? debArch : rpmArch;
def buildTarget(String path) {
final String system_name = !path.contains('mingw') ? sh(returnStdout: true, script: 'uname -s').trim() : 'Windows'
final String linker = "/usr/bin/${path}-ld"
final String build_directory = "cmake-build-${packageArch}${suffix}"
final String build_directory = "cmake-build-${path}"
final boolean is_riscv = path.contains('riscv')
// Note: CMake 3.20 or higher is needed
cmakeBuild buildDir: build_directory, buildType: 'release', cleanBuild: true, installation: 'Latest',
cmakeArgs: "--no-warn-unused-cli -DCMAKE_SYSTEM_NAME=\"${system_name}\" -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 -DCPACK_RPM_PACKAGE_ARCHITECTURE=${rpmArch} -DCPACK_DEBIAN_PACKAGE_ARCHITECTURE=${debArch} -DCXX_TARGET=${packageArch} -DCMAKE_EXE_LINKER_FLAGS=-static -DNO_SELF_PACKER=${!is_riscv ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON ${no_compilation_cache_flags()}",
cmakeArgs: "--no-warn-unused-cli -DCMAKE_SYSTEM_NAME=\"${system_name}\" -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=${!is_riscv ? "OFF" : "ON"} -DIGNORE_MINIMAL_COMPILER_VERSION=ON ${no_compilation_cache_flags()}",
generator: cmake_generator()
cmake arguments: "--build ./$build_directory --target ybcon", installation: 'Latest'
cpack installation: 'Latest', workingDir: build_directory
}
final String windowsSuffix = '-windows'
/* Required Plugins:
- CMake
- Sidebar Link
@ -48,8 +45,8 @@ pipeline {
stage('Build') {
steps {
echo "Building the ${env.BRANCH_NAME} branch.."
buildTarget('x86_64-linux-musl', 'x86_64', 'amd64')
buildTarget('i686-linux-musl', 'i386', 'i386')
buildTarget('x86_64-linux-musl')
buildTarget('i686-linux-musl')
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
cmakeBuild buildDir: "cmake-build-release-emscripten", buildType: 'release', cleanBuild: true, installation: 'Latest',
cmakeArgs: "-DCMAKE_TOOLCHAIN_FILE=\"/usr/share/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake\" ${no_compilation_cache_flags()} -DNO_SELF_PACKER=ON",
@ -61,22 +58,22 @@ pipeline {
stage('Build for other architectures') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
buildTarget('armel-linux-musleabi', 'armv4l', 'armel')
buildTarget('armv7l-linux-musleabihf', 'armv7hl', 'armhf')
buildTarget('aarch64-linux-musl', 'aarch64', 'arm64', false)
buildTarget('riscv64-linux-gnu', 'riscv64', 'riscv64')
buildTarget('armel-linux-musleabi')
buildTarget('armv7l-linux-musleabihf')
buildTarget('aarch64-linux-musl')
buildTarget('riscv64-linux-gnu')
}
}
}
stage('Build for other platforms') {
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
buildTarget('armv7-w64-mingw32', 'armv7hl', 'armhf', true, windowsSuffix)
buildTarget('aarch64-w64-mingw32', 'aarch64', 'arm64', false, windowsSuffix)
buildTarget('armv7-w64-mingw32')
buildTarget('aarch64-w64-mingw32')
}
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
buildTarget('x86_64-w64-mingw32', 'x86_64', 'amd64', true, windowsSuffix)
buildTarget('i686-w64-mingw32', 'i386', 'i386', true, windowsSuffix)
buildTarget('x86_64-w64-mingw32')
buildTarget('i686-w64-mingw32')
}
}
}
@ -85,7 +82,7 @@ pipeline {
echo 'Deploying....'
archiveArtifacts artifacts: 'cmake-build-*/*.deb, cmake-build-*/*.rpm, cmake-build-*/*.tar.gz, cmake-build-*/*.sh, cmake-build-release-emscripten/*.js', fingerprint: false
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
archiveArtifacts artifacts: 'cmake-build-*/*wpkg.*.exe, cmake-build-*/*.zip'
archiveArtifacts artifacts: 'cmake-build-*/*Windows.*.exe, cmake-build-*/*.zip'
}
}
}