diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..ba37b67d7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,184 @@ +# A pipeline is composed of independent jobs that run scripts, grouped into stages. +# Stages run in sequential order, but jobs within stages run in parallel. +# +# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages + +.shared_windows_runners: + tags: + - shared-windows + - windows-1809 + variables: + VCPKG_ROOT: C:\vcpkg + +.shared_linux_runners: + tags: + - saas-linux-small-amd64 + +.shared_macos_runners: + tags: + - saas-macos-medium-m1 + image: macos-12-xcode-14 + +stages: + - prepenv + - build + - release + + +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= +## The Windows build +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= + +cmake-windows-native-build: + extends: + - .shared_windows_runners + stage: build + needs: + - job: "prep_environment" + artifacts: true + script: + - | + if (!(Test-Path Env:\VCPKG_ROOT)) { + New-Item -Force -Path Env:\VCPKG_ROOT -Value ${VCPKG_ROOT} + } + pushd ${VCPKG_ROOT} + git checkout master + git pull --rebase + popd + - choco feature enable -n allowGlobalConfirmation + - choco install -y nsis + - .\cmake\cmake-builder.ps1 -flavor vs2019 -config Release -clean -parallel -verbose -cpack_suffix win32-native + - cd cmake\build-vs2019 + - cpack -G "NSIS;ZIP" -C Release + - cd ..\.. + artifacts: + when: on_success + expire_in: 30 days + name: "simh-$SIMH_VERSION-win32-vs2019" + paths: + - "cmake/build-vs2019/simh-$SIMH_VERSION-win32-native.zip" + - "cmake/build-vs2019/simh-$SIMH_VERSION-win32-native.exe" + + +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= +## Ubuntu 22.04 (jammy) +## +## This runs inside the Ubuntu Docker container from hub.docker.com. The container is +## pretty primeval, so GCC, Ninja and Git have to be installed before adding the +## SIMH-required runtime dependencies. +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= + +cmake-ubuntu-jammy-build: + extends: + - .shared_linux_runners + image: ubuntu:jammy + stage: build + needs: + - job: "prep_environment" + artifacts: true + script: + - apt update && apt -ym upgrade && apt -y autoremove + - apt install -ym sudo gcc g++ ninja-build git cmake && .travis/deps.sh linux + - cmake/cmake-builder.sh --config Release --flavor ninja --parallel --verbose --cpack_suffix x86_64-ubuntu22.04 + - cd cmake/build-ninja && cpack -G DEB -C Release + artifacts: + when: on_success + expire_in: 30 days + name: "simh-$SIMH_VERSION-x86_64-ubuntu22.04" + paths: + - "cmake/build-ninja/simh-$SIMH_VERSION-x86_64-ubuntu22.04.deb" + + +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= +## macOS +## +## Note: This produces Apple Silicon images, not x86_64! +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= + +# cmake-macos-12-build: +# extends: +# - .shared_macos_runners +# stage: build +# needs: +# - job: "prep_environment" +# artifacts: true +# script: +# - .travis/deps.sh osx +# - cmake/cmake-builder.sh --config Release --flavor xcode --parallel --verbose --cpack_suffix apple-macos12 +# - cd cmake/build-xcode && cpack -G "ZIP;TGZ" -C Release && cpack -G DragNDrop -C Release +# artifacts: +# when: on_success +# expire_in: 30 days +# name: "simh-$SIMH_VERSION-apple-macos12" +# paths: +# - "cmake/build-xcode/simh-$SIMH_VERSION-apple-macos12.zip" +# - "cmake/build-xcode/simh-$SIMH_VERSION-apple-macos12.dmg" + + +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= +## Release management: +## ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= + +prep_environment: + # This stage must run before the release stage to set up the 'dotenv' artifact that + # do_release grabs for variables: + + stage: prepenv + image: ubuntu:jammy + + # Run this job when commits are pushed or merged to the default branch + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + variables: + TAGNAME: "latest" + script: + - apt update && apt -ym upgrade && apt -y autoremove && apt install -ym sudo gcc g++ cmake ninja-build + - echo "EXTRA_DESCRIPTION=Open-Simh latest release" > variables.env + - echo "TAG=$TAGNAME" >> variables.env + - cmake/cmake-builder.sh --config Release --flavor ninja --cache | grep SIMH_VERSION | sed 's/:.*=/=/' >> variables.env + artifacts: + reports: + # Use artifacts:reports:dotenv to expose the variables to other jobs + dotenv: variables.env + +do_release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + needs: + - job: "cmake-windows-native-build" + artifacts: true + - job: "cmake-ubuntu-jammy-build" + artifacts: true + # - job: "cmake-macos-12-build" + # artifacts: true + - job: "prep_environment" + artifacts: true + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + script: + - echo "running release_job for $TAG" + artifacts: + name: "simh-$SIMH_VERSION-latest" + paths: + - "cmake/build-vs2019/simh-$SIMH_VERSON-win32-native.zip" + - "cmake/build-vs2019/simh-$SIMH_VERSION-win32-native.exe" + - "cmake/build-ninja/simh-$SIMH_VERSION-x86_64-ubuntu22.04.deb" + # - "cmake/build-xcode/simh-$SIMH_VERSION-apple-macos12.zip" + # - "cmake/build-xcode/simh-$SIMH_VERSION-apple-macos12.dmg" + release: + name: 'Release $TAG' + description: 'Created using the release-cli $EXTRA_DESCRIPTION' + tag_name: '$TAG' + ref: '$CI_COMMIT_SHA' + assets: + links: + - name: 'simh-$SIMH_VERSION-x86_64-ubuntu22.04.deb' + url: "https://gitlab.com/scooter-phd/open-simh/-/jobs/${CI_JOB_ID}/artifacts/file/cmake/build-ninja/simh-$SIMH_VERSION-x86_64-ubuntu22.04.deb" + - name: 'simh-$SIMH_VERSION-win32-native.zip' + url: 'https://gitlab.com/scooter-phd/open-simh/-/jobs/${CI_JOB_ID}/artifacts/file/cmake/build-vs2019/simh-$SIMH_VERSION-win32-native.zip' + - name: 'simh-$SIMH_VERSION-win32-native.exe' + url: 'https://gitlab.com/scooter-phd/open-simh/-/jobs/${CI_JOB_ID}/artifacts/file/cmake/build-vs2019/simh-$SIMH_VERSION-win32-native.exe' + # - name: "cmake/build-xcode/simh-$SIMH_VERSION-x86_64.apple-macos12.zip" + # url: 'https://gitlab.com/scooter-phd/open-simh/-/jobs/${CI_JOB_ID}/artifacts/file/cmake/build-xcode/simh-$SIMH_VERSION-x86_64.apple-macos12.zip' + # - name: "cmake/build-xcode/simh-$SIMH_VERSION-x86_64.apple-macos12.dmg" + # url: 'https://gitlab.com/scooter-phd/open-simh/-/jobs/${CI_JOB_ID}/artifacts/file/cmake/build-xcode/simh-$SIMH_VERSION-x86_64.apple-macos12.dmg' diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f5832e64..60b0b3d88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,13 @@ if (CMAKE_VERSION VERSION_LESS "3.21" AND NOT DEFINED SIMH_INSTALLER_WARNING) set(SIMH_INSTALLER_WARNING TRUE CACHE BOOL "Installer/CPack warning issued when CMAKE_VERSION < 3.21" FORCE) endif () +## SIMH Version variables: +set(SIMH_VERSION_MAJOR 4) +set(SIMH_VERSION_MINOR 1) +set(SIMH_VERSION_PATCH 0) +set(SIMH_VERSION "${SIMH_VERSION_MAJOR}.${SIMH_VERSION_MINOR}.${SIMH_VERSION_PATCH}" + CACHE PATH "Open-Simh version string.") + # Places to look for CMake modules/includes set(SIMH_INCLUDE_PATH_LIST ${CMAKE_SOURCE_DIR}/cmake @@ -73,12 +80,6 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) cmake_policy(SET CMP0091 NEW) endif() -## SIMH Version variables: -set(SIMH_VERSION_MAJOR 4) -set(SIMH_VERSION_MINOR 1) -set(SIMH_VERSION_PATCH 0) -set(SIMH_VERSION "${SIMH_VERSION_MAJOR}.${SIMH_VERSION_MINOR}.${SIMH_VERSION_PATCH}") - project(simh VERSION "${SIMH_VERSION}" LANGUAGES C CXX) include(vcpkg-setup) diff --git a/cmake/cmake-builder.sh b/cmake/cmake-builder.sh index 083fc45bf..d75b1af64 100755 --- a/cmake/cmake-builder.sh +++ b/cmake/cmake-builder.sh @@ -15,6 +15,7 @@ Options: -------- --clean (-x) Remove the build subdirectory --generate (-g) Generate the build environment, don't compile/build +--cache '--generate' and show CMake's variable cache --regenerate (-r) Regenerate the build environment from scratch. --parallel (-p) Enable build parallelism (parallel builds) --nonetwork Build simulators without network support @@ -153,6 +154,7 @@ fi longopts=clean,help,flavor:,config:,nonetwork,novideo,notest,parallel,generate,testonly,regenerate longopts=${longopts},noinstall,installonly,verbose,target:,lto,debugWall,cppcheck,cpack_suffix: +longopts=${longopts},cache ARGS=$(${getopt_prog} --longoptions $longopts --options xhf:cpg -- "$@") if [ $? -ne 0 ] ; then @@ -252,6 +254,11 @@ while true; do generateOnly=yes shift ;; + --cache) + generateOnly=yes + generateArgs="${generateArgs} -LA" + shift + ;; -r | --regenerate) generateOnly=yes regenerateFlag=yes