|
| 1 | +#-------------------------------------------------------------------------- |
| 2 | +# Constants |
| 3 | +#-------------------------------------------------------------------------- |
| 4 | + |
| 5 | +# List of triplets to build |
| 6 | +triplets = [ |
| 7 | + 'x64-windows-webkit', |
| 8 | + 'x86-windows-webkit', |
| 9 | +] |
| 10 | + |
| 11 | +# Current Windows version to use |
| 12 | +windows_version = 1809 |
| 13 | + |
| 14 | +#-------------------------------------------------------------------------- |
| 15 | +# Build config |
| 16 | +#-------------------------------------------------------------------------- |
| 17 | + |
| 18 | +def build_config(triplet): |
| 19 | + suffix = '64' if triplet.startswith('x64') else '32' |
| 20 | + |
| 21 | + return { |
| 22 | + 'triplet': triplet, |
| 23 | + 'build-image': 'webkitdev/msbuild', |
| 24 | + 'ports': [ |
| 25 | + # This should be kept in sync with WindowsRequirements.json |
| 26 | + 'zlib', |
| 27 | + 'brotli', |
| 28 | + 'libressl', |
| 29 | + 'nghttp2', |
| 30 | + 'curl[ssl,ipv6]', |
| 31 | + 'icu', |
| 32 | + 'libxml2[xslt]', |
| 33 | + 'libxslt', |
| 34 | + 'libpng', |
| 35 | + 'libjpeg-turbo', |
| 36 | + 'libwebp', |
| 37 | + 'openjpeg', |
| 38 | + 'sqlite3', |
| 39 | + 'pixman', |
| 40 | + 'cairo', |
| 41 | + 'libpsl', |
| 42 | + # Additional ports |
| 43 | + 'pthreads', |
| 44 | + 'cflite', |
| 45 | + ], |
| 46 | + 'distribution': 'WebKitRequirementsWin' + suffix + '.zip', |
| 47 | + 'volumes': [], |
| 48 | + 'environment': {}, |
| 49 | + } |
| 50 | + |
| 51 | +#-------------------------------------------------------------------------- |
| 52 | +# Steps |
| 53 | +#-------------------------------------------------------------------------- |
| 54 | + |
| 55 | +def build_vcpkg(config): |
| 56 | + return { |
| 57 | + 'name': 'vcpkg', |
| 58 | + 'image': config['build-image'], |
| 59 | + 'pull': 'always', |
| 60 | + 'commands': ['./Install-Vcpkg.ps1 -VcpkgPath C:/vcpkg'], |
| 61 | + } |
| 62 | + |
| 63 | +def download_vcpkg_tools(config): |
| 64 | + return { |
| 65 | + 'name': 'download-vcpkg-tools', |
| 66 | + 'image': config['build-image'], |
| 67 | + 'commands': ['./Download-VcpkgTools.ps1 -ToolsPath ./scripts/vcpkgTools.xml'], |
| 68 | + } |
| 69 | + |
| 70 | +def build_port(port, config): |
| 71 | + triplet = config['triplet'] |
| 72 | + build_image = config['build-image'] |
| 73 | + # Don't include any feature defines (e.g [foo]) |
| 74 | + port_name = port.split('[')[0] |
| 75 | + |
| 76 | + return { |
| 77 | + 'name': port_name, |
| 78 | + 'image': build_image, |
| 79 | + 'commands': ['./vcpkg.exe install {} --triplet {}'.format(port, triplet)], |
| 80 | + 'volumes': config['volumes'], |
| 81 | + 'environment': config['environment'], |
| 82 | + 'steps': _build_output(port_name, triplet, build_image), |
| 83 | + } |
| 84 | + |
| 85 | +def _build_output(port, triplet, build_image, step_name=''): |
| 86 | + # These steps should always run to capture config and compilation errors |
| 87 | + when_clause = {'status': ['success', 'failure']} |
| 88 | + if not step_name: |
| 89 | + step_name = port |
| 90 | + |
| 91 | + return [ |
| 92 | + { |
| 93 | + 'name': step_name + '-config', |
| 94 | + 'image': build_image, |
| 95 | + 'commands': ['Get-Content ./buildtrees/{}/config-{}-out.log'.format(port, triplet)], |
| 96 | + 'when': when_clause, |
| 97 | + }, |
| 98 | + { |
| 99 | + 'name': step_name + '-debug-build', |
| 100 | + 'image': build_image, |
| 101 | + 'commands': ['Get-Content ./buildtrees/{}/install-{}-dbg-out.log'.format(port, triplet)], |
| 102 | + 'when': when_clause, |
| 103 | + }, |
| 104 | + { |
| 105 | + 'name': step_name + '-release-build', |
| 106 | + 'image': build_image, |
| 107 | + 'commands': ['Get-Content ./buildtrees/{}/install-{}-rel-out.log'.format(port, triplet)], |
| 108 | + 'when': when_clause, |
| 109 | + }, |
| 110 | + ] |
| 111 | + |
| 112 | +def bundle_requirements(config): |
| 113 | + return { |
| 114 | + 'name': 'bundle', |
| 115 | + 'image': config['build-image'], |
| 116 | + 'commands': ['./Release-Requirements.ps1 -Triplet {}'.format(config['triplet'])], |
| 117 | + } |
| 118 | + |
| 119 | +def release_requirements(config): |
| 120 | + return { |
| 121 | + 'name': 'release', |
| 122 | + 'image': 'plugins/github-release', |
| 123 | + 'pull': 'always', |
| 124 | + 'settings': { |
| 125 | + 'api_key': {'from_secret': 'github_token'}, |
| 126 | + 'files': [config['distribution']], |
| 127 | + # Currently the release is manual |
| 128 | + 'prerelease': True, |
| 129 | + }, |
| 130 | + 'when': { |
| 131 | + 'event': ['tag'], |
| 132 | + }, |
| 133 | + } |
| 134 | + |
| 135 | +#-------------------------------------------------------------------------- |
| 136 | +# Pipelines |
| 137 | +#-------------------------------------------------------------------------- |
| 138 | + |
| 139 | +def build_pipeline(triplet): |
| 140 | + config = build_config(triplet) |
| 141 | + |
| 142 | + # Add initial steps |
| 143 | + build_steps = [ |
| 144 | + build_vcpkg(config), |
| 145 | + download_vcpkg_tools(config), |
| 146 | + ] |
| 147 | + |
| 148 | + for port in config['ports']: |
| 149 | + build_steps.append(build_port(port, config)) |
| 150 | + |
| 151 | + # Add packaging steps |
| 152 | + build_steps.append(bundle_requirements(config)) |
| 153 | + build_steps.append(release_requirements(config)) |
| 154 | + |
| 155 | + prev_step = 'clone' |
| 156 | + steps = [] |
| 157 | + |
| 158 | + for step in build_steps: |
| 159 | + step['depends_on'] = [prev_step] |
| 160 | + steps.append(step) |
| 161 | + prev_step = step['name'] |
| 162 | + |
| 163 | + # See if there are additional sub steps |
| 164 | + if 'steps' in step: |
| 165 | + sub_steps = step.pop('steps') |
| 166 | + |
| 167 | + for sub_step in sub_steps: |
| 168 | + sub_step['depends_on'] = [prev_step] |
| 169 | + steps.append(sub_step) |
| 170 | + |
| 171 | + # Remove the depends_on for the first step to make sure a drone exec works |
| 172 | + # when there is no clone step |
| 173 | + steps[0].pop('depends_on') |
| 174 | + |
| 175 | + # Create volumes |
| 176 | + volumes = [] |
| 177 | + for volume in config['volumes']: |
| 178 | + volume = { |
| 179 | + 'name': volume['name'], |
| 180 | + 'temp': {}, |
| 181 | + } |
| 182 | + |
| 183 | + volumes.append(volume) |
| 184 | + |
| 185 | + # Create pipeline |
| 186 | + current = _windows_pipeline(windows_version) |
| 187 | + current['name'] = 'Build {}'.format(triplet) |
| 188 | + current['steps'] = steps |
| 189 | + current['volumes'] = volumes |
| 190 | + |
| 191 | + return current |
| 192 | + |
| 193 | +def _windows_pipeline(version): |
| 194 | + return { |
| 195 | + 'kind': 'pipeline', |
| 196 | + 'type': 'docker', |
| 197 | + 'platform': { |
| 198 | + 'os': 'windows', |
| 199 | + 'arch': 'amd64', |
| 200 | + 'version': version |
| 201 | + } |
| 202 | + } |
| 203 | + |
| 204 | +#-------------------------------------------------------------------------- |
| 205 | +# Main |
| 206 | +#-------------------------------------------------------------------------- |
| 207 | + |
| 208 | +def main(ctx): |
| 209 | + definitions = [] |
| 210 | + |
| 211 | + for triplet in triplets: |
| 212 | + definitions.append(build_pipeline(triplet)) |
| 213 | + |
| 214 | + return definitions |
0 commit comments