mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
build: Add CMakePresets.json
This commit is contained in:
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
@@ -144,7 +144,6 @@ jobs:
|
|||||||
cat >vatsim.json <<EOF
|
cat >vatsim.json <<EOF
|
||||||
{ "vatsim": { "id": "$VATSIM_ID", "key": "$VATSIM_KEY" } }
|
{ "vatsim": { "id": "$VATSIM_ID", "key": "$VATSIM_KEY" } }
|
||||||
EOF
|
EOF
|
||||||
echo "vatsim_key_file=vatsim.json" >>$GITHUB_ENV
|
|
||||||
env:
|
env:
|
||||||
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
||||||
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
||||||
@@ -152,11 +151,11 @@ jobs:
|
|||||||
- name: Build swift (without symbols)
|
- name: Build swift (without symbols)
|
||||||
if: ${{ env.do_symbols != 'true' }}
|
if: ${{ env.do_symbols != 'true' }}
|
||||||
run: |
|
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)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' }}
|
if: ${{ env.do_symbols == 'true' }}
|
||||||
run: |
|
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
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -242,7 +241,6 @@ jobs:
|
|||||||
echo >vatsim.json @"
|
echo >vatsim.json @"
|
||||||
{ "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } }
|
{ "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } }
|
||||||
"@
|
"@
|
||||||
echo "vatsim_key_file=vatsim.json" >>$env:GITHUB_ENV
|
|
||||||
env:
|
env:
|
||||||
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
||||||
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
||||||
@@ -250,11 +248,11 @@ jobs:
|
|||||||
- name: Build swift (without symbols)
|
- name: Build swift (without symbols)
|
||||||
if: ${{ env.do_symbols != 'true' }}
|
if: ${{ env.do_symbols != 'true' }}
|
||||||
run: |
|
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)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' }}
|
if: ${{ env.do_symbols == 'true' }}
|
||||||
run: |
|
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
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -340,7 +338,6 @@ jobs:
|
|||||||
echo >vatsim.json @"
|
echo >vatsim.json @"
|
||||||
{ "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } }
|
{ "vatsim": { "id": "$env:VATSIM_ID", "key": "$env:VATSIM_KEY" } }
|
||||||
"@
|
"@
|
||||||
echo "vatsim_key_file=vatsim.json" >>$env:GITHUB_ENV
|
|
||||||
env:
|
env:
|
||||||
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
||||||
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
||||||
@@ -348,11 +345,11 @@ jobs:
|
|||||||
- name: Build swift (without symbols)
|
- name: Build swift (without symbols)
|
||||||
if: ${{ env.do_symbols != 'true' }}
|
if: ${{ env.do_symbols != 'true' }}
|
||||||
run: |
|
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)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' }}
|
if: ${{ env.do_symbols == 'true' }}
|
||||||
run: |
|
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
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -428,7 +425,6 @@ jobs:
|
|||||||
cat >vatsim.json <<EOF
|
cat >vatsim.json <<EOF
|
||||||
{ "vatsim": { "id": "$VATSIM_ID", "key": "$VATSIM_KEY" } }
|
{ "vatsim": { "id": "$VATSIM_ID", "key": "$VATSIM_KEY" } }
|
||||||
EOF
|
EOF
|
||||||
echo "vatsim_key_file=vatsim.json" >>$GITHUB_ENV
|
|
||||||
env:
|
env:
|
||||||
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
VATSIM_ID: ${{ secrets.VATSIM_ID }}
|
||||||
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
VATSIM_KEY: ${{ secrets.VATSIM_KEY }}
|
||||||
@@ -436,11 +432,11 @@ jobs:
|
|||||||
- name: Build swift (without symbols)
|
- name: Build swift (without symbols)
|
||||||
if: ${{ env.do_symbols != 'true' }}
|
if: ${{ env.do_symbols != 'true' }}
|
||||||
run: |
|
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)
|
- name: Build swift (with symbols)
|
||||||
if: ${{ env.do_symbols == 'true' }}
|
if: ${{ env.do_symbols == 'true' }}
|
||||||
run: |
|
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
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -50,4 +50,4 @@ cmake-build-*/
|
|||||||
# Install folders
|
# Install folders
|
||||||
/out/
|
/out/
|
||||||
/dist/
|
/dist/
|
||||||
CMakePresets.json
|
CMakeUserPresets.json
|
||||||
|
|||||||
69
CMakePresets.json
Normal file
69
CMakePresets.json
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ class Builder:
|
|||||||
shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share'))
|
shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share'))
|
||||||
datastore.update_shared(host, datastore_version, shared_path)
|
datastore.update_shared(host, datastore_version, shared_path)
|
||||||
|
|
||||||
def build(self, cmake_args):
|
def build(self):
|
||||||
"""
|
"""
|
||||||
Run the build itself
|
Run the build itself
|
||||||
"""
|
"""
|
||||||
@@ -43,15 +43,9 @@ class Builder:
|
|||||||
os.makedirs(build_path)
|
os.makedirs(build_path)
|
||||||
os.chdir(build_path)
|
os.chdir(build_path)
|
||||||
|
|
||||||
use_crashpad = "ON" if platform.system() == 'Darwin' or platform.system() == 'Windows' else "OFF"
|
|
||||||
|
|
||||||
cmake_call = ['cmake',
|
cmake_call = ['cmake',
|
||||||
'..',
|
'..',
|
||||||
'-G {}'.format(self._get_generator()),
|
f'--preset=ci-build-{self.os_map[platform.system()]}']
|
||||||
'-DCMAKE_BUILD_TYPE=RelWithDebInfo',
|
|
||||||
'-DSWIFT_MINIFY_DEBUG_SYMBOLS=ON',
|
|
||||||
'-DCMAKE_INSTALL_PREFIX=../dist',
|
|
||||||
'-DSWIFT_USE_CRASHPAD={}'.format(use_crashpad)] + cmake_args
|
|
||||||
subprocess.check_call(cmake_call, env=dict(os.environ))
|
subprocess.check_call(cmake_call, env=dict(os.environ))
|
||||||
|
|
||||||
# Workaround while using Make for macOS to pass number of jobs
|
# Workaround while using Make for macOS to pass number of jobs
|
||||||
@@ -77,11 +71,10 @@ class Builder:
|
|||||||
def create_installer(self):
|
def create_installer(self):
|
||||||
bitrock_builder_bin = os.environ["BITROCK_BUILDER"]
|
bitrock_builder_bin = os.environ["BITROCK_BUILDER"]
|
||||||
os.chdir(utils.get_swift_source_path())
|
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'}
|
installer_platform_map = {'Linux': 'linux-x{}'.format(self.word_size), 'Darwin': 'osx', 'Windows': 'windows'}
|
||||||
extension_map = {'Linux': 'run', 'Darwin': 'app', 'Windows': 'exe'}
|
extension_map = {'Linux': 'run', 'Darwin': 'app', 'Windows': 'exe'}
|
||||||
extension = extension_map[platform.system()]
|
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_full = utils.get_swift_version_base()
|
||||||
version_rev = utils.get_rev_count()
|
version_rev = utils.get_rev_count()
|
||||||
windows64 = 1 if os_name == 'windows' and int(self.word_size) == 64 else 0
|
windows64 = 1 if os_name == 'windows' and int(self.word_size) == 64 else 0
|
||||||
@@ -119,12 +112,11 @@ class Builder:
|
|||||||
|
|
||||||
def publish(self):
|
def publish(self):
|
||||||
if self._should_publish():
|
if self._should_publish():
|
||||||
os_map = {'Linux': 'linux', 'Darwin': 'macos', 'Windows': 'windows'}
|
|
||||||
extension_map = {'Linux': 'run', 'Darwin': 'dmg', 'Windows': 'exe'}
|
extension_map = {'Linux': 'run', 'Darwin': 'dmg', 'Windows': 'exe'}
|
||||||
version_segments = self.version.split('.')
|
version_segments = self.version.split('.')
|
||||||
last_segment = version_segments.pop()
|
last_segment = version_segments.pop()
|
||||||
version_without_timestamp = '.'.join(version_segments)
|
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_new = '.'.join([installer_name_old, last_segment])
|
||||||
installer_name_old = installer_name_old + '.' + extension_map[platform.system()]
|
installer_name_old = installer_name_old + '.' + extension_map[platform.system()]
|
||||||
installer_name_new = installer_name_new + '.' + extension_map[platform.system()]
|
installer_name_new = installer_name_new + '.' + extension_map[platform.system()]
|
||||||
@@ -216,9 +208,6 @@ class Builder:
|
|||||||
def _get_platform_name(self) -> str:
|
def _get_platform_name(self) -> str:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def _get_generator(self) -> str:
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
def _should_run_checks(self) -> bool:
|
def _should_run_checks(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -235,6 +224,7 @@ class Builder:
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def __init__(self, word_size):
|
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'))
|
self.__build_path = path.abspath(path.join(utils.get_swift_source_path(), 'build'))
|
||||||
|
|
||||||
files = os.listdir(utils.get_swift_source_path())
|
files = os.listdir(utils.get_swift_source_path())
|
||||||
@@ -304,9 +294,6 @@ class LinuxBuilder(Builder):
|
|||||||
def _get_platform_name(self) -> str:
|
def _get_platform_name(self) -> str:
|
||||||
return 'linux-g++'
|
return 'linux-g++'
|
||||||
|
|
||||||
def _get_generator(self) -> str:
|
|
||||||
return 'Ninja'
|
|
||||||
|
|
||||||
def _strip_debug(self):
|
def _strip_debug(self):
|
||||||
files = [
|
files = [
|
||||||
"bin/swiftcore",
|
"bin/swiftcore",
|
||||||
@@ -347,9 +334,6 @@ class MacOSBuilder(Builder):
|
|||||||
def _get_platform_name(self) -> str:
|
def _get_platform_name(self) -> str:
|
||||||
return 'macx-clang'
|
return 'macx-clang'
|
||||||
|
|
||||||
def _get_generator(self) -> str:
|
|
||||||
return 'Unix Makefiles'
|
|
||||||
|
|
||||||
def _should_create_symbols(self) -> bool:
|
def _should_create_symbols(self) -> bool:
|
||||||
return True
|
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("-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("-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("-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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
builder = builders[platform.system()][args.toolchain](args.wordsize)
|
builder = builders[platform.system()][args.toolchain](args.wordsize)
|
||||||
|
|
||||||
builder.prepare()
|
builder.prepare()
|
||||||
builder.build(args.cmake_args)
|
builder.build()
|
||||||
builder.bundle_csl2xsb()
|
builder.bundle_csl2xsb()
|
||||||
builder.checks()
|
builder.checks()
|
||||||
builder.install()
|
builder.install()
|
||||||
|
|||||||
Reference in New Issue
Block a user