Add package python script, replace .cmd with py variants from PS
This commit is contained in:
+1
-117
@@ -1,121 +1,5 @@
|
||||
@echo off
|
||||
REM Echo off to avoid spam.
|
||||
|
||||
REM Non zero is failure, 0 is success.
|
||||
SET exit_code_success=0
|
||||
SET exit_code_failure_build_apps=1
|
||||
SET exit_code_failure_build_locations=2
|
||||
|
||||
REM Used for echos.
|
||||
SET current_activity=BUILD
|
||||
|
||||
REM If scripts are chain called the original dirs should not be overwritten.
|
||||
IF NOT DEFINED original_dir (
|
||||
SET original_dir=%CD%
|
||||
)
|
||||
IF NOT DEFINED project_dir (
|
||||
REM Arg 0 (called %0) is the full path to the file.
|
||||
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
|
||||
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
|
||||
REM Project dir is up two dirs from the file.
|
||||
SET project_dir=%~dp0\..\..\
|
||||
)
|
||||
|
||||
REM Change dir to the project dir, otherwise qmake doesn't know where it is.
|
||||
CD %project_dir%
|
||||
|
||||
REM QT_LOC is a directory, it can't be in the path, no reason to check using WHERE.
|
||||
ECHO %current_activity%: Testing if all required build environment values are set:
|
||||
IF NOT DEFINED QT_LOC (
|
||||
ECHO %current_activity%: QT_LOC not defined. Using default value.
|
||||
SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\"
|
||||
)
|
||||
ECHO %current_activity%: QT_LOC set to '%QT_LOC%'.
|
||||
IF EXIST %QT_LOC% (
|
||||
ECHO %current_activity%: QT_LOC exists.
|
||||
) ELSE (
|
||||
ECHO %current_activity%: QT_LOC directory does not exist. Exiting.
|
||||
EXIT /B %exit_code_failure_build_locations%
|
||||
)
|
||||
|
||||
IF NOT DEFINED VS_LOC (
|
||||
ECHO %current_activity%: VS_LOC not defined. Using default value.
|
||||
SET VS_LOC="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
)
|
||||
ECHO %current_activity%: VS_LOC set to '%VS_LOC%'.
|
||||
|
||||
REM EXIST won't find items in the PATH. WHERE will.
|
||||
SET VS_VALID=0
|
||||
IF EXIST %VS_LOC% SET VS_VALID=1
|
||||
REM Prevents error message spam if it doesn't find it in PATH.
|
||||
IF NOT %VS_VALID% EQU 1 (
|
||||
WHERE /Q %VS_LOC%
|
||||
IF NOT ERRORLEVEL 1 SET VS_VALID=1
|
||||
)
|
||||
|
||||
IF %VS_VALID% EQU 1 (
|
||||
ECHO %current_activity%: VS_LOC exists.
|
||||
) ELSE (
|
||||
ECHO %current_activity%: VS_LOC directory does not exist. Exiting.
|
||||
EXIT /B %exit_code_failure_build_locations%
|
||||
)
|
||||
|
||||
ECHO %current_activity%: All required build environment values are set.
|
||||
|
||||
IF DEFINED BUILD_DEBUG (
|
||||
ECHO %current_activity%: BUILD_DEBUG var set. Compiling for debug.
|
||||
SET compile_level=debug
|
||||
) ELSE (
|
||||
ECHO %current_activity%: BUILD_DEBUG var not set. Compiling for release.
|
||||
SET compile_level=release
|
||||
)
|
||||
|
||||
ECHO %current_activity%: Setting up environment with Visual Studio 'vcvarsall.bat'.
|
||||
REM Currently only this platform is supported.
|
||||
SET target_platform=AMD64
|
||||
REM Set up environment for qmake.
|
||||
CALL %VS_LOC% %target_platform%
|
||||
|
||||
IF DEFINED BUILD_VSPROJ (
|
||||
ECHO %current_activity%: BUILD_VSPROJ defined. Building Visual Studio project files.
|
||||
%QT_LOC%\qmake -tp vc
|
||||
ECHO %current_activity%: Building Visual Studio project files done.
|
||||
) ELSE (
|
||||
ECHO %current_activity%: BUILD_VSPROJ not defined. Not building Visual Studio project files.
|
||||
)
|
||||
|
||||
ECHO %current_activity%: Running qmake for %compile_level%:
|
||||
%QT_LOC%\qmake -spec win32-msvc CONFIG+=x86_64 CONFIG+=%compile_level%
|
||||
ECHO %current_activity%: qmake done.
|
||||
|
||||
IF NOT DEFINED JOM_LOC (
|
||||
ECHO %current_activity%: JOM_LOC not defined. Using default value.
|
||||
SET JOM_LOC="C:\Qt\Tools\QtCreator\bin\jom.exe"
|
||||
)
|
||||
ECHO %current_activity%: JOM_LOC set to '%JOM_LOC%'.
|
||||
|
||||
IF EXIST %JOM_LOC% (
|
||||
ECHO %current_activity%: JOM_LOC exists.
|
||||
ECHO %current_activity%: Running jom:
|
||||
%JOM_LOC%
|
||||
REM jom will not exit with an error code. Leading to a passing build even with errors.
|
||||
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
|
||||
ECHO %current_activity%: jom done.
|
||||
) ELSE (
|
||||
ECHO JOM_LOC directory does not exist. Using nmake.
|
||||
ECHO %current_activity%: Running nmake:
|
||||
nmake
|
||||
REM nmake will not exit with an error code. Leading to a passing build even with errors.
|
||||
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
|
||||
ECHO %current_activity%: nmake done.
|
||||
)
|
||||
|
||||
CD %original_dir%
|
||||
|
||||
ECHO %current_activity%: %current_activity% DONE.
|
||||
=======
|
||||
@ECHO OFF
|
||||
python build.py
|
||||
python build.py build
|
||||
call test.bat
|
||||
rm test.bat
|
||||
PAUSE
|
||||
|
||||
@@ -1,6 +1,37 @@
|
||||
import os
|
||||
from sys import argv
|
||||
from common import *
|
||||
|
||||
def package():
|
||||
set_current_activity("PACKAGE")
|
||||
set_original_folder(os.getcwd())
|
||||
set_project_folder(os.path.abspath(os.path.join(ORIGINAL_DIR , "..\..")))
|
||||
|
||||
say("Testing if all required build environment variables are set:")
|
||||
ZIP_LOC = get_required_env_var_path(ZIP_LOC_VAR_NAME, ZIP_LOC_DEFAULT)
|
||||
NSIS_LOC = get_required_env_var_path(NSIS_LOC_VAR_NAME, NSIS_LOC_DEFAULT)
|
||||
say("All required build environment values are set.")
|
||||
|
||||
say("Adding 7zip to file:")
|
||||
ZIP_NAME = "AdvancedSettings-" + VERSION_STRING + ".7z"
|
||||
|
||||
add_line_to_run_bat_file("@ECHO Starting 7zip:")
|
||||
add_line_to_run_bat_file('"' + ZIP_LOC + '"' + " a -t7z " + get_project_dir() + "\\" + OUTPUT_DIR + "\\" + ZIP_NAME + " " + get_deploy_dir() + "\\*")
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO 7zip done.")
|
||||
say("7zip added to file.")
|
||||
|
||||
say("Adding NSIS to file.")
|
||||
add_line_to_run_bat_file("@ECHO Starting NSIS:")
|
||||
add_line_to_run_bat_file("cd " + NSIS_LOC)
|
||||
add_line_to_run_bat_file("makensis /V2 /WX " + get_project_dir() + "\\installer\\installer.nsi")
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO NSIS done.")
|
||||
say("NSIS added to file.")
|
||||
|
||||
create_batch_file()
|
||||
|
||||
|
||||
def deploy():
|
||||
set_current_activity("DEPLOY")
|
||||
set_original_folder(os.getcwd())
|
||||
@@ -19,8 +50,18 @@ def deploy():
|
||||
|
||||
say("Adding windeployqt to file.")
|
||||
|
||||
add_line_to_run_bat_file("set PATH=%PATH%;" + QT_LOC + ";")
|
||||
|
||||
add_line_to_run_bat_file("@ECHO Starting windeployqt:")
|
||||
|
||||
#Extremely long line
|
||||
add_line_to_run_bat_file('"' + "windeployqt" + '"' + "--dir $DEPLOY_DIRECTORY\qtdata --libdir $DEPLOY_DIRECTORY --plugindir $DEPLOY_DIRECTORY\qtdata\plugins --no-system-d3d-compiler --no-opengl-sw "+ COMPILE_MODE + " --qmldir $PROJECT_DIRECTORY\src\res\qml\ $DEPLOY_DIRECTORY\AdvancedSettings.exe")
|
||||
add_line_to_run_bat_file('"' + "windeployqt" + '"'
|
||||
+ " --dir " + get_deploy_dir()
|
||||
+ "\\qtdata --libdir " + get_deploy_dir()
|
||||
+ " --plugindir " + get_deploy_dir() + "\\qtdata\\plugins --no-system-d3d-compiler --no-opengl-sw --"
|
||||
+ COMPILE_MODE + " --qmldir " + get_project_dir() + "\\src\\res\\qml\\ " + get_deploy_dir() + "\\AdvancedSettings.exe")
|
||||
|
||||
add_line_to_run_bat_file("@ECHO windeployqt finished.")
|
||||
|
||||
say("windeployqt added to file.")
|
||||
|
||||
@@ -41,7 +82,12 @@ def deploy():
|
||||
copy_folder(get_project_dir() + "\\src\\package_files", get_deploy_dir())
|
||||
|
||||
#openvr dll
|
||||
copy_file(get_project_dir() + "\\third-party\\openvr\\bin\\win64\\openvr_api.dll", get_deploy_dir() + "openvr_api.dll")
|
||||
copy_file(get_project_dir() + "\\third-party\\openvr\\bin\\win64\\openvr_api.dll", get_deploy_dir() + "openvr_api.dll")
|
||||
|
||||
say("Creating batch file:")
|
||||
create_batch_file()
|
||||
say("Batch file created.")
|
||||
|
||||
|
||||
def build():
|
||||
set_current_activity("BUILD")
|
||||
@@ -126,7 +172,12 @@ def build():
|
||||
create_batch_file()
|
||||
|
||||
if __name__ == "__main__":
|
||||
deploy()
|
||||
if argv[1] == "build":
|
||||
build()
|
||||
elif argv[1] == "deploy":
|
||||
deploy()
|
||||
elif argv[1] == "package":
|
||||
package()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,11 @@ import sys
|
||||
import argparse
|
||||
import subprocess
|
||||
import shutil
|
||||
import distutils.dir_util
|
||||
|
||||
#Const globals
|
||||
VERSION_STRING = "2-8-0"
|
||||
|
||||
EXIT_CODE_SUCCESS = 0
|
||||
EXIT_CODE_FAILURE_BUILD_APP = 1
|
||||
EXIT_CODE_FAILURE_BUILD_LOCATION = 2
|
||||
@@ -35,7 +38,7 @@ PLATFORM_TARGET = "AMD64"
|
||||
#Mutable globals
|
||||
ORIGINAL_DIR = ""
|
||||
PROJECT_DIR = ""
|
||||
OUTPUT_DIR = r"\\bin\\win64\\"
|
||||
OUTPUT_DIR = r"\\bin\\win64\\AdvancedSettings"
|
||||
DEPLOY_DIR = ""
|
||||
|
||||
current_activity = ""
|
||||
@@ -116,7 +119,7 @@ def copy_file(src, dest):
|
||||
|
||||
def copy_folder(src, dest):
|
||||
say(f"Copying {src} to {dest}")
|
||||
shutil.copy(src, dest)
|
||||
distutils.dir_util.copy_tree(src, dest)
|
||||
say(f"{src} to {dest} copied.")
|
||||
|
||||
|
||||
|
||||
@@ -1,119 +1,5 @@
|
||||
@echo off
|
||||
REM Echo off to avoid spam.
|
||||
|
||||
REM Non zero is failure, 0 is success.
|
||||
SET exit_code_success=0
|
||||
SET exit_code_failure_build_apps=1
|
||||
SET exit_code_failure_build_locations=2
|
||||
|
||||
SET output_dir="\bin\win64\"
|
||||
|
||||
REM Used for echos.
|
||||
SET current_activity=DEPLOY
|
||||
|
||||
REM If scripts are chain called the original dirs should not be overwritten.
|
||||
IF NOT DEFINED original_dir (
|
||||
SET original_dir=%CD%
|
||||
)
|
||||
IF NOT DEFINED project_dir (
|
||||
REM Arg 0 (called %0) is the full path to the file.
|
||||
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
|
||||
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
|
||||
REM Project dir is up two dirs from the file.
|
||||
SET project_dir=%~dp0\..\..\
|
||||
)
|
||||
|
||||
ECHO %current_activity%: Testing if all required build environment values are set:
|
||||
IF NOT DEFINED QT_LOC (
|
||||
ECHO %current_activity%: QT_LOC not defined. Using default value.
|
||||
SET QT_LOC="C:\Qt\5.11.1\msvc2017_64\bin\"
|
||||
)
|
||||
REM QT_LOC is a directory, it can't be in the path, no reason to check using WHERE.
|
||||
ECHO %current_activity%: QT_LOC set to '%QT_LOC%'.
|
||||
IF EXIST %QT_LOC% (
|
||||
ECHO %current_activity%: QT_LOC exists.
|
||||
) ELSE (
|
||||
ECHO %current_activity%: QT_LOC directory does not exist. Exiting.
|
||||
EXIT /B %exit_code_failure_build_locations%
|
||||
)
|
||||
|
||||
ECHO %current_activity%: All required build environment values are set.
|
||||
|
||||
IF NOT EXIST %project_dir%\%output_dir% (
|
||||
ECHO %current_activity%: Output dir '%output_dir%' does not exist. Creating.
|
||||
mkdir %project_dir%\%output_dir%
|
||||
ECHO %current_activity%: Output dir created.
|
||||
)
|
||||
|
||||
cd %project_dir%\%output_dir%
|
||||
|
||||
IF DEFINED BUILD_DEBUG (
|
||||
ECHO %current_activity%: BUILD_DEBUG var set. Compiling for debug.
|
||||
SET compile_level=debug
|
||||
) ELSE (
|
||||
ECHO %current_activity%: BUILD_DEBUG var not set. Compiling for release.
|
||||
SET compile_level=release
|
||||
)
|
||||
|
||||
ECHO %current_activity%: Running windeployqt:
|
||||
|
||||
REM windeployqt requires the QT\bin location to be in the path.
|
||||
REM Changing the PATH var is not ideal, but windeployqt does not work otherwise.
|
||||
set original_path=%PATH%
|
||||
set PATH=%QT_LOC%;%PATH%
|
||||
|
||||
REM Caret newline (^CFLR) splits a command over several lines.
|
||||
REM This is done to avoid one ultra long line.
|
||||
|
||||
windeployqt --dir AdvancedSettings\qtdata ^
|
||||
--libdir AdvancedSettings ^
|
||||
--plugindir AdvancedSettings\qtdata\plugins ^
|
||||
--no-system-d3d-compiler ^
|
||||
--no-opengl-sw ^
|
||||
--%compile_level% ^
|
||||
--qmldir ..\..\src\res\qml\ ^
|
||||
AdvancedSettings\AdvancedSettings.exe
|
||||
|
||||
REM windeployqt does not exit on error by itself.
|
||||
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
|
||||
REM Return the PATH to original as quickly as possible.
|
||||
set PATH=%original_path%
|
||||
ECHO %current_activity%: windeployqt done.
|
||||
|
||||
REM Switches used for copy:
|
||||
REM /V Verifies that files have been copied correctly.
|
||||
REM /Q Suppresses xcopy spam.
|
||||
REM /Y Skips the overwrite yes prompt.
|
||||
REM /E Copies all subdirs, even if they are empty.
|
||||
REM /I "If Source is a directory or contains wildcards and Destination does not exist,
|
||||
REM xcopy assumes Destination specifies a directory name and creates a new directory.
|
||||
REM Then, xcopy copies all specified files into the new directory. By default,
|
||||
REM xcopy prompts you to specify whether Destination is a file or a directory."
|
||||
|
||||
ECHO %current_activity%: Copying necessary files.
|
||||
copy /V /Y "%project_dir%\Readme.md" "%project_dir%\%output_dir%\AdvancedSettings\Readme.md"
|
||||
ECHO %current_activity%: README copied.
|
||||
|
||||
REM All three licenses must be included in binary releases, as per the terms.
|
||||
copy /V /Y "%project_dir%\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-GPL.txt"
|
||||
copy /V /Y "%project_dir%\third-party\openvr\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-VALVE.txt"
|
||||
copy /V /Y "%project_dir%\third-party\easylogging++\LICENSE" "%project_dir%\%output_dir%\AdvancedSettings\LICENSE-MIT.txt"
|
||||
ECHO %current_activity%: LICENSE files copied.
|
||||
|
||||
xcopy /Q /Y /E /I /V "%project_dir%\src\res" "%project_dir%\%output_dir%\AdvancedSettings\res\"
|
||||
ECHO %current_activity%: Resource files copied.
|
||||
|
||||
copy /V /Y "%project_dir%\src\restartvrserver.bat" "%project_dir%\%output_dir%\AdvancedSettings\restartvrserver.bat"
|
||||
copy /V /Y "%project_dir%\src\startdesktopmode.bat" "%project_dir%\%output_dir%\AdvancedSettings\startdesktopmode.bat"
|
||||
ECHO %current_activity%: Extra batch files copied.
|
||||
|
||||
copy /V /Y "%project_dir%\src\qt.conf" "%project_dir%\%output_dir%\AdvancedSettings\qt.conf"
|
||||
copy /V /Y "%project_dir%\src\manifest.vrmanifest" "%project_dir%\%output_dir%\AdvancedSettings\manifest.vrmanifest"
|
||||
ECHO %current_activity%: VR specific configuration files copied.
|
||||
|
||||
copy /V /Y "%project_dir%\third-party\openvr\bin\win64\openvr_api.dll" "%project_dir%\%output_dir%\AdvancedSettings\openvr_api.dll"
|
||||
ECHO %current_activity%: OpenVR .dll copied.
|
||||
|
||||
cd %original_dir%
|
||||
|
||||
ECHO %current_activity%: %current_activity% DONE.
|
||||
@ECHO OFF
|
||||
python build.py deploy
|
||||
call test.bat
|
||||
rm test.bat
|
||||
PAUSE
|
||||
|
||||
@@ -1,96 +1,5 @@
|
||||
@echo off
|
||||
REM Echo off to avoid spam.
|
||||
|
||||
REM Non zero is failure, 0 is success.
|
||||
SET exit_code_success=0
|
||||
SET exit_code_failure_build_apps=1
|
||||
SET exit_code_failure_build_locations=2
|
||||
|
||||
SET output_dir="\bin\win64\"
|
||||
|
||||
REM Used for echos.
|
||||
SET current_activity=PACKAGE
|
||||
|
||||
REM If scripts are chain called the original dirs should not be overwritten.
|
||||
IF NOT DEFINED original_dir (
|
||||
SET original_dir=%CD%
|
||||
)
|
||||
IF NOT DEFINED project_dir (
|
||||
REM Arg 0 (called %0) is the full path to the file.
|
||||
REM https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/call#batch-parameters
|
||||
REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path only.
|
||||
REM Project dir is up two dirs from the file.
|
||||
SET project_dir=%~dp0\..\..\
|
||||
)
|
||||
|
||||
REM ZIP_LOC can't be called 7Z_LOC because of Windows limitations.
|
||||
ECHO %current_activity%: Testing if all required build environment values are set:
|
||||
|
||||
IF NOT DEFINED ZIP_LOC (
|
||||
ECHO %current_activity%: ZIP_LOC not defined. Using default value.
|
||||
SET ZIP_LOC="C:\Program Files\7-Zip\7z.exe"
|
||||
)
|
||||
ECHO %current_activity%: ZIP_LOC set to '%ZIP_LOC%'.
|
||||
|
||||
REM EXIST won't find items in the PATH. WHERE will.
|
||||
SET ZIP_VALID=0
|
||||
IF EXIST %ZIP_LOC% SET ZIP_VALID=1
|
||||
IF %ZIP_VALID% EQU 0 (
|
||||
WHERE /Q %ZIP_LOC%
|
||||
IF NOT ERRORLEVEL 1 SET ZIP_VALID=1
|
||||
)
|
||||
|
||||
IF %ZIP_VALID% EQU 1 (
|
||||
ECHO %current_activity%: ZIP_LOC exists.
|
||||
) ELSE (
|
||||
ECHO %current_activity%: ZIP_LOC directory does not exist. Exiting.
|
||||
EXIT /B %exit_code_failure_build_locations%
|
||||
)
|
||||
|
||||
IF NOT DEFINED NSIS_LOC (
|
||||
ECHO %current_activity%: NSIS_LOC not defined. Using default value.
|
||||
SET NSIS_LOC="C:\Program Files (x86)\NSIS\"
|
||||
)
|
||||
ECHO %current_activity%: NSIS_LOC set to '%NSIS_LOC%'.
|
||||
|
||||
REM EXIST won't find items in the PATH. WHERE will.
|
||||
SET NSIS_VALID=0
|
||||
IF EXIST %NSIS_LOC% SET NSIS_VALID=1
|
||||
REM Prevents error message spam if it doesn't find it in PATH.
|
||||
IF %NSIS_VALID% EQU 0 (
|
||||
WHERE /Q %NSIS_LOC%
|
||||
IF NOT ERRORLEVEL 1 SET NSIS_VALID=1
|
||||
)
|
||||
|
||||
IF %NSIS_VALID% EQU 1 (
|
||||
ECHO %current_activity%: NSIS_LOC exists.
|
||||
) ELSE (
|
||||
ECHO %current_activity%: NSIS_LOC directory does not exist. Exiting.
|
||||
EXIT /B %exit_code_failure_build_locations%
|
||||
)
|
||||
|
||||
ECHO %current_activity%: All required build environment values are set.
|
||||
|
||||
IF DEFINED BUILD_DEBUG (
|
||||
ECHO %current_activity%: BUILD_DEBUG var set. NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
|
||||
ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
|
||||
ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
|
||||
ECHO %current_activity%: NOT PACKAGING TO AVOID SHIPPING DEBUG BUILDS.
|
||||
EXIT /B %exit_code_failure_build_apps%
|
||||
)
|
||||
|
||||
ECHO %current_activity%: Running 7zip:
|
||||
%ZIP_LOC% a %project_dir%\%output_dir%\AdvancedSettings.zip %project_dir%\%output_dir%\AdvancedSettings\*
|
||||
ECHO %current_activity%: 7zip done.
|
||||
|
||||
ECHO %current_activity%: Running NSIS:
|
||||
REM Trying to launch makensis without CD into the dir does not work for some reason.
|
||||
CD %NSIS_LOC%
|
||||
REM /V2 is show warnings and errors, /WX is treat warnings as errors.
|
||||
makensis /V2 /WX %project_dir%\installer\installer.nsi
|
||||
IF ERRORLEVEL 1 EXIT /B %exit_code_failure_build_apps%
|
||||
ECHO %current_activity%: NSIS done.
|
||||
|
||||
CD %original_dir%
|
||||
|
||||
ECHO %current_activity%: %current_activity% DONE.
|
||||
@ECHO OFF
|
||||
python build.py package
|
||||
call test.bat
|
||||
rm test.bat
|
||||
PAUSE
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
import os
|
||||
from common import *
|
||||
|
||||
def build():
|
||||
set_current_activity("BUILD")
|
||||
set_original_folder(os.getcwd())
|
||||
set_project_folder(os.path.abspath(os.path.join(ORIGINAL_DIR , "..\..")))
|
||||
|
||||
COMPILE_MODE = ""
|
||||
COMPILER = ""
|
||||
|
||||
say("Testing if all required build environment variables are set:")
|
||||
QT_LOC = get_required_env_var_path(QT_LOC_VAR_NAME, QT_LOC_DEFAULT)
|
||||
VS_LOC = get_required_env_var_path(VS_LOC_VAR_NAME, VS_LOC_DEFAULT)
|
||||
|
||||
if is_env_var_set(BUILD_CLANG_VAR_NAME):
|
||||
say(f"{BUILD_CLANG_VAR_NAME} defined. Building for win32-clang-msvc.")
|
||||
get_required_env_var_path(LLVM_LOC_VAR_NAME, LLVM_LOC_DEFAULT)
|
||||
COMPILER = "win32-clang-msvc"
|
||||
else:
|
||||
say(f"{BUILD_CLANG_VAR_NAME} not defined. Building for msvc.")
|
||||
COMPILER = "win32-msvc"
|
||||
|
||||
say("All required build environment values are set.")
|
||||
|
||||
#Otherwise qmake gets confused
|
||||
add_line_to_run_bat_file("cd " + get_project_dir())
|
||||
|
||||
say("Adding 'vcvarsall.bat' to batch file.")
|
||||
add_line_to_run_bat_file("@ECHO Setting up environment with Visual Studio 'vcvarsall.bat':")
|
||||
add_line_to_run_bat_file("call " + '"' + VS_LOC + '"' + " " + PLATFORM_TARGET)
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO Environment set up.")
|
||||
say("'vcvarsall.bat' added to batch file.")
|
||||
|
||||
QMAKE_LOC = QT_LOC + r"\qmake.exe"
|
||||
|
||||
if is_env_var_set(BUILD_VSPROJ_VAR_NAME):
|
||||
say(f"{BUILD_VSPROJ_VAR_NAME} defined. Building Visual Studio project files.")
|
||||
add_line_to_run_bat_file("@ECHO Running Visual Studio project file building:")
|
||||
add_line_to_run_bat_file('"' + QMAKE_LOC + '"' + " -tp vc")
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO Done building Visual Studio project files.")
|
||||
else:
|
||||
say(f"{BUILD_VSPROJ_VAR_NAME} not defined. Not building Visual Studio project files.")
|
||||
|
||||
if is_env_var_set(BUILD_DEBUG_VAR_NAME):
|
||||
COMPILE_MODE = "debug"
|
||||
say(f"{BUILD_DEBUG_VAR_NAME} defined. Building '{COMPILE_MODE}' version.")
|
||||
else:
|
||||
COMPILE_MODE = "release"
|
||||
say(f"{BUILD_DEBUG_VAR_NAME} not defined. Building '{COMPILE_MODE}' version.")
|
||||
|
||||
add_line_to_run_bat_file("@ECHO Running qmake:")
|
||||
add_line_to_run_bat_file('"' + QMAKE_LOC + '"' + " -spec " + COMPILER + " CONFIG+=X86_64 " + "CONFIG+=" + COMPILE_MODE)
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO qmake done.")
|
||||
|
||||
if is_env_var_set(JOM_LOC_VAR_NAME):
|
||||
JOM_LOC = os.getenv(JOM_LOC_VAR_NAME)
|
||||
else:
|
||||
say(f"{JOM_LOC_VAR_NAME} not defined. Using default value")
|
||||
JOM_LOC = JOM_LOC_DEFAULT
|
||||
say(f"{JOM_LOC_VAR_NAME} set to '{JOM_LOC}")
|
||||
|
||||
if os.path.exists(JOM_LOC):
|
||||
say(f"{JOM_LOC_VAR_NAME} exists. Using jom.")
|
||||
add_line_to_run_bat_file("@ECHO Running jom:")
|
||||
add_line_to_run_bat_file(JOM_LOC)
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO jom done.")
|
||||
say(f"{JOM_LOC_VAR_NAME} added to batch file.")
|
||||
else:
|
||||
say(f"{JOM_LOC_VAR_NAME} does not exists. Using nmake.")
|
||||
add_line_to_run_bat_file("@ECHO Running nmake:")
|
||||
#nmake is in the path because of 'vcvarsall.bat' from VS_LOC
|
||||
add_line_to_run_bat_file("nmake")
|
||||
add_error_handling_line_to_bat_file()
|
||||
add_line_to_run_bat_file("@ECHO nmake done.")
|
||||
say("nmake added to batch file.")
|
||||
|
||||
add_line_to_run_bat_file("cd " + get_original_dir())
|
||||
|
||||
create_batch_file()
|
||||
|
||||
if __name__ == "__main__":
|
||||
build()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user