|
| 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