diff --git a/build.py b/build.py index 0c818d968f5bb2930aa20970e59ed08799584d3e..34fcac292b70319989abc3184ccf879605b4f1b1 100755 --- a/build.py +++ b/build.py @@ -366,13 +366,27 @@ def cwd(path): def run_install(args): # Platforms with special compilation scripts if args.distribution == WIN32_DISTRIBUTION_NAME: + # Build daemon if not using pywinmake if not args.pywinmake: with cwd('daemon/compat/msvc'): execute_script([f'python winmake.py -iv -s {args.sdk} -b daemon']) + # Prepare the build-windows.py script call build_windows = 'extras/scripts/build-windows.py' + # Initialize build environment execute_script([f'python {build_windows} --init']) - execute_script([f'python {build_windows} --qt={args.qt}']) + + # Construct build command with options + build_cmd = [ + 'python', + build_windows, + f'--qt={args.qt}' + ] + + if args.enable_crash_reports: + build_cmd.append('--enable-crash-reports') + + execute_script([' '.join(build_cmd)]) return True # Unix-like platforms @@ -401,6 +415,8 @@ def run_install(args): install_args += ('-a', args.arch) if args.extra_cmake_flags: install_args += ('-D', args.extra_cmake_flags) + if args.enable_crash_reports: + install_args.append('-C') if args.distribution == OSX_DISTRIBUTION_NAME: # The `universal_newlines` parameter has been renamed to `text` in @@ -750,6 +766,9 @@ def parse_args(): # Allow supplying extra congifure flags to the client cmake. ap.add_argument('--extra-cmake-flags', type=str, help='Extra flags to pass to the client cmake') + ap.add_argument('--enable-crash-reports', + action='store_true', default=False, + help='Enable crash reporting') dist = choose_distribution() diff --git a/extras/scripts/build-windows.py b/extras/scripts/build-windows.py index b53f55fd50274bff72d768fe5fc03e15a012bcd7..963777ff1ef5f9c75571c4b976fd55810d38833a 100644 --- a/extras/scripts/build-windows.py +++ b/extras/scripts/build-windows.py @@ -9,14 +9,15 @@ and package the project for Windows. usage: build.py [-q] [-h] [-a ARCH] [-c CONFIG] [-t] [-i] [-v] {pack} ... optional arguments: - -q, --qt PATH Sets the Qt installation path - -a ARCH, --arch ARCH Sets the build architecture + -q, --qt PATH Sets the Qt installation path + -a ARCH, --arch ARCH Sets the build architecture -c CONFIG, --config CONFIG - Sets the build configuration type - -t, --tests Build and run tests - -i, --init Initialize submodules - -v, --version Show the version number and exit - -s, --skip-build Only do packaging or run tests, skip building + Sets the build configuration type + -t, --tests Build and run tests + -i, --init Initialize submodules + -v, --version Show the version number and exit + -s, --skip-build Only do packaging or run tests, skip building + --enable-crash-reports Enable crash reports positional arguments: {pack} @@ -260,7 +261,7 @@ def cmake_build(config_str, env_vars, cmake_build_dir): return True -def build(config_str, qt_dir, tests): +def build(config_str, qt_dir, tests, enable_crash_reports): """Use cmake to build the project.""" print("Building with Qt at " + qt_dir) @@ -284,6 +285,11 @@ def build(config_str, qt_dir, tests): "-DBETA=" + str((0, 1)[config_str == "Beta"]), ] + if enable_crash_reports: + cmake_options.append("-DENABLE_CRASHREPORTS=ON") + else: + cmake_options.append("-DENABLE_CRASHREPORTS=OFF") + # Make sure the build directory exists. if not os.path.exists(build_dir): os.makedirs(build_dir) @@ -471,17 +477,20 @@ def parse_args(): parser.add_argument( "-i", "--init", action="store_true", help="Initialize submodules") parser.add_argument( - '-sd', '--skip-deploy', action='store_true', default=False, help='Force skip deployment of runtime files needed for packaging') parser.add_argument( - "-sb", "--skip-build", action="store_true", default=False, help="Only do packaging or run tests, skip build step") + parser.add_argument( + '--enable-crash-reports', + action='store_true', + default=False, + help='Enable crash reporting') pack_arg_parser = subparsers.add_parser("pack") pack_group = pack_arg_parser.add_mutually_exclusive_group(required=True) @@ -534,7 +543,7 @@ def main(): def do_build(do_tests): if not parsed_args.skip_build: - build(config_str, parsed_args.qt, do_tests) + build(config_str, parsed_args.qt, do_tests, parsed_args.enable_crash_reports) if not parsed_args.skip_deploy: deploy_runtimes(config_str, parsed_args.qt) diff --git a/extras/scripts/install.sh b/extras/scripts/install.sh index e39d541ce2a54fa5378a536847ec578b5e55bcc4..de536a46fe32ef9ec92fa7b8557c17d86a15cfd4 100755 --- a/extras/scripts/install.sh +++ b/extras/scripts/install.sh @@ -31,6 +31,7 @@ export OSTYPE # -a: arch to build # -A: enable AddressSanitizer # -D: extra CMake flags for the client + # -C: enable crash reporting set -ex @@ -49,8 +50,9 @@ asan= extra_cmake_flags='' arch='' enable_testing=false +enable_crashreports=false -while getopts gsc:dQ:P:p:uWwa:AtD: OPT; do +while getopts gsc:dQ:P:p:uWwa:AtD:C OPT; do case "$OPT" in g) global='true' @@ -91,6 +93,9 @@ while getopts gsc:dQ:P:p:uWwa:AtD: OPT; do D) extra_cmake_flags="${OPTARG}" ;; + C) + enable_crashreports='true' + ;; \?) exit 1 ;; @@ -212,6 +217,12 @@ else client_cmake_flags+=(-DBUILD_TESTING=Off) fi +if [ "${enable_crashreports}" = "true" ]; then + client_cmake_flags+=(-DENABLE_CRASHREPORTS=ON) +else + client_cmake_flags+=(-DENABLE_CRASHREPORTS=OFF) +fi + if [[ "$OSTYPE" == "darwin"* ]]; then #detect arch for macos CMAKE_OSX_ARCHITECTURES="arm64"