Siddharth Shukla | 8e64d90 | 2017-03-12 19:50:18 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 2 | # Copyright 2016, Google Inc. |
| 3 | # All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are |
| 7 | # met: |
| 8 | # |
| 9 | # * Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # * Redistributions in binary form must reproduce the above |
| 12 | # copyright notice, this list of conditions and the following disclaimer |
| 13 | # in the documentation and/or other materials provided with the |
| 14 | # distribution. |
| 15 | # * Neither the name of Google Inc. nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | """Definition of targets to build artifacts.""" |
| 32 | |
Masood Malekghassemi | 0e12875 | 2016-07-15 14:36:54 -0700 | [diff] [blame] | 33 | import os.path |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 34 | import random |
| 35 | import string |
Masood Malekghassemi | 0e12875 | 2016-07-15 14:36:54 -0700 | [diff] [blame] | 36 | import sys |
| 37 | |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 38 | sys.path.insert(0, os.path.abspath('..')) |
| 39 | import python_utils.jobset as jobset |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 40 | |
| 41 | |
| 42 | def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={}, |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 43 | flake_retries=0, timeout_retries=0, timeout_seconds=30*60, |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame^] | 44 | docker_base_image=None, extra_docker_args=None): |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 45 | """Creates jobspec for a task running under docker.""" |
| 46 | environ = environ.copy() |
| 47 | environ['RUN_COMMAND'] = shell_command |
| 48 | |
| 49 | docker_args=[] |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 50 | for k,v in environ.items(): |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 51 | docker_args += ['-e', '%s=%s' % (k, v)] |
| 52 | docker_env = {'DOCKERFILE_DIR': dockerfile_dir, |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 53 | 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh', |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 54 | 'OUTPUT_DIR': 'artifacts'} |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 55 | |
| 56 | if docker_base_image is not None: |
| 57 | docker_env['DOCKER_BASE_IMAGE'] = docker_base_image |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame^] | 58 | if extra_docker_args is not None: |
| 59 | docker_env['EXTRA_DOCKER_ARGS'] = extra_docker_args |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 60 | jobspec = jobset.JobSpec( |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 61 | cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args, |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 62 | environ=docker_env, |
| 63 | shortname='build_artifact.%s' % (name), |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 64 | timeout_seconds=timeout_seconds, |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 65 | flake_retries=flake_retries, |
| 66 | timeout_retries=timeout_retries) |
| 67 | return jobspec |
| 68 | |
| 69 | |
| 70 | def create_jobspec(name, cmdline, environ=None, shell=False, |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 71 | flake_retries=0, timeout_retries=0, timeout_seconds=30*60): |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 72 | """Creates jobspec.""" |
| 73 | jobspec = jobset.JobSpec( |
| 74 | cmdline=cmdline, |
| 75 | environ=environ, |
| 76 | shortname='build_artifact.%s' % (name), |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 77 | timeout_seconds=timeout_seconds, |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 78 | flake_retries=flake_retries, |
| 79 | timeout_retries=timeout_retries, |
| 80 | shell=shell) |
| 81 | return jobspec |
| 82 | |
| 83 | |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 84 | _MACOS_COMPAT_FLAG = '-mmacosx-version-min=10.7' |
| 85 | |
| 86 | _ARCH_FLAG_MAP = { |
| 87 | 'x86': '-m32', |
| 88 | 'x64': '-m64' |
| 89 | } |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 90 | |
Nicolas "Pixel" Noble | 6a4e473 | 2016-02-20 01:30:57 +0100 | [diff] [blame] | 91 | |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 92 | class PythonArtifact: |
| 93 | """Builds Python artifacts.""" |
| 94 | |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 95 | def __init__(self, platform, arch, py_version): |
| 96 | self.name = 'python_%s_%s_%s' % (platform, arch, py_version) |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 97 | self.platform = platform |
| 98 | self.arch = arch |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 99 | self.labels = ['artifact', 'python', platform, arch, py_version] |
| 100 | self.py_version = py_version |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 101 | |
| 102 | def pre_build_jobspecs(self): |
Masood Malekghassemi | 0e12875 | 2016-07-15 14:36:54 -0700 | [diff] [blame] | 103 | return [] |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 104 | |
| 105 | def build_jobspec(self): |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 106 | environ = {} |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame^] | 107 | if self.platform == 'linux_extra': |
| 108 | # Raspberry Pi build |
| 109 | environ['PYTHON'] = '/usr/local/bin/python{}'.format(self.py_version) |
| 110 | environ['PIP'] = '/usr/local/bin/pip{}'.format(self.py_version) |
| 111 | # https://github.com/resin-io-projects/armv7hf-debian-qemu/issues/9 |
| 112 | # A QEMU bug causes submodule update to hang, so we copy directly |
| 113 | environ['RELATIVE_COPY_PATH'] = '.' |
| 114 | extra_args = ' --entrypoint=/usr/bin/qemu-arm-static ' |
| 115 | return create_docker_jobspec(self.name, |
| 116 | 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), |
| 117 | 'tools/run_tests/artifacts/build_artifact_python.sh', |
| 118 | environ=environ, |
| 119 | timeout_seconds=60*60*5, |
| 120 | docker_base_image='quay.io/grpc/raspbian_{}'.format(self.arch), |
| 121 | extra_docker_args=extra_args) |
| 122 | elif self.platform == 'linux': |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 123 | if self.arch == 'x86': |
| 124 | environ['SETARCH_CMD'] = 'linux32' |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 125 | # Inside the manylinux container, the python installations are located in |
| 126 | # special places... |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 127 | environ['PYTHON'] = '/opt/python/{}/bin/python'.format(self.py_version) |
| 128 | environ['PIP'] = '/opt/python/{}/bin/pip'.format(self.py_version) |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 129 | # Platform autodetection for the manylinux1 image breaks so we set the |
| 130 | # defines ourselves. |
| 131 | # TODO(atash) get better platform-detection support in core so we don't |
| 132 | # need to do this manually... |
Masood Malekghassemi | f4c70ca | 2016-05-05 19:14:05 -0700 | [diff] [blame] | 133 | environ['CFLAGS'] = '-DGPR_MANYLINUX1=1' |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 134 | environ['GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS'] = 'TRUE' |
| 135 | environ['GRPC_BUILD_MANYLINUX_WHEEL'] = 'TRUE' |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 136 | return create_docker_jobspec(self.name, |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 137 | 'tools/dockerfile/grpc_artifact_python_manylinux_%s' % self.arch, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 138 | 'tools/run_tests/artifacts/build_artifact_python.sh', |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 139 | environ=environ, |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 140 | timeout_seconds=60*60, |
| 141 | docker_base_image='quay.io/pypa/manylinux1_i686' if self.arch == 'x86' else 'quay.io/pypa/manylinux1_x86_64') |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 142 | elif self.platform == 'windows': |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 143 | if 'Python27' in self.py_version or 'Python34' in self.py_version: |
| 144 | environ['EXT_COMPILER'] = 'mingw32' |
| 145 | else: |
| 146 | environ['EXT_COMPILER'] = 'msvc' |
| 147 | # For some reason, the batch script %random% always runs with the same |
| 148 | # seed. We create a random temp-dir here |
| 149 | dir = ''.join(random.choice(string.ascii_uppercase) for _ in range(10)) |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 150 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 151 | ['tools\\run_tests\\artifacts\\build_artifact_python.bat', |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 152 | self.py_version, |
| 153 | '32' if self.arch == 'x86' else '64', |
| 154 | dir |
Nicolas "Pixel" Noble | 6a4e473 | 2016-02-20 01:30:57 +0100 | [diff] [blame] | 155 | ], |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 156 | environ=environ, |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 157 | shell=True) |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 158 | else: |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 159 | environ['PYTHON'] = self.py_version |
| 160 | environ['SKIP_PIP_INSTALL'] = 'TRUE' |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 161 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 162 | ['tools/run_tests/artifacts/build_artifact_python.sh'], |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 163 | environ=environ) |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 164 | |
| 165 | def __str__(self): |
| 166 | return self.name |
| 167 | |
| 168 | |
Jan Tattermusch | 4437213 | 2016-02-01 16:20:03 -0800 | [diff] [blame] | 169 | class RubyArtifact: |
| 170 | """Builds ruby native gem.""" |
| 171 | |
| 172 | def __init__(self, platform, arch): |
| 173 | self.name = 'ruby_native_gem_%s_%s' % (platform, arch) |
| 174 | self.platform = platform |
| 175 | self.arch = arch |
| 176 | self.labels = ['artifact', 'ruby', platform, arch] |
| 177 | |
| 178 | def pre_build_jobspecs(self): |
| 179 | return [] |
| 180 | |
| 181 | def build_jobspec(self): |
| 182 | if self.platform == 'windows': |
| 183 | raise Exception("Not supported yet") |
| 184 | else: |
| 185 | if self.platform == 'linux': |
| 186 | environ = {} |
| 187 | if self.arch == 'x86': |
Jan Tattermusch | 7cf8bf4 | 2016-02-03 13:41:07 -0800 | [diff] [blame] | 188 | environ['SETARCH_CMD'] = 'linux32' |
Jan Tattermusch | 4437213 | 2016-02-01 16:20:03 -0800 | [diff] [blame] | 189 | return create_docker_jobspec(self.name, |
| 190 | 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 191 | 'tools/run_tests/artifacts/build_artifact_ruby.sh', |
Jan Tattermusch | 4437213 | 2016-02-01 16:20:03 -0800 | [diff] [blame] | 192 | environ=environ) |
| 193 | else: |
| 194 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 195 | ['tools/run_tests/artifacts/build_artifact_ruby.sh']) |
Jan Tattermusch | 4437213 | 2016-02-01 16:20:03 -0800 | [diff] [blame] | 196 | |
| 197 | |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 198 | class CSharpExtArtifact: |
| 199 | """Builds C# native extension library""" |
| 200 | |
| 201 | def __init__(self, platform, arch): |
| 202 | self.name = 'csharp_ext_%s_%s' % (platform, arch) |
| 203 | self.platform = platform |
| 204 | self.arch = arch |
| 205 | self.labels = ['artifact', 'csharp', platform, arch] |
| 206 | |
| 207 | def pre_build_jobspecs(self): |
Jan Tattermusch | 6dce2f5 | 2017-02-09 17:03:03 -0800 | [diff] [blame] | 208 | return [] |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 209 | |
| 210 | def build_jobspec(self): |
| 211 | if self.platform == 'windows': |
Jan Tattermusch | 6dce2f5 | 2017-02-09 17:03:03 -0800 | [diff] [blame] | 212 | cmake_arch_option = 'Win32' if self.arch == 'x86' else self.arch |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 213 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 214 | ['tools\\run_tests\\artifacts\\build_artifact_csharp.bat', |
Jan Tattermusch | 6dce2f5 | 2017-02-09 17:03:03 -0800 | [diff] [blame] | 215 | cmake_arch_option], |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 216 | shell=True) |
| 217 | else: |
| 218 | environ = {'CONFIG': 'opt', |
| 219 | 'EMBED_OPENSSL': 'true', |
Craig Tiller | 71ea4a1 | 2016-02-04 15:06:41 -0800 | [diff] [blame] | 220 | 'EMBED_ZLIB': 'true', |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 221 | 'CFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE', |
| 222 | 'LDFLAGS': ''} |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 223 | if self.platform == 'linux': |
| 224 | return create_docker_jobspec(self.name, |
| 225 | 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 226 | 'tools/run_tests/artifacts/build_artifact_csharp.sh', |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 227 | environ=environ) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 228 | else: |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 229 | archflag = _ARCH_FLAG_MAP[self.arch] |
| 230 | environ['CFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG) |
| 231 | environ['LDFLAGS'] += ' %s' % archflag |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 232 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 233 | ['tools/run_tests/artifacts/build_artifact_csharp.sh'], |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 234 | environ=environ) |
| 235 | |
| 236 | def __str__(self): |
| 237 | return self.name |
| 238 | |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 239 | |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 240 | node_gyp_arch_map = { |
| 241 | 'x86': 'ia32', |
| 242 | 'x64': 'x64' |
| 243 | } |
| 244 | |
| 245 | class NodeExtArtifact: |
| 246 | """Builds Node native extension""" |
| 247 | |
| 248 | def __init__(self, platform, arch): |
| 249 | self.name = 'node_ext_{0}_{1}'.format(platform, arch) |
| 250 | self.platform = platform |
| 251 | self.arch = arch |
| 252 | self.gyp_arch = node_gyp_arch_map[arch] |
| 253 | self.labels = ['artifact', 'node', platform, arch] |
| 254 | |
| 255 | def pre_build_jobspecs(self): |
| 256 | return [] |
| 257 | |
| 258 | def build_jobspec(self): |
| 259 | if self.platform == 'windows': |
| 260 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 261 | ['tools\\run_tests\\artifacts\\build_artifact_node.bat', |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 262 | self.gyp_arch], |
| 263 | shell=True) |
| 264 | else: |
| 265 | if self.platform == 'linux': |
| 266 | return create_docker_jobspec( |
| 267 | self.name, |
| 268 | 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 269 | 'tools/run_tests/artifacts/build_artifact_node.sh {}'.format(self.gyp_arch)) |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 270 | else: |
| 271 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 272 | ['tools/run_tests/artifacts/build_artifact_node.sh', |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 273 | self.gyp_arch]) |
| 274 | |
Stanley Cheung | bf74d69 | 2016-02-23 22:39:25 -0800 | [diff] [blame] | 275 | class PHPArtifact: |
| 276 | """Builds PHP PECL package""" |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 277 | |
| 278 | def __init__(self, platform, arch): |
Stanley Cheung | bf74d69 | 2016-02-23 22:39:25 -0800 | [diff] [blame] | 279 | self.name = 'php_pecl_package_{0}_{1}'.format(platform, arch) |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 280 | self.platform = platform |
| 281 | self.arch = arch |
| 282 | self.labels = ['artifact', 'php', platform, arch] |
| 283 | |
| 284 | def pre_build_jobspecs(self): |
| 285 | return [] |
| 286 | |
| 287 | def build_jobspec(self): |
Stanley Cheung | 80db5be | 2016-02-24 21:35:56 -0800 | [diff] [blame] | 288 | if self.platform == 'linux': |
| 289 | return create_docker_jobspec( |
| 290 | self.name, |
| 291 | 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 292 | 'tools/run_tests/artifacts/build_artifact_php.sh') |
Stanley Cheung | 80db5be | 2016-02-24 21:35:56 -0800 | [diff] [blame] | 293 | else: |
| 294 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 295 | ['tools/run_tests/artifacts/build_artifact_php.sh']) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 296 | |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 297 | class ProtocArtifact: |
| 298 | """Builds protoc and protoc-plugin artifacts""" |
| 299 | |
| 300 | def __init__(self, platform, arch): |
| 301 | self.name = 'protoc_%s_%s' % (platform, arch) |
| 302 | self.platform = platform |
| 303 | self.arch = arch |
| 304 | self.labels = ['artifact', 'protoc', platform, arch] |
| 305 | |
| 306 | def pre_build_jobspecs(self): |
| 307 | return [] |
| 308 | |
| 309 | def build_jobspec(self): |
| 310 | if self.platform != 'windows': |
| 311 | cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch] |
Jan Tattermusch | e7b7d86 | 2016-02-19 09:49:35 -0800 | [diff] [blame] | 312 | ldflags = '%s' % _ARCH_FLAG_MAP[self.arch] |
| 313 | if self.platform != 'macos': |
Jan Tattermusch | 07591a5 | 2016-02-19 10:28:24 -0800 | [diff] [blame] | 314 | ldflags += ' -static-libgcc -static-libstdc++ -s' |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 315 | environ={'CONFIG': 'opt', |
| 316 | 'CXXFLAGS': cxxflags, |
| 317 | 'LDFLAGS': ldflags, |
| 318 | 'PROTOBUF_LDFLAGS_EXTRA': ldflags} |
| 319 | if self.platform == 'linux': |
| 320 | return create_docker_jobspec(self.name, |
| 321 | 'tools/dockerfile/grpc_artifact_protoc', |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 322 | 'tools/run_tests/artifacts/build_artifact_protoc.sh', |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 323 | environ=environ) |
| 324 | else: |
Jan Tattermusch | e7b7d86 | 2016-02-19 09:49:35 -0800 | [diff] [blame] | 325 | environ['CXXFLAGS'] += ' -std=c++11 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 326 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 327 | ['tools/run_tests/artifacts/build_artifact_protoc.sh'], |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 328 | environ=environ) |
| 329 | else: |
Jan Tattermusch | 6d15982 | 2016-02-19 16:03:22 -0800 | [diff] [blame] | 330 | generator = 'Visual Studio 12 Win64' if self.arch == 'x64' else 'Visual Studio 12' |
| 331 | vcplatform = 'x64' if self.arch == 'x64' else 'Win32' |
| 332 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 333 | ['tools\\run_tests\\artifacts\\build_artifact_protoc.bat'], |
Jan Tattermusch | 6d15982 | 2016-02-19 16:03:22 -0800 | [diff] [blame] | 334 | environ={'generator': generator, |
| 335 | 'Platform': vcplatform}) |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 336 | |
| 337 | def __str__(self): |
| 338 | return self.name |
| 339 | |
| 340 | |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 341 | def targets(): |
| 342 | """Gets list of supported targets""" |
murgatroid99 | 41a9e83 | 2016-02-03 09:47:35 -0800 | [diff] [blame] | 343 | return ([Cls(platform, arch) |
Jan Tattermusch | 6d15982 | 2016-02-19 16:03:22 -0800 | [diff] [blame] | 344 | for Cls in (CSharpExtArtifact, NodeExtArtifact, ProtocArtifact) |
murgatroid99 | 41a9e83 | 2016-02-03 09:47:35 -0800 | [diff] [blame] | 345 | for platform in ('linux', 'macos', 'windows') |
| 346 | for arch in ('x86', 'x64')] + |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 347 | [PythonArtifact('linux', 'x86', 'cp27-cp27m'), |
| 348 | PythonArtifact('linux', 'x86', 'cp27-cp27mu'), |
| 349 | PythonArtifact('linux', 'x86', 'cp34-cp34m'), |
| 350 | PythonArtifact('linux', 'x86', 'cp35-cp35m'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 351 | PythonArtifact('linux', 'x86', 'cp36-cp36m'), |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame^] | 352 | PythonArtifact('linux_extra', 'armv7', '2.7'), |
| 353 | PythonArtifact('linux_extra', 'armv7', '3.4'), |
| 354 | PythonArtifact('linux_extra', 'armv7', '3.5'), |
| 355 | PythonArtifact('linux_extra', 'armv7', '3.6'), |
| 356 | PythonArtifact('linux_extra', 'armv6', '2.7'), |
| 357 | PythonArtifact('linux_extra', 'armv6', '3.4'), |
| 358 | PythonArtifact('linux_extra', 'armv6', '3.5'), |
| 359 | PythonArtifact('linux_extra', 'armv6', '3.6'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 360 | PythonArtifact('linux', 'x64', 'cp27-cp27m'), |
| 361 | PythonArtifact('linux', 'x64', 'cp27-cp27mu'), |
| 362 | PythonArtifact('linux', 'x64', 'cp34-cp34m'), |
| 363 | PythonArtifact('linux', 'x64', 'cp35-cp35m'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 364 | PythonArtifact('linux', 'x64', 'cp36-cp36m'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 365 | PythonArtifact('macos', 'x64', 'python2.7'), |
| 366 | PythonArtifact('macos', 'x64', 'python3.4'), |
| 367 | PythonArtifact('macos', 'x64', 'python3.5'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 368 | PythonArtifact('macos', 'x64', 'python3.6'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 369 | PythonArtifact('windows', 'x86', 'Python27_32bits'), |
| 370 | PythonArtifact('windows', 'x86', 'Python34_32bits'), |
| 371 | PythonArtifact('windows', 'x86', 'Python35_32bits'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 372 | PythonArtifact('windows', 'x86', 'Python36_32bits'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 373 | PythonArtifact('windows', 'x64', 'Python27'), |
| 374 | PythonArtifact('windows', 'x64', 'Python34'), |
| 375 | PythonArtifact('windows', 'x64', 'Python35'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 376 | PythonArtifact('windows', 'x64', 'Python36'), |
murgatroid99 | 41a9e83 | 2016-02-03 09:47:35 -0800 | [diff] [blame] | 377 | RubyArtifact('linux', 'x86'), |
murgatroid99 | 33c808b | 2016-02-03 15:27:41 -0800 | [diff] [blame] | 378 | RubyArtifact('linux', 'x64'), |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 379 | RubyArtifact('macos', 'x64'), |
Stanley Cheung | bf74d69 | 2016-02-23 22:39:25 -0800 | [diff] [blame] | 380 | PHPArtifact('linux', 'x64'), |
| 381 | PHPArtifact('macos', 'x64')]) |