diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 21e5e02..8092318 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -17,58 +17,93 @@ jobs: buildConfig: release displayName: grad_replay_intercept_windows triplet: x64-windows-static - vcpkgCommitId: 'c4937039b0704c711dff11ffa729f1c105b20e42' - vcpkgPackages: 'nlohmann-json boost-program-options boost-property-tree cpr' configuration: 'x64.*' - cmakeArgs: '-DCMAKE_BUILD_TYPE=Release' - installPath: 'install/bin/' + installPath: 'install/bin/' - os: ubuntu-latest buildConfig: release displayName: grad_replay_intercept_ubuntu triplet: x64-linux - vcpkgCommitId: 'c4937039b0704c711dff11ffa729f1c105b20e42' - vcpkgPackages: 'nlohmann-json boost-program-options boost-property-tree cpr' configuration: 'x64.*' - cmakeArgs: '-DCMAKE_BUILD_TYPE=Release' installPath: 'install/lib/' steps: - name: Use gcc-9/g++-9 on ubuntu run: | - echo "::set-env name=CC::gcc-9" - echo "::set-env name=CXX::g++-9" + echo "CC=gcc-9" >> $GITHUB_ENV + echo "CXX=g++-9" >> $GITHUB_ENV shell: bash if: matrix.os == 'ubuntu-latest' - - - uses: actions/checkout@v1 + + # Checkout + - uses: actions/checkout@v2 with: submodules: true + fetch-depth: 0 - - uses: lukka/get-cmake@master - - name: dir - run: find $RUNNER_WORKSPACE - shell: bash + # Install latest CMake + - uses: lukka/get-cmake@latest + + # Setup vcpkg and build deps - name: Restore artifacts, or Run vcpkg, build and cache artifacts - uses: lukka/run-vcpkg@v2 + uses: lukka/run-vcpkg@v5 id: runvcpkg with: - vcpkgArguments: '${{ matrix.vcpkgPackages }}' - vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg' + #setupOnly: true + vcpkgDirectory: '${{ github.workspace }}/vcpkg' vcpkgTriplet: '${{ matrix.triplet }}' - vcpkgGitCommitId: '${{ matrix.vcpkgCommitId }}' + vcpkgArguments: 'nlohmann-json boost-program-options boost-property-tree cpr' + vcpkgGitCommitId: 'acb6b10e7fdf5e8519c18398d0b069e1d58ca025' + # Build with CMake and Ninja - name: Run CMake+Ninja - uses: lukka/run-cmake@v2 + uses: lukka/run-cmake@v3 id: runcmake with: cmakeListsOrSettingsJson: CMakeListsTxtAdvanced cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - useVcpkgToolchainFile: true buildWithCMakeArgs: ' -- install -v' buildDirectory: '${{ runner.workspace }}/b/ninja/' - cmakeAppendedArgs: '-G Ninja ${{ matrix.cmakeArgs }} -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install' - + cmakeAppendedArgs: '-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install' + useVcpkgToolchainFile: true + buildWithCMake: true + + # Build the mod + - uses: gruppe-adler/action-release-with-hemtt@60f7195 + name: 'Build Mod with HEMTT' + id: build + + # Upload the mod - uses: actions/upload-artifact@v1 with: name: ${{ matrix.displayName }} - path: ${{ matrix.installPath }} + path: ${{ steps.build.outputs.release_path }} + + job_release: + runs-on: windows-latest + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + needs: [job_build_cpp] + steps: + # Download the build mod + - name: Download windows build + uses: actions/download-artifact@v2 + with: + name: grad_replay_intercept_windows + - name: Download ubuntu build + uses: actions/download-artifact@v2 + with: + name: grad_replay_intercept_ubuntu + + # zip it + - uses: papeloto/action-zip@v1 + with: + files: \@grad_replay_intercept/ + dest: \@grad_replay_intercept.zip + + # release it + - uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: true + files: | + \@grad_replay_intercept.zip + diff --git a/.gitignore b/.gitignore index 7732856..950fc7f 100644 --- a/.gitignore +++ b/.gitignore @@ -31,14 +31,14 @@ *.out *.app -# Arma Addons +# Arma *.pbo +*.biprivatekey +keys/* # HEMTT -!tools/hemtt.exe -!tools/hemtt -releases/ -keys/ +.hemtt/local +releases/* # Others .vs diff --git a/CMakeLists.txt b/CMakeLists.txt index d6a42f2..18df33f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,11 @@ message("COMPILER USED: '${CMAKE_CXX_COMPILER_ID}'") set(CMAKE_CL_64 ${USE_64BIT_BUILD}) if(USE_64BIT_BUILD) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/win64/") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/lib64/") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/lib64/") else() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/win32/") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/lib32/") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/lib32/") endif() set(CMAKE_CXX_STANDARD 17) @@ -38,4 +40,4 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) -add_subdirectory(src) \ No newline at end of file +add_subdirectory(src) diff --git a/addons/replay_intercept/config.cpp b/addons/main/config.cpp similarity index 52% rename from addons/replay_intercept/config.cpp rename to addons/main/config.cpp index 321ab6f..ee238f5 100644 --- a/addons/replay_intercept/config.cpp +++ b/addons/main/config.cpp @@ -1,20 +1,19 @@ +#include "script_component.hpp" + class CfgPatches { - class grad_replay_intercept { + class grad_replay_intercept_main { name = "Gruppe Adler Replay Intercept Client"; units[] = {}; weapons[] = {}; - requiredVersion = 1.82; + requiredVersion = 1.92; requiredAddons[] = {"intercept_core"}; - author = "Willard"; - authors[] = {"Willard"}; - url = "/~https://github.com/gruppe-adler"; - version = "1.0"; - versionStr = "1.0"; - versionAr[] = {1,0}; + authors[] = { "Willard" }; + url = "/~https://github.com/gruppe-adler/grad_replay_intercept"; + VERSION_CONFIG; }; }; class Intercept { - class Willard { + class grad { class grad_replay_intercept { pluginName = "grad_replay_intercept"; }; diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp new file mode 100644 index 0000000..3ba044a --- /dev/null +++ b/addons/main/script_component.hpp @@ -0,0 +1 @@ +#include "script_mod.hpp" \ No newline at end of file diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp new file mode 100644 index 0000000..6e3de7c --- /dev/null +++ b/addons/main/script_mod.hpp @@ -0,0 +1,6 @@ +#include "script_version.hpp" + +#define VERSION MAJOR.MINOR.PATCHLVL-BUILD +#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD + +#define VERSION_CONFIG version = #VERSION; versionStr = #VERSION; versionAr[] = {VERSION_AR} \ No newline at end of file diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp new file mode 100644 index 0000000..a5c9cb5 --- /dev/null +++ b/addons/main/script_version.hpp @@ -0,0 +1,4 @@ +#define MAJOR 1 +#define MINOR 0 +#define PATCHLVL 10 +#define BUILD 2 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 71ea784..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: "{build}" - -image: - - Visual Studio 2017 - - Ubuntu1804 - -for: - - - matrix: - only: - - image: Visual Studio 2017 - cache: - - c:\tools\prebuild\vcpkg-export-x64-windows-static.7z - - install: - - cd %APPVEYOR_BUILD_FOLDER% - - git submodule update --init --recursive - - ps: if(![System.IO.Directory]::Exists('c:\tools\prebuild')) { mkdir c:\tools\prebuild } - - cd c:\tools\prebuild - - ps: if(![System.IO.File]::Exists('vcpkg-export-x64-windows-static.7z')) { Invoke-WebRequest /~https://github.com/TheWillard/ci-toolchains/raw/master/vcpkg-export-x64-windows-static.7z -OutFile vcpkg-export-x64-windows-static.7z } - - 7z x vcpkg-export-x64-windows-static.7z - - cd %APPVEYOR_BUILD_FOLDER% - - before_build: - - mkdir build - - mkdir vcproj64 - - cd vcproj64 - - cmake .. -G "Visual Studio 15 2017 Win64" -DUSE_64BIT_BUILD=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=c:/tools/prebuild/vcpkg-export-20190519-024108/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static - - cd .. - - build_script: - - msbuild vcproj64\grad_replay_intercept.sln /m - - tools\hemtt.exe build - - after_build: - - ps: .\tools\packageWindows.ps1 - - artifacts: - - path: build\win64 - name: win64 - - path: addons\grad_replay_intercept.pbo - name: grad_replay_intercept_pbo - - - matrix: - only: - - image: Ubuntu1804 - cache: - - $HOME/deps/vcpkg-export-x64-linux.7z - - install: - - cd $APPVEYOR_BUILD_FOLDER - - git submodule update --init --recursive - - mkdir -p $HOME/deps - - cd $HOME/deps/ - - if [[ ! -f vcpkg-export-x64-linux.7z ]]; then appveyor DownloadFile /~https://github.com/TheWillard/ci-toolchains/raw/master/vcpkg-export-x64-linux.7z; fi - - 7z x vcpkg-export-x64-linux.7z > /dev/null - - cd $APPVEYOR_BUILD_FOLDER - - before_build: - - CXX=g++-8 CC=gcc-8 cmake . -DCMAKE_TOOLCHAIN_FILE=$HOME/deps/vcpkg-export-x64-linux/scripts/buildsystems/vcpkg.cmake - - build_script: - - make - - ./tools/hemtt build - - after_build: - - ./tools/packageLinux.sh - - artifacts: - - path: src\grad_replay_intercept_x64.so - name: linux64 - - path: addons\grad_replay_intercept.pbo - name: grad_replay_intercept_pbo - - - - branches: - only: - - master - - deploy: - - provider: GitHub - auth_token: - secure: MXV97Ngzyn/C/TrCbWG4tdIZcxS/rTfojUq45KbgspSafhcTut3HseMq2002oYkg - artifact: zip - draft: false - prerelease: false - force_update: true - skip_tags: false - on: - APPVEYOR_REPO_TAG: true - - configuration: Release - - - - configuration: Debug diff --git a/cmake/hemtt.cmake b/cmake/hemtt.cmake new file mode 100644 index 0000000..15b78bf --- /dev/null +++ b/cmake/hemtt.cmake @@ -0,0 +1,8 @@ +find_program(HEMTT "hemtt") +if(HEMTT) + message("Found hemtt!") + execute_process(COMMAND HEMTT build --release --force-release WORKING_DIRECTORY ${SRC_PATH}) + execute_process(COMMAND HEMTT zip) +else() + message("Could not find hemtt!") +endif() \ No newline at end of file diff --git a/cmake/version.cmake b/cmake/version.cmake new file mode 100644 index 0000000..16181da --- /dev/null +++ b/cmake/version.cmake @@ -0,0 +1,68 @@ +# From https://www.mattkeeter.com/blog/2018-01-06-versioning/ + +message("Writing script_version.hpp") + +find_program(GIT "git") + +if(GIT) + message("Found git at:") + message(${GIT}) +else() + message("Did not find git!") +endif() + +execute_process(COMMAND ${GIT} log --pretty=format:'%h' -n 1 + OUTPUT_VARIABLE GIT_REV + WORKING_DIRECTORY ${SRCDIR} + # ERROR_QUIET + ) + +# Check whether we got any revision (which isn't +# always the case, e.g. when someone downloaded a zip +# file from Github instead of a checkout) +if ("${GIT_REV}" STREQUAL "") + set(VERSION_MAJOR "0") + set(VERSION_MINOR "0") + set(VERSION_PATCH "0") + set(VERSION_BUILD "0") +else() + execute_process( + COMMAND ${GIT} describe --tag --always + OUTPUT_VARIABLE GIT_TAG ERROR_QUIET + WORKING_DIRECTORY ${SRCDIR}) + + message("Using git tag ${GIT_TAG}") + + string(REPLACE "-" ";" GIT_TAG_LIST ${GIT_TAG}) + list(LENGTH GIT_TAG_LIST GIT_TAG_LIST_LENGTH) + + list(GET GIT_TAG_LIST 0 VERSION_TAG) + if(GIT_TAG_LIST_LENGTH GREATER 1) + list(GET GIT_TAG_LIST 1 VERSION_BUILD) + else() + set(VERSION_BUILD "0") + endif() + message("Tag: ${VERSION_TAG}") + message("Build: ${VERSION_BUILD}") + message("") + string(REPLACE "." ";" GIT_VERSION_LIST ${VERSION_TAG}) + list(GET GIT_VERSION_LIST 0 VERSION_MAJOR) + list(GET GIT_VERSION_LIST 1 VERSION_MINOR) + list(GET GIT_VERSION_LIST 2 VERSION_PATCH) +endif() + +set(VERSION "#define MAJOR ${VERSION_MAJOR} +#define MINOR ${VERSION_MINOR} +#define PATCHLVL ${VERSION_PATCH} +#define BUILD ${VERSION_BUILD} +") + +if(EXISTS ${VERSIONFILE_PATH}) + file(READ ${VERSIONFILE_PATH} VERSION_) +else() + set(VERSION_ "") +endif() + +if (NOT "${VERSION}" STREQUAL "${VERSION_}") + file(WRITE ${VERSIONFILE_PATH} "${VERSION}") +endif() diff --git a/hemtt.toml b/hemtt.toml index 8309a5f..e486c51 100644 --- a/hemtt.toml +++ b/hemtt.toml @@ -1,5 +1,5 @@ -name = "replay_intercept" -prefix = "grad" +name = "grad_replay_intercept" +prefix = "grad_replay_intercept" author = "Gruppe Adler" folder_optionals = false files = [ @@ -7,4 +7,22 @@ files = [ "Adler.paa", "LICENSE", "README.md" -] \ No newline at end of file +] + +key_name = "{{prefix}}-{{version}}" +authority = "{{version}}" + +releasebuild = [ + "!copyInterceptPlugin" +] + +[scripts.copyInterceptPlugin] +steps_linux = [ + "mkdir -p releases/{{version}}/@{{prefix}}/intercept", + "cp build/lib64/* releases/{{version}}/@{{prefix}}/intercept" +] +steps_windows = [ + 'xcopy build\lib64\* releases\\{{version}}\@{{prefix}}\intercept\ /Y /F' +] + +show_output = true \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e087d3f..7e338b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,14 @@ SOURCE_GROUP("src" FILES ${INTERCEPT_PLUGIN_SOURCES}) #file(GLOB INTERCEPT_plugin_utilities_SOURCES "utilities/*.cpp" "utilities/*.hpp" "utilities/*.h") #SOURCE_GROUP("src/utilities" FILES ${INTERCEPT_plugin_utilities_SOURCES}) -#----Don't change anything below this line +# Version file +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/../addons/main/script_version.hpp + ${CMAKE_CURRENT_BINARY_DIR}/../addons/main/_script_version.hpp # fake file + #${CMAKE_CURRENT_SOURCE_DIR}/_version.cpp + COMMAND ${CMAKE_COMMAND} -DVERSIONFILE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/../addons/main/script_version.hpp -DSRCDIR=${CMAKE_CURRENT_SOURCE_DIR}/.. -P + ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/version.cmake) + # nlohmann json find_package(nlohmann_json CONFIG REQUIRED) @@ -43,7 +50,10 @@ endif() file(GLOB INTERCEPT_HOST_SOURCES "${INTERCEPT_CLIENT_PATH}/intercept/client/*.cpp" "${INTERCEPT_CLIENT_PATH}/intercept/client/sqf/*.cpp" "${INTERCEPT_CLIENT_PATH}/intercept/shared/*.cpp") SOURCE_GROUP("intercept" FILES ${INTERCEPT_HOST_SOURCES}) -add_library( ${INTERCEPT_PLUGIN_NAME} SHARED ${INTERCEPT_PLUGIN_SOURCES} ${INTERCEPT_HOST_SOURCES}) +add_library(${INTERCEPT_PLUGIN_NAME} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/../addons/main/script_version.hpp ${INTERCEPT_PLUGIN_SOURCES} ${INTERCEPT_HOST_SOURCES}) + +# HEMTT Build +add_custom_command(TARGET ${INTERCEPT_PLUGIN_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -DSRC_PATH=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/hemtt.cmake) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${INTERCEPT_INCLUDE_PATH}) include_directories(${Boost_INCLUDE_DIR}) @@ -68,7 +78,7 @@ else() set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 /MP /EHsc") set(CMAKE_CXX_FLAGS_RELEASE "/MT /Zi /O2 /Ob1 /EHsc /MP") #with debug info set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:LIBCMT") # LIBCMT conflicts with POCO - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/OPT:REF /DEBUG:FULL") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/OPT:REF /DEBUG:FULL /MANIFEST:NO") endif() -install(TARGETS ${INTERCEPT_PLUGIN_NAME} RUNTIME DESTINATION bin) \ No newline at end of file +install(TARGETS ${INTERCEPT_PLUGIN_NAME} RUNTIME DESTINATION bin) diff --git a/tools/hemtt b/tools/hemtt deleted file mode 100755 index 0c61a24..0000000 Binary files a/tools/hemtt and /dev/null differ diff --git a/tools/hemtt.exe b/tools/hemtt.exe deleted file mode 100644 index 4908e91..0000000 Binary files a/tools/hemtt.exe and /dev/null differ diff --git a/tools/packageLinux.sh b/tools/packageLinux.sh deleted file mode 100755 index 0012c1c..0000000 --- a/tools/packageLinux.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -repoName=${APPVEYOR_PROJECT_NAME} - -mkdir -p @${repoName}/addons -mkdir -p @${repoName}/intercept - -cp src/${repoName}_x64.so @${repoName}/intercept/${repoName}_x64.so -cp addons/${repoName}.pbo @${repoName}/addons/${repoName}.pbo - -tagToAdd="" -if [ ! -z "$APPVEYOR_REPO_TAG_NAME" ] -then - echo "Using Tag: $APPVEYOR_REPO_TAG_NAME" - tagToAdd="$APPVEYOR_REPO_TAG_NAME" -else - tagToAdd="$APPVEYOR_REPO_COMMIT" - echo "Tag not found, using commit hash" -fi - -zip -r "${repoName}_${tagToAdd}_linux.zip" @${repoName} -appveyor PushArtifact "${repoName}_${tagToAdd}_linux.zip" -DeploymentName zip -echo "Done" \ No newline at end of file diff --git a/tools/packageWindows.ps1 b/tools/packageWindows.ps1 deleted file mode 100644 index 16dd549..0000000 --- a/tools/packageWindows.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -New-Item $env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME\addons -type directory | Out-Null -New-Item $env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME\intercept -type directory | Out-Null - -Copy-Item $env:APPVEYOR_BUILD_FOLDER\build\win64\${env:CONFIGURATION}\${env:APPVEYOR_PROJECT_NAME}_x64.dll $env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME\intercept -Copy-Item $env:APPVEYOR_BUILD_FOLDER\build\win64\${env:CONFIGURATION}\${env:APPVEYOR_PROJECT_NAME}_x64.pdb $env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME\intercept -if(${env:CONFIGURATION} -eq 'Debug') { - Copy-Item $env:APPVEYOR_BUILD_FOLDER\build\win64\${env:CONFIGURATION}\${env:APPVEYOR_PROJECT_NAME}_x64.ilk $env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME\intercept -} - -Copy-Item $env:APPVEYOR_BUILD_FOLDER\addons\$env:APPVEYOR_PROJECT_NAME.pbo $env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME\addons - -$tagToAdd = "" -if(![string]::IsNullOrEmpty($env:APPVEYOR_REPO_TAG_NAME)) { - Write-Host "Using Tag: $env:APPVEYOR_REPO_TAG_NAME" - $tagToAdd = "$env:APPVEYOR_REPO_TAG_NAME" -} else { - $tagToAdd = "${env:APPVEYOR_REPO_COMMIT}" - Write-Host "Tag not found, using commit hash" -} - -7z a "$env:APPVEYOR_BUILD_FOLDER\release\${env:APPVEYOR_PROJECT_NAME}_$tagToAdd.zip" "$env:APPVEYOR_BUILD_FOLDER\release\@$env:APPVEYOR_PROJECT_NAME" | Out-Null -Write-Host "Zipped mod folder" -Push-AppveyorArtifact "$env:APPVEYOR_BUILD_FOLDER\release\${env:APPVEYOR_PROJECT_NAME}_$tagToAdd.zip" -DeploymentName zip \ No newline at end of file