Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
gantsevdenis committed Jan 4, 2023
2 parents 2f9ef8d + 3131d76 commit a4b08d4
Show file tree
Hide file tree
Showing 1,809 changed files with 533,855 additions and 381,800 deletions.
57 changes: 34 additions & 23 deletions .ci/azure/templates/macos-build-pipeline-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ parameters:
default: 'default'
- name: vcpkgBuildXcodeDeveloperDir
default: 'default'
- name: vcpkgInstallXcodeDeveloperDir
default: 'default'
- name: includeVideos
type: boolean
default: false
Expand All @@ -24,11 +26,11 @@ parameters:
default: false
- name: artifact
default: 'warzone2100_macOS'
- name: uploadArtifactToGitHubReleases
type: boolean
default: false
- name: gitHubConnection
default: ''
# - name: uploadArtifactToGitHubReleases
# type: boolean
# default: false
# - name: gitHubConnection
# default: ''

jobs:
- job: ${{ parameters.name }}
Expand All @@ -41,6 +43,7 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: 10.10
DESIRED_XCODE_DEV_DIR: ${{ parameters.xcodeDeveloperDir }}
DESIRED_VCPKG_BUILD_XCODE_DEV_DIR: ${{ parameters.vcpkgBuildXcodeDeveloperDir }}
DESIRED_VCPKG_INSTALL_XCODE_DEV_DIR: ${{ parameters.vcpkgInstallXcodeDeveloperDir }}
WZ_INCLUDE_VIDEOS: ${{ parameters.includeVideos }}

steps:
Expand Down Expand Up @@ -110,8 +113,12 @@ jobs:
echo "cmake ${ADDITIONAL_CONFIGURE_ARGS} -DVCPKG_BUILD_TYPE=release -DWZ_DISTRIBUTOR:STRING=\"${WZ_DISTRIBUTOR}\" -DADDITIONAL_CMAKE_ARGUMENTS=\"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY=;-DCODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO\" -P ../configure_mac.cmake"
cmake ${ADDITIONAL_CONFIGURE_ARGS} -DVCPKG_BUILD_TYPE=release -DWZ_DISTRIBUTOR:STRING="${WZ_DISTRIBUTOR}" -DADDITIONAL_CMAKE_ARGUMENTS="${ADDITIONAL_CMAKE_ARGUMENTS}" -P ../src/configure_mac.cmake
echo "Switching Xcode: ${DESIRED_XCODE_DEV_DIR}"
sudo xcode-select -switch "${DESIRED_XCODE_DEV_DIR}"
VCPKG_INSTALL_XCODE_DEV_DIR="${DESIRED_XCODE_DEV_DIR}"
if [ "${DESIRED_VCPKG_INSTALL_XCODE_DEV_DIR}" != "default" ]; then
VCPKG_INSTALL_XCODE_DEV_DIR="${DESIRED_VCPKG_INSTALL_XCODE_DEV_DIR}"
fi
echo "Switching Xcode: ${VCPKG_INSTALL_XCODE_DEV_DIR}"
sudo xcode-select -switch "${VCPKG_INSTALL_XCODE_DEV_DIR}"
ADDITIONAL_CONFIGURE_ARGS="-DSKIP_VCPKG_BUILD=true"
fi
echo "cmake ${ADDITIONAL_CONFIGURE_ARGS} -DVCPKG_BUILD_TYPE=release -DWZ_DISTRIBUTOR:STRING=\"${WZ_DISTRIBUTOR}\" -DADDITIONAL_CMAKE_ARGUMENTS=\"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY=;-DCODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO\" -P ../configure_mac.cmake"
Expand All @@ -121,6 +128,10 @@ jobs:
echo "ERROR: configure_mac.cmake failed"
exit ${result}
fi
if [ "${DESIRED_XCODE_DEV_DIR}" != "default" ] && [ "${DESIRED_VCPKG_INSTALL_XCODE_DEV_DIR}" != "${DESIRED_XCODE_DEV_DIR}" ]; then
echo "Switching Xcode: ${DESIRED_XCODE_DEV_DIR}"
sudo xcode-select -switch "${DESIRED_XCODE_DEV_DIR}"
fi
cd - > /dev/null
failOnStderr: false
- task: Xcode@5
Expand Down Expand Up @@ -207,19 +218,19 @@ jobs:
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: ${{ parameters.artifact }}
- task: GithubRelease@1
displayName: 'Upload to GitHub Release'
condition: and(succeeded(), eq('${{ parameters.uploadArtifactToGitHubReleases }}', true), ne('${{ parameters.gitHubConnection }}', ''), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
inputs:
gitHubConnection: ${{ parameters.gitHubConnection }}
action: edit
tagSource: userSpecifiedTag
# We can't use Build.SourceBranchName because:
# - "Build.SourceBranchName does not include full name, if name includes forward slash"
# - Link: https://github.com/microsoft/azure-pipelines-agent/issues/838
tag: $(FULL_SOURCE_BRANCH_NAME)
assets: |
$(Build.ArtifactStagingDirectory)/*.zip
assetUploadMode: 'replace'
isDraft: true
addChangeLog: false
# - task: GithubRelease@1
# displayName: 'Upload to GitHub Release'
# condition: and(succeeded(), eq('${{ parameters.uploadArtifactToGitHubReleases }}', true), ne('${{ parameters.gitHubConnection }}', ''), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
# inputs:
# gitHubConnection: ${{ parameters.gitHubConnection }}
# action: edit
# tagSource: userSpecifiedTag
# # We can't use Build.SourceBranchName because:
# # - "Build.SourceBranchName does not include full name, if name includes forward slash"
# # - Link: https://github.com/microsoft/azure-pipelines-agent/issues/838
# tag: $(FULL_SOURCE_BRANCH_NAME)
# assets: |
# $(Build.ArtifactStagingDirectory)/*.zip
# assetUploadMode: 'replace'
# isDraft: true
# addChangeLog: false
24 changes: 24 additions & 0 deletions .ci/flatpak/Toolchain-cross-arch.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Toolchain for cross-compiling

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR "@WZ_CROSS_COMPILE_TARGET_ARCH@")

# Specify the cross compiler
set(CMAKE_C_COMPILER "@WZ_CROSS_COMPILE_TARGET_ARCH@-unknown-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "@WZ_CROSS_COMPILE_TARGET_ARCH@-unknown-linux-gnu-g++")

# Target search paths
set(CMAKE_FIND_ROOT_PATH "/app;/usr/lib/@WZ_CROSS_COMPILE_TARGET_ARCH@-linux-gnu;/usr/include/@WZ_CROSS_COMPILE_TARGET_ARCH@-linux-gnu" CACHE STRING "Find root path" FORCE)

# Search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# Point pkgconfig at target arch .pc files first, falling back to regular system .pc files
if(EXISTS "/usr/lib/@WZ_CROSS_COMPILE_TARGET_ARCH@-linux-gnu/pkgconfig")
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/@WZ_CROSS_COMPILE_TARGET_ARCH@-linux-gnu/pkgconfig")
endif()
57 changes: 57 additions & 0 deletions .ci/flatpak/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# This requires a bunch of environment variables to be set. See the CI workflow

echo "::group::flatpak-builder"
flatpak-builder --repo=${WZ_FLATPAK_LOCAL_REPO_NAME} --disable-rofiles-fuse --force-clean --default-branch=${WZ_FLATPAK_BRANCH} --mirror-screenshots-url=${WZ_FLATPAK_MIRROR_SCREENSHOTS_URL} "${WZ_FLATPAK_BUILD_DIR}" ${WZ_FLATPAK_MANIFEST_PATH}
echo "::endgroup::"

if [[ "$WZ_FLATPAK_TARGET_ARCH" != "$WZ_FLATPAK_BUILD_ARCH" ]]; then
SRC_LOCAL_REPO_NAME="${WZ_FLATPAK_LOCAL_REPO_NAME}"

# Create a new repository containing the commits for the cross target arch
echo "::group::Creating new local repo for target arch: ${WZ_FLATPAK_LOCAL_REPO_NAME}"
WZ_FLATPAK_LOCAL_REPO_NAME="${WZ_FLATPAK_TARGET_ARCH}-repo"
ostree init --mode archive-z2 --repo=${WZ_FLATPAK_LOCAL_REPO_NAME}
echo "::endgroup::"

echo "::group::Rename commits to new target arch repo"
for i in app/${WZ_FLATPAK_APPID} \
runtime/${WZ_FLATPAK_APPID}.Debug
do
# Rename the commits to target arch
echo "Processing: --src-ref=${i}/${WZ_FLATPAK_BUILD_ARCH}/${WZ_FLATPAK_BRANCH}"
flatpak build-commit-from --src-ref=${i}/${WZ_FLATPAK_BUILD_ARCH}/${WZ_FLATPAK_BRANCH} --src-repo=${SRC_LOCAL_REPO_NAME} \
${WZ_FLATPAK_LOCAL_REPO_NAME} ${i}/${WZ_FLATPAK_TARGET_ARCH}/${WZ_FLATPAK_BRANCH}
done
echo "::endgroup::"
fi

echo "::group::flatpak build-bundle"
flatpak build-bundle --arch=${WZ_FLATPAK_TARGET_ARCH} ${WZ_FLATPAK_LOCAL_REPO_NAME} "${WZ_FLATPAK_BUNDLE}" --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo ${WZ_FLATPAK_APPID} ${WZ_FLATPAK_BRANCH}
echo "::endgroup::"

echo "Generated .flatpak: \"${WZ_FLATPAK_BUNDLE}\""
echo " -> SHA512: $(sha512sum "${WZ_FLATPAK_BUNDLE}")"
echo " -> Size (bytes): $(stat -c %s "${WZ_FLATPAK_BUNDLE}")"

WZ_FLATPAK_BUILD_PATH="${WZ_FLATPAK_BUILD_DIR}/files/share"

echo "::group::Validating: appdata/${WZ_FLATPAK_APPID}.appdata.xml"
if [ -x "$(command -v appstreamcli)" ]; then
echo "appstreamcli validate ${WZ_FLATPAK_BUILD_PATH}/appdata/${WZ_FLATPAK_APPID}.appdata.xml"
appstreamcli validate ${WZ_FLATPAK_BUILD_PATH}/appdata/${WZ_FLATPAK_APPID}.appdata.xml
else
# Older utility fallback
echo "appstream-util validate ${WZ_FLATPAK_BUILD_PATH}/appdata/${WZ_FLATPAK_APPID}.appdata.xml"
appstream-util validate ${WZ_FLATPAK_BUILD_PATH}/appdata/${WZ_FLATPAK_APPID}.appdata.xml
fi
echo "::endgroup::"

echo "::group::Verify icon and metadata in app-info"
test -f "${WZ_FLATPAK_BUILD_PATH}/app-info/icons/flatpak/128x128/${WZ_FLATPAK_APPID}.png" || { echo "Missing 128x128 icon in app-info" ; exit 1; }
test -f "${WZ_FLATPAK_BUILD_PATH}/app-info/xmls/${WZ_FLATPAK_APPID}.xml.gz" || { echo "Missing ${WZ_FLATPAK_APPID}.xml.gz in app-info" ; exit 1; }
echo "::endgroup::"

echo "::group::Commit screenshots to the OSTree repository"
ostree commit --repo=${WZ_FLATPAK_LOCAL_REPO_NAME} --canonical-permissions --branch=screenshots/${WZ_FLATPAK_TARGET_ARCH} "${WZ_FLATPAK_BUILD_DIR}/screenshots"
echo "::endgroup::"
143 changes: 143 additions & 0 deletions .ci/flatpak/generate_flatpak_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
cmake_minimum_required(VERSION 3.5)

# Automatically generate a Flatpak manifest from the template file
#
# Required input defines:
# - TEMPLATE_FILE: the full filename + path for the input net.wz2100.warzone2100.appdata.xml.in template file
# - OUTPUT_FILE: the full filename + path for the output net.wz2100.warzone2100.appdata.xml file
# - PROJECT_ROOT: the path the project root (${PROJECT_SOURCE_DIR})
#
# And also, these input defines:
# - WZ_OUTPUT_NAME_SUFFIX: The desired suffix to apply to the app id in the manifest (should match the main build)
#
# If cross-compiling, specify:
# - WZ_CROSS_COMPILE_TARGET_ARCH: <aarch64, etc>
#

if(NOT DEFINED TEMPLATE_FILE OR "${TEMPLATE_FILE}" STREQUAL "")
message( FATAL_ERROR "Missing required input define: TEMPLATE_FILE" )
endif()
if(NOT DEFINED OUTPUT_FILE OR "${OUTPUT_FILE}" STREQUAL "")
message( FATAL_ERROR "Missing required input define: OUTPUT_FILE" )
endif()
if(NOT DEFINED PROJECT_ROOT OR "${PROJECT_ROOT}" STREQUAL "")
message( FATAL_ERROR "Missing required input define: PROJECT_ROOT" )
endif()

if(NOT DEFINED WZ_OUTPUT_NAME_SUFFIX)
message( FATAL_ERROR "Missing expected input define: WZ_OUTPUT_NAME_SUFFIX" )
endif()
if (DEFINED WZ_CROSS_COMPILE_TARGET_ARCH)
message( STATUS "WZ_CROSS_COMPILE_TARGET_ARCH detected - configuring for cross-compile to: ${WZ_CROSS_COMPILE_TARGET_ARCH}" )
endif()

get_filename_component(_input_dir "${TEMPLATE_FILE}" DIRECTORY)
get_filename_component(_output_dir "${OUTPUT_FILE}" DIRECTORY)

##################################
# Handling cross-compilation

if (DEFINED WZ_CROSS_COMPILE_TARGET_ARCH)

if (NOT WZ_CROSS_COMPILE_TARGET_ARCH MATCHES "^(aarch64)$") # update when new target arch is needed, ensure the anchor is defined in net.wz2100.wz2100.yaml.in
message( FATAL_ERROR "Target arch is not yet supported in the template: ${WZ_CROSS_COMPILE_TARGET_ARCH}" )
endif()

# Runtime target arch suffix
set(WZ_RUNTIME_SUFFIX "/${WZ_CROSS_COMPILE_TARGET_ARCH}")

# SDK extensions
set(WZ_CROSS_COMPILE_SDK_EXTENSIONS "sdk-extensions:\n\
# We need to ensure the toolchain is available\n\
- org.freedesktop.Sdk.Extension.toolchain-${WZ_CROSS_COMPILE_TARGET_ARCH}\n\
# As well as the target SDK\n\
- org.freedesktop.Sdk.Compat.${WZ_CROSS_COMPILE_TARGET_ARCH}\n")

# Cross files setup module
set(WZ_CROSS_FILES_SETUP "- name: cross-files-setup\n\
buildsystem: simple\n\
cleanup:\n\
- '*'\n\
build-commands:\n\
- mkdir -p /app/etc/wz-config/\n\
- install -Dm644 Toolchain-cross-arch.cmake /app/etc/wz-config/Toolchain-cross-arch.cmake\n\
- install -Dm644 meson-cross-file.txt /app/etc/wz-config/meson-cross-file.txt\n\
sources:\n\
- type: file\n\
path: ../../.ci/flatpak/Toolchain-cross-arch.cmake\n\
- type: file\n\
path: ../../.ci/flatpak/meson-cross-file.txt\n\
")

# Configure CMake cross-compile toolchain
configure_file("${_input_dir}/Toolchain-cross-arch.cmake.in" "${_output_dir}/Toolchain-cross-arch.cmake" @ONLY)
set(WZ_CMAKE_CROSS_CONFIG_OPTIONS "- -DCMAKE_TOOLCHAIN_FILE=/app/etc/wz-config/Toolchain-cross-arch.cmake")

# Construct simple meson cross-compile file
configure_file("${_input_dir}/meson-cross-file.txt.in" "${_output_dir}/meson-cross-file.txt" @ONLY)
set(WZ_MESON_CROSS_CONFIG_OPTIONS "- --cross-file=/app/etc/wz-config/meson-cross-file.txt")

# Autotools just requires a config option
set(WZ_AUTOTOOLS_CROSS_CONFIG_OPTIONS "- --host=${WZ_CROSS_COMPILE_TARGET_ARCH}-unknown-linux-gnu")

# Set the build-options anchor tag
set(WZ_CROSS_BUILD_OPTIONS "build-options: *compat-${WZ_CROSS_COMPILE_TARGET_ARCH}-build-options")

else()
unset(WZ_RUNTIME_SUFFIX)
unset(WZ_CROSS_COMPILE_SDK_EXTENSIONS)
unset(WZ_CROSS_FILES_SETUP)
set(WZ_CMAKE_CROSS_CONFIG_OPTIONS "# No cross build options")
set(WZ_MESON_CROSS_CONFIG_OPTIONS "# No cross build options")
set(WZ_AUTOTOOLS_CROSS_CONFIG_OPTIONS "# No cross build options")
set(WZ_CROSS_BUILD_OPTIONS "# No cross build options")
endif()

##################################
# Handle sentry-native

# Get the source URL AND SHA512 from a data file
set(_sentry_dl_data_file "${PROJECT_ROOT}/.sentrynative")
file(STRINGS "${_sentry_dl_data_file}" _sentry_native_url_info ENCODING UTF-8)
while(_sentry_native_url_info)
list(POP_FRONT _sentry_native_url_info LINE)
if (LINE MATCHES "^URL=(.*)")
set(WZ_SENTRY_NATIVE_URL "${CMAKE_MATCH_1}")
endif()
if (LINE MATCHES "^SHA512=(.*)")
set(WZ_SENTRY_NATIVE_SHA512 "${CMAKE_MATCH_1}")
endif()
endwhile()
unset(_sentry_native_url_info)
if(NOT DEFINED WZ_SENTRY_NATIVE_URL OR NOT DEFINED WZ_SENTRY_NATIVE_SHA512)
message(FATAL_ERROR "Failed to load URL and hash from: ${_sentry_dl_data_file}")
endif()
unset(_sentry_dl_data_file)

##################################
# Debug output

execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++TEMPLATE_FILE: ${TEMPLATE_FILE}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++OUTPUT_FILE: ${OUTPUT_FILE}")

execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_OUTPUT_NAME_SUFFIX: ${WZ_OUTPUT_NAME_SUFFIX}")
if (DEFINED WZ_CROSS_COMPILE_TARGET_ARCH)
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_CROSS_COMPILE_TARGET_ARCH: ${WZ_CROSS_COMPILE_TARGET_ARCH}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_CROSS_COMPILE_SDK_EXTENSIONS: ${WZ_CROSS_COMPILE_SDK_EXTENSIONS}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_CMAKE_CROSS_CONFIG_OPTIONS: ${WZ_CMAKE_CROSS_CONFIG_OPTIONS}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_MESON_CROSS_CONFIG_OPTIONS: ${WZ_MESON_CROSS_CONFIG_OPTIONS}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_AUTOTOOLS_CROSS_CONFIG_OPTIONS: ${WZ_AUTOTOOLS_CROSS_CONFIG_OPTIONS}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_CROSS_BUILD_OPTIONS: ${WZ_CROSS_BUILD_OPTIONS}")
endif()

execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_SENTRY_NATIVE_URL: ${WZ_SENTRY_NATIVE_URL}")
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "++WZ_SENTRY_NATIVE_SHA512: ${WZ_SENTRY_NATIVE_SHA512}")

##################################
# Output configured file based on the template

if(NOT EXISTS "${TEMPLATE_FILE}")
message( FATAL_ERROR "Input TEMPLATE_FILE does not exist: \"${TEMPLATE_FILE}\"" )
endif()
configure_file("${TEMPLATE_FILE}" "${OUTPUT_FILE}" @ONLY)

12 changes: 12 additions & 0 deletions .ci/flatpak/meson-cross-file.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[binaries]
c = '@WZ_CROSS_COMPILE_TARGET_ARCH@-unknown-linux-gnu-gcc'
cpp = '@WZ_CROSS_COMPILE_TARGET_ARCH@-unknown-linux-gnu-g++'
ar = '@WZ_CROSS_COMPILE_TARGET_ARCH@-unknown-linux-gnu-ar'
pkgconfig = 'pkg-config'
strip = '@WZ_CROSS_COMPILE_TARGET_ARCH@-unknown-linux-gnu-strip'

[host_machine]
system = 'linux'
cpu_family = '@WZ_CROSS_COMPILE_TARGET_ARCH@'
cpu = '@WZ_CROSS_COMPILE_TARGET_ARCH@'
endian = 'little'
Loading

0 comments on commit a4b08d4

Please sign in to comment.