From 69f31a67a4c08b55cc71049aec378877d38e81ab Mon Sep 17 00:00:00 2001 From: wraitii Date: Wed, 9 Dec 2020 15:22:24 +0000 Subject: [PATCH] More improvements to the release scripts. - Add a 'dev' option to the mac bundle that's much faster, intended to quickly test bundle-like behaviour. - Add an option to only archive the 'mod' folder, intended to speed up the CI weekly builds and avoid taking too much disk space. - Tweak the windows installer, add an option to create a shortcut to the desktop (Fixes #1637). This uses the readme 'hack' which appears to be a relatively standard way of doing that. - Make the scripts executable. - Update jenkinsfile. Follows d95550248b Differential Revision: https://code.wildfiregames.com/D3191 This was SVN commit r24353. --- ...kinsfile => macos-all-bundles.Jenkinsfile} | 12 +++- source/tools/dist/0ad.nsi | 67 +++++++++++++------ source/tools/dist/build-archives.sh | 29 ++++---- source/tools/dist/build-osx-bundle.py | 22 ++++-- source/tools/dist/build-osx-executable.sh | 0 source/tools/dist/build-unix-win32.sh | 2 +- source/tools/dist/build.sh | 4 +- 7 files changed, 95 insertions(+), 41 deletions(-) rename build/jenkins/pipelines/{macos-bundle.Jenkinsfile => macos-all-bundles.Jenkinsfile} (79%) mode change 100644 => 100755 source/tools/dist/build-archives.sh mode change 100644 => 100755 source/tools/dist/build-osx-bundle.py mode change 100644 => 100755 source/tools/dist/build-osx-executable.sh mode change 100644 => 100755 source/tools/dist/build-unix-win32.sh diff --git a/build/jenkins/pipelines/macos-bundle.Jenkinsfile b/build/jenkins/pipelines/macos-all-bundles.Jenkinsfile similarity index 79% rename from build/jenkins/pipelines/macos-bundle.Jenkinsfile rename to build/jenkins/pipelines/macos-all-bundles.Jenkinsfile index 5a5cfb3922..d462b88bb4 100644 --- a/build/jenkins/pipelines/macos-bundle.Jenkinsfile +++ b/build/jenkins/pipelines/macos-all-bundles.Jenkinsfile @@ -23,6 +23,11 @@ pipeline { buildDiscarder(logRotator(artifactNumToKeepStr: '1')) } + parameters { + string(name: 'BUNDLE_VERSION', defaultValue: '0.0.24dev', description: 'Bundle Version') + booleanParam(name: 'ONLY_MOD', defaultValue: true, description: 'Only archive the mod mod.') + } + stages { stage("Checkout") { steps { @@ -39,12 +44,12 @@ pipeline { } stage("Create archive data") { steps { - sh "source/tools/dist/build-archives.sh" + sh "ONLY_MOD=${ONLY_MOD} source/tools/dist/build-archives.sh" } } stage("Create Mac Bundle") { steps { - sh "python3 source/tools/dist/build-osx-bundle.py '0.0.24dev'" + sh "python3 source/tools/dist/build-osx-bundle.py ${BUNDLE_VERSION}" } } stage("Create Windows installer & *nix files") { @@ -55,7 +60,8 @@ pipeline { sh "svn st libraries/ --no-ignore | cut -c 9- | xargs rm -rf" sh "svn revert build/ -R" - sh "BUNDLE_VERSION='0.0.24dev' source/tools/dist/build-unix-win32.sh" + // Then run the core object. + sh "BUNDLE_VERSION=${BUNDLE_VERSION} source/tools/dist/build-unix-win32.sh" } } } diff --git a/source/tools/dist/0ad.nsi b/source/tools/dist/0ad.nsi index 4bfb8feccd..a8881c83ec 100644 --- a/source/tools/dist/0ad.nsi +++ b/source/tools/dist/0ad.nsi @@ -2,14 +2,17 @@ ; Do an 'svn export' into a directory called e.g. "export-win32" ; makensis -nocd -dcheckoutpath=export-win32 -drevision=1234 -dprefix=0ad-0.1.2-alpha export-win32/source/tools/dist/0ad.nsi - SetCompressor /SOLID ZLIB + SetCompressor /SOLID LZMA !include "MUI2.nsh" !include "LogicLib.nsh" !include "source/tools/dist/FileAssociation.nsh" ;Control whether to include source code (and component selection screen) - !define INCLUDE_SOURCE 0 + ;Off by default, uncomment or pass directly to use. + !ifndef INCLUDE_SOURCE + ;!define INCLUDE_SOURCE 1 + !endif ;-------------------------------- ;General @@ -55,7 +58,7 @@ ;Pages !insertmacro MUI_PAGE_WELCOME - !if INCLUDE_SOURCE + !ifdef INCLUDE_SOURCE !insertmacro MUI_PAGE_COMPONENTS !endif !insertmacro MUI_PAGE_DIRECTORY @@ -70,6 +73,10 @@ !insertmacro MUI_PAGE_INSTFILES + !define MUI_FINISHPAGE_SHOWREADME "" + !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED + !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut" + !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopLink !define MUI_FINISHPAGE_RUN $INSTDIR\binaries\system\pyrogenesis.exe !insertmacro MUI_PAGE_FINISH @@ -115,12 +122,26 @@ Section "!Game and data files" GameSection SetOutPath "$INSTDIR" File "${CHECKOUTPATH}\*.txt" File "${CHECKOUTPATH}\source\tools\openlogsfolder\*.*" - !if INCLUDE_SOURCE - File /r /x "*.a" /x "*.dylib" /x "public" /x "mod" /x "dev.cfg" "${CHECKOUTPATH}\binaries" - !else - ;Exclude debug DLLs and related files - File /r /x "public" /x "mod" /x "dev.cfg" /x "*_d.dll" /x "enetd.dll" /x "FColladaD.dll" /x "gloox-1.0d.dll" /x "glooxwrapper_dbg.*" /x "libcurld.dll" /x "libpng16d.dll" /x "*.a" /x "*.dylib" /x "pyrogenesis" /x "*.dsym*" /x "test" /x "libsodiumd.dll" /x "miniupnpcd.dll" /x "mozjs*-ps-debug*" /x "mozjs*vc140.*" /x "msvc*d.dll" /x "zlib1d.dll" "${CHECKOUTPATH}\binaries\" - !endif + + ; Binaries: exclude debug DLLs and related files + SetOutPath "$INSTDIR\binaries\data" + File /r /x "public" /x "mod" /x "dev.cfg" "${CHECKOUTPATH}\binaries\data\" + + ; Warning: libraries that end in 'd' need to be added explicitly. + ; There are currently none. + SetOutPath "$INSTDIR\binaries\system" + File /r /x "*d.dll" /x "*_dbg*" /x "*debug*" "${CHECKOUTPATH}\binaries\system\*.dll" + File /r /x "*d.pdb" /x "*_dbg*" /x "*debug*" /x "test" "${CHECKOUTPATH}\binaries\system\*.pdb" + File /r /x "*_dbg*" /x "*debug*" /x "test" "${CHECKOUTPATH}\binaries\system\*.exe" + File /r "${CHECKOUTPATH}\binaries\system\*.bat" + File /r "${CHECKOUTPATH}\binaries\system\*.txt" + + ; Create shortcuts in the root installation folder. + ; Keep synched with the start menu shortcuts. + SetOutPath "$INSTDIR" + CreateShortCut "$INSTDIR\0 A.D..lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" "" + CreateShortCut "$INSTDIR\Map editor.lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" "-editor" "$INSTDIR\binaries\data\tools\atlas\icons\ScenarioEditor.ico" + WriteINIStr "$INSTDIR\Web site.url" "InternetShortcut" "URL" "http://play0ad.com/" !ifdef ARCHIVE_PATH SetOutPath "$INSTDIR\binaries\data\mods\" @@ -172,14 +193,14 @@ Section "!Game and data files" GameSection SectionEnd -!if INCLUDE_SOURCE +!ifdef INCLUDE_SOURCE Section /o "Source code" SourceSection SetOutPath "$INSTDIR" - File /r ${CHECKOUTPATH}\source - File /r ${CHECKOUTPATH}\docs - File /r ${CHECKOUTPATH}\build - File /r ${CHECKOUTPATH}\libraries + File /r "${CHECKOUTPATH}\source\" + File /r "${CHECKOUTPATH}\docs\" + File /r "${CHECKOUTPATH}\build" + File /r "${CHECKOUTPATH}\libraries" SectionEnd !endif @@ -208,10 +229,14 @@ done: FunctionEnd +Function CreateDesktopLink + CreateShortCut "$DESKTOP\0 A.D..lnk" "$INSTDIR\binaries\system\pyrogenesis.exe" "" +FunctionEnd + ;-------------------------------- ;Descriptions - !if INCLUDE_SOURCE + !ifdef INCLUDE_SOURCE ;Assign descriptions to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN @@ -227,7 +252,7 @@ FunctionEnd Section "Uninstall" RMDir /r "$INSTDIR\binaries" - !if INCLUDE_SOURCE + !ifdef INCLUDE_SOURCE RMDir /r "$INSTDIR\source" RMDir /r "$INSTDIR\docs" RMDir /r "$INSTDIR\build" @@ -236,14 +261,18 @@ Section "Uninstall" Delete "$INSTDIR\*.txt" Delete "$INSTDIR\*.bat" Delete "$INSTDIR\OpenLogsFolder.vbs" - Delete "$INSTDIR\Uninstall.exe" - - RMDir "$INSTDIR" + Delete "$INSTDIR\Map editor.lnk" + Delete "$INSTDIR\0 A.D..lnk" + Delete "$INSTDIR\Web site.url" + Delete /REBOOTOK "$INSTDIR\Uninstall.exe" + RMDir /REBOOTOK "$INSTDIR" RMDir /r "$LOCALAPPDATA\0ad\cache" RMDir /r "$LOCALAPPDATA\0ad\logs" ; leave the other directories (screenshots, config files, etc) + Delete "$DESKTOP\0 A.D..lnk" + !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder Delete "$SMPROGRAMS\$StartMenuFolder\Open logs folder.lnk" diff --git a/source/tools/dist/build-archives.sh b/source/tools/dist/build-archives.sh old mode 100644 new mode 100755 index 5db746766a..0e18f6d3a6 --- a/source/tools/dist/build-archives.sh +++ b/source/tools/dist/build-archives.sh @@ -3,8 +3,8 @@ set -e die() { - echo ERROR: $* - exit 1 + echo ERROR: $* + exit 1 } # Build the mod .zip using the pyrogenesis executable. @@ -28,20 +28,25 @@ echo "${SVN_REV}-release" > build/svn_revision/svn_revision.txt # Build archive(s) - don't archive the _test.* mods pushd binaries/data/mods > /dev/null archives="" -for modname in [a-zA-Z0-9]* -do - archives="${archives} ${modname}" -done +ONLY_MOD="${ONLY_MOD:=false}" +if [ "${ONLY_MOD}" = true ]; then + archives="mod" +else + for modname in [a-zA-Z0-9]* + do + archives="${archives} ${modname}" + done +fi popd > /dev/null for modname in $archives do - echo "\nBuilding archive for '${modname}'\n" - ARCHIVEBUILD_INPUT="binaries/data/mods/${modname}" - ARCHIVEBUILD_OUTPUT="archives/${modname}" + echo "\nBuilding archive for '${modname}'\n" + ARCHIVEBUILD_INPUT="binaries/data/mods/${modname}" + ARCHIVEBUILD_OUTPUT="archives/${modname}" - mkdir -p "${ARCHIVEBUILD_OUTPUT}" + mkdir -p "${ARCHIVEBUILD_OUTPUT}" - (./binaries/system/pyrogenesis -archivebuild="${ARCHIVEBUILD_INPUT}" -archivebuild-output="${ARCHIVEBUILD_OUTPUT}/${modname}.zip") || die "Archive build for '${modname}' failed!" - cp "${ARCHIVEBUILD_INPUT}/mod.json" "${ARCHIVEBUILD_OUTPUT}" || true + (./binaries/system/pyrogenesis -archivebuild="${ARCHIVEBUILD_INPUT}" -archivebuild-output="${ARCHIVEBUILD_OUTPUT}/${modname}.zip") || die "Archive build for '${modname}' failed!" + cp "${ARCHIVEBUILD_INPUT}/mod.json" "${ARCHIVEBUILD_OUTPUT}" &> /dev/null || true done diff --git a/source/tools/dist/build-osx-bundle.py b/source/tools/dist/build-osx-bundle.py old mode 100644 new mode 100755 index 32dfd94b7b..a4cd5caee4 --- a/source/tools/dist/build-osx-bundle.py +++ b/source/tools/dist/build-osx-bundle.py @@ -24,6 +24,8 @@ parser.add_argument('--min_osx', help='Minimum supported OSX version', default='10.12') parser.add_argument('--bundle_identifier', help='Bundle identifier', default='com.wildfiregames.0ad') +parser.add_argument('--dev', help='Turn on dev mode, which isn\'t fit for release but faster', + action="store_true") args = parser.parse_args() BUNDLE_DMG_NAME = "0 A.D." @@ -59,10 +61,18 @@ print("Copying libs") shutil.copy("binaries/system/libAtlasUI.dylib", BUNDLE_FRAMEWORKS) shutil.copy("binaries/system/libCollada.dylib", BUNDLE_FRAMEWORKS) -print("Copying archived game data") -for mod in glob.glob("archives/*/"): - print(f"Copying {mod}") - shutil.copytree(mod, BUNDLE_RESOURCES + "/data/mods/" + mod.replace("archives/", "")) +if not args.dev: + print("Copying archived game data from archives/") + for mod in glob.glob("archives/*/"): + print(f"Copying {mod}") + shutil.copytree(mod, BUNDLE_RESOURCES + "/data/mods/" + mod.replace("archives/", "")) +else: + print("Symlinking mods") + os.makedirs(BUNDLE_RESOURCES + "/data/mods") + os.chdir(BUNDLE_RESOURCES + "/data/mods") + for mod in glob.glob("../../../../../binaries/data/mods/*"): + os.symlink(mod, mod.replace("../../../../../binaries/data/mods/", "")) + os.chdir("../../../../../") print("Copying non-archived game data") shutil.copytree("binaries/data/config", BUNDLE_RESOURCES + "/data/config") @@ -99,6 +109,10 @@ with open(BUNDLE_CONTENTS + "/Info.plist", 'wb') as f: 'NSHumanReadableCopyright': f'Copyright © {datetime.datetime.now().year} Wildfire Games', }, f) +if args.dev: + print(f"Dev mode bundle complete, located at {BUNDLE_OUTPUT}") + exit(0) + print("Creating .dmg") # Package the app into a dmg diff --git a/source/tools/dist/build-osx-executable.sh b/source/tools/dist/build-osx-executable.sh old mode 100644 new mode 100755 diff --git a/source/tools/dist/build-unix-win32.sh b/source/tools/dist/build-unix-win32.sh old mode 100644 new mode 100755 index db41c3f51a..fe0e80a7f0 --- a/source/tools/dist/build-unix-win32.sh +++ b/source/tools/dist/build-unix-win32.sh @@ -7,7 +7,7 @@ GZIP7ZOPTS="-mx=9" BUNDLE_VERSION=${BUNDLE_VERSION:="0.0.xxx"} PREFIX="0ad-${BUNDLE_VERSION}-alpha" -SVN_REV=$(svnversion -n .) +SVN_REV=${SVN_REV:=$(svnversion -n .)} echo "${SVN_REV}-release" > build/svn_revision/svn_revision.txt # Collect the relevant files diff --git a/source/tools/dist/build.sh b/source/tools/dist/build.sh index 38f76e132c..5358b32ab0 100755 --- a/source/tools/dist/build.sh +++ b/source/tools/dist/build.sh @@ -7,7 +7,7 @@ set -e ./source/tools/dist/build-osx-executable.sh ./source/tools/dist/build-archives.sh -python3 source/tools/dist/build-osx-bundle.py +python3 source/tools/dist/build-osx-bundle.py 0ad-dev # Note that at this point, you'll have left-over compilation files. # The CI cleans them via svn st | cut -c9- | xargs rm -rf -./source/tools/dist/build-unix-win32.sh +BUNDLE_VERSION=0ad-dev ./source/tools/dist/build-unix-win32.sh