2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
11 import buildbot_common
12 from build_paths import SCRIPT_DIR
14 SDK_BUILD_DIR = SCRIPT_DIR
15 MONO_BUILD_DIR = os.path.join(SDK_BUILD_DIR, 'mono_build')
16 MONO_DIR = os.path.join(MONO_BUILD_DIR, 'nacl-mono')
20 parser = optparse.OptionParser()
21 parser.add_option('--arch',
22 help='Target architecture',
25 parser.add_option('--sdk-revision',
27 ' (default=buildbot revision)',
30 parser.add_option('--sdk-url',
31 help='SDK Download URL',
34 parser.add_option('--install-dir',
35 help='Install Directory',
38 (options, args) = parser.parse_args(args[1:])
40 assert sys.platform.find('linux') != -1
42 buildbot_revision = os.environ.get('BUILDBOT_REVISION', '')
44 build_prefix = options.arch + ' '
46 buildbot_common.BuildStep(build_prefix + 'Clean Old SDK')
47 buildbot_common.MakeDir(MONO_BUILD_DIR)
48 buildbot_common.RemoveDir(os.path.join(MONO_BUILD_DIR, 'pepper_*'))
50 buildbot_common.BuildStep(build_prefix + 'Setup New SDK')
52 sdk_revision = options.sdk_revision
53 sdk_url = options.sdk_url
56 assert buildbot_revision
57 sdk_revision = buildbot_revision.split(':')[0]
58 sdk_url = 'gs://nativeclient-mirror/nacl/nacl_sdk/'\
59 'trunk.%s/naclsdk_linux.tar.bz2' % sdk_revision
61 sdk_url = sdk_url.replace('https://commondatastorage.googleapis.com/',
64 sdk_file = sdk_url.split('/')[-1]
66 buildbot_common.Run([buildbot_common.GetGsutil(), 'cp', sdk_url, sdk_file],
70 tar_file = tarfile.open(os.path.join(MONO_BUILD_DIR, sdk_file))
71 pepper_dir = os.path.commonprefix(tar_file.getnames())
72 tar_file.extractall(path=MONO_BUILD_DIR)
73 sdk_dir = os.path.join(MONO_BUILD_DIR, pepper_dir)
80 buildbot_common.BuildStep(build_prefix + 'Checkout Mono')
81 # TODO(elijahtaylor): Get git URL from master/trigger to make this
82 # more flexible for building from upstream and release branches.
83 if options.arch == 'arm':
84 git_url = 'git://github.com/igotti-google/mono.git'
87 git_url = 'git://github.com/elijahtaylor/mono.git'
90 # Unfortunately, we use different git branches/revisions
91 # for ARM and x86 now, so ignore buildbot_revision variable for ARM.
92 # Need to rethink this approach, if we'll plan to support
93 # more flexible repo selection mechanism.
94 if options.arch != 'arm':
95 git_rev = buildbot_revision.split(':')[1]
96 # ARM and x86 is built out of different git trees, so distinguish
97 # them by appending the arch. It also makes 32 and 64 bit x86 separated,
99 # TODO(olonho): maybe we need to avoid modifications of global.
102 MONO_DIR = "%s-%s" % (MONO_DIR, tag)
103 if not os.path.exists(MONO_DIR):
104 buildbot_common.MakeDir(MONO_DIR)
105 buildbot_common.Run(['git', 'clone', git_url, MONO_DIR])
107 buildbot_common.Run(['git', 'fetch'], cwd=MONO_DIR)
109 buildbot_common.Run(['git', 'checkout', git_rev], cwd=MONO_DIR)
111 arch_to_bitsize = {'x86-32': '32',
114 arch_to_output_folder = {'x86-32': 'runtime-x86-32-build',
115 'x86-64': 'runtime-x86-64-build',
116 'arm': 'runtime-arm-build'}
118 buildbot_common.BuildStep(build_prefix + 'Configure Mono')
119 os.environ['NACL_SDK_ROOT'] = sdk_dir
120 os.environ['TARGET_ARCH'] = options.arch
121 os.environ['TARGET_BITSIZE'] = arch_to_bitsize[options.arch]
122 buildbot_common.Run(['./autogen.sh'], cwd=MONO_DIR)
123 buildbot_common.Run(['make', 'distclean'], cwd=MONO_DIR)
125 buildbot_common.BuildStep(build_prefix + 'Build and Install Mono')
126 nacl_interp_script = os.path.join(SDK_BUILD_DIR, 'nacl_interp_loader_mono.sh')
127 os.environ['NACL_INTERP_LOADER'] = nacl_interp_script
128 buildbot_common.Run(['./nacl-mono-runtime.sh',
129 MONO_DIR, # Mono directory with 'configure'
130 arch_to_output_folder[options.arch], # Build dir
131 options.install_dir],
134 # TODO(elijahtaylor,olonho): Re-enable tests on arm when they compile/run.
135 if options.arch != 'arm':
136 buildbot_common.BuildStep(build_prefix + 'Test Mono')
137 buildbot_common.Run(['make', 'check', '-j8'],
138 cwd=os.path.join(SDK_BUILD_DIR, arch_to_output_folder[options.arch]))
143 if __name__ == '__main__':
144 sys.exit(main(sys.argv))