Skip to content

Commit 040c869

Browse files
authored
Merge pull request #3 from ccpgames/build-via-vcpkg
Integrate vcpkg to cmake build scripts
2 parents 16c0b55 + ad56e15 commit 040c869

25 files changed

Lines changed: 2288 additions & 45 deletions

‎.github/workflows/sync_prs.yml‎

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: PR Target Sync
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
list-prs:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
pr_list: ${{ steps.list_prs.outputs.pr_list }}
18+
steps:
19+
- name: List Open PRs
20+
id: list_prs
21+
uses: actions/github-script@v7
22+
with:
23+
github-token: ${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}
24+
script: |
25+
const { data: pullRequests } = await github.rest.pulls.list({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
state: 'open',
29+
});
30+
const prList = pullRequests.map(pr => ({
31+
number: pr.number,
32+
headRef: pr.head.ref,
33+
baseRef: pr.base.ref,
34+
headRepo: pr.head.repo.full_name,
35+
baseRepo: pr.base.repo.full_name,
36+
}));
37+
console.log(`PR List: ${JSON.stringify(prList)}`);
38+
core.setOutput('pr_list', JSON.stringify(prList));
39+
40+
process-prs:
41+
needs: list-prs
42+
runs-on: ubuntu-latest
43+
outputs:
44+
forks: ${{ steps.filter_prs.outputs.forks }}
45+
same_repo: ${{ steps.filter_prs.outputs.same_repo }}
46+
steps:
47+
- name: Filter PRs Targeting the Updated Branch
48+
id: filter_prs
49+
uses: actions/github-script@v7
50+
with:
51+
github-token: ${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}
52+
script: |
53+
const branchUpdated = context.payload.ref.replace('refs/heads/', '');
54+
const rawPrList = `${{ needs.list-prs.outputs.pr_list }}`;
55+
56+
console.log(`Raw PR List: ${rawPrList}`);
57+
58+
let pullRequests;
59+
60+
try {
61+
pullRequests = JSON.parse(rawPrList);
62+
console.log(`Parsed PR List: ${JSON.stringify(pullRequests)}`);
63+
} catch (error) {
64+
console.error('Error parsing PR list:', error);
65+
pullRequests = [];
66+
}
67+
68+
if (pullRequests.length === 0) {
69+
console.log('No PRs found in the list.');
70+
core.setOutput('forks', '[]');
71+
core.setOutput('same_repo', '[]');
72+
return;
73+
}
74+
75+
const prsToProcess = pullRequests.filter(pr => pr.baseRef === branchUpdated);
76+
77+
console.log(`PRs targeting branch ${branchUpdated}: ${JSON.stringify(prsToProcess)}`);
78+
79+
if (prsToProcess.length === 0) {
80+
console.log(`No PRs found targeting the branch: ${branchUpdated}`);
81+
core.setOutput('forks', '[]');
82+
core.setOutput('same_repo', '[]');
83+
return;
84+
}
85+
86+
const forks = [];
87+
const sameRepo = [];
88+
89+
for (const pr of prsToProcess) {
90+
if (pr.headRepo === `${context.repo.owner}/${context.repo.repo}`) {
91+
sameRepo.push(pr);
92+
} else {
93+
forks.push(pr);
94+
}
95+
}
96+
97+
console.log(`Fork PRs: ${JSON.stringify(forks)}`);
98+
console.log(`Same-repo PRs: ${JSON.stringify(sameRepo)}`);
99+
100+
core.setOutput('forks', JSON.stringify(forks));
101+
core.setOutput('same_repo', JSON.stringify(sameRepo));
102+
103+
104+
sync-forks:
105+
needs: process-prs
106+
if: needs.process-prs.outputs.forks != '[]'
107+
runs-on: ubuntu-latest
108+
strategy:
109+
fail-fast: false
110+
matrix:
111+
pr: ${{ fromJson(needs.process-prs.outputs.forks || '[]') }}
112+
steps:
113+
- name: Checkout Fork Repository
114+
uses: actions/checkout@v4
115+
with:
116+
repository: ${{ matrix.pr.headRepo }}
117+
ref: ${{ matrix.pr.headRef }}
118+
fetch-depth: 0
119+
token: ${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}
120+
121+
- name: Add Upstream Remote and Fetch All Branches
122+
run: |
123+
git remote add upstream https://x-access-token:${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}@github.com/${{ matrix.pr.baseRepo }}.git
124+
git fetch --all --prune
125+
126+
- name: Configure Committer Identity
127+
run: |
128+
git config --global user.email "teamcoreexternal@ccpgames.com"
129+
git config --global user.name "Platform Automation"
130+
131+
- name: Merge Parent Branch into Fork Branch
132+
run: |
133+
echo "Merging base branch '${{ matrix.pr.baseRef }}' into fork branch '${{ matrix.pr.headRef }}'."
134+
git checkout ${{ matrix.pr.headRef }}
135+
git merge upstream/${{ matrix.pr.baseRef }} --no-edit
136+
git push origin ${{ matrix.pr.headRef }}
137+
138+
- name: Log Merge Result
139+
run: |
140+
echo "Successfully merged '${{ matrix.pr.baseRef }}' from upstream into '${{ matrix.pr.headRef }}' in fork '${{ matrix.pr.headRepo }}'."
141+
142+
143+
sync-same-repo:
144+
needs: process-prs
145+
if: needs.process-prs.outputs.same_repo != '[]'
146+
runs-on: ubuntu-latest
147+
strategy:
148+
fail-fast: false
149+
matrix:
150+
pr: ${{ fromJson(needs.process-prs.outputs.same_repo || '[]') }}
151+
steps:
152+
- name: Checkout Repository
153+
uses: actions/checkout@v4
154+
with:
155+
fetch-depth: 0
156+
157+
- name: Fetch All Remote Branches
158+
run: |
159+
git fetch --all --prune
160+
161+
- name: Configure Committer Identity
162+
run: |
163+
git config --global user.email "teamcoreexternal@ccpgames.com"
164+
git config --global user.name "Platform Automation"
165+
166+
- name: Merge Parent Branch into Child Branch
167+
run: |
168+
echo "Merging parent branch '${{ matrix.pr.baseRef }}' into child branch '${{ matrix.pr.headRef }}'."
169+
git checkout ${{ matrix.pr.headRef }}
170+
git merge origin/${{ matrix.pr.baseRef }} --no-edit
171+
git push origin ${{ matrix.pr.headRef }}
172+
173+
- name: Log Merge Result
174+
run: |
175+
echo "Successfully merged '${{ matrix.pr.baseRef }}' into '${{ matrix.pr.headRef }}'."
176+
177+
178+
179+
180+
181+

‎.gitmodules‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "vendor/github.com/microsoft/vcpkg"]
2+
path = vendor/github.com/microsoft/vcpkg
3+
url = https://github.com/microsoft/vcpkg.git
4+
[submodule "vendor/github.com/carbonengine/vcpkg-registry"]
5+
path = vendor/github.com/carbonengine/vcpkg-registry
6+
url = https://github.com/carbonengine/vcpkg-registry.git

‎.teamcity/MacOS/Project.kt‎

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
package MacOS
2+
3+
import jetbrains.buildServer.configs.kotlin.DslContext
4+
import jetbrains.buildServer.configs.kotlin.Project
5+
import jetbrains.buildServer.configs.kotlin.*
6+
import jetbrains.buildServer.configs.kotlin.buildFeatures.PullRequests
7+
import jetbrains.buildServer.configs.kotlin.buildFeatures.XmlReport
8+
import jetbrains.buildServer.configs.kotlin.buildFeatures.commitStatusPublisher
9+
import jetbrains.buildServer.configs.kotlin.buildFeatures.freeDiskSpace
10+
import jetbrains.buildServer.configs.kotlin.buildFeatures.nuGetFeedCredentials
11+
import jetbrains.buildServer.configs.kotlin.buildFeatures.perfmon
12+
import jetbrains.buildServer.configs.kotlin.buildFeatures.pullRequests
13+
import jetbrains.buildServer.configs.kotlin.buildFeatures.sshAgent
14+
import jetbrains.buildServer.configs.kotlin.buildFeatures.xmlReport
15+
import jetbrains.buildServer.configs.kotlin.buildSteps.exec
16+
import jetbrains.buildServer.configs.kotlin.buildSteps.powerShell
17+
import jetbrains.buildServer.configs.kotlin.buildSteps.python
18+
import jetbrains.buildServer.configs.kotlin.buildSteps.script
19+
import jetbrains.buildServer.configs.kotlin.triggers.vcs
20+
import jetbrains.buildServer.configs.kotlin.vcs.GitVcsRoot
21+
import jetbrains.buildServer.configs.kotlin.buildFeatures.provideAwsCredentials
22+
23+
val arm64_Debug = CarbonBuildMacOS("Debug MacOS arm64", "Debug", "arm64-osx-debug", "aarch64")
24+
val arm64_Internal = CarbonBuildMacOS("Internal MacOS arm64", "Internal", "arm64-osx-internal", "aarch64")
25+
val arm64_TrinityDev = CarbonBuildMacOS("TrinityDev MacOS arm64", "TrinityDev", "arm64-osx-trinitydev", "aarch64")
26+
val arm64_Release = CarbonBuildMacOS("Release MacOS arm64", "Release", "arm64-osx-release", "aarch64")
27+
28+
val x64_Debug = CarbonBuildMacOS("Debug MacOS x64", "Debug", "x64-osx-debug", "x86_64")
29+
val x64_Internal = CarbonBuildMacOS("Internal MacOS x64", "Internal", "x64-osx-internal", "x86_64")
30+
val x64_TrinityDev = CarbonBuildMacOS("TrinityDev MacOS x64", "TrinityDev", "x64-osx-trinitydev", "x86_64")
31+
val x64_Release = CarbonBuildMacOS("Release MacOS x64", "Release", "x64-osx-release", "x86_64")
32+
33+
object Project : Project({
34+
id("MacOS")
35+
name = "macOS"
36+
37+
buildType(_Self.buildTypes.CreateUniversalBuilds)
38+
39+
buildType(arm64_Debug)
40+
buildType(arm64_Internal)
41+
buildType(arm64_TrinityDev)
42+
buildType(arm64_Release)
43+
44+
buildType(x64_Debug)
45+
buildType(x64_Internal)
46+
buildType(x64_TrinityDev)
47+
buildType(x64_Release)
48+
})
49+
50+
class CarbonBuildMacOS(buildName: String, configType: String, preset: String, agentArchitecture: String) : BuildType({
51+
id(buildName.toId())
52+
name = buildName
53+
54+
artifactRules = "%env.CMAKE_INSTALL_PREFIX%"
55+
56+
params {
57+
param("env.SENTRY_CLI_DEBUG_SYMBOL_TYPE", "dsym")
58+
param("env.GIT_TAG_HASH_OVERRIDE", "")
59+
param("env.CMAKE_CONFIG_TYPE", configType)
60+
param("env.CMAKE_GENERATOR", "Ninja Multi-Config")
61+
param("teamcity.vcsTrigger.runBuildInNewEmptyBranch", "true")
62+
param("github_checkout_folder", "github")
63+
param("env.CTEST_JUNIT_OUTPUT_FILE", "ctest_results.xml")
64+
select("env.VISUAL_STUDIO_PLATFORM_TOOLSET", "v141", label = "Visual Studio Platform Toolset", description = "Specify the toolset for the build. e.g. v141 or v143.",
65+
options = listOf("v141 (2017)" to "v141", "v143 (2022)" to "v143"))
66+
param("env.CMAKE_BUILD_TARGETS", "all")
67+
param("env.CMAKE_INSTALL_PREFIX", ".build-artifact")
68+
param("env.SENTRY_PROJECT", "exefile-crashes")
69+
param("env.CMAKE_BUILD_FOLDER", ".cmake-build-%build.number%")
70+
param("env.GIT_TAG_HASH", "")
71+
param("env.EXECUTABLE_FILENAMES_MATCH", "")
72+
param("env.CMAKE_PRESET", preset)
73+
param("env.VCPKG_BINARY_SOURCES", "clear;x-aws,s3://vcpkg-binary-cache-static/cache/,readwrite")
74+
param("env.X_VCPKG_REGISTRIES_CACHE", "%teamcity.build.checkoutDir%/%github_checkout_folder%/regcache")
75+
param("env.CMAKE_BUILD_PARALLEL_LEVEL", "8")
76+
param("env.CTEST_PARALLEL_LEVEL", "8")
77+
}
78+
79+
80+
vcs {
81+
root(DslContext.settingsRootId, "+:. => %github_checkout_folder%")
82+
root(AbsoluteId("CarbonPipelineTools"), "+:. => carbon_pipeline_tools")
83+
cleanCheckout = true
84+
}
85+
86+
steps {
87+
exec {
88+
name = "Create VCPKG registrycache location"
89+
workingDir = "%teamcity.build.checkoutDir%/%github_checkout_folder%"
90+
path = "mkdir"
91+
arguments = "regcache"
92+
}
93+
exec {
94+
name = "(macOS) Get Git Tag/Hash"
95+
workingDir = "%teamcity.build.checkoutDir%/%github_checkout_folder%"
96+
path = "python3"
97+
arguments = "%teamcity.build.checkoutDir%/carbon_pipeline_tools/carbon/GetGitTagAndOrHash.py"
98+
}
99+
exec {
100+
name = "(macOS) Remove build artifacts folder"
101+
path = "rm"
102+
arguments = "-rf %env.CMAKE_INSTALL_PREFIX%"
103+
}
104+
exec {
105+
name = "Configure"
106+
path = "cmake"
107+
arguments = "--preset %env.CMAKE_PRESET% -S %teamcity.build.checkoutDir%/%github_checkout_folder% -B %env.CMAKE_BUILD_FOLDER% -DINSTALL_TO_MONOLITH=ON -DCMAKE_INSTALL_PREFIX=%env.CMAKE_INSTALL_PREFIX% -DVCPKG_INSTALL_OPTIONS=--x-buildtrees-root=%teamcity.build.checkoutDir%/%github_checkout_folder%/buildtrees"
108+
}
109+
exec {
110+
name = "Build"
111+
path = "cmake"
112+
arguments = "--build %env.CMAKE_BUILD_FOLDER% --config %env.CMAKE_CONFIG_TYPE% --target %env.CMAKE_BUILD_TARGETS%"
113+
}
114+
exec {
115+
name = "Run Tests"
116+
workingDir = "%env.CMAKE_BUILD_FOLDER%"
117+
path = "ctest"
118+
arguments = "-C %env.CMAKE_CONFIG_TYPE% -V --output-on-failure --output-junit %env.CTEST_JUNIT_OUTPUT_FILE%"
119+
}
120+
exec {
121+
name = "Package artifact"
122+
path = "cmake"
123+
arguments = "--install %env.CMAKE_BUILD_FOLDER% --config %env.CMAKE_CONFIG_TYPE%"
124+
}
125+
exec {
126+
name = "Upload symbols to sentry"
127+
path = "sentry-cli"
128+
arguments = "upload-dif --wait %env.CMAKE_BUILD_FOLDER%"
129+
param("script.content", """
130+
#!/usr/bin/env bash -eu
131+
filesWithSymbols = (
132+
# insert your binary files with symbols here!
133+
)
134+
""".trimIndent())
135+
}
136+
}
137+
138+
triggers {
139+
vcs {
140+
triggerRules = "+:root=${DslContext.settingsRootId.id}:."
141+
branchFilter = """
142+
+:<default>
143+
+pr:*
144+
""".trimIndent()
145+
}
146+
}
147+
148+
features {
149+
pullRequests {
150+
vcsRootExtId = "${DslContext.settingsRootId.id}"
151+
provider = github {
152+
authType = token {
153+
token = "%GITHUB_CARBON_PAT%"
154+
}
155+
filterAuthorRole = PullRequests.GitHubRoleFilter.MEMBER
156+
}
157+
}
158+
commitStatusPublisher {
159+
publisher = github {
160+
githubUrl = "https://api.github.com"
161+
authType = personalToken {
162+
token = "%GITHUB_CARBON_PAT%"
163+
}
164+
}
165+
}
166+
xmlReport {
167+
reportType = XmlReport.XmlReportType.JUNIT
168+
rules = "+:%env.CMAKE_BUILD_FOLDER%/%env.CTEST_JUNIT_OUTPUT_FILE%"
169+
verbose = true
170+
}
171+
perfmon {
172+
}
173+
freeDiskSpace {
174+
requiredSpace = "10gb"
175+
failBuild = true
176+
}
177+
sshAgent {
178+
teamcitySshKey = "ccpgames-evetech GitHub"
179+
}
180+
provideAwsCredentials {
181+
awsConnectionId = "Carbon_AwsVcpkgBinaryCacheServiceAccount"
182+
}
183+
}
184+
185+
requirements {
186+
startsWith("teamcity.agent.jvm.os.name", "Mac OS X")
187+
startsWith("teamcity.agent.jvm.os.arch", agentArchitecture)
188+
}
189+
})
190+
191+

0 commit comments

Comments
 (0)