mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Merge pull request #4335 from OpenRCT2/new-msbuild-proj
Change Windows build configuration to msbuild and add x64 publish and deployment.
This commit is contained in:
commit
d2cb3fa0b4
15 changed files with 588 additions and 860 deletions
28
appveyor.yml
28
appveyor.yml
|
@ -7,22 +7,30 @@ cache:
|
|||
environment:
|
||||
ENCKEY:
|
||||
secure: saYAIpqXzpq0U+JH+MNi/isRQ6Y51PZhm4BrnePDiAPptFO5htxFOLegrYqxdy67
|
||||
CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD:
|
||||
SIGN_PASSWORD:
|
||||
secure: bzYmf0ElxisSGyZnIjUOYQ==
|
||||
OPENRCT2.ORG_TOKEN:
|
||||
OPENRCT2_ORG_TOKEN:
|
||||
secure: leQX3xCQpmBLGuMqrxjFlzexDt96ypNRMM5TTRVHbGE8PwVg9crgeykLc2BIZU6HDHveJCHqh2cGMdHtHYJYcw==
|
||||
BUILD_SERVER: AppVeyor
|
||||
GIT_TAG: $(APPVEYOR_REPO_TAG_NAME)
|
||||
GIT_BRANCH: $(APPVEYOR_REPO_BRANCH)
|
||||
GIT_COMMIT_SHA1: $(APPVEYOR_REPO_COMMIT)
|
||||
install:
|
||||
- ps: >-
|
||||
.\scripts\ps\appveyor_install.ps1
|
||||
build_script:
|
||||
- ps: >-
|
||||
.\setenv.ps1
|
||||
|
||||
appveyor_build
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
configuration: Release
|
||||
build:
|
||||
project: openrct2.proj
|
||||
artifacts:
|
||||
- path: .\artifacts\openrct2.zip
|
||||
- path: .\artifacts\openrct2-portable*.zip
|
||||
name: OpenRCT2-portable
|
||||
- path: .\artifacts\*.exe
|
||||
- path: .\artifacts\openrct2-installer*.exe
|
||||
name: OpenRCT2-installer
|
||||
- path: .\artifacts\openrct2-symbols-*.zip
|
||||
- path: .\artifacts\openrct2-symbols*.zip
|
||||
name: OpenRCT2 debug symbols
|
||||
deploy_script:
|
||||
- ps: >-
|
||||
.\scripts\ps\appveyor_deploy.ps1
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
param (
|
||||
[Parameter(Position = 1)]
|
||||
[string]$VersionExtra = ""
|
||||
)
|
||||
|
||||
$path = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
Write-Host "Building Windows Installer (NSIS script)";
|
||||
Write-Host " $VersionExtra";
|
||||
makensis /DAPPV_EXTRA=$VersionExtra `
|
||||
/DVERSION_INCLUDE=$path\win32.txt `
|
||||
$path\install.nsi > $path\win32.log;
|
|
@ -3,18 +3,35 @@
|
|||
!define /ifndef APPV_MINOR 0
|
||||
!define /ifndef APPV_MAINT 5
|
||||
!define /ifndef APPV_BUILD 0
|
||||
!define /ifndef APPV_EXTRA "-beta"
|
||||
|
||||
!define APPNAME "OpenRCT2" ; Define application name
|
||||
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
|
||||
!define APPVERSIONINTERNAL "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}.${APPV_BUILD}" ; Define application version in X.X.X.X
|
||||
!include ${VERSION_INCLUDE}
|
||||
!define APPNAME "OpenRCT2"
|
||||
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}"
|
||||
!define APPVERSIONINTERNAL "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}.${APPV_BUILD}"
|
||||
|
||||
!define /ifndef APPURLLINK "https://github.com/OpenRCT2/OpenRCT2"
|
||||
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"
|
||||
|
||||
!if "${PLATFORM}" == "Win32"
|
||||
!define OPENRCT2_EXE "openrct2.exe"
|
||||
!define OPENRCT2_DLL "openrct2.dll"
|
||||
!define APPBITS 32
|
||||
!define APPARCH "win32"
|
||||
|
||||
InstallDir "$PROGRAMFILES32\OpenRCT2\"
|
||||
!else
|
||||
!define OPENRCT2_EXE "openrct2_x64.exe"
|
||||
!define OPENRCT2_SEGMENT_INFO "openrct2_data"
|
||||
!define APPBITS 64
|
||||
!define APPARCH "win64"
|
||||
|
||||
InstallDir "$PROGRAMFILES64\OpenRCT2\"
|
||||
!endif
|
||||
|
||||
!define SUPPORTED_OS "Windows Vista, 7, 8.1 and 10"
|
||||
|
||||
; Define root variable relative to installer
|
||||
!define PATH_ROOT "..\..\"
|
||||
!define BINARY_DIR "${PATH_ROOT}bin"
|
||||
|
||||
!define MUI_ICON "${PATH_ROOT}resources\logo\icon.ico"
|
||||
!define MUI_UNICON "${PATH_ROOT}resources\logo\icon.ico"
|
||||
|
@ -27,7 +44,7 @@ SetCompressor LZMA
|
|||
|
||||
; Version Info
|
||||
VIProductVersion "${APPVERSIONINTERNAL}"
|
||||
VIAddVersionKey "ProductName" "OpenRCT2 ${APPBITS}-bit Installer for Windows ${EXTRA_VERSION}"
|
||||
VIAddVersionKey "ProductName" "OpenRCT2 ${APPBITS}-bit Installer for ${SUPPORTED_OS}"
|
||||
VIAddVersionKey "Comments" "Installs ${APPNAMEANDVERSION}"
|
||||
VIAddVersionKey "CompanyName" "OpenRCT2 Developers"
|
||||
VIAddVersionKey "FileDescription" "Installs ${APPNAMEANDVERSION}"
|
||||
|
@ -36,12 +53,12 @@ VIAddVersionKey "InternalName" "InstOpenRCT2-${APPARCH}"
|
|||
VIAddVersionKey "FileVersion" "${APPVERSION}-${APPARCH}"
|
||||
VIAddVersionKey "LegalCopyright" " "
|
||||
; Main Install settings
|
||||
Name "${APPNAMEANDVERSION} ${APPBITS}-bit for Windows ${EXTRA_VERSION}"
|
||||
Name "${APPNAMEANDVERSION} ${APPBITS}-bit for ${SUPPORTED_OS}"
|
||||
|
||||
; NOTE: Keep trailing backslash!
|
||||
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Install Folder"
|
||||
!ifndef OUTFILE
|
||||
!define OUTFILE "openrct2-install.exe"
|
||||
!define OUTFILE "openrct2-install.exe"
|
||||
!endif
|
||||
OutFile "${OUTFILE}"
|
||||
CRCCheck force
|
||||
|
@ -83,7 +100,7 @@ ManifestDPIAware true
|
|||
|
||||
!define MUI_FINISHPAGE_TITLE_3LINES
|
||||
!define MUI_FINISHPAGE_RUN_TEXT "Run ${APPNAMEANDVERSION} now!"
|
||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\openrct2.exe"
|
||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\${OPENRCT2_EXE}"
|
||||
!define MUI_FINISHPAGE_LINK "Visit the OpenRCT2 site for more information"
|
||||
!define MUI_FINISHPAGE_LINK_LOCATION "${APPURLLINK}"
|
||||
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
|
||||
|
@ -118,8 +135,8 @@ Section "!OpenRCT2" Section1
|
|||
; Copy the rest of the stuff
|
||||
SetOutPath "$INSTDIR\"
|
||||
|
||||
; Copy curl ca file
|
||||
File ..\..\curl-ca-bundle.crt
|
||||
; Copy curl ca file
|
||||
File ..\..\curl-ca-bundle.crt
|
||||
|
||||
; Copy text files
|
||||
File ..\changelog.txt
|
||||
|
@ -139,12 +156,17 @@ Section "!OpenRCT2" Section1
|
|||
Call unix2dos
|
||||
|
||||
; Copy executable
|
||||
File /oname=openrct2.exe ${BINARY_DIR}\openrct2.exe
|
||||
File /oname=openrct2.dll ${BINARY_DIR}\openrct2.dll
|
||||
File /oname=${OPENRCT2_EXE} ${BINARY_DIR}\${OPENRCT2_EXE}
|
||||
!ifdef OPENRCT2_DLL
|
||||
File /oname=${OPENRCT2_DLL} ${BINARY_DIR}\${OPENRCT2_DLL}
|
||||
!endif
|
||||
!ifdef OPENRCT2_SEGMENT_INFO
|
||||
File /oname=${OPENRCT2_SEGMENT_INFO} ${BINARY_DIR}\${OPENRCT2_SEGMENT_INFO}
|
||||
!endif
|
||||
|
||||
; Create the Registry Entries
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Comments" "Visit ${APPURLLINK}"
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayIcon" "$INSTDIR\openrct2.exe,0"
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayIcon" "$INSTDIR\${OPENRCT2_EXE},0"
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayName" "OpenRCT2 ${APPVERSION}"
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "DisplayVersion" "${APPVERSION}"
|
||||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "HelpLink" "${APPURLLINK}"
|
||||
|
@ -157,9 +179,9 @@ Section "!OpenRCT2" Section1
|
|||
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Version" "${APPVERSIONINTERNAL}"
|
||||
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN "OpenRCT2"
|
||||
CreateShortCut "$DESKTOP\OpenRCT2.lnk" "$INSTDIR\openrct2.exe"
|
||||
CreateShortCut "$DESKTOP\OpenRCT2.lnk" "$INSTDIR\${OPENRCT2_EXE}"
|
||||
CreateDirectory "$SMPROGRAMS\$SHORTCUTS"
|
||||
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\OpenRCT2.lnk" "$INSTDIR\openrct2.exe"
|
||||
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\OpenRCT2.lnk" "$INSTDIR\${OPENRCT2_EXE}"
|
||||
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Uninstall.lnk" "$INSTDIR\uninstall.exe"
|
||||
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Readme.lnk" "$INSTDIR\Readme.txt"
|
||||
CreateShortCut "$SMPROGRAMS\$SHORTCUTS\Changelog.lnk" "$INSTDIR\Changelog.txt"
|
||||
|
@ -201,23 +223,26 @@ Section "Uninstall"
|
|||
Delete "$SMPROGRAMS\$SHORTCUTS\Contributors.lnk"
|
||||
|
||||
; Clean up OpenRCT2 dir
|
||||
Delete "$INSTDIR\curl-ca-bundle.crt"
|
||||
Delete "$INSTDIR\changelog.txt"
|
||||
Delete "$INSTDIR\known_issues.txt"
|
||||
Delete "$INSTDIR\licence.txt"
|
||||
Delete "$INSTDIR\readme.txt"
|
||||
Delete "$INSTDIR\contributors.md"
|
||||
Delete "$INSTDIR\openrct2.exe"
|
||||
Delete "$INSTDIR\openrct2.dll"
|
||||
Delete "$INSTDIR\licence.txt"
|
||||
Delete "$INSTDIR\${OPENRCT2_EXE}"
|
||||
!ifdef OPENRCT2_DLL
|
||||
Delete "$INSTDIR\${OPENRCT2_DLL}"
|
||||
!endif
|
||||
!ifdef OPENRCT2_SEGMENT_INFO
|
||||
Delete "$INSTDIR\${OPENRCT2_SEGMENT_INFO}"
|
||||
!endif
|
||||
Delete "$INSTDIR\INSTALL.LOG"
|
||||
Delete "$INSTDIR\crash.log"
|
||||
Delete "$INSTDIR\crash.dmp"
|
||||
|
||||
; Data files
|
||||
Delete "$INSTDIR\data\language\*.txt"
|
||||
Delete "$INSTDIR\data\title\*.*"
|
||||
RMDir /r "$INSTDIR\data"
|
||||
|
||||
; Remove remaining directories
|
||||
RMDir "$SMPROGRAMS\$SHORTCUTS"
|
||||
RMDir "$INSTDIR\data"
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
SectionEnd
|
||||
|
@ -285,13 +310,13 @@ FunctionEnd
|
|||
;-------------------------------------------------------------------------------
|
||||
; Check whether OpenRCT2 is running
|
||||
Function CheckOpenRCT2Running
|
||||
IfFileExists "$INSTDIR\openrct2.exe" 0 Done
|
||||
IfFileExists "$INSTDIR\${OPENRCT2_EXE}" 0 Done
|
||||
Retry:
|
||||
FindProcDLL::FindProc "openrct2.exe"
|
||||
FindProcDLL::FindProc "${OPENRCT2_EXE}"
|
||||
Pop $R0
|
||||
IntCmp $R0 1 0 Done
|
||||
ClearErrors
|
||||
Delete "$INSTDIR\openrct2.exe"
|
||||
Delete "$INSTDIR\${OPENRCT2_EXE}"
|
||||
IfErrors 0 Done
|
||||
ClearErrors
|
||||
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "OpenRCT2 is running. Please close it and retry." IDRETRY Retry
|
||||
|
@ -363,88 +388,88 @@ FunctionEnd
|
|||
; $var=1 Version1 is newer
|
||||
; $var=2 Version2 is newer
|
||||
Function VersionCompare
|
||||
!define VersionCompare `!insertmacro VersionCompareCall`
|
||||
!define VersionCompare `!insertmacro VersionCompareCall`
|
||||
|
||||
!macro VersionCompareCall _VER1 _VER2 _RESULT
|
||||
Push `${_VER1}`
|
||||
Push `${_VER2}`
|
||||
Call VersionCompare
|
||||
Pop ${_RESULT}
|
||||
!macroend
|
||||
!macro VersionCompareCall _VER1 _VER2 _RESULT
|
||||
Push `${_VER1}`
|
||||
Push `${_VER2}`
|
||||
Call VersionCompare
|
||||
Pop ${_RESULT}
|
||||
!macroend
|
||||
|
||||
Exch $1
|
||||
Exch
|
||||
Exch $0
|
||||
Exch
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
Push $6
|
||||
Push $7
|
||||
Exch $1
|
||||
Exch
|
||||
Exch $0
|
||||
Exch
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
Push $6
|
||||
Push $7
|
||||
|
||||
begin:
|
||||
StrCpy $2 -1
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $3 $0 1 $2
|
||||
StrCmp $3 '' +2
|
||||
StrCmp $3 '.' 0 -3
|
||||
StrCpy $4 $0 $2
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $0 $0 '' $2
|
||||
begin:
|
||||
StrCpy $2 -1
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $3 $0 1 $2
|
||||
StrCmp $3 '' +2
|
||||
StrCmp $3 '.' 0 -3
|
||||
StrCpy $4 $0 $2
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $0 $0 '' $2
|
||||
|
||||
StrCpy $2 -1
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $3 $1 1 $2
|
||||
StrCmp $3 '' +2
|
||||
StrCmp $3 '.' 0 -3
|
||||
StrCpy $5 $1 $2
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $1 $1 '' $2
|
||||
StrCpy $2 -1
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $3 $1 1 $2
|
||||
StrCmp $3 '' +2
|
||||
StrCmp $3 '.' 0 -3
|
||||
StrCpy $5 $1 $2
|
||||
IntOp $2 $2 + 1
|
||||
StrCpy $1 $1 '' $2
|
||||
|
||||
StrCmp $4$5 '' equal
|
||||
StrCmp $4$5 '' equal
|
||||
|
||||
StrCpy $6 -1
|
||||
IntOp $6 $6 + 1
|
||||
StrCpy $3 $4 1 $6
|
||||
StrCmp $3 '0' -2
|
||||
StrCmp $3 '' 0 +2
|
||||
StrCpy $4 0
|
||||
StrCpy $6 -1
|
||||
IntOp $6 $6 + 1
|
||||
StrCpy $3 $4 1 $6
|
||||
StrCmp $3 '0' -2
|
||||
StrCmp $3 '' 0 +2
|
||||
StrCpy $4 0
|
||||
|
||||
StrCpy $7 -1
|
||||
IntOp $7 $7 + 1
|
||||
StrCpy $3 $5 1 $7
|
||||
StrCmp $3 '0' -2
|
||||
StrCmp $3 '' 0 +2
|
||||
StrCpy $5 0
|
||||
StrCpy $7 -1
|
||||
IntOp $7 $7 + 1
|
||||
StrCpy $3 $5 1 $7
|
||||
StrCmp $3 '0' -2
|
||||
StrCmp $3 '' 0 +2
|
||||
StrCpy $5 0
|
||||
|
||||
StrCmp $4 0 0 +2
|
||||
StrCmp $5 0 begin newer2
|
||||
StrCmp $5 0 newer1
|
||||
IntCmp $6 $7 0 newer1 newer2
|
||||
StrCmp $4 0 0 +2
|
||||
StrCmp $5 0 begin newer2
|
||||
StrCmp $5 0 newer1
|
||||
IntCmp $6 $7 0 newer1 newer2
|
||||
|
||||
StrCpy $4 '1$4'
|
||||
StrCpy $5 '1$5'
|
||||
IntCmp $4 $5 begin newer2 newer1
|
||||
StrCpy $4 '1$4'
|
||||
StrCpy $5 '1$5'
|
||||
IntCmp $4 $5 begin newer2 newer1
|
||||
|
||||
equal:
|
||||
StrCpy $0 0
|
||||
goto end
|
||||
newer1:
|
||||
StrCpy $0 1
|
||||
goto end
|
||||
newer2:
|
||||
StrCpy $0 2
|
||||
equal:
|
||||
StrCpy $0 0
|
||||
goto end
|
||||
newer1:
|
||||
StrCpy $0 1
|
||||
goto end
|
||||
newer2:
|
||||
StrCpy $0 2
|
||||
|
||||
end:
|
||||
Pop $7
|
||||
Pop $6
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Exch $0
|
||||
end:
|
||||
Pop $7
|
||||
Pop $6
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Exch $0
|
||||
FunctionEnd
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
!define APPBITS 32 ; Define number of bits for the architecture
|
||||
!define EXTRA_VERSION "Vista, 7, 8.1 and 10"
|
||||
!define APPARCH "win32" ; Define the application architecture
|
||||
!define BINARY_DIR "${PATH_ROOT}bin"
|
||||
InstallDir "$PROGRAMFILES32\OpenRCT2\"
|
279
openrct2.proj
Normal file
279
openrct2.proj
Normal file
|
@ -0,0 +1,279 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Main msbuild project for OpenRCT2 -->
|
||||
<!-- Inputs (/p: or environment variables)
|
||||
- OPENRCT2_BUILD_SERVER
|
||||
- GIT_TAG
|
||||
- GIT_BRANCH
|
||||
- GIT_COMMIT_SHA1
|
||||
- SIGN_PASSWORD
|
||||
- OPENRCT2_ORG_TOKEN
|
||||
- NO_NSIS: set to true to prevent the NSIS installer building
|
||||
-->
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="PublishAll">
|
||||
<!-- Import custom build tasks -->
|
||||
<Import Project="openrct2.targets" />
|
||||
|
||||
<!-- Import the C++ project for OpenRCT2 -->
|
||||
<Import Project="openrct2.vcxproj" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>0.0.5</Version>
|
||||
<TargetLibsVersion>9</TargetLibsVersion>
|
||||
|
||||
<BUILD_SERVER Condition="'$(BUILD_SERVER)'==''">$(COMPUTERNAME)</BUILD_SERVER>
|
||||
<GIT_COMMIT_SHA1_SHORT Condition="'$(GIT_COMMIT_SHA1)'!=''">$(GIT_COMMIT_SHA1.Substring(0, 7))</GIT_COMMIT_SHA1_SHORT>
|
||||
|
||||
<!-- Set dynamic OpenRCT2 #defines -->
|
||||
<OPENRCT2_DEFINES Condition="'$(BUILD_SERVER)'!=''">OPENRCT2_BUILD_SERVER="$(BUILD_SERVER)";$(OPENRCT2_DEFINES)</OPENRCT2_DEFINES>
|
||||
<OPENRCT2_DEFINES Condition="'$(GIT_BRANCH)'!=''">OPENRCT2_BRANCH="$(GIT_BRANCH)";$(OPENRCT2_DEFINES)</OPENRCT2_DEFINES>
|
||||
<OPENRCT2_DEFINES Condition="'$(GIT_COMMIT_SHA1)'!=''">OPENRCT2_COMMIT_SHA1="$(GIT_COMMIT_SHA1)";$(OPENRCT2_DEFINES)</OPENRCT2_DEFINES>
|
||||
<OPENRCT2_DEFINES Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">OPENRCT2_COMMIT_SHA1_SHORT="$(GIT_COMMIT_SHA1_SHORT)";$(OPENRCT2_DEFINES)</OPENRCT2_DEFINES>
|
||||
|
||||
<RootDir>$(MsBuildThisFileDirectory)</RootDir>
|
||||
<DistDir>$(RootDir)distribution\</DistDir>
|
||||
<ArtifactsDir>$(RootDir)artifacts\</ArtifactsDir>
|
||||
|
||||
<NsisScript>$(DistDir)windows\install.nsi</NsisScript>
|
||||
|
||||
<OutputDll Condition="'$(Platform)'=='Win32'">$(TargetDir)openrct2.dll</OutputDll>
|
||||
<OutputExe Condition="'$(Platform)'=='Win32'">$(TargetDir)openrct2.exe</OutputExe>
|
||||
<OutputExe Condition="'$(Platform)'=='x64'">$(TargetPath)</OutputExe>
|
||||
<OutputSegmentInfo Condition="'$(Platform)'=='x64'">$(TargetDir)openrct2_data</OutputSegmentInfo>
|
||||
<g2Output>$(TargetDir)data\g2.dat</g2Output>
|
||||
|
||||
<SignCertificate Condition="'$(SignCertificate)'==''">$(DistDir)windows\code-sign-key-openrct2.org.pfx</SignCertificate>
|
||||
<SignTimestampUrl>http://timestamp.comodoca.com/authenticode</SignTimestampUrl>
|
||||
|
||||
<PublishPostfix>-$(Configuration)-$(Platform)</PublishPostfix>
|
||||
<PublishPostfix Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">$(PublishPostfix)-$(GIT_COMMIT_SHA1_SHORT)</PublishPostfix>
|
||||
<PublishPostfix>$(PublishPostfix.ToLower())</PublishPostfix>
|
||||
<PublishZip>$(ArtifactsDir)openrct2-portable$(PublishPostfix).zip</PublishZip>
|
||||
<PublishSymbolsZip Condition="'$(GIT_COMMIT_SHA1_SHORT)'==''">$(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip</PublishSymbolsZip>
|
||||
<PublishSymbolsZip Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">$(ArtifactsDir)openrct2-symbols$(PublishPostfix).zip</PublishSymbolsZip>
|
||||
<PublishInstallerExe>$(ArtifactsDir)openrct2-installer$(PublishPostfix).exe</PublishInstallerExe>
|
||||
|
||||
<UploadFilename>OpenRCT2-$(Version)$(VersionExtension)-windows</UploadFilename>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- 3rd party libraries / dependencies -->
|
||||
<PropertyGroup>
|
||||
<LibsUrl>https://github.com/OpenRCT2/Dependencies/releases/download/v$(TargetLibsVersion)/openrct2-libs-vs2015.zip</LibsUrl>
|
||||
<LibsPath>$(RootDir)lib\</LibsPath>
|
||||
<LibsVersionPath>$(LibsPath)libversion</LibsVersionPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<g2Inputs Include="$(RootDir)resources\g2\*" />
|
||||
<SignItems Include="$(OutputExe)" />
|
||||
<SignItems Condition="'$(Platform)'=='Win32'" Include="$(OutputDll)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Label="Symbol Items">
|
||||
<SymbolItems Condition="'$(Platform)'=='Win32'" Include="$(OutputDll)" />
|
||||
<SymbolItems Include="$(OutputExe)" />
|
||||
<SymbolItems Include="$(TargetDir)$(TargetName).pdb" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Label="Publish Items">
|
||||
<PublishItems Include="$(OutputExe)" />
|
||||
<PublishItems Include="$(OutputDll)" Condition="'$(Platform)'=='Win32'" />
|
||||
<PublishItems Include="$(OutputSegmentInfo)" Condition="'$(Platform)'=='x64'" />
|
||||
<PublishItems Include="$(TargetDir)data" />
|
||||
<PublishItems Include="$(RootDir)curl-ca-bundle.crt" />
|
||||
<PublishItems Include="$(DistDir)changelog.txt" />
|
||||
<PublishItems Include="$(DistDir)known_issues.txt" />
|
||||
<PublishItems Include="$(DistDir)readme.txt" />
|
||||
<PublishItems Include="$(RootDir)contributors.md" />
|
||||
<PublishItems Include="$(RootDir)licence.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Label="Upload Artifacts">
|
||||
<UploadArtifacts Include="$(PublishZip)">
|
||||
<Name>$(UploadFilename).zip</Name>
|
||||
<FlavourId Condition="'$(Platform)'=='Win32'">1</FlavourId>
|
||||
<FlavourId Condition="'$(Platform)'=='x64'">6</FlavourId>
|
||||
</UploadArtifacts>
|
||||
<UploadArtifacts Include="$(PublishInstallerExe)">
|
||||
<Name>$(UploadFilename).exe</Name>
|
||||
<FlavourId Condition="'$(Platform)'=='Win32'">2</FlavourId>
|
||||
<FlavourId Condition="'$(Platform)'=='x64'">7</FlavourId>
|
||||
</UploadArtifacts>
|
||||
<UploadArtifacts Include="$(PublishSymbolsZip)">
|
||||
<Name>$(UploadFilename)-symbols.zip</Name>
|
||||
<FlavourId Condition="'$(Platform)'=='Win32'">5</FlavourId>
|
||||
<FlavourId Condition="'$(Platform)'=='x64'">10</FlavourId>
|
||||
</UploadArtifacts>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CheckLibs">
|
||||
<!-- Get libversion file and check version -->
|
||||
<Message Text="Checking if libraries need updating..." Importance="high" />
|
||||
<PropertyGroup>
|
||||
<CurrentLibsVersion>0</CurrentLibsVersion>
|
||||
<CurrentLibsVersion Condition="Exists($(LibsVersionPath))">$([System.IO.File]::ReadAllText($(LibsVersionPath)).Trim())</CurrentLibsVersion>
|
||||
<UpdateLibs Condition="$(TargetLibsVersion) > $(CurrentLibsVersion)">true</UpdateLibs>
|
||||
</PropertyGroup>
|
||||
|
||||
<Message Condition="'$(UpdateLibs)'!='true'" Text="Libraries up to date" Importance="high" />
|
||||
<Message Condition="'$(UpdateLibs)'=='true'" Text="Libraries out of date, updating..." Importance="high" />
|
||||
<CallTarget Condition="'$(UpdateLibs)'=='true'" Targets="DownloadLibs" />
|
||||
</Target>
|
||||
|
||||
<Target Name="DownloadLibs">
|
||||
<PropertyGroup>
|
||||
<LibsZipPath>$(LibsPath)openrct2-libs-vs2015.zip</LibsZipPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Clean libs directory -->
|
||||
<RemoveDir Directories="$(LibsPath)" />
|
||||
<MakeDir Directories="$(LibsPath)" />
|
||||
|
||||
<Message Text="Downloading libraries..." Importance="normal" />
|
||||
<Exec Command="powershell -ExecutionPolicy Unrestricted -Command "Invoke-WebRequest '$(LibsUrl)' -OutFile '$(LibsZipPath)'"" StandardOutputImportance="low" />
|
||||
<Unzip Input="$(LibsZipPath)" OutputDirectory="$(LibsPath)" />
|
||||
<Delete Files="$(LibsZipPath)" ContinueOnError="true" />
|
||||
|
||||
<!-- Update libversion file -->
|
||||
<WriteLinesToFile Lines="$(TargetLibsVersion)" File="$(LibsVersionPath)" Overwrite="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BeforeClean">
|
||||
<ItemGroup>
|
||||
<CleanItems Condition="'$(Platform)'=='Win32'" Include="$(OutputExe)" />
|
||||
<CleanItems Condition="'$(Platform)'=='x64'" Include="$(OutputSegmentInfo)" />
|
||||
<CleanItems Include="$(TargetDir)curl-ca-bundle.crt" />
|
||||
<CleanItems Include="$(g2Output)" />
|
||||
<CleanItems Include="$(ArtifactsDir)openrct2-installer-$(Configuration)-$(Platform)*.exe" />
|
||||
<CleanItems Include="$(ArtifactsDir)openrct2-portable-$(Configuration)-$(Platform)*.zip" />
|
||||
<CleanItems Include="$(ArtifactsDir)openrct2-symbols-$(Configuration)-$(Platform)*.zip" />
|
||||
</ItemGroup>
|
||||
<Delete Files="@(CleanItems)" />
|
||||
<Delete Files="%(SignItems.Identity).signed" />
|
||||
<RemoveDir Directories="$(TargetDir)data" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BeforeBuild" BeforeTargets="InitializeBuildStatus" DependsOnTargets="CheckLibs">
|
||||
<PropertyGroup>
|
||||
<BuildString Condition="'$(GIT_COMMIT_SHA1_SHORT)'!=''">$(GIT_COMMIT_SHA1_SHORT)</BuildString>
|
||||
<BuildString Condition="'$(GIT_BRANCH)'!=''">$(BuildString) ($(GIT_BRANCH))</BuildString>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<CopyItems Condition="'$(Platform)'=='Win32'" Include="$(RootDir)openrct2.exe" />
|
||||
<CopyItems Include="$(RootDir)curl-ca-bundle.crt" />
|
||||
<DataItems Include="$(RootDir)data\**\*" />
|
||||
</ItemGroup>
|
||||
<Message Condition="'$(BuildString)'!=''" Text="Building $(BuildString)" Importance="high" />
|
||||
<Copy SourceFiles="@(CopyItems)" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="@(DataItems)" DestinationFolder="$(TargetDir)data\%(RecursiveDir)" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
<!-- Target to create the segment information x64 builds currently require -->
|
||||
<Target Name="CreateRCT2SegmentInfo"
|
||||
AfterTargets="Build"
|
||||
Inputs="$(RootDir)openrct2.exe"
|
||||
Outputs="$(OutputSegmentInfo)"
|
||||
Condition="'$(Platform)'=='x64'">
|
||||
<Exec Command="dd if=$(RootDir)openrct2.exe of=$(OutputSegmentInfo) bs=4096 skip=1188 count=318"
|
||||
StandardOutputImportance="normal"
|
||||
StandardErrorImportance="normal" />
|
||||
<Exec Command="dd if=/dev/zero of=$(OutputSegmentInfo) bs=4096 seek=318 count=2630 conv=notrunc"
|
||||
StandardOutputImportance="normal"
|
||||
StandardErrorImportance="normal" />
|
||||
<Exec Command="dd if=$(RootDir)openrct2.exe of=$(OutputSegmentInfo) bs=4096 skip=1506 seek=2948 count=1 conv=notrunc"
|
||||
StandardOutputImportance="normal"
|
||||
StandardErrorImportance="normal" />
|
||||
</Target>
|
||||
|
||||
<!-- Target to build g2.dat containing OpenRCT2 sprites -->
|
||||
<Target Name="g2" DependsOnTargets="Build" AfterTargets="Build" Inputs="@(g2Inputs)" Outputs="$(g2Output)">
|
||||
<Message Text="Building g2.dat..." />
|
||||
<Exec Command="$(OutputExe) sprite build $(g2Output) $(RootDir)resources\g2"
|
||||
StandardOutputImportance="low" />
|
||||
</Target>
|
||||
|
||||
<!-- Target to sign OpenRCT2 (exe and dll)
|
||||
This requires the project parameter SIGN_PASSWORD to be set -->
|
||||
<Target Name="Sign" AfterTargets="Build" Inputs="@(SignItems)" Outputs="%(SignItems.Identity).signed">
|
||||
<Warning Condition="'$(SIGN_PASSWORD)'==''" Text="SIGN_PASSWORD was not set, skipping signing of %(SignItems.Filename)%(SignItems.Extension)." />
|
||||
<Message Condition="'$(SIGN_PASSWORD)'!=''" Text="Signing %(SignItems.Filename)%(SignItems.Extension)"
|
||||
Importance="high" />
|
||||
<Exec Condition="'$(SIGN_PASSWORD)'!=''"
|
||||
Command="signtool.exe sign /f $(SignCertificate) /p $(SIGN_PASSWORD) /t $(SignTimestampUrl) %(SignItems.Identity)"
|
||||
StandardOutputImportance="low" />
|
||||
|
||||
<!-- Create a dummy file so that msbuild can use it to determine if the binary is newer than the last sign time -->
|
||||
<Touch AlwaysCreate="true" Files="%(SignItems.Identity).signed" />
|
||||
</Target>
|
||||
|
||||
<!-- Target to publish OpenRCT2 as a portable zip -->
|
||||
<Target Name="PublishPortable" DependsOnTargets="Build;g2" Inputs="@(PublishItems)" Outputs="$(PublishZip)">
|
||||
<MakeDir Directories="$(ArtifactsDir)" />
|
||||
<Message Importance="high" Text="Creating $([System.IO.Path]::GetFileName($(PublishZip)))..." />
|
||||
<_7z Output="$(PublishZip)" Inputs="@(PublishItems)" />
|
||||
</Target>
|
||||
|
||||
<!-- Target to publish the OpenRCT2 debug symbols -->
|
||||
<Target Name="PublishSymbols" DependsOnTargets="Build" Inputs="@(SymbolItems)" Outputs="$(PublishSymbolsZip)">
|
||||
<MakeDir Directories="$(ArtifactsDir)" />
|
||||
<Message Importance="high" Text="Creating $([System.IO.Path]::GetFileName($(PublishSymbolsZip)))..." />
|
||||
<_7z Output="$(PublishSymbolsZip)" Inputs="@(SymbolItems)" />
|
||||
</Target>
|
||||
|
||||
<!-- Target to publish the OpenRCT2 as an NSIS installer -->
|
||||
<Target Name="PublishInstaller"
|
||||
DependsOnTargets="Build;g2"
|
||||
Inputs="@(PublishItems);$(NsisScript)"
|
||||
Outputs="$(PublishInstallerExe)"
|
||||
Condition="'$(NO_NSIS)'!='true'">
|
||||
<PropertyGroup>
|
||||
<VersionExtra Condition="'$(GIT_BRANCH)'!=''">-$(GIT_BRANCH)-$(GIT_COMMIT_SHA1_SHORT)</VersionExtra>
|
||||
<VersionTag Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(GIT_TAG)', '^v[0-9]'))">$(GIT_TAG)</VersionTag>
|
||||
<VersionExtra Condition="'$(GIT_TAG)'!='' AND '$(VersionTag)'==''">-$(GIT_TAG)</VersionExtra>
|
||||
<PublishInstallerExeName>$([System.IO.Path]::GetFilename($(PublishInstallerExe)))</PublishInstallerExeName>
|
||||
</PropertyGroup>
|
||||
|
||||
<MakeDir Directories="$(ArtifactsDir)" />
|
||||
|
||||
<!-- Create the installer -->
|
||||
<Message Text="Building Windows Installer (NSIS script)" Importance="high" />
|
||||
<Exec Command="makensis /DOUTFILE=$(PublishInstallerExe) ^
|
||||
/DAPPV_EXTRA=$(VersionExtra) ^
|
||||
/DPLATFORM=$(Platform) ^
|
||||
$(NsisScript)"
|
||||
StandardOutputImportance="normal" />
|
||||
|
||||
<!-- Sign the installer -->
|
||||
<Warning Condition="'$(SIGN_PASSWORD)'==''" Text="SIGN_PASSWORD was not set, skipping signing of $(PublishInstallerExeName)." />
|
||||
<Message Condition="'$(SIGN_PASSWORD)'!=''" Text="Signing $(PublishInstallerExeName)"
|
||||
Importance="high" />
|
||||
<Exec Condition="'$(SIGN_PASSWORD)'!=''"
|
||||
Command="signtool.exe sign /f $(SignCertificate) /p $(SIGN_PASSWORD) /t $(SignTimestampUrl) $(PublishInstallerExe)"
|
||||
StandardOutputImportance="low" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PublishAll"
|
||||
DependsOnTargets="PublishSymbols;PublishPortable;PublishInstaller" />
|
||||
|
||||
<!-- Target to upload the artifacts to OpenRCT2.org -->
|
||||
<Target Name="UploadArtifacts" DependsOnTargets="PublishAll">
|
||||
<PropertyGroup>
|
||||
<UploadLink>https://openrct2.org/altapi/?command=push-build</UploadLink>
|
||||
<UploadFileNameShort>%(UploadArtifacts.Filename)%(UploadArtifacts.Extension)</UploadFileNameShort>
|
||||
</PropertyGroup>
|
||||
<Message Text="Uploading $(UploadFileNameShort)" Importance="high" />
|
||||
<Error Condition="'$(OPENRCT2_ORG_TOKEN)'==''" Text="OPENRCT2_ORG_TOKEN not set." />
|
||||
<Error Condition="'$(GIT_COMMIT_SHA1)'==''" Text="GIT_COMMIT_SHA1 not set." />
|
||||
<Error Condition="'$(GIT_BRANCH)'==''" Text="GIT_BRANCH not set." />
|
||||
<Exec Command="curl.exe -s -o - ^
|
||||
--form "key=$(OPENRCT2_ORG_TOKEN)" ^
|
||||
--form "fileName=%(UploadArtifacts.Name)" ^
|
||||
--form "version=$(Version)" ^
|
||||
--form "gitHash=$(GIT_COMMIT_SHA1)" ^
|
||||
--form "gitBranch=$(GIT_BRANCH)" ^
|
||||
--form "flavourId=%(UploadArtifacts.FlavourId)" ^
|
||||
--form "file=@%(UploadArtifacts.Identity)" ^
|
||||
"$(UploadLink)""
|
||||
CustomErrorRegularExpression=""error":1" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
126
openrct2.targets
Normal file
126
openrct2.targets
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!-- 7z Task -->
|
||||
<UsingTask TaskName="_7z"
|
||||
TaskFactory="CodeTaskFactory"
|
||||
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<Inputs Required="true" ParameterType="System.String" />
|
||||
<Output Required="true" ParameterType="System.String" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Using Namespace="System"/>
|
||||
<Using Namespace="System.Diagnostics"/>
|
||||
<Using Namespace="System.IO"/>
|
||||
<Code Type="Method" Language="cs">
|
||||
<![CDATA[
|
||||
public override bool Execute()
|
||||
{
|
||||
string appPath = Find7zPath();
|
||||
if (appPath == null)
|
||||
{
|
||||
Log.LogError("Unable to find 7z.exe.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var argsSB = new StringBuilder();
|
||||
argsSB.Append("a -tzip -mx9 -mtc=off ");
|
||||
argsSB.Append("\"" + Output + "\" ");
|
||||
foreach (string input in Inputs.Split(';'))
|
||||
{
|
||||
argsSB.Append("\"" + input + "\" ");
|
||||
}
|
||||
string args = argsSB.ToString();
|
||||
|
||||
Log.LogMessage(MessageImportance.Normal, "7z " + args);
|
||||
|
||||
var psi = new ProcessStartInfo(appPath, args);
|
||||
psi.CreateNoWindow = true;
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardOutput = true;
|
||||
psi.RedirectStandardError = true;
|
||||
var process = Process.Start(psi);
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode != 0)
|
||||
{
|
||||
string appError = process.StandardError.ReadToEnd();
|
||||
appError = appError.Replace("\r\n", "\n");
|
||||
appError = appError.Replace("\r", "\n");
|
||||
appError = appError.Replace("\n", " ");
|
||||
int colonIndex = appError.IndexOf(":");
|
||||
if (colonIndex != -1)
|
||||
{
|
||||
appError = appError.Substring(colonIndex + 1);
|
||||
}
|
||||
appError = appError.Trim();
|
||||
Log.LogError(appError);
|
||||
return false;
|
||||
}
|
||||
|
||||
string appOutput = process.StandardOutput.ReadToEnd();
|
||||
Log.LogMessage(MessageImportance.Normal, appOutput);
|
||||
return true;
|
||||
}
|
||||
|
||||
private string Find7zPath()
|
||||
{
|
||||
const string DefaultAppFileName = "7z.exe";
|
||||
string DefaultAppPath = Path.Combine("7-Zip", DefaultAppFileName);
|
||||
|
||||
// HACK needed as SpecialFolder.ProgramFiles returns x86 for a 32-bit process
|
||||
string programFiles = Path.Combine(Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)), "Program Files");
|
||||
string appPath = Path.Combine(programFiles, DefaultAppPath);
|
||||
if (File.Exists(appPath))
|
||||
{
|
||||
return appPath;
|
||||
}
|
||||
|
||||
programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||
appPath = Path.Combine(programFiles, DefaultAppPath);
|
||||
if (File.Exists(appPath))
|
||||
{
|
||||
return appPath;
|
||||
}
|
||||
|
||||
programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
|
||||
appPath = Path.Combine(programFiles, DefaultAppPath);
|
||||
if (File.Exists(appPath))
|
||||
{
|
||||
return appPath;
|
||||
}
|
||||
|
||||
string[] envPaths = Environment.GetEnvironmentVariable("PATH").Split(';');
|
||||
foreach (string envPath in envPaths)
|
||||
{
|
||||
appPath = Path.Combine(envPath, DefaultAppFileName);
|
||||
if (File.Exists(appPath))
|
||||
{
|
||||
return appPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
<UsingTask TaskName="Unzip"
|
||||
TaskFactory="CodeTaskFactory"
|
||||
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<Input Required="true" ParameterType="System.String" />
|
||||
<OutputDirectory Required="true" ParameterType="System.String" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
Log.LogMessage(MessageImportance.Normal, String.Format("Extracting '{0}' to '{1}'.", Input, OutputDirectory));
|
||||
System.IO.Compression.ZipFile.ExtractToDirectory(Input, OutputDirectory);
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
</Project>
|
|
@ -1,9 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build0;Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="Build0">
|
||||
<Copy SourceFiles="openrct2.exe" DestinationFolder="$(OutDir)" />
|
||||
<Copy SourceFiles="curl-ca-bundle.crt" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
|
|
20
readme.md
20
readme.md
|
@ -53,7 +53,8 @@ OpenRCT2 requires original files of RollerCoaster Tycoon 2 to play. It can be bo
|
|||
### Windows:
|
||||
- Vista / 7 / 8 / 10
|
||||
- Visual Studio 2015 Update 2 (Enterprise / Professional / [Community (Free)](https://www.visualstudio.com/products/visual-studio-community-vs))
|
||||
- [Powershell 4.0](http://social.technet.microsoft.com/wiki/contents/articles/21016.how-to-install-windows-powershell-4-0.aspx).
|
||||
- [7-Zip](http://www.7-zip.org/) (for deployment only)
|
||||
- [NSIS](http://nsis.sourceforge.net/) (for deployment only)
|
||||
|
||||
### Mac:
|
||||
- [Homebrew](http://brew.sh)
|
||||
|
@ -71,13 +72,18 @@ All libs listed here (bar cmake) required in 32 bit variants.
|
|||
## 3.2 Compiling and running
|
||||
### Windows:
|
||||
1. Check out the repository. This can be done using [GitHub Desktop](https://desktop.github.com) or [other tools](https://help.github.com/articles/which-remote-url-should-i-use).
|
||||
2. Open a new Developer Command Prompt for VS2015, run PowerShell and then navigate to the repository.
|
||||
3. Run the ```setenv.ps1``` script in the repository to set up your PowerShell environment for OpenRCT2 development. This will warn you of any missing applications required to build OpenRCT2.
|
||||
4. Run ```install``` to download the required dependencies to build OpenRCT2.
|
||||
5. Run ```build all``` to build all the required components for OpenRCT2.
|
||||
6. Run ```run``` to run OpenRCT2.
|
||||
2. Open a new Developer Command Prompt for VS2015, then navigate to the repository (e.g. `cd C:\GitHub\OpenRCT2`).
|
||||
3. Run `msbuild openrct2.proj /t:build`.
|
||||
|
||||
These PowerShell scripts are stored in ```.\scripts\ps``` and have parameters. Once you have used the build script once, further development can be done within Visual Studio by opening ```openrct2.sln```. The build scripts have several commands allowing you to rebuild certain components such ```g2.dat``` or language files.
|
||||
Once you have ran msbuild once, further development can be done within Visual Studio by opening `openrct2.sln`.
|
||||
|
||||
Other examples:
|
||||
```
|
||||
msbuild openrct2.proj /t:clean
|
||||
msbuild openrct2.proj /t:rebuild /p:configuration=release /p:platform=x64
|
||||
msbuild openrct2.proj /t:g2
|
||||
msbuild openrct2.proj /t:PublishPortable
|
||||
```
|
||||
|
||||
### Mac:
|
||||
We support native builds for macOS (limited to i386 only for now).
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
#########################################################
|
||||
# Script to build OpenRCT2 on AppVeyor
|
||||
#########################################################
|
||||
|
||||
function Push-Build($file, $name, $version, $flavourId)
|
||||
{
|
||||
curl.exe -s -o - `
|
||||
--form "key=${env:OPENRCT2.ORG_TOKEN}" `
|
||||
--form "fileName=$name" `
|
||||
--form "version=$version" `
|
||||
--form "gitHash=${env:APPVEYOR_REPO_COMMIT}" `
|
||||
--form "gitBranch=${env:APPVEYOR_REPO_BRANCH}" `
|
||||
--form "flavourId=$flavourId" `
|
||||
--form "file=@$file" `
|
||||
"https://openrct2.org/altapi/?command=push-build"
|
||||
}
|
||||
|
||||
$server = "AppVeyor"
|
||||
|
||||
# Provide a short commit SHA1 too
|
||||
${env:APPVEYOR_REPO_COMMIT_SHORT} = (${env:APPVEYOR_REPO_COMMIT}).Substring(0, 7)
|
||||
|
||||
# Current version
|
||||
$version = "0.0.5.0"
|
||||
|
||||
# Tagged builds will hide branch and commit SHA1
|
||||
$tag = $null
|
||||
if (${env:APPVEYOR_REPO_TAG} -ne $null)
|
||||
{
|
||||
$tag = ${env:APPVEYOR_REPO_TAG_NAME}
|
||||
}
|
||||
|
||||
# Enable code signing if password environment variable is set
|
||||
$codeSign = $false
|
||||
if (${env:CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD} -ne $null)
|
||||
{
|
||||
$codeSign = $true
|
||||
}
|
||||
|
||||
# Enable pushing builds to OpenRCT2.org if token environment variable is set
|
||||
$pushBuilds = $false
|
||||
$installer = $false
|
||||
$symbols = $true
|
||||
if (${env:OPENRCT2.ORG_TOKEN} -ne $null)
|
||||
{
|
||||
$installer = $true
|
||||
|
||||
if ($tag -ne $null -or $env:APPVEYOR_REPO_BRANCH -match "^develop$|^push/")
|
||||
{
|
||||
$pushBuilds = $true
|
||||
}
|
||||
}
|
||||
|
||||
# Write out summary of the build
|
||||
Write-Host "AppVeyor CI Build" -ForegroundColor Green
|
||||
if ($tag -ne $null)
|
||||
{
|
||||
Write-Host " $version ($tag)" -ForegroundColor Green
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host " $version-$env:APPVEYOR_REPO_BRANCH-$env:APPVEYOR_REPO_COMMIT_SHORT" -ForegroundColor Green
|
||||
}
|
||||
Write-Host " Signed: $codeSign" -ForegroundColor Green
|
||||
Write-Host " Push : $pushBuilds" -ForegroundColor Green
|
||||
|
||||
# Install dependencies
|
||||
install -Quiet
|
||||
|
||||
# Build OpenRCT2
|
||||
publish build `
|
||||
-Server $server `
|
||||
-GitTag $tag `
|
||||
-GitBranch $env:APPVEYOR_REPO_BRANCH `
|
||||
-GitSha1 $env:APPVEYOR_REPO_COMMIT `
|
||||
-GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
|
||||
-CodeSign $codeSign
|
||||
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create a Portable ZIP
|
||||
publish package `
|
||||
-Server $server `
|
||||
-GitTag $tag `
|
||||
-GitBranch $env:APPVEYOR_REPO_BRANCH `
|
||||
-GitSha1 $env:APPVEYOR_REPO_COMMIT `
|
||||
-GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
|
||||
-CodeSign $codeSign
|
||||
|
||||
# Create an Installer
|
||||
if ($installer)
|
||||
{
|
||||
publish package `
|
||||
-Installer `
|
||||
-Server $server `
|
||||
-GitTag $tag `
|
||||
-GitBranch $env:APPVEYOR_REPO_BRANCH `
|
||||
-GitSha1 $env:APPVEYOR_REPO_COMMIT `
|
||||
-GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
|
||||
-CodeSign $codeSign
|
||||
}
|
||||
|
||||
if ($symbols)
|
||||
{
|
||||
publish package `
|
||||
-Symbols `
|
||||
-Server $server `
|
||||
-GitTag $tag `
|
||||
-GitBranch $env:APPVEYOR_REPO_BRANCH `
|
||||
-GitSha1 $env:APPVEYOR_REPO_COMMIT `
|
||||
-GitSha1Short $env:APPVEYOR_REPO_COMMIT_SHORT `
|
||||
-CodeSign $codeSign
|
||||
}
|
||||
|
||||
if ($pushBuilds)
|
||||
{
|
||||
$versionExtension = ""
|
||||
if ($tag -ne $null)
|
||||
{
|
||||
# Hide tag if it is a version
|
||||
if ($GitTag -notmatch "^v[0-9]")
|
||||
{
|
||||
$versionExtension = "-$tag"
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$versionExtension = "-${env:APPVEYOR_REPO_BRANCH}-${env:APPVEYOR_REPO_COMMIT_SHORT}"
|
||||
}
|
||||
$pushFileName = "OpenRCT2-${version}${versionExtension}-windows"
|
||||
|
||||
# Push portable zip
|
||||
Write-Host "Sending portable zip to OpenRCT2.org" -ForegroundColor Cyan
|
||||
Push-Build -file ".\artifacts\openrct2.zip" `
|
||||
-name "$pushFileName.zip" `
|
||||
-version $version `
|
||||
-flavourId 1
|
||||
|
||||
# Push installer
|
||||
if ($installer)
|
||||
{
|
||||
Write-Host "Sending installer to OpenRCT2.org" -ForegroundColor Cyan
|
||||
Push-Build -file ".\artifacts\openrct2-install.exe" `
|
||||
-name "$pushFileName.exe" `
|
||||
-version $version `
|
||||
-flavourId 2
|
||||
}
|
||||
|
||||
# Push symbols
|
||||
if ($symbols)
|
||||
{
|
||||
Write-Host "Sending symbols to OpenRCT2.org" -ForegroundColor Cyan
|
||||
Push-Build -file ".\artifacts\openrct2-symbols-${env:APPVEYOR_REPO_COMMIT_SHORT}.zip" `
|
||||
-name "$pushFileName-symbols.zip" `
|
||||
-version $version `
|
||||
-flavourId 5
|
||||
}
|
||||
}
|
21
scripts/ps/appveyor_deploy.ps1
Normal file
21
scripts/ps/appveyor_deploy.ps1
Normal file
|
@ -0,0 +1,21 @@
|
|||
###########################################
|
||||
# Script to deploy OpenRCT2 from AppVeyor #
|
||||
###########################################
|
||||
|
||||
# Check if OpenRCT2.org API security token is available
|
||||
if (${env:OPENRCT2_ORG_TOKEN})
|
||||
{
|
||||
# Only upload tagged builds, develop branch or push/ branches
|
||||
if (${env:APPVEYOR_REPO_TAG} -eq "true" -or ${env:APPVEYOR_REPO_BRANCH} -match "^develop$|^push/")
|
||||
{
|
||||
msbuild openrct2.proj /t:UploadArtifacts /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "No deployment: Non-tagged or push branch." -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "No deployment: %OPENRCT2_ORG_TOKEN% not available." -ForegroundColor Yellow
|
||||
}
|
|
@ -23,7 +23,8 @@ if ($env:ENCKEY)
|
|||
Check-ExitCode
|
||||
}
|
||||
|
||||
if (${env:OPENRCT2.ORG_TOKEN})
|
||||
# Check if OpenRCT2.org API security token is available
|
||||
if (${env:OPENRCT2_ORG_TOKEN})
|
||||
{
|
||||
if (-not (Test-Path "C:\ProgramData\chocolatey\lib\nsis.portable"))
|
||||
{
|
||||
|
@ -43,3 +44,8 @@ if (${env:OPENRCT2.ORG_TOKEN})
|
|||
cp FindProcDLL.dll "C:\ProgramData\chocolatey\lib\nsis.portable\tools\nsis-3.0b1\Plugins\x86-ansi"
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Don't build the NSIS installer for non-uploaded builds
|
||||
${env:NO_NSIS} = "true"
|
||||
}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#########################################################
|
||||
# Script to build different parts of OpenRCT2
|
||||
#########################################################
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory = $false, Position = 1)]
|
||||
[string]$Task = "openrct2",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Configuration = "Release",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$Rebuild = $false,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$Breakpad = $false
|
||||
)
|
||||
|
||||
# Setup
|
||||
$ErrorActionPreference = "Stop"
|
||||
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
|
||||
|
||||
# Get paths
|
||||
$rootPath = Get-RootPath
|
||||
$binPath = Join-Path $rootPath "bin"
|
||||
$openrct2Path = Join-Path $binPath "openrct2.exe"
|
||||
|
||||
function Build-Data()
|
||||
{
|
||||
$dataPath = "$rootPath\data"
|
||||
$binDataPath = "$binPath\data"
|
||||
|
||||
# Create data directory in bin
|
||||
Write-Host "Create data directory..." -ForegroundColor Cyan
|
||||
New-Item -Force -ItemType Directory $binDataPath > $null
|
||||
|
||||
# Create symlinks
|
||||
Symlink-or-Copy "$binDataPath\language" "$dataPath\language" > $null
|
||||
Symlink-or-Copy "$binDataPath\shaders" "$dataPath\shaders" > $null
|
||||
Symlink-or-Copy "$binDataPath\title" "$dataPath\title" > $null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function Build-OpenRCT2()
|
||||
{
|
||||
Write-Host "Building OpenRCT2 ($Configuration)..." -ForegroundColor Cyan
|
||||
|
||||
$target = ""
|
||||
if ($Rebuild)
|
||||
{
|
||||
$target = "/t:rebuild"
|
||||
}
|
||||
msbuild $rootPath\openrct2.sln /p:Breakpad=$Breakpad /p:Configuration=$Configuration /p:Platform=Win32 $target /v:minimal | Write-Host
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
function Build-G2()
|
||||
{
|
||||
# Check if OpenRCT2 binary exists
|
||||
if (-not (Test-Path $openrct2Path))
|
||||
{
|
||||
Write-Host "You must build OpenRCT2 first before g2.dat can be built." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
Write-Host "Building g2.dat..." -ForegroundColor Cyan
|
||||
& $openrct2Path sprite build "$binPath\data\g2.dat" "$rootPath\resources\g2"
|
||||
return $LASTEXITCODE
|
||||
}
|
||||
|
||||
function Build-All()
|
||||
{
|
||||
if (($result = (Build-Data )) -ne 0) { return $result }
|
||||
if (($result = (Build-OpenRCT2)) -ne 0) { return $result }
|
||||
if (($result = (Build-G2 )) -ne 0) { return $result }
|
||||
}
|
||||
|
||||
# Script entry point
|
||||
switch ($Task)
|
||||
{
|
||||
"data" { $result = Build-Data }
|
||||
"openrct2" { $result = Build-OpenRCT2 }
|
||||
"g2" { $result = Build-G2 }
|
||||
"all" { $result = Build-All }
|
||||
default { Write-Host "Unknown build task." -ForegroundColor Red
|
||||
$result = 1 }
|
||||
}
|
||||
exit $result
|
|
@ -1,83 +0,0 @@
|
|||
#########################################################
|
||||
# Common functions for OpenRCT2 PowerShell scripts
|
||||
#########################################################
|
||||
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
|
||||
function AppExists($app)
|
||||
{
|
||||
$result = (Get-Command $app -CommandType Application -ErrorAction SilentlyContinue)
|
||||
return ($result -ne $null -and $result.Count -gt 0)
|
||||
}
|
||||
|
||||
function AddPath($path)
|
||||
{
|
||||
$env:path = "$path;$env:path"
|
||||
}
|
||||
|
||||
function Get-RootPath()
|
||||
{
|
||||
return Split-Path (Split-Path $scriptsPath)
|
||||
}
|
||||
|
||||
function Prompt-User($message)
|
||||
{
|
||||
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Yes"
|
||||
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No"
|
||||
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
|
||||
$choice = $host.UI.PromptForChoice("", $message, $options, 1)
|
||||
return ($choice -eq 0)
|
||||
}
|
||||
|
||||
function Resolve-PathFromBase($path)
|
||||
{
|
||||
$rootPath = Get-RootPath
|
||||
if ($path.StartsWith($rootPath)) {
|
||||
$path = $path.Remove(0, $rootPath.Length + 1)
|
||||
}
|
||||
return $path
|
||||
}
|
||||
|
||||
function Symlink-or-Copy($path, $target)
|
||||
{
|
||||
$pathDirectory = Split-Path $path
|
||||
$pathName = Split-Path $path -Leaf
|
||||
|
||||
$friendlyPath = Resolve-PathFromBase $path
|
||||
$friendlyTarget = Resolve-PathFromBase $target
|
||||
|
||||
# If the path is not a symlink, copy files instead
|
||||
$mustCopy = $false
|
||||
if (Test-Path $path)
|
||||
{
|
||||
if (-not ((Get-Item $path).Attributes -band [IO.FileAttributes]::ReparsePoint))
|
||||
{
|
||||
$mustCopy = $true
|
||||
}
|
||||
}
|
||||
|
||||
$symlinkSuccessful = $false
|
||||
if (-not $mustCopy)
|
||||
{
|
||||
try
|
||||
{
|
||||
Write-Host "Symlink $friendlyPath to $friendlyTarget..." -ForegroundColor Cyan
|
||||
New-Item -Force -ItemType SymbolicLink -Path $pathDirectory -Name $pathName -Target $target -ErrorAction Stop
|
||||
$symlinkSuccessful = $true
|
||||
}
|
||||
catch [System.Management.Automation.ParameterBindingException]
|
||||
{
|
||||
Write-Host " Your powershell can not create symlinks, try updating it" -ForegroundColor Red
|
||||
}
|
||||
catch [System.UnauthorizedAccessException]
|
||||
{
|
||||
Write-Host " You need to run powershell in administration mode to create symlinks" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $symlinkSuccessful)
|
||||
{
|
||||
Write-Host "Copying $friendlyTarget to $friendlyPath..." -ForegroundColor Cyan
|
||||
New-Item -Force -Type Directory $path > $null
|
||||
Copy-Item -Force -Recurse "$target\*" $path
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
#########################################################
|
||||
# Script to install the latest dependencies for OpenRCT2
|
||||
#########################################################
|
||||
param (
|
||||
[switch]$Force,
|
||||
[switch]$Quiet
|
||||
)
|
||||
Write-Host "Installing OpenRCT2 development environment for Windows" -ForegroundColor Cyan
|
||||
|
||||
# Setup
|
||||
$ErrorActionPreference = "Stop"
|
||||
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
|
||||
|
||||
# Constants
|
||||
$libsVersion = 9
|
||||
$libsUrl = "https://github.com/OpenRCT2/Dependencies/releases/download/v$libsVersion/openrct2-libs-vs2015.zip"
|
||||
|
||||
# Get paths
|
||||
$rootPath = Get-RootPath
|
||||
$libsPath = Join-Path $rootPath "lib"
|
||||
$zipPath = Join-Path $libsPath "openrct2-libs-vs2015.zip"
|
||||
$libsVersionPath = Join-Path $libsPath "libversion"
|
||||
|
||||
# Check if we need to update the dependencies
|
||||
$currentLibsVersion = 0
|
||||
$updateLibs = $true
|
||||
if (Test-Path $libsVersionPath)
|
||||
{
|
||||
$currentLibsVersion = [IO.File]::ReadAllText($libsVersionPath)
|
||||
}
|
||||
if ($currentLibsVersion -ge $libsVersion)
|
||||
{
|
||||
$updateLibs = $false
|
||||
}
|
||||
|
||||
# Check if user needs to download dependencies
|
||||
$libsPathExists = Test-Path $libsPath
|
||||
if ($libsPathExists -and -not $updateLibs -and -not $Force)
|
||||
{
|
||||
if (-not $Quiet -and (Prompt-User "Dependencies already exists, reinstall?"))
|
||||
{
|
||||
$updateLibs = $true
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$updateLibs = $true
|
||||
}
|
||||
|
||||
# Download latest version of the dependencies
|
||||
if ($updateLibs) {
|
||||
Write-Host "Updating dependencies..." -ForegroundColor Cyan
|
||||
|
||||
Remove-Item -Force -Recurse $libsPath -ErrorAction SilentlyContinue
|
||||
New-Item -Force -ItemType Directory $libsPath > $null
|
||||
|
||||
Invoke-WebRequest $libsUrl -OutFile $zipPath
|
||||
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') > $null
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $libsPath)
|
||||
Remove-Item $zipPath -Force -ErrorAction SilentlyContinue
|
||||
$libsVersion | Set-Content $libsVersionPath
|
||||
}
|
|
@ -1,326 +0,0 @@
|
|||
#########################################################
|
||||
# Script to build and package OpenRCT2
|
||||
# - Sets the source code preprocessor defines
|
||||
# - Builds a clean release of OpenRCT2
|
||||
# - Creates a ZIP for distribution
|
||||
#########################################################
|
||||
param (
|
||||
[Parameter(Position = 1)]
|
||||
[string]$Task = "all",
|
||||
|
||||
[string]$Server = "",
|
||||
[string]$GitTag = "",
|
||||
[string]$GitBranch = "",
|
||||
[string]$GitSha1 = "",
|
||||
[string]$GitSha1Short = "",
|
||||
[bool] $CodeSign = $false,
|
||||
[switch]$Installer = $false,
|
||||
[switch]$Symbols = $false
|
||||
)
|
||||
|
||||
if (-not $GitTag)
|
||||
{
|
||||
if (-not $GitBranch)
|
||||
{
|
||||
$GitBranch = (git rev-parse --abbrev-ref HEAD)
|
||||
}
|
||||
if (-not $GitCommitSha1)
|
||||
{
|
||||
$GitCommitSha1 = (git rev-parse HEAD)
|
||||
}
|
||||
if (-not $GitCommitSha1Short)
|
||||
{
|
||||
$GitCommitSha1Short = (git rev-parse --short HEAD)
|
||||
}
|
||||
}
|
||||
|
||||
# Setup
|
||||
$ErrorActionPreference = "Stop"
|
||||
$scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
Import-Module "$scriptsPath\common.psm1" -DisableNameChecking
|
||||
|
||||
# Get paths
|
||||
$rootPath = Get-RootPath
|
||||
|
||||
# Set build attributes
|
||||
function Do-PrepareSource()
|
||||
{
|
||||
Write-Host "Setting build #defines..." -ForegroundColor Cyan
|
||||
$defines = @{ }
|
||||
$defines["OPENRCT2_BUILD_SERVER"] = $Server;
|
||||
if ($GitTag -ne "")
|
||||
{
|
||||
# Hide tag if it is a version
|
||||
if ($GitTag -match "^v[0-9]")
|
||||
{
|
||||
$defines["OPENRCT2_BRANCH"] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$defines["OPENRCT2_BRANCH"] = $GitTag;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$defines["OPENRCT2_BRANCH"] = $GitBranch;
|
||||
$defines["OPENRCT2_COMMIT_SHA1"] = $GitCommitSha1;
|
||||
$defines["OPENRCT2_COMMIT_SHA1_SHORT"] = $GitCommitSha1Short;
|
||||
}
|
||||
|
||||
$defineString = ""
|
||||
foreach ($key in $defines.Keys) {
|
||||
$value = $defines[$key]
|
||||
if ($value -is [System.String]) {
|
||||
$value = $value.Replace('"', '\"')
|
||||
}
|
||||
$defineString += "$key=""$value"";";
|
||||
}
|
||||
|
||||
# Set the environment variable which the msbuild project will use
|
||||
$env:OPENRCT2_DEFINES = $defineString;
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Building OpenRCT2
|
||||
function Do-Build()
|
||||
{
|
||||
Write-Host "Building OpenRCT2..." -ForegroundColor Cyan
|
||||
& "$scriptsPath\build.ps1" all -Rebuild -Breakpad
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to build OpenRCT2" -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
if ($CodeSign)
|
||||
{
|
||||
$releaseDir = "$rootPath\bin"
|
||||
$exePath = "$releaseDir\openrct2.exe"
|
||||
$dllPath = "$releaseDir\openrct2.dll"
|
||||
|
||||
if (-not (Sign-Binary($exePath))) { return 1 }
|
||||
if (-not (Sign-Binary($dllPath))) { return 1 }
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Symbols
|
||||
function Do-Symbols()
|
||||
{
|
||||
Write-Host "Publishing OpenRCT2 debug symbols as zip..." -ForegroundColor Cyan
|
||||
$artifactsDir = "$rootPath\artifacts"
|
||||
$releaseDir = "$rootPath\bin"
|
||||
$outZip = "$rootPath\artifacts\openrct2-symbols-$GitSha1Short.zip"
|
||||
|
||||
Copy-Item -Force "$releaseDir\openrct2.pdb" $artifactsDir -ErrorAction Stop
|
||||
Copy-Item -Force "$releaseDir\openrct2.dll" $artifactsDir -ErrorAction Stop
|
||||
|
||||
# Create archive using 7z (renowned for speed and compression)
|
||||
$7zcmd = "7za"
|
||||
if (-not (AppExists($7zcmd)))
|
||||
{
|
||||
# AppVeyor in particular uses '7z' instead
|
||||
$7zcmd = "7z"
|
||||
if (-not (AppExists($7zcmd)))
|
||||
{
|
||||
Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
}
|
||||
& $7zcmd a -tzip -mx9 -mtc=off $outZip "$artifactsDir\openrct2.pdb" "$artifactsDir\openrct2.dll" > $null
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to create zip." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
Remove-Item -Force -Recurse "$artifactsDir\openrct2.pdb" -ErrorAction SilentlyContinue
|
||||
return 0
|
||||
}
|
||||
|
||||
# Package
|
||||
function Do-Package()
|
||||
{
|
||||
Write-Host "Publishing OpenRCT2 as zip..." -ForegroundColor Cyan
|
||||
$releaseDir = "$rootPath\bin"
|
||||
$distDir = "$rootPath\distribution"
|
||||
$tempDir = "$rootPath\artifacts\temp"
|
||||
$outZip = "$rootPath\artifacts\openrct2.zip"
|
||||
|
||||
# Create new temp directory
|
||||
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
|
||||
New-Item -Force -ItemType Directory $tempDir > $null
|
||||
|
||||
# Copy files to be archived
|
||||
Copy-Item -Force -Recurse "$releaseDir\data" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$releaseDir\openrct2.exe" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$releaseDir\openrct2.dll" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$releaseDir\curl-ca-bundle.crt" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$distDir\changelog.txt" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$distDir\known_issues.txt" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$distDir\readme.txt" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$rootPath\contributors.md" $tempDir -ErrorAction Stop
|
||||
Copy-Item -Force "$rootPath\licence.txt" $tempDir -ErrorAction Stop
|
||||
|
||||
# Create archive using 7z (renowned for speed and compression)
|
||||
$7zcmd = "7za"
|
||||
if (-not (AppExists($7zcmd)))
|
||||
{
|
||||
# AppVeyor in particular uses '7z' instead
|
||||
$7zcmd = "7z"
|
||||
if (-not (AppExists($7zcmd)))
|
||||
{
|
||||
Write-Host "Publish script requires 7z to be in PATH" -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
}
|
||||
& $7zcmd a -tzip -mx9 -mtc=off $outZip "$tempDir\*" > $null
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to create zip." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
# Remove temp directory
|
||||
Remove-Item -Force -Recurse $tempDir -ErrorAction SilentlyContinue
|
||||
return 0
|
||||
}
|
||||
|
||||
# Installer
|
||||
function Do-Installer()
|
||||
{
|
||||
Write-Host "Publishing OpenRCT2 as installer..." -ForegroundColor Cyan
|
||||
$artifactsDir = "$rootPath\artifacts"
|
||||
$installerDir = "$rootPath\distribution\windows"
|
||||
|
||||
# Create artifacts directory
|
||||
New-Item -Force -ItemType Directory $artifactsDir > $null
|
||||
|
||||
# Resolve version extension
|
||||
$VersionExtra = ""
|
||||
if ($GitTag -ne "")
|
||||
{
|
||||
# Hide tag if it is a version
|
||||
if ($GitTag -notmatch "^v[0-9]")
|
||||
{
|
||||
$VersionExtra = "-$GitTag";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$VersionExtra = "-$GitBranch-$GitCommitSha1Short"
|
||||
}
|
||||
|
||||
# Create installer
|
||||
& "$installerDir\build.ps1" -VersionExtra $VersionExtra
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to create installer." -ForegroundColor Red
|
||||
if (Test-Path -PathType Leaf "$installerDir\win32.log")
|
||||
{
|
||||
Get-Content "$installerDir\win32.log" | Write-Host
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
$binaries = (Get-ChildItem "$installerDir\*.exe" | Sort-Object -Property LastWriteTime -Descending)
|
||||
if ($binaries -eq 0)
|
||||
{
|
||||
Write-Host "Unable to find created installer." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
$installerPath = $binaries[0].FullName
|
||||
|
||||
if ($CodeSign)
|
||||
{
|
||||
if (-not (Sign-Binary($installerPath))) { return 1 }
|
||||
}
|
||||
|
||||
Move-Item -Force $installerPath "$artifactsDir\openrct2-install.exe"
|
||||
return 0
|
||||
}
|
||||
|
||||
function Do-Task-Build()
|
||||
{
|
||||
if (($result = (Do-PrepareSource)) -ne 0) { return $result }
|
||||
if (($result = (Do-Build )) -ne 0) { return $result }
|
||||
return 0
|
||||
}
|
||||
|
||||
function Do-Task-Package()
|
||||
{
|
||||
if ($Installer)
|
||||
{
|
||||
if (($result = (Do-Installer)) -ne 0) { return $result }
|
||||
}
|
||||
elseif ($Symbols)
|
||||
{
|
||||
if (($result = (Do-Symbols)) -ne 0) { return $result }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($result = (Do-Package)) -ne 0) { return $result }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function Do-Task-All()
|
||||
{
|
||||
if (($result = (Do-Task-Build )) -ne 0) { return $result }
|
||||
if (($result = (Do-Task-Package)) -ne 0) { return $result }
|
||||
return 0
|
||||
}
|
||||
|
||||
function Sign-Binary($binaryPath)
|
||||
{
|
||||
$pfxPath = "$rootPath\distribution\windows\code-sign-key-openrct2.org.pfx"
|
||||
$pfxPassword = ${env:CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD}
|
||||
$timestampUrl = "http://timestamp.comodoca.com/authenticode"
|
||||
|
||||
if (-not (Test-Path -PathType Leaf $pfxPath))
|
||||
{
|
||||
Write-Host "Unable to sign, code signature key was not found." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
if ($pfxPassword -eq $null)
|
||||
{
|
||||
Write-Host "Unable to sign, %CODE-SIGN-KEY-OPENRCT2.ORG.PFX.PASSWORD% was not set." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
# Resolve signtool path
|
||||
$signtoolcmd = "signtool"
|
||||
if (-not (AppExists($signtoolcmd)))
|
||||
{
|
||||
$signtoolcmd = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\SignTool.exe"
|
||||
if (-not (AppExists($signtoolcmd)))
|
||||
{
|
||||
Write-Host "Publish script requires signtool to be in PATH" -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
# Sign the binary
|
||||
& $signtoolcmd sign /f $pfxPath /p $pfxPassword /t $timestampUrl $binaryPath
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Failed to sign binary." -ForegroundColor Red
|
||||
return 1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Script entry point
|
||||
switch ($Task)
|
||||
{
|
||||
"build" { $result = Do-Task-Build }
|
||||
"package" { $result = Do-Task-Package }
|
||||
"all" { $result = Do-Task-All }
|
||||
default { Write-Host "Unknown publish task." -ForegroundColor Red
|
||||
$result = 1 }
|
||||
}
|
||||
exit $result
|
Loading…
Reference in a new issue