Siddharth Shukla | 8e64d90 | 2017-03-12 19:50:18 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 2 | # Copyright 2016 gRPC authors. |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 3 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 7 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 9 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 15 | |
| 16 | """Definition of targets to build artifacts.""" |
| 17 | |
Masood Malekghassemi | 0e12875 | 2016-07-15 14:36:54 -0700 | [diff] [blame] | 18 | import os.path |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 19 | import random |
| 20 | import string |
Masood Malekghassemi | 0e12875 | 2016-07-15 14:36:54 -0700 | [diff] [blame] | 21 | import sys |
| 22 | |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 23 | sys.path.insert(0, os.path.abspath('..')) |
| 24 | import python_utils.jobset as jobset |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 25 | |
| 26 | |
| 27 | def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={}, |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 28 | flake_retries=0, timeout_retries=0, timeout_seconds=30*60, |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame] | 29 | docker_base_image=None, extra_docker_args=None): |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 30 | """Creates jobspec for a task running under docker.""" |
| 31 | environ = environ.copy() |
| 32 | environ['RUN_COMMAND'] = shell_command |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 33 | environ['ARTIFACTS_OUT'] = 'artifacts/%s' % name |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 34 | |
| 35 | docker_args=[] |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 36 | for k,v in environ.items(): |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 37 | docker_args += ['-e', '%s=%s' % (k, v)] |
| 38 | docker_env = {'DOCKERFILE_DIR': dockerfile_dir, |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 39 | 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh', |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 40 | 'OUTPUT_DIR': 'artifacts'} |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 41 | |
| 42 | if docker_base_image is not None: |
| 43 | docker_env['DOCKER_BASE_IMAGE'] = docker_base_image |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame] | 44 | if extra_docker_args is not None: |
| 45 | docker_env['EXTRA_DOCKER_ARGS'] = extra_docker_args |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 46 | jobspec = jobset.JobSpec( |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 47 | cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args, |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 48 | environ=docker_env, |
| 49 | shortname='build_artifact.%s' % (name), |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 50 | timeout_seconds=timeout_seconds, |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 51 | flake_retries=flake_retries, |
| 52 | timeout_retries=timeout_retries) |
| 53 | return jobspec |
| 54 | |
| 55 | |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 56 | def create_jobspec(name, cmdline, environ={}, shell=False, |
| 57 | flake_retries=0, timeout_retries=0, timeout_seconds=30*60, |
Jan Tattermusch | edc06e7 | 2017-05-11 21:50:13 +0200 | [diff] [blame] | 58 | use_workspace=False, |
| 59 | cpu_cost=1.0): |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 60 | """Creates jobspec.""" |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 61 | environ = environ.copy() |
| 62 | if use_workspace: |
| 63 | environ['WORKSPACE_NAME'] = 'workspace_%s' % name |
| 64 | environ['ARTIFACTS_OUT'] = os.path.join('..', 'artifacts', name) |
| 65 | cmdline = ['bash', |
| 66 | 'tools/run_tests/artifacts/run_in_workspace.sh'] + cmdline |
| 67 | else: |
| 68 | environ['ARTIFACTS_OUT'] = os.path.join('artifacts', name) |
| 69 | |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 70 | jobspec = jobset.JobSpec( |
| 71 | cmdline=cmdline, |
| 72 | environ=environ, |
| 73 | shortname='build_artifact.%s' % (name), |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 74 | timeout_seconds=timeout_seconds, |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 75 | flake_retries=flake_retries, |
| 76 | timeout_retries=timeout_retries, |
Jan Tattermusch | edc06e7 | 2017-05-11 21:50:13 +0200 | [diff] [blame] | 77 | shell=shell, |
| 78 | cpu_cost=cpu_cost) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 79 | return jobspec |
| 80 | |
| 81 | |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 82 | _MACOS_COMPAT_FLAG = '-mmacosx-version-min=10.7' |
| 83 | |
| 84 | _ARCH_FLAG_MAP = { |
| 85 | 'x86': '-m32', |
| 86 | 'x64': '-m64' |
| 87 | } |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 88 | |
Nicolas "Pixel" Noble | 6a4e473 | 2016-02-20 01:30:57 +0100 | [diff] [blame] | 89 | |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 90 | class PythonArtifact: |
| 91 | """Builds Python artifacts.""" |
| 92 | |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 93 | def __init__(self, platform, arch, py_version): |
| 94 | self.name = 'python_%s_%s_%s' % (platform, arch, py_version) |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 95 | self.platform = platform |
| 96 | self.arch = arch |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 97 | self.labels = ['artifact', 'python', platform, arch, py_version] |
| 98 | self.py_version = py_version |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 99 | |
| 100 | def pre_build_jobspecs(self): |
Masood Malekghassemi | 0e12875 | 2016-07-15 14:36:54 -0700 | [diff] [blame] | 101 | return [] |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 102 | |
| 103 | def build_jobspec(self): |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 104 | environ = {} |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame] | 105 | if self.platform == 'linux_extra': |
| 106 | # Raspberry Pi build |
| 107 | environ['PYTHON'] = '/usr/local/bin/python{}'.format(self.py_version) |
| 108 | environ['PIP'] = '/usr/local/bin/pip{}'.format(self.py_version) |
| 109 | # https://github.com/resin-io-projects/armv7hf-debian-qemu/issues/9 |
| 110 | # A QEMU bug causes submodule update to hang, so we copy directly |
| 111 | environ['RELATIVE_COPY_PATH'] = '.' |
| 112 | extra_args = ' --entrypoint=/usr/bin/qemu-arm-static ' |
| 113 | return create_docker_jobspec(self.name, |
| 114 | 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), |
| 115 | 'tools/run_tests/artifacts/build_artifact_python.sh', |
| 116 | environ=environ, |
| 117 | timeout_seconds=60*60*5, |
| 118 | docker_base_image='quay.io/grpc/raspbian_{}'.format(self.arch), |
| 119 | extra_docker_args=extra_args) |
| 120 | elif self.platform == 'linux': |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 121 | if self.arch == 'x86': |
| 122 | environ['SETARCH_CMD'] = 'linux32' |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 123 | # Inside the manylinux container, the python installations are located in |
| 124 | # special places... |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 125 | environ['PYTHON'] = '/opt/python/{}/bin/python'.format(self.py_version) |
| 126 | environ['PIP'] = '/opt/python/{}/bin/pip'.format(self.py_version) |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 127 | # Platform autodetection for the manylinux1 image breaks so we set the |
| 128 | # defines ourselves. |
| 129 | # TODO(atash) get better platform-detection support in core so we don't |
| 130 | # need to do this manually... |
Masood Malekghassemi | f4c70ca | 2016-05-05 19:14:05 -0700 | [diff] [blame] | 131 | environ['CFLAGS'] = '-DGPR_MANYLINUX1=1' |
Masood Malekghassemi | aff6936 | 2016-09-21 15:10:36 -0700 | [diff] [blame] | 132 | environ['GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS'] = 'TRUE' |
| 133 | environ['GRPC_BUILD_MANYLINUX_WHEEL'] = 'TRUE' |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 134 | return create_docker_jobspec(self.name, |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 135 | 'tools/dockerfile/grpc_artifact_python_manylinux_%s' % self.arch, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 136 | 'tools/run_tests/artifacts/build_artifact_python.sh', |
Masood Malekghassemi | 027835f | 2016-07-15 22:31:50 -0700 | [diff] [blame] | 137 | environ=environ, |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 138 | timeout_seconds=60*60, |
| 139 | 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] | 140 | elif self.platform == 'windows': |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 141 | if 'Python27' in self.py_version or 'Python34' in self.py_version: |
| 142 | environ['EXT_COMPILER'] = 'mingw32' |
| 143 | else: |
| 144 | environ['EXT_COMPILER'] = 'msvc' |
| 145 | # For some reason, the batch script %random% always runs with the same |
| 146 | # seed. We create a random temp-dir here |
| 147 | dir = ''.join(random.choice(string.ascii_uppercase) for _ in range(10)) |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 148 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 149 | ['tools\\run_tests\\artifacts\\build_artifact_python.bat', |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 150 | self.py_version, |
Jan Tattermusch | 5c74d90 | 2017-07-04 14:49:23 +0200 | [diff] [blame] | 151 | '32' if self.arch == 'x86' else '64'], |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 152 | environ=environ, |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 153 | use_workspace=True) |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 154 | else: |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 155 | environ['PYTHON'] = self.py_version |
| 156 | environ['SKIP_PIP_INSTALL'] = 'TRUE' |
Nicolas "Pixel" Noble | de808bb | 2016-02-18 01:13:14 +0100 | [diff] [blame] | 157 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 158 | ['tools/run_tests/artifacts/build_artifact_python.sh'], |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 159 | environ=environ, |
| 160 | use_workspace=True) |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 161 | |
| 162 | def __str__(self): |
| 163 | return self.name |
| 164 | |
| 165 | |
Jan Tattermusch | 4437213 | 2016-02-01 16:20:03 -0800 | [diff] [blame] | 166 | class RubyArtifact: |
| 167 | """Builds ruby native gem.""" |
| 168 | |
| 169 | def __init__(self, platform, arch): |
| 170 | self.name = 'ruby_native_gem_%s_%s' % (platform, arch) |
| 171 | self.platform = platform |
| 172 | self.arch = arch |
| 173 | self.labels = ['artifact', 'ruby', platform, arch] |
| 174 | |
| 175 | def pre_build_jobspecs(self): |
| 176 | return [] |
| 177 | |
| 178 | def build_jobspec(self): |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 179 | # Ruby build uses docker internally and docker cannot be nested. |
| 180 | # We are using a custom workspace instead. |
| 181 | return create_jobspec(self.name, |
| 182 | ['tools/run_tests/artifacts/build_artifact_ruby.sh'], |
| 183 | use_workspace=True) |
Jan Tattermusch | 4437213 | 2016-02-01 16:20:03 -0800 | [diff] [blame] | 184 | |
| 185 | |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 186 | class CSharpExtArtifact: |
| 187 | """Builds C# native extension library""" |
| 188 | |
| 189 | def __init__(self, platform, arch): |
| 190 | self.name = 'csharp_ext_%s_%s' % (platform, arch) |
| 191 | self.platform = platform |
| 192 | self.arch = arch |
| 193 | self.labels = ['artifact', 'csharp', platform, arch] |
| 194 | |
| 195 | def pre_build_jobspecs(self): |
Jan Tattermusch | 6dce2f5 | 2017-02-09 17:03:03 -0800 | [diff] [blame] | 196 | return [] |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 197 | |
| 198 | def build_jobspec(self): |
| 199 | if self.platform == 'windows': |
Jan Tattermusch | 6dce2f5 | 2017-02-09 17:03:03 -0800 | [diff] [blame] | 200 | cmake_arch_option = 'Win32' if self.arch == 'x86' else self.arch |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 201 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 202 | ['tools\\run_tests\\artifacts\\build_artifact_csharp.bat', |
Jan Tattermusch | 6dce2f5 | 2017-02-09 17:03:03 -0800 | [diff] [blame] | 203 | cmake_arch_option], |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 204 | use_workspace=True) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 205 | else: |
| 206 | environ = {'CONFIG': 'opt', |
| 207 | 'EMBED_OPENSSL': 'true', |
Craig Tiller | 71ea4a1 | 2016-02-04 15:06:41 -0800 | [diff] [blame] | 208 | 'EMBED_ZLIB': 'true', |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 209 | 'CFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE', |
Jan Tattermusch | 1d00ccc | 2017-05-09 16:28:38 +0200 | [diff] [blame] | 210 | 'CXXFLAGS': '-DGPR_BACKWARDS_COMPATIBILITY_MODE', |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 211 | 'LDFLAGS': ''} |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 212 | if self.platform == 'linux': |
| 213 | return create_docker_jobspec(self.name, |
| 214 | 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 215 | 'tools/run_tests/artifacts/build_artifact_csharp.sh', |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 216 | environ=environ) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 217 | else: |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 218 | archflag = _ARCH_FLAG_MAP[self.arch] |
| 219 | environ['CFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG) |
Jan Tattermusch | 1d00ccc | 2017-05-09 16:28:38 +0200 | [diff] [blame] | 220 | environ['CXXFLAGS'] += ' %s %s' % (archflag, _MACOS_COMPAT_FLAG) |
Jan Tattermusch | 60cbec7 | 2016-02-26 13:47:16 -0800 | [diff] [blame] | 221 | environ['LDFLAGS'] += ' %s' % archflag |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 222 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 223 | ['tools/run_tests/artifacts/build_artifact_csharp.sh'], |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 224 | environ=environ, |
| 225 | use_workspace=True) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 226 | |
| 227 | def __str__(self): |
| 228 | return self.name |
| 229 | |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 230 | |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 231 | node_gyp_arch_map = { |
| 232 | 'x86': 'ia32', |
| 233 | 'x64': 'x64' |
| 234 | } |
| 235 | |
| 236 | class NodeExtArtifact: |
| 237 | """Builds Node native extension""" |
| 238 | |
| 239 | def __init__(self, platform, arch): |
| 240 | self.name = 'node_ext_{0}_{1}'.format(platform, arch) |
| 241 | self.platform = platform |
| 242 | self.arch = arch |
| 243 | self.gyp_arch = node_gyp_arch_map[arch] |
| 244 | self.labels = ['artifact', 'node', platform, arch] |
| 245 | |
| 246 | def pre_build_jobspecs(self): |
| 247 | return [] |
| 248 | |
| 249 | def build_jobspec(self): |
| 250 | if self.platform == 'windows': |
Jan Tattermusch | edc06e7 | 2017-05-11 21:50:13 +0200 | [diff] [blame] | 251 | # Simultaneous builds of node on the same windows machine are flaky. |
| 252 | # Set x86 build as exclusive to make sure there is only one node build |
| 253 | # at a time. See https://github.com/grpc/grpc/issues/8293 |
| 254 | cpu_cost = 1e6 if self.arch != 'x64' else 1.0 |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 255 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 256 | ['tools\\run_tests\\artifacts\\build_artifact_node.bat', |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 257 | self.gyp_arch], |
Jan Tattermusch | edc06e7 | 2017-05-11 21:50:13 +0200 | [diff] [blame] | 258 | use_workspace=True, |
| 259 | cpu_cost=cpu_cost) |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 260 | else: |
| 261 | if self.platform == 'linux': |
| 262 | return create_docker_jobspec( |
| 263 | self.name, |
| 264 | 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), |
murgatroid99 | 17e0168 | 2017-06-09 16:26:14 -0700 | [diff] [blame] | 265 | 'tools/run_tests/artifacts/build_artifact_node.sh {} {}'.format( |
| 266 | self.gyp_arch, self.platform)) |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 267 | else: |
| 268 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 269 | ['tools/run_tests/artifacts/build_artifact_node.sh', |
murgatroid99 | 17e0168 | 2017-06-09 16:26:14 -0700 | [diff] [blame] | 270 | self.gyp_arch, self.platform], |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 271 | use_workspace=True) |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 272 | |
Stanley Cheung | bf74d69 | 2016-02-23 22:39:25 -0800 | [diff] [blame] | 273 | class PHPArtifact: |
| 274 | """Builds PHP PECL package""" |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 275 | |
| 276 | def __init__(self, platform, arch): |
Stanley Cheung | bf74d69 | 2016-02-23 22:39:25 -0800 | [diff] [blame] | 277 | self.name = 'php_pecl_package_{0}_{1}'.format(platform, arch) |
Stanley Cheung | 5adb71f | 2016-02-13 00:03:02 -0800 | [diff] [blame] | 278 | self.platform = platform |
| 279 | self.arch = arch |
| 280 | self.labels = ['artifact', 'php', platform, arch] |
| 281 | |
| 282 | def pre_build_jobspecs(self): |
| 283 | return [] |
| 284 | |
| 285 | def build_jobspec(self): |
Stanley Cheung | 80db5be | 2016-02-24 21:35:56 -0800 | [diff] [blame] | 286 | if self.platform == 'linux': |
| 287 | return create_docker_jobspec( |
| 288 | self.name, |
| 289 | 'tools/dockerfile/grpc_artifact_linux_{}'.format(self.arch), |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 290 | 'tools/run_tests/artifacts/build_artifact_php.sh') |
Stanley Cheung | 80db5be | 2016-02-24 21:35:56 -0800 | [diff] [blame] | 291 | else: |
| 292 | return create_jobspec(self.name, |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 293 | ['tools/run_tests/artifacts/build_artifact_php.sh'], |
| 294 | use_workspace=True) |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 295 | |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 296 | class ProtocArtifact: |
| 297 | """Builds protoc and protoc-plugin artifacts""" |
| 298 | |
| 299 | def __init__(self, platform, arch): |
| 300 | self.name = 'protoc_%s_%s' % (platform, arch) |
| 301 | self.platform = platform |
| 302 | self.arch = arch |
| 303 | self.labels = ['artifact', 'protoc', platform, arch] |
| 304 | |
| 305 | def pre_build_jobspecs(self): |
| 306 | return [] |
| 307 | |
| 308 | def build_jobspec(self): |
| 309 | if self.platform != 'windows': |
| 310 | cxxflags = '-DNDEBUG %s' % _ARCH_FLAG_MAP[self.arch] |
Jan Tattermusch | e7b7d86 | 2016-02-19 09:49:35 -0800 | [diff] [blame] | 311 | ldflags = '%s' % _ARCH_FLAG_MAP[self.arch] |
| 312 | if self.platform != 'macos': |
Jan Tattermusch | 07591a5 | 2016-02-19 10:28:24 -0800 | [diff] [blame] | 313 | ldflags += ' -static-libgcc -static-libstdc++ -s' |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 314 | environ={'CONFIG': 'opt', |
| 315 | 'CXXFLAGS': cxxflags, |
| 316 | 'LDFLAGS': ldflags, |
| 317 | 'PROTOBUF_LDFLAGS_EXTRA': ldflags} |
| 318 | if self.platform == 'linux': |
| 319 | return create_docker_jobspec(self.name, |
| 320 | 'tools/dockerfile/grpc_artifact_protoc', |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 321 | 'tools/run_tests/artifacts/build_artifact_protoc.sh', |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 322 | environ=environ) |
| 323 | else: |
Jan Tattermusch | e7b7d86 | 2016-02-19 09:49:35 -0800 | [diff] [blame] | 324 | environ['CXXFLAGS'] += ' -std=c++11 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 325 | return create_jobspec(self.name, |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 326 | ['tools/run_tests/artifacts/build_artifact_protoc.sh'], |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 327 | environ=environ, |
| 328 | use_workspace=True) |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 329 | else: |
murgatroid99 | 17e0168 | 2017-06-09 16:26:14 -0700 | [diff] [blame] | 330 | generator = 'Visual Studio 12 Win64' if self.arch == 'x64' else 'Visual Studio 12' |
Jan Tattermusch | 6d15982 | 2016-02-19 16:03:22 -0800 | [diff] [blame] | 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, |
Jan Tattermusch | 47c7521 | 2017-04-21 13:27:42 +0200 | [diff] [blame] | 335 | 'Platform': vcplatform}, |
| 336 | use_workspace=True) |
Jan Tattermusch | e046f71 | 2016-02-18 16:06:10 -0800 | [diff] [blame] | 337 | |
| 338 | def __str__(self): |
| 339 | return self.name |
| 340 | |
| 341 | |
Jan Tattermusch | be538a1 | 2016-01-28 14:58:15 -0800 | [diff] [blame] | 342 | def targets(): |
| 343 | """Gets list of supported targets""" |
murgatroid99 | 41a9e83 | 2016-02-03 09:47:35 -0800 | [diff] [blame] | 344 | return ([Cls(platform, arch) |
Jan Tattermusch | 6d15982 | 2016-02-19 16:03:22 -0800 | [diff] [blame] | 345 | for Cls in (CSharpExtArtifact, NodeExtArtifact, ProtocArtifact) |
murgatroid99 | 41a9e83 | 2016-02-03 09:47:35 -0800 | [diff] [blame] | 346 | for platform in ('linux', 'macos', 'windows') |
| 347 | for arch in ('x86', 'x64')] + |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 348 | [PythonArtifact('linux', 'x86', 'cp27-cp27m'), |
| 349 | PythonArtifact('linux', 'x86', 'cp27-cp27mu'), |
| 350 | PythonArtifact('linux', 'x86', 'cp34-cp34m'), |
| 351 | PythonArtifact('linux', 'x86', 'cp35-cp35m'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 352 | PythonArtifact('linux', 'x86', 'cp36-cp36m'), |
Ken Payson | 7ff21a6 | 2017-05-10 12:24:13 -0700 | [diff] [blame] | 353 | PythonArtifact('linux_extra', 'armv7', '2.7'), |
| 354 | PythonArtifact('linux_extra', 'armv7', '3.4'), |
| 355 | PythonArtifact('linux_extra', 'armv7', '3.5'), |
| 356 | PythonArtifact('linux_extra', 'armv7', '3.6'), |
| 357 | PythonArtifact('linux_extra', 'armv6', '2.7'), |
| 358 | PythonArtifact('linux_extra', 'armv6', '3.4'), |
| 359 | PythonArtifact('linux_extra', 'armv6', '3.5'), |
| 360 | PythonArtifact('linux_extra', 'armv6', '3.6'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 361 | PythonArtifact('linux', 'x64', 'cp27-cp27m'), |
| 362 | PythonArtifact('linux', 'x64', 'cp27-cp27mu'), |
| 363 | PythonArtifact('linux', 'x64', 'cp34-cp34m'), |
| 364 | PythonArtifact('linux', 'x64', 'cp35-cp35m'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 365 | PythonArtifact('linux', 'x64', 'cp36-cp36m'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 366 | PythonArtifact('macos', 'x64', 'python2.7'), |
| 367 | PythonArtifact('macos', 'x64', 'python3.4'), |
| 368 | PythonArtifact('macos', 'x64', 'python3.5'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 369 | PythonArtifact('macos', 'x64', 'python3.6'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 370 | PythonArtifact('windows', 'x86', 'Python27_32bits'), |
| 371 | PythonArtifact('windows', 'x86', 'Python34_32bits'), |
| 372 | PythonArtifact('windows', 'x86', 'Python35_32bits'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 373 | PythonArtifact('windows', 'x86', 'Python36_32bits'), |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 374 | PythonArtifact('windows', 'x64', 'Python27'), |
| 375 | PythonArtifact('windows', 'x64', 'Python34'), |
| 376 | PythonArtifact('windows', 'x64', 'Python35'), |
Ken Payson | 626fb45 | 2017-02-17 22:52:27 -0800 | [diff] [blame] | 377 | PythonArtifact('windows', 'x64', 'Python36'), |
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')]) |