From 709c89a1d82369c1f45fcdd565a88b04c163d663 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Thu, 28 Sep 2017 10:27:42 -0600 Subject: [PATCH] Installer: Converted the build scripts to cmake and added an "installer" target --- .gitignore | 5 ----- CMakeLists.txt | 1 + CMakeModules/BuildInstaller.cmake | 28 ++++++++++++++++++++++++ dist/installer/CMakeLists.txt | 22 +++++++++++++++++++ dist/installer/README.md | 25 ++------------------- dist/installer/build.ps1 | 14 ------------ dist/installer/build.sh | 36 ------------------------------- dist/installer/packages/.gitkeep | 0 8 files changed, 53 insertions(+), 78 deletions(-) create mode 100644 CMakeModules/BuildInstaller.cmake create mode 100644 dist/installer/CMakeLists.txt delete mode 100644 dist/installer/build.ps1 delete mode 100755 dist/installer/build.sh delete mode 100644 dist/installer/packages/.gitkeep diff --git a/.gitignore b/.gitignore index 3196fa9e8..ec74b0fa4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,8 +26,3 @@ src/common/scm_rev.cpp # Windows global filetypes Thumbs.db -# QtIFW builds -dist/installer/redist -dist/installer/citra-installer* -dist/installer/*.zip -dist/installer/*.tar.gz diff --git a/CMakeLists.txt b/CMakeLists.txt index d9c2f78a2..2fe092157 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,6 +303,7 @@ get_timestamp(BUILD_DATE) enable_testing() add_subdirectory(externals) add_subdirectory(src) +add_subdirectory(dist/installer) # Installation instructions diff --git a/CMakeModules/BuildInstaller.cmake b/CMakeModules/BuildInstaller.cmake new file mode 100644 index 000000000..fefec2662 --- /dev/null +++ b/CMakeModules/BuildInstaller.cmake @@ -0,0 +1,28 @@ +# To use this as a script, make sure you pass in the variables SRC_DIR BUILD_DIR and TARGET_FILE + +if(WIN32) + set(PLATFORM "windows") +elseif(APPLE) + set(PLATFORM "mac") +elseif(LINUX) + set(PLATFORM "linux") +else() + message(FATAL_ERROR "Cannot build installer for this unsupported platform") +endif() + +set(DIST_DIR "${BUILD_DIR}/dist") +set(ARCHIVE "${PLATFORM}.7z") + +file(MAKE_DIRECTORY ${DIST_DIR}) +file(DOWNLOAD https://github.com/citra-emu/ext-windows-bin/raw/master/qtifw/${ARCHIVE} + "${BUILD_DIR}/${ARCHIVE}" SHOW_PROGRESS) +execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${BUILD_DIR}/${ARCHIVE}" + WORKING_DIRECTORY "${BUILD_DIR}/") + +set(CONFIG_FILE "${SRC_DIR}/config/config_${PLATFORM}.xml") +set(INSTALLER_BASE "${BUILD_DIR}/installerbase_${PLATFORM}") +set(BINARY_CREATOR "${BUILD_DIR}/binarycreator_${PLATFORM}") +set(PACKAGES_DIR "${BUILD_DIR}/packages") +file(MAKE_DIRECTORY ${PACKAGES_DIR}) + +execute_process(COMMAND ${BINARY_CREATOR} -t ${INSTALLER_BASE} -n -c ${CONFIG_FILE} -p ${PACKAGES_DIR} ${TARGET_FILE}) diff --git a/dist/installer/CMakeLists.txt b/dist/installer/CMakeLists.txt new file mode 100644 index 000000000..57630d7dc --- /dev/null +++ b/dist/installer/CMakeLists.txt @@ -0,0 +1,22 @@ + +if(WIN32) + set(PLATFORM "windows") +elseif(APPLE) + set(PLATFORM "mac") +elseif(LINUX) + set(PLATFORM "linux") +endif() + +set(BUILD_DIR "${CMAKE_BINARY_DIR}/installer") +set(DIST_DIR "${BUILD_DIR}/dist") +set(TARGET_FILE "${DIST_DIR}/citra-setup-${PLATFORM}") + +# Adds a custom target that will run the BuildInstaller.cmake file +# CMake can't just run a cmake function as a custom command, so this is a way around it. +# Calls the cmake command and runs a cmake file in "scripting" mode passing in variables with -D +add_custom_command(OUTPUT "${TARGET_FILE}" + COMMAND ${CMAKE_COMMAND} -DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} -D BUILD_DIR=${BUILD_DIR} -D TARGET_FILE=${TARGET_FILE} -P ${CMAKE_SOURCE_DIR}/CMakeModules/BuildInstaller.cmake + WORKING_DIRECTORY ${BUILD_DIR} +) + +add_custom_target(installer DEPENDS ${TARGET_FILE}) \ No newline at end of file diff --git a/dist/installer/README.md b/dist/installer/README.md index 984c5a58f..dc58093dd 100644 --- a/dist/installer/README.md +++ b/dist/installer/README.md @@ -3,28 +3,7 @@ Citra Qt Installer This contains the configuration files for building Citra's installer. -`packages` is empty as Qt expects that it gets a valid directory for offline - packages, even if you are a online-only installer. - Installers can only be built on the platform that they are targeting. -Windows -------- - -Using Powershell 2.0 (Windows 10): - -```powershell -cd dist\installer -powershell –ExecutionPolicy Bypass .\build.ps1 -``` - -Linux/Mac ---------- - -Curl + Bash must be available. - -```bash -cd dist/installer -chmod +x build.sh -./build.sh -``` +Build the `installer` target to generate the installer, and the installer will be in +${build_dir}/installer/dist/ diff --git a/dist/installer/build.ps1 b/dist/installer/build.ps1 deleted file mode 100644 index 3a4fda7cd..000000000 --- a/dist/installer/build.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -if (!(Test-Path redist\installerbase_win.exe)) { - echo "Downloading dependencies..." - if (!(Test-Path redist)) { - New-Item -path . -name redist -itemtype directory - } - Invoke-WebRequest -Uri "https://github.com/citra-emu/ext-windows-bin/raw/master/qtifw/windows.zip" -OutFile windows.zip - echo "Extracting..." - Expand-Archive windows.zip -DestinationPath redist -} else { - echo "Found pre-downloaded redist." -} - -echo "Building Qt Installer to '.\citra-installer-windows.exe'..." -.\redist\binarycreator_win.exe -t .\redist\installerbase_win.exe -n -c .\config\config_windows.xml -p .\packages\ citra-installer-windows diff --git a/dist/installer/build.sh b/dist/installer/build.sh deleted file mode 100755 index 2e4fb2264..000000000 --- a/dist/installer/build.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -set -e - -PLATFORM="" -if [[ "$OSTYPE" == "linux-gnu" ]]; then - PLATFORM="linux" -elif [[ "$OSTYPE" == "darwin"* ]]; then - PLATFORM="mac" -else - echo Your platform is not supported. - exit 1 -fi - -if [ ! -f redist/installerbase_$PLATFORM ]; then - echo Downloading dependencies... - curl -L -O https://github.com/citra-emu/ext-windows-bin/raw/master/qtifw/$PLATFORM.tar.gz - - echo Extracting... - mkdir -p redist - cd redist - tar -zxvf ../$PLATFORM.tar.gz - cd .. - - chmod +x redist/* -fi - -TARGET_FILE=citra-installer-$PLATFORM -CONFIG_FILE=config/config_$PLATFORM.xml -REDIST_BASE=redist/installerbase_$PLATFORM -BINARY_CREATOR=redist/binarycreator_$PLATFORM -PACKAGES_DIR=packages - -echo Building to \'$TARGET_FILE\'... - -$BINARY_CREATOR -t $REDIST_BASE -n -c $CONFIG_FILE -p $PACKAGES_DIR $TARGET_FILE diff --git a/dist/installer/packages/.gitkeep b/dist/installer/packages/.gitkeep deleted file mode 100644 index e69de29bb..000000000