1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import os
import sys
import tarfile
import buildbot_common
from build_paths import SCRIPT_DIR
SDK_BUILD_DIR = SCRIPT_DIR
MONO_BUILD_DIR = os.path.join(SDK_BUILD_DIR, 'mono_build')
MONO_DIR = os.path.join(MONO_BUILD_DIR, 'nacl-mono')
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument('--arch',
help='Target architecture',
dest='arch',
default='x86-32')
parser.add_argument('--sdk-revision',
help='SDK Revision'
' (default=buildbot revision)',
dest='sdk_revision',
default=None)
parser.add_argument('--sdk-url',
help='SDK Download URL',
dest='sdk_url',
default=None)
parser.add_argument('--install-dir',
help='Install Directory',
dest='install_dir',
default='naclmono')
options = parser.parse_args(args)
assert sys.platform.find('linux') != -1
buildbot_revision = os.environ.get('BUILDBOT_REVISION', '')
build_prefix = options.arch + ' '
buildbot_common.BuildStep(build_prefix + 'Clean Old SDK')
buildbot_common.MakeDir(MONO_BUILD_DIR)
buildbot_common.RemoveDir(os.path.join(MONO_BUILD_DIR, 'pepper_*'))
buildbot_common.BuildStep(build_prefix + 'Setup New SDK')
sdk_dir = None
sdk_revision = options.sdk_revision
sdk_url = options.sdk_url
if not sdk_url:
if not sdk_revision:
assert buildbot_revision
sdk_revision = buildbot_revision.split(':')[0]
sdk_url = 'gs://nativeclient-mirror/nacl/nacl_sdk/'\
'trunk.%s/naclsdk_linux.tar.bz2' % sdk_revision
sdk_url = sdk_url.replace('https://storage.googleapis.com/', 'gs://')
sdk_file = sdk_url.split('/')[-1]
buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', sdk_url, sdk_file],
cwd=MONO_BUILD_DIR)
tar_file = None
try:
tar_file = tarfile.open(os.path.join(MONO_BUILD_DIR, sdk_file))
pepper_dir = os.path.commonprefix(tar_file.getnames())
tar_file.extractall(path=MONO_BUILD_DIR)
sdk_dir = os.path.join(MONO_BUILD_DIR, pepper_dir)
finally:
if tar_file:
tar_file.close()
assert sdk_dir
buildbot_common.BuildStep(build_prefix + 'Checkout Mono')
# TODO(elijahtaylor): Get git URL from master/trigger to make this
# more flexible for building from upstream and release branches.
if options.arch == 'arm':
git_url = 'git://github.com/igotti-google/mono.git'
git_rev = 'arm_nacl'
else:
git_url = 'git://github.com/elijahtaylor/mono.git'
git_rev = 'HEAD'
if buildbot_revision:
# Unfortunately, we use different git branches/revisions
# for ARM and x86 now, so ignore buildbot_revision variable for ARM.
# Need to rethink this approach, if we'll plan to support
# more flexible repo selection mechanism.
if options.arch != 'arm':
git_rev = buildbot_revision.split(':')[1]
# ARM and x86 is built out of different git trees, so distinguish
# them by appending the arch. It also makes 32 and 64 bit x86 separated,
# which is good.
# TODO(olonho): maybe we need to avoid modifications of global.
global MONO_DIR
tag = options.arch
MONO_DIR = "%s-%s" % (MONO_DIR, tag)
if not os.path.exists(MONO_DIR):
buildbot_common.MakeDir(MONO_DIR)
buildbot_common.Run(['git', 'clone', git_url, MONO_DIR])
else:
buildbot_common.Run(['git', 'fetch'], cwd=MONO_DIR)
if git_rev:
buildbot_common.Run(['git', 'checkout', git_rev], cwd=MONO_DIR)
arch_to_bitsize = {'x86-32': '32',
'x86-64': '64',
'arm': 'arm'}
arch_to_output_folder = {'x86-32': 'runtime-x86-32-build',
'x86-64': 'runtime-x86-64-build',
'arm': 'runtime-arm-build'}
buildbot_common.BuildStep(build_prefix + 'Configure Mono')
os.environ['NACL_SDK_ROOT'] = sdk_dir
os.environ['TARGET_ARCH'] = options.arch
os.environ['TARGET_BITSIZE'] = arch_to_bitsize[options.arch]
buildbot_common.Run(['./autogen.sh'], cwd=MONO_DIR)
buildbot_common.Run(['make', 'distclean'], cwd=MONO_DIR)
buildbot_common.BuildStep(build_prefix + 'Build and Install Mono')
nacl_interp_script = os.path.join(SDK_BUILD_DIR, 'nacl_interp_loader_mono.sh')
os.environ['NACL_INTERP_LOADER'] = nacl_interp_script
buildbot_common.Run(['./nacl-mono-runtime.sh',
MONO_DIR, # Mono directory with 'configure'
arch_to_output_folder[options.arch], # Build dir
options.install_dir],
cwd=SDK_BUILD_DIR)
# TODO(elijahtaylor,olonho): Re-enable tests on arm when they compile/run.
if options.arch != 'arm':
buildbot_common.BuildStep(build_prefix + 'Test Mono')
buildbot_common.Run(['make', 'check', '-j8'],
cwd=os.path.join(SDK_BUILD_DIR, arch_to_output_folder[options.arch]))
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
|