mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-26 12:28:34 -06:00
Some checks are pending
Generate Translation Template / Generate Translation Template (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (/rpcs3/.ci/build-linux.sh, gcc, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (a1d35836e8d45bfc6f63c26f0a3e5d46ef622fe1, rpcs3/rpcs3-binaries-linux-arm64, /rpcs3/.ci/build-linux-aarch64.sh, clang, rpcs3/rpcs3-ci-jammy-aarch64:1.6, ubuntu-24.04-arm) (push) Waiting to run
Build RPCS3 / RPCS3 Linux ${{ matrix.os }} ${{ matrix.compiler }} (d812f1254a1157c80fd402f94446310560f54e5f, rpcs3/rpcs3-binaries-linux, /rpcs3/.ci/build-linux.sh, clang, rpcs3/rpcs3-ci-jammy:1.6, ubuntu-24.04) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (51ae32f468089a8169aaf1567de355ff4a3e0842, rpcs3/rpcs3-binaries-mac, arch -X86_64 .ci/build-mac.sh, Intel) (push) Waiting to run
Build RPCS3 / RPCS3 Mac ${{ matrix.name }} (8e21bdbc40711a3fccd18fbf17b742348b0f4281, rpcs3/rpcs3-binaries-mac-arm64, .ci/build-mac-arm64.sh, Apple Silicon) (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Build RPCS3 / RPCS3 FreeBSD (push) Waiting to run
Build FreeBSD on Github Actions
79 lines
2.8 KiB
CMake
79 lines
2.8 KiB
CMake
set(RPCS3_GIT_VERSION "local_build")
|
|
set(RPCS3_GIT_BRANCH "local_build")
|
|
set(RPCS3_GIT_FULL_BRANCH "local_build")
|
|
|
|
find_package(Git)
|
|
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
RESULT_VARIABLE exit_code
|
|
OUTPUT_VARIABLE RPCS3_GIT_VERSION)
|
|
if(NOT ${exit_code} EQUAL 0)
|
|
message(WARNING "git rev-list failed, unable to include version.")
|
|
endif()
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
RESULT_VARIABLE exit_code
|
|
OUTPUT_VARIABLE GIT_VERSION_)
|
|
if(NOT ${exit_code} EQUAL 0)
|
|
message(WARNING "git rev-parse failed, unable to include version.")
|
|
endif()
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
RESULT_VARIABLE exit_code
|
|
OUTPUT_VARIABLE RPCS3_GIT_BRANCH)
|
|
if(NOT ${exit_code} EQUAL 0)
|
|
message(WARNING "git rev-parse failed, unable to include git branch.")
|
|
endif()
|
|
|
|
string(STRIP ${RPCS3_GIT_VERSION} RPCS3_GIT_VERSION)
|
|
string(STRIP ${GIT_VERSION_} GIT_VERSION_)
|
|
string(STRIP ${RPCS3_GIT_VERSION}-${GIT_VERSION_} RPCS3_GIT_VERSION)
|
|
string(STRIP ${RPCS3_GIT_BRANCH} RPCS3_GIT_BRANCH)
|
|
else()
|
|
message(WARNING "git not found, unable to include version.")
|
|
endif()
|
|
|
|
function(gen_git_version rpcs3_src_dir)
|
|
set(GIT_VERSION_FILE "${rpcs3_src_dir}/git-version.h")
|
|
set(GIT_VERSION_UPDATE "1")
|
|
|
|
# These environment variables are defined by CI
|
|
# BUILD_REPOSITORY_NAME will look like "RPCS3/rpcs3"
|
|
# BUILD_SOURCEBRANCHNAME will look like "master"
|
|
if (DEFINED ENV{BUILD_REPOSITORY_NAME} AND NOT "$ENV{BUILD_REPOSITORY_NAME}" STREQUAL "")
|
|
set(RPCS3_GIT_FULL_BRANCH "$ENV{BUILD_REPOSITORY_NAME}/$ENV{BUILD_SOURCEBRANCHNAME}")
|
|
endif()
|
|
|
|
message(STATUS "RPCS3_GIT_VERSION: " ${RPCS3_GIT_VERSION})
|
|
message(STATUS "RPCS3_GIT_BRANCH: " ${RPCS3_GIT_BRANCH})
|
|
message(STATUS "RPCS3_GIT_FULL_BRANCH: " ${RPCS3_GIT_FULL_BRANCH})
|
|
|
|
if(EXISTS ${GIT_VERSION_FILE})
|
|
# Don't update if marked not to update.
|
|
file(STRINGS ${GIT_VERSION_FILE} match
|
|
REGEX "RPCS3_GIT_VERSION_NO_UPDATE 1")
|
|
if(NOT "${match}" STREQUAL "")
|
|
set(GIT_VERSION_UPDATE "0")
|
|
endif()
|
|
|
|
# Don't update if it's already the same.
|
|
file(STRINGS ${GIT_VERSION_FILE} match
|
|
REGEX "${RPCS3_GIT_VERSION}")
|
|
if(NOT "${match}" STREQUAL "")
|
|
set(GIT_VERSION_UPDATE "0")
|
|
endif()
|
|
endif()
|
|
|
|
set(code_string "// This is a generated file.\n\n"
|
|
"#define RPCS3_GIT_VERSION \"${RPCS3_GIT_VERSION}\"\n"
|
|
"#define RPCS3_GIT_BRANCH \"${RPCS3_GIT_BRANCH}\"\n"
|
|
"#define RPCS3_GIT_FULL_BRANCH \"${RPCS3_GIT_FULL_BRANCH}\"\n\n"
|
|
"// If you don't want this file to update/recompile, change to 1.\n"
|
|
"#define RPCS3_GIT_VERSION_NO_UPDATE 0\n")
|
|
|
|
if ("${GIT_VERSION_UPDATE}" EQUAL "1")
|
|
file(WRITE ${GIT_VERSION_FILE} ${code_string})
|
|
endif()
|
|
endfunction()
|