cmake: Add some release automation steps.

Use ENV{MSYSTEM_PREFIX} instead of ENV{MSYSTEM} to check for msys2 as
that is more reliable.

Generate the translations.zip when building for Windows from the
generated .gmo files.

Add the UPSTREAM_RELEASE option to perform some additional release
automation steps:

- Codesign for Windows with either the Visual Studio signtool or
  osslsigncode when using MinGW.

- On Windows zip up the .exe into the appropriate zip file for release.

- Generate the gpg signature .asc files for the translations zip and the
  .exe zip on Windows.

- On Mac codesign the app, zip it and sign the zip.

- On all platforms try to strip the binary.

Remove the release automation steps from the builder script as they are
now in cmake.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-12-24 06:32:01 +00:00
parent bbbe9fe73f
commit e98d89310e
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
8 changed files with 203 additions and 53 deletions

View File

@ -76,7 +76,7 @@ endif()
# use ccache if available, and not already enabled on the command line # use ccache if available, and not already enabled on the command line
# but not with ninja and msys ccache on msys2 # but not with ninja and msys ccache on msys2
if(NOT (WIN32 AND (NOT $ENV{MSYSTEM} STREQUAL "") AND CMAKE_GENERATOR STREQUAL Ninja)) if(NOT (WIN32 AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "" AND CMAKE_GENERATOR STREQUAL Ninja))
if(NOT CMAKE_CXX_COMPILER_LAUNCHER AND NOT CMAKE_C_COMPILER_LAUNCHER) if(NOT CMAKE_CXX_COMPILER_LAUNCHER AND NOT CMAKE_C_COMPILER_LAUNCHER)
find_program(CCACHE_FOUND ccache) find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND) if(CCACHE_FOUND)
@ -262,7 +262,7 @@ else()
endif() endif()
# hack for ninja in msys2 # hack for ninja in msys2
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND (NOT $ENV{MSYSTEM} STREQUAL "")) if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON) set(MSYS ON)
endif() endif()

View File

@ -191,6 +191,7 @@ Here is the complete list:
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | AUTO | | ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | AUTO |
| ENABLE_SSP | Enable gcc stack protector support (gcc only) | OFF | | ENABLE_SSP | Enable gcc stack protector support (gcc only) | OFF |
| ENABLE_ASAN | Enable libasan sanitizers (by default address, only in debug mode) | OFF | | ENABLE_ASAN | Enable libasan sanitizers (by default address, only in debug mode) | OFF |
| UPSTREAM_RELEASE | Do some release tasks, like codesigning, making zip and gpg sigs. | OFF |
| VBAM_STATIC | Try link all libs statically (the following are set to ON if ON) | OFF | | VBAM_STATIC | Try link all libs statically (the following are set to ON if ON) | OFF |
| SDL2_STATIC | Try to link static SDL2 libraries | OFF | | SDL2_STATIC | Try to link static SDL2 libraries | OFF |
| SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF | | SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF |

View File

@ -18,10 +18,12 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|i[3-9]86|[aA][mM][dD]64")
set(X86_32 ON) set(X86_32 ON)
set(X86 ON) set(X86 ON)
set(WINARCH x86) set(WINARCH x86)
set(BITS 32)
else() else()
set(AMD64 ON) set(AMD64 ON)
set(X64 ON) set(X64 ON)
set(WINARCH x64) set(WINARCH x64)
set(BITS 64)
endif() endif()
if(DEFINED VCPKG_TARGET_TRIPLET) if(DEFINED VCPKG_TARGET_TRIPLET)

View File

@ -1,8 +1,8 @@
file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/*.po") file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/*.po")
GETTEXT_CREATE_TRANSLATIONS( gettext_create_translations(
wxvbam.pot wxvbam.pot
${po_files} ${po_files}
) )
ADD_DEPENDENCIES(visualboyadvance-m translations) add_dependencies(visualboyadvance-m translations)

View File

@ -181,6 +181,8 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
execute_process( execute_process(
COMMAND powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip', '${CMAKE_CURRENT_BINARY_DIR}'); }" COMMAND powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip', '${CMAKE_CURRENT_BINARY_DIR}'); }"
) )
set(ZIP_PROGRAM ${CMAKE_CURRENT_BINARY_DIR}/zip.exe CACHE STRING "zip compressor executable" FORCE)
endif() endif()
# SDL2.dll does not get copied to build dir # SDL2.dll does not get copied to build dir
@ -568,6 +570,12 @@ include_directories(widgets)
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})
find_program(ZIP_PROGRAM zip DOC "zip compressor executable")
if(NOT ZIP_PROGRAM)
message(FATAL_ERROR "The zip compressor program is required for building.")
endif()
set(XRC_SOURCES set(XRC_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/xrc/AccelConfig.xrc ${CMAKE_CURRENT_SOURCE_DIR}/xrc/AccelConfig.xrc
${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatAdd.xrc ${CMAKE_CURRENT_SOURCE_DIR}/xrc/CheatAdd.xrc
@ -940,6 +948,107 @@ if(NOT WIN32 AND NOT APPLE)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/sizes/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/sizes/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
endif() endif()
# make the translations.zip for windows builds
if(ENABLE_NLS AND WIN32)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/translations.zip
COMMAND ${CMAKE_COMMAND} -D "ZIP_PROGRAM=${ZIP_PROGRAM}" -P ${CMAKE_CURRENT_SOURCE_DIR}/make-translations-zip.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS translations make-translations-zip.cmake
)
add_custom_target(translations-zip DEPENDS ${CMAKE_BINARY_DIR}/translations.zip)
add_dependencies(visualboyadvance-m translations-zip)
endif()
option(UPSTREAM_RELEASE "do some release automation tasks" OFF)
if(UPSTREAM_RELEASE AND WIN32)
set(home $ENV{HOME})
if(NOT CMAKE_CROSSCOMPILING AND "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(home $ENV{USERPROFILE})
endif()
# rewrite backslashes to slashes, needed for msys osslsigncode
string(REGEX REPLACE "\\\\" "/" home ${home})
set(cert ${home}/.codesign/windows_comodo.pkcs12)
if(EXISTS ${cert})
if(MSVC)
find_program(SIGNTOOL_PROGRAM signtool)
if(SIGNTOOL_PROGRAM)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy visualboyadvance-m.exe visualboyadvance-m-unsigned.exe
COMMAND ${SIGNTOOL_PROGRAM} sign /f ${cert} /p "vbam3!13" /tr http://timestamp.digicert.com /du https://github.com/visualboyadvance-m/visualboyadvance-m /a visualboyadvance-m.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
else()
find_program(OSSLSIGNCODE_PROGRAM osslsigncode)
if(OSSLSIGNCODE_PROGRAM)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename visualboyadvance-m.exe visualboyadvance-m-unsigned.exe
COMMAND ${OSSLSIGNCODE_PROGRAM} sign -pkcs12 ${cert} -pass "vbam3!13" -t http://timestamp.digicert.com -n visualboyadvance-m -i https://github.com/visualboyadvance-m/visualboyadvance-m -in visualboyadvance-m-unsigned.exe -out visualboyadvance-m.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif()
endif()
set(exezip visualboyadvance-m-Win-${BITS}bit.zip)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${ZIP_PROGRAM} -9 ${exezip} visualboyadvance-m.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
find_program(GPG_PROGRAM gpg)
if(GPG_PROGRAM)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/translations.zip.asc
COMMAND ${GPG_PROGRAM} --detach-sign -a ${CMAKE_BINARY_DIR}/translations.zip
DEPENDS translations-zip
)
add_custom_target(translations-zip-sig DEPENDS ${CMAKE_BINARY_DIR}/translations.zip.asc)
add_dependencies(visualboyadvance-m translations-zip-sig)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove ${exezip}.asc
COMMAND ${GPG_PROGRAM} --detach-sign -a ${exezip}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
if(NOT MSVC AND NOT CMAKE_BUILD_TYPE MATCHES Debug)
find_program(STRIP_PROGRAM strip)
if(STRIP_PROGRAM)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${STRIP_PROGRAM} visualboyadvance-m.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif()
endif()
if(APPLE) if(APPLE)
# this should set ROM file types correctly # this should set ROM file types correctly
set_property(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in) set_property(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in)
@ -964,6 +1073,73 @@ if(APPLE)
endif() endif()
endif() endif()
if(UPSTREAM_RELEASE AND APPLE)
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
find_program(STRIP_PROGRAM strip)
if(STRIP_PROGRAM)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${STRIP_PROGRAM} visualboyadvance-m.app/Contents/MacOS/visualboyadvance-m
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif()
if(DEFINED ENV{LOGIN_KEYCHAIN_PASSWORD})
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND /bin/sh -c "security unlock-keychain -p \"\$LOGIN_KEYCHAIN_PASSWORD\" ~/Library/Keychains/login.keychain*"
)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND codesign -s "Developer ID Application" --deep ./visualboyadvance-m.app
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
else()
message(WARNING "Set the environment variable LOGIN_KEYCHAIN_PASSWORD to your login keychain password to codesign.")
endif()
set(appzip visualboyadvance-m-Mac-${BITS}bit.zip)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove ${appzip}
COMMAND ${ZIP_PROGRAM} -9r ${appzip} ./visualboyadvance-m.app
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
find_program(GPG_PROGRAM gpg)
if(GPG_PROGRAM)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove ${appzip}.asc
COMMAND ${GPG_PROGRAM} --detach-sign -a ${appzip}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif()
if(UPSTREAM_RELEASE AND NOT WIN32 AND NOT APPLE AND NOT CMAKE_BUILD_TYPE MATCHES Debug)
find_program(STRIP_PROGRAM strip)
if(STRIP_PROGRAM)
add_custom_command(
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${STRIP_PROGRAM} visualboyadvance-m
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif()
install( install(
TARGETS visualboyadvance-m TARGETS visualboyadvance-m
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

View File

@ -0,0 +1,16 @@
file(GLOB catalogs po/wxvbam/*.gmo)
file(MAKE_DIRECTORY translations)
foreach(catalog ${catalogs})
string(REGEX REPLACE ".*/([^/]+)\\.gmo" "\\1" locale ${catalog})
file(MAKE_DIRECTORY translations/${locale}/LC_MESSAGES)
configure_file(${catalog} translations/${locale}/LC_MESSAGES/wxvbam.mo COPYONLY)
endforeach()
execute_process(
COMMAND ${ZIP_PROGRAM} -9r ../translations.zip *
WORKING_DIRECTORY translations
)

View File

@ -2658,56 +2658,9 @@ build_project() {
lto=OFF lto=OFF
fi fi
echo_eval_run cmake "'$CHECKOUT'" $CMAKE_REQUIRED_ARGS -DVBAM_STATIC=ON -DENABLE_LTO=${lto} $CMAKE_ARGS $PROJECT_ARGS $@ echo_eval_run cmake "'$CHECKOUT'" $CMAKE_REQUIRED_ARGS -DVBAM_STATIC=ON -DENABLE_LTO=${lto} -DUPSTREAM_RELEASE=TRUE $CMAKE_ARGS $PROJECT_ARGS $@
echo_run make -j$NUM_CPUS VERBOSE=1 echo_run make -j$NUM_CPUS VERBOSE=1
if [ "$target_os" = mac ]; then
$STRIP visualboyadvance-m.app/Contents/MacOS/visualboyadvance-m
# unlock keychain for codesigning certificate
security -v unlock-keychain ~/Library/Keychains/login.keychain* || :
codesign -s "Developer ID Application" --deep ./visualboyadvance-m.app || :
zip=./visualboyadvance-m-Mac-${target_bits:-$bits}bit.zip
rm -f $zip
zip -9r $zip ./visualboyadvance-m.app
rm -f $zip.asc
gpg --detach-sign -a $zip || :
elif [ "$target_os" != windows ] && path_exists visualboyadvance-m; then
$STRIP visualboyadvance-m
elif [ "$target_os" = windows ] && path_exists visualboyadvance-m.exe; then
$STRIP visualboyadvance-m.exe
mv visualboyadvance-m.exe visualboyadvance-m-unsigned.exe
message 'Press ENTER to use your GPG passphrase to unlock your code-signing certificate...'
read -r dummy
osslsigncode sign -pkcs12 ~/.codesign/windows_comodo.pkcs12 -pass "$(pass vbam-windows-codesign-cert)" \
-n visualboyadvance-m -i https://github.com/visualboyadvance-m/visualboyadvance-m \
-in visualboyadvance-m-unsigned.exe -out visualboyadvance-m.exe || cp visualboyadvance-m-unsigned.exe visualboyadvance-m.exe
zip=./visualboyadvance-m-Win-${target_bits:-$bits}bit.zip
rm -f $zip
zip -9 $zip ./visualboyadvance-m.exe
rm -f translations.zip
make install DESTDIR=./destdir
cd destdir/usr/share/locale
zip -9r ../../../../translations.zip *
cd ../../../..
rm -f $zip.asc translations.zip.asc
gpg --detach-sign -a $zip || :
gpg --detach-sign -a translations.zip || :
fi
dist_post_build project dist_post_build project
puts "${NL}Build Successful!!!${NL}${NL}Build results can be found in: $BUILD_ROOT/project${NL}${NL}" puts "${NL}Build Successful!!!${NL}${NL}Build results can be found in: $BUILD_ROOT/project${NL}${NL}"

View File

@ -10,6 +10,7 @@ case "$1" in
OPWD=$PWD OPWD=$PWD
export MSYSTEM=MINGW32 export MSYSTEM=MINGW32
. /etc/profile || : . /etc/profile || :
. ~/.bashrc 2>/dev/null || :
cd "$OPWD" cd "$OPWD"
fi fi
;; ;;
@ -20,6 +21,7 @@ case "$1" in
OPWD=$PWD OPWD=$PWD
export MSYSTEM=MINGW64 export MSYSTEM=MINGW64
. /etc/profile || : . /etc/profile || :
. ~/.bashrc 2>/dev/null || :
cd "$OPWD" cd "$OPWD"
fi fi
;; ;;
@ -92,7 +94,7 @@ export TMP_DIR="$BUILD_ROOT/tmp_$$"
BUILD_ENV=$BUILD_ENV$(cat <<'EOF' BUILD_ENV=$BUILD_ENV$(cat <<'EOF'
# on don't translate prefix and defines by default # don't translate prefix and defines by default
export MSYS2_ARG_CONV_EXCL="-D;/usr;/etc" export MSYS2_ARG_CONV_EXCL="-D;/usr;/etc"
EOF EOF