diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7635dd055..1cb6f4d75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,7 +144,6 @@ jobs: cat >vatsim.json <>$GITHUB_ENV env: VATSIM_ID: ${{ secrets.VATSIM_ID }} VATSIM_KEY: ${{ secrets.VATSIM_KEY }} @@ -152,11 +151,11 @@ jobs: - name: Build swift (without symbols) if: ${{ env.do_symbols != 'true' }} run: | - python3 -u scripts/build.py -w 64 -t gcc -c "-DVATSIM_KEY_JSON=$vatsim_key_file" + python3 -u scripts/build.py -w 64 -t gcc - name: Build swift (with symbols) if: ${{ env.do_symbols == 'true' }} run: | - python3 -u scripts/build.py -w 64 -t gcc -c "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload-symbols + python3 -u scripts/build.py -w 64 -t gcc --upload-symbols - name: Upload installer uses: actions/upload-artifact@v4 with: @@ -242,7 +241,6 @@ jobs: echo >vatsim.json @" { "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } } "@ - echo "vatsim_key_file=vatsim.json" >>$env:GITHUB_ENV env: VATSIM_ID: ${{ secrets.VATSIM_ID }} VATSIM_KEY: ${{ secrets.VATSIM_KEY }} @@ -250,11 +248,11 @@ jobs: - name: Build swift (without symbols) if: ${{ env.do_symbols != 'true' }} run: | - python -u scripts/build.py -w 64 -t msvc -c "-DVATSIM_KEY_JSON=$env:vatsim_key_file" + python -u scripts/build.py -w 64 -t msvc - name: Build swift (with symbols) if: ${{ env.do_symbols == 'true' }} run: | - python -u scripts/build.py -w 64 -t msvc -c "-DVATSIM_KEY_JSON=$env:vatsim_key_file" --upload-symbols + python -u scripts/build.py -w 64 -t msvc --upload-symbols - name: Upload installer uses: actions/upload-artifact@v4 with: @@ -340,7 +338,6 @@ jobs: echo >vatsim.json @" { "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } } "@ - echo "vatsim_key_file=vatsim.json" >>$env:GITHUB_ENV env: VATSIM_ID: ${{ secrets.VATSIM_ID }} VATSIM_KEY: ${{ secrets.VATSIM_KEY }} @@ -348,11 +345,11 @@ jobs: - name: Build swift (without symbols) if: ${{ env.do_symbols != 'true' }} run: | - python -u scripts/build.py -w 32 -t msvc -c "-DVATSIM_KEY_JSON=$env:vatsim_key_file" + python -u scripts/build.py -w 32 -t msvc - name: Build swift (with symbols) if: ${{ env.do_symbols == 'true' }} run: | - python -u scripts/build.py -w 32 -t msvc -c "-DVATSIM_KEY_JSON=$env:vatsim_key_file" --upload-symbols + python -u scripts/build.py -w 32 -t msvc --upload-symbols - name: Upload installer uses: actions/upload-artifact@v4 with: @@ -428,7 +425,6 @@ jobs: cat >vatsim.json <>$GITHUB_ENV env: VATSIM_ID: ${{ secrets.VATSIM_ID }} VATSIM_KEY: ${{ secrets.VATSIM_KEY }} @@ -436,11 +432,11 @@ jobs: - name: Build swift (without symbols) if: ${{ env.do_symbols != 'true' }} run: | - python3 -u scripts/build.py -w 64 -t clang -c "-DVATSIM_KEY_JSON=$vatsim_key_file" + python3 -u scripts/build.py -w 64 -t clang - name: Build swift (with symbols) if: ${{ env.do_symbols == 'true' }} run: | - python3 -u scripts/build.py -w 64 -t clang -c "-DVATSIM_KEY_JSON=$vatsim_key_file" --upload-symbols + python3 -u scripts/build.py -w 64 -t clang --upload-symbols - name: Upload installer uses: actions/upload-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 89049eb2f..670f69ce2 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,4 @@ cmake-build-*/ # Install folders /out/ /dist/ -CMakePresets.json +CMakeUserPresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..7acbe09f6 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,69 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "ci-base", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "SWIFT_MINIFY_DEBUG_SYMBOLS": "ON", + "SWIFT_USE_CRASHPAD": "ON", + "VATSIM_KEY_JSON": "vatsim.json", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/dist" + } + }, + { + "name": "ci-build-windows", + "displayName": "CI Build Windows", + "inherits": "ci-base", + "generator": "Ninja", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "cacheVariables": { + "SWIFT_USE_CRASHPAD": "ON" + } + }, + { + "name": "ci-build-macos", + "displayName": "CI Build macOS", + "inherits": "ci-base", + "generator": "Unix Makefiles", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + }, + "cacheVariables": { + "SWIFT_USE_CRASHPAD": "ON" + } + }, + { + "name": "ci-build-linux", + "displayName": "CI Build Linux", + "inherits": "ci-base", + "generator": "Ninja", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "cacheVariables": { + "SWIFT_USE_CRASHPAD": "OFF" + } + }, + { + "name": "dev-debug", + "displayName": "Development Debug", + "description": "Base preset that can either be used directly or can be customized through a CMakeUserPresets.json", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "SWIFT_USE_CRASHPAD": "OFF", + "SWIFT_VATSIM_SUPPORT": "OFF", + "SWIFT_MINIFY_DEBUG_SYMBOLS": "OFF" + } + } + ] +} diff --git a/scripts/build.py b/scripts/build.py index 58107a37c..58fbba1b9 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -33,7 +33,7 @@ def prepare(self): shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share')) datastore.update_shared(host, datastore_version, shared_path) - def build(self, cmake_args): + def build(self): """ Run the build itself """ @@ -43,15 +43,9 @@ def build(self, cmake_args): os.makedirs(build_path) os.chdir(build_path) - use_crashpad = "ON" if platform.system() == 'Darwin' or platform.system() == 'Windows' else "OFF" - cmake_call = ['cmake', '..', - '-G {}'.format(self._get_generator()), - '-DCMAKE_BUILD_TYPE=RelWithDebInfo', - '-DSWIFT_MINIFY_DEBUG_SYMBOLS=ON', - '-DCMAKE_INSTALL_PREFIX=../dist', - '-DSWIFT_USE_CRASHPAD={}'.format(use_crashpad)] + cmake_args + f'--preset=ci-build-{self.os_map[platform.system()]}'] subprocess.check_call(cmake_call, env=dict(os.environ)) # Workaround while using Make for macOS to pass number of jobs @@ -77,11 +71,10 @@ def checks(self): def create_installer(self): bitrock_builder_bin = os.environ["BITROCK_BUILDER"] os.chdir(utils.get_swift_source_path()) - os_map = {'Linux': 'linux', 'Darwin': 'macos', 'Windows': 'windows'} installer_platform_map = {'Linux': 'linux-x{}'.format(self.word_size), 'Darwin': 'osx', 'Windows': 'windows'} extension_map = {'Linux': 'run', 'Darwin': 'app', 'Windows': 'exe'} extension = extension_map[platform.system()] - os_name = os_map[platform.system()] + os_name = self.os_map[platform.system()] version_full = utils.get_swift_version_base() version_rev = utils.get_rev_count() windows64 = 1 if os_name == 'windows' and int(self.word_size) == 64 else 0 @@ -119,12 +112,11 @@ def install(self): def publish(self): if self._should_publish(): - os_map = {'Linux': 'linux', 'Darwin': 'macos', 'Windows': 'windows'} extension_map = {'Linux': 'run', 'Darwin': 'dmg', 'Windows': 'exe'} version_segments = self.version.split('.') last_segment = version_segments.pop() version_without_timestamp = '.'.join(version_segments) - installer_name_old = '-'.join(['swiftinstaller', os_map[platform.system()], self.word_size, version_without_timestamp]) + installer_name_old = '-'.join(['swiftinstaller', self.os_map[platform.system()], self.word_size, version_without_timestamp]) installer_name_new = '.'.join([installer_name_old, last_segment]) installer_name_old = installer_name_old + '.' + extension_map[platform.system()] installer_name_new = installer_name_new + '.' + extension_map[platform.system()] @@ -216,9 +208,6 @@ def _specific_prepare(self): def _get_platform_name(self) -> str: raise NotImplementedError() - def _get_generator(self) -> str: - raise NotImplementedError() - def _should_run_checks(self) -> bool: return True @@ -235,6 +224,7 @@ def _strip_debug(self): raise NotImplementedError() def __init__(self, word_size): + self.os_map = {'Linux': 'linux', 'Darwin': 'macos', 'Windows': 'windows'} self.__build_path = path.abspath(path.join(utils.get_swift_source_path(), 'build')) files = os.listdir(utils.get_swift_source_path()) @@ -304,9 +294,6 @@ def _specific_prepare(self): def _get_platform_name(self) -> str: return 'linux-g++' - def _get_generator(self) -> str: - return 'Ninja' - def _strip_debug(self): files = [ "bin/swiftcore", @@ -347,9 +334,6 @@ def _specific_prepare(self): def _get_platform_name(self) -> str: return 'macx-clang' - def _get_generator(self) -> str: - return 'Unix Makefiles' - def _should_create_symbols(self) -> bool: return True @@ -410,14 +394,13 @@ def main(): parser.add_argument("-w", "--wordsize", choices=supported_wordsizes, required=True, help='Wordsize for the build') parser.add_argument("-t", "--toolchain", choices=supported_toolchains, required=True, help='Toolchain for the build') parser.add_argument("-u", "--upload-symbols", action='store_true', help='Upload the symbols') - parser.add_argument("-c", "--cmake-args", action='extend', nargs="+", type=str, help='Arguments to pass to CMake') args = parser.parse_args() builder = builders[platform.system()][args.toolchain](args.wordsize) builder.prepare() - builder.build(args.cmake_args) + builder.build() builder.bundle_csl2xsb() builder.checks() builder.install()