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