blob: 3389dcdadeb06af9e8b92a49f0a974490a5ab067 [file] [log] [blame]
Alexandre Ramesb78f1392016-07-01 14:22:22 +01001# Copyright 2015, VIXL authors
armvixlad96eda2013-06-14 11:42:37 +01002# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# * Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12# * Neither the name of ARM Limited nor the names of its contributors may be
13# used to endorse or promote products derived from this software without
14# specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
armvixldb644342015-07-21 11:37:10 +010027import glob
armvixlad96eda2013-06-14 11:42:37 +010028import os
armvixldb644342015-07-21 11:37:10 +010029from os.path import join
armvixlc68cb642014-09-25 18:49:30 +010030import platform
armvixl4a102ba2014-07-14 09:02:40 +010031import subprocess
armvixlad96eda2013-06-14 11:42:37 +010032import sys
Pierre Langloisa3b21462016-08-04 16:01:51 +010033from collections import OrderedDict
armvixlad96eda2013-06-14 11:42:37 +010034
armvixl4a102ba2014-07-14 09:02:40 +010035root_dir = os.path.dirname(File('SConstruct').rfile().abspath)
armvixldb644342015-07-21 11:37:10 +010036sys.path.insert(0, join(root_dir, 'tools'))
37import config
armvixl4a102ba2014-07-14 09:02:40 +010038import util
39
armvixlc68cb642014-09-25 18:49:30 +010040
41Help('''
42Build system for the VIXL project.
43See README.md for documentation and details about the build system.
armvixlc68cb642014-09-25 18:49:30 +010044''')
45
46
armvixldb644342015-07-21 11:37:10 +010047# We track top-level targets to automatically generate help and alias them.
48class TopLevelTargets:
49 def __init__(self):
50 self.targets = []
51 self.help_messages = []
52 def Add(self, target, help_message):
53 self.targets.append(target)
54 self.help_messages.append(help_message)
55 def Help(self):
armvixl684cd2a2015-10-23 13:38:33 +010056 res = ""
armvixldb644342015-07-21 11:37:10 +010057 for i in range(len(self.targets)):
58 res += '\t{0:<{1}}{2:<{3}}\n'.format(
59 'scons ' + self.targets[i],
60 len('scons ') + max(map(len, self.targets)),
61 ' : ' + self.help_messages[i],
62 len(' : ') + max(map(len, self.help_messages)))
63 return res
armvixlad96eda2013-06-14 11:42:37 +010064
armvixldb644342015-07-21 11:37:10 +010065top_level_targets = TopLevelTargets()
armvixlad96eda2013-06-14 11:42:37 +010066
67
armvixldb644342015-07-21 11:37:10 +010068
69# Build options ----------------------------------------------------------------
70
71# Store all the options in a dictionary.
72# The SConstruct will check the build variables and construct the build
73# environment as appropriate.
74options = {
75 'all' : { # Unconditionally processed.
76 'CCFLAGS' : ['-Wall',
77 '-Werror',
78 '-fdiagnostics-show-option',
79 '-Wextra',
80 '-Wredundant-decls',
81 '-pedantic',
armvixl684cd2a2015-10-23 13:38:33 +010082 '-Wmissing-noreturn',
Alexandre Ramesfd098172016-08-09 10:29:53 +010083 '-Wwrite-strings',
84 '-Wunused'],
armvixldb644342015-07-21 11:37:10 +010085 'CPPPATH' : [config.dir_src_vixl]
86 },
87# 'build_option:value' : {
88# 'environment_key' : 'values to append'
89# },
90 'mode:debug' : {
91 'CCFLAGS' : ['-DVIXL_DEBUG', '-O0']
92 },
93 'mode:release' : {
Alexandre Ramesfa4a4bd2016-07-25 14:14:22 +010094 'CCFLAGS' : ['-O3'],
armvixldb644342015-07-21 11:37:10 +010095 },
Alexandre Ramesd5bfa5a2016-10-25 09:55:51 +010096 'target_arch:aarch32' : {
Alexandre Rames586c6b92016-10-24 11:59:33 +010097 'CCFLAGS' : ['-DVIXL_INCLUDE_TARGET_AARCH32']
98 },
Alexandre Ramesd5bfa5a2016-10-25 09:55:51 +010099 'target_arch:aarch64' : {
Alexandre Rames586c6b92016-10-24 11:59:33 +0100100 'CCFLAGS' : ['-DVIXL_INCLUDE_TARGET_AARCH64']
101 },
Alexandre Ramesd5bfa5a2016-10-25 09:55:51 +0100102 'target_arch:both' : {
Alexandre Ramesa3aef4f2016-10-28 15:39:51 +0100103 'CCFLAGS' : ['-DVIXL_INCLUDE_TARGET_AARCH32',
104 '-DVIXL_INCLUDE_TARGET_AARCH64']
Alexandre Rames586c6b92016-10-24 11:59:33 +0100105 },
Pierre Langloisa3b21462016-08-04 16:01:51 +0100106 'simulator:aarch64' : {
Pierre Langlois1e85b7f2016-08-05 14:20:36 +0100107 'CCFLAGS' : ['-DVIXL_INCLUDE_SIMULATOR_AARCH64'],
armvixldb644342015-07-21 11:37:10 +0100108 },
109 'symbols:on' : {
110 'CCFLAGS' : ['-g'],
111 'LINKFLAGS' : ['-g']
112 },
Georgia Kouveli38d5d1b2016-11-16 11:58:41 +0000113 'negative_testing:on' : {
114 'CCFLAGS' : ['-DVIXL_NEGATIVE_TESTING']
115 }
armvixldb644342015-07-21 11:37:10 +0100116 }
armvixlad96eda2013-06-14 11:42:37 +0100117
118
armvixldb644342015-07-21 11:37:10 +0100119# A `DefaultVariable` has a default value that depends on elements not known
120# when variables are first evaluated.
121# Each `DefaultVariable` has a handler that will compute the default value for
122# the given environment.
123def modifiable_flags_handler(env):
124 env['modifiable_flags'] = \
125 'on' if 'mode' in env and env['mode'] == 'debug' else 'off'
armvixl6e2c8272015-03-31 11:04:14 +0100126
127
armvixldb644342015-07-21 11:37:10 +0100128def symbols_handler(env):
129 env['symbols'] = 'on' if 'mode' in env and env['mode'] == 'debug' else 'off'
armvixlad96eda2013-06-14 11:42:37 +0100130
131
Pierre Langloisa3b21462016-08-04 16:01:51 +0100132# The architecture targeted by default will depend on the compiler being
133# used. 'host_arch' is extracted from the compiler while 'target_arch' can be
134# set by the user.
135# By default, we target both AArch32 and AArch64 unless the compiler
136# targets AArch32. At the moment, we cannot build VIXL's AArch64 support on a 32
137# bit platform.
138# TODO: Port VIXL to build on a 32 bit platform.
139def target_arch_handler(env):
140 if env['host_arch'] == 'aarch32':
141 env['target_arch'] = 'aarch32'
142 else:
143 env['target_arch'] = 'both'
144
145
146# By default, include the simulator only if AArch64 is targeted and we are not
147# building VIXL natively for AArch64.
148def simulator_handler(env):
149 if env['host_arch'] != 'aarch64' and \
150 env['target_arch'] in ['aarch64', 'both']:
151 env['simulator'] = 'aarch64'
152 else:
153 env['simulator'] = 'none'
154
155
156# Default variables may depend on each other, therefore we need this dictionnary
157# to be ordered.
158vars_default_handlers = OrderedDict({
armvixldb644342015-07-21 11:37:10 +0100159 # variable_name : [ 'default val', 'handler' ]
160 'symbols' : [ 'mode==debug', symbols_handler ],
Pierre Langloisa3b21462016-08-04 16:01:51 +0100161 'modifiable_flags' : [ 'mode==debug', modifiable_flags_handler ],
162 'target_arch' : [ 'same as host architecture if running on AArch32 - '
163 'otherwise both',
164 target_arch_handler ],
165 'simulator' : ['on if the target architectures include AArch64 but '
166 'the host is not AArch64, else off',
167 simulator_handler ]
168 })
armvixldb644342015-07-21 11:37:10 +0100169
170
Pierre Langloisa3b21462016-08-04 16:01:51 +0100171def DefaultVariable(name, help, allowed_values):
172 help = '%s (%s)' % (help, '|'.join(allowed_values))
armvixldb644342015-07-21 11:37:10 +0100173 default_value = vars_default_handlers[name][0]
Pierre Langloisa3b21462016-08-04 16:01:51 +0100174 def validator(name, value, env):
175 if value != default_value and value not in allowed_values:
176 raise SCons.Errors.UserError(
177 'Invalid value for option {name}: {value}. '
178 'Valid values are: {allowed_values}'.format(name,
179 value,
180 allowed_values))
181 return (name, help, default_value, validator)
armvixldb644342015-07-21 11:37:10 +0100182
183
184vars = Variables()
185# Define command line build options.
armvixldb644342015-07-21 11:37:10 +0100186vars.AddVariables(
187 EnumVariable('mode', 'Build mode',
188 'release', allowed_values=config.build_options_modes),
Georgia Kouveli38d5d1b2016-11-16 11:58:41 +0000189 EnumVariable('negative_testing', 'Enable negative testing (needs exceptions)',
190 'off', allowed_values=['on', 'off']),
armvixldb644342015-07-21 11:37:10 +0100191 DefaultVariable('symbols', 'Include debugging symbols in the binaries',
192 ['on', 'off']),
Pierre Langloisa3b21462016-08-04 16:01:51 +0100193 DefaultVariable('target_arch', 'Target architecture',
194 ['aarch32', 'aarch64', 'both']),
195 DefaultVariable('simulator', 'Simulators to include', ['aarch64', 'none']),
armvixldb644342015-07-21 11:37:10 +0100196 ('std', 'C++ standard. The standards tested are: %s.' % \
197 ', '.join(config.tested_cpp_standards))
198 )
armvixlad96eda2013-06-14 11:42:37 +0100199
armvixldb644342015-07-21 11:37:10 +0100200# We use 'variant directories' to avoid recompiling multiple times when build
201# options are changed, different build paths are used depending on the options
202# set. These are the options that should be reflected in the build directory
203# path.
Pierre Langloisa3b21462016-08-04 16:01:51 +0100204options_influencing_build_path = [
Georgia Kouveli38d5d1b2016-11-16 11:58:41 +0000205 'target_arch', 'mode', 'symbols', 'CXX', 'std', 'simulator', 'negative_testing'
Pierre Langloisa3b21462016-08-04 16:01:51 +0100206]
armvixlad96eda2013-06-14 11:42:37 +0100207
armvixlad96eda2013-06-14 11:42:37 +0100208
armvixldb644342015-07-21 11:37:10 +0100209
210# Build helpers ----------------------------------------------------------------
211
212def RetrieveEnvironmentVariables(env):
Pierre Langlois88c46b82016-06-02 18:15:32 +0100213 for key in ['CC', 'CXX', 'AR', 'RANLIB', 'LD']:
armvixldb644342015-07-21 11:37:10 +0100214 if os.getenv(key): env[key] = os.getenv(key)
215 if os.getenv('LD_LIBRARY_PATH'): env['LIBPATH'] = os.getenv('LD_LIBRARY_PATH')
Pierre Langlois88c46b82016-06-02 18:15:32 +0100216 if os.getenv('CCFLAGS'):
217 env.Append(CCFLAGS = os.getenv('CCFLAGS').split())
armvixldb644342015-07-21 11:37:10 +0100218 if os.getenv('CXXFLAGS'):
219 env.Append(CXXFLAGS = os.getenv('CXXFLAGS').split())
220 if os.getenv('LINKFLAGS'):
221 env.Append(LINKFLAGS = os.getenv('LINKFLAGS').split())
222 # This allows colors to be displayed when using with clang.
223 env['ENV']['TERM'] = os.getenv('TERM')
armvixl4a102ba2014-07-14 09:02:40 +0100224
225
armvixldb644342015-07-21 11:37:10 +0100226def ProcessBuildOptions(env):
227 # 'all' is unconditionally processed.
228 if 'all' in options:
229 for var in options['all']:
230 if var in env and env[var]:
231 env[var] += options['all'][var]
232 else:
233 env[var] = options['all'][var]
Pierre Langloisa3b21462016-08-04 16:01:51 +0100234
armvixldb644342015-07-21 11:37:10 +0100235 # Other build options must match 'option:value'
236 env_dict = env.Dictionary()
Pierre Langloisa3b21462016-08-04 16:01:51 +0100237
238 # First apply the default variables handlers in order.
239 for key, value in vars_default_handlers.items():
240 default = value[0]
241 handler = value[1]
242 if env_dict.get(key) == default:
243 handler(env_dict)
244
armvixldb644342015-07-21 11:37:10 +0100245 for key in env_dict.keys():
armvixldb644342015-07-21 11:37:10 +0100246 # Then update the environment according to the value of the variable.
247 key_val_couple = key + ':%s' % env_dict[key]
248 if key_val_couple in options:
249 for var in options[key_val_couple]:
250 env[var] += options[key_val_couple][var]
251
252
253def ConfigureEnvironmentForCompiler(env):
Pierre Langloisf737e0a2016-11-02 13:08:11 +0000254 compiler = util.CompilerInformation(env['CXX'])
255 if compiler == 'clang':
armvixldb644342015-07-21 11:37:10 +0100256 # These warnings only work for Clang.
257 # -Wimplicit-fallthrough only works when compiling the code base as C++11 or
258 # newer. The compiler does not complain if the option is passed when
259 # compiling earlier C++ standards.
260 env.Append(CPPFLAGS = ['-Wimplicit-fallthrough', '-Wshorten-64-to-32'])
261
262 # The '-Wunreachable-code' flag breaks builds for clang 3.4.
Jacob Bramley176a3792016-11-09 14:44:39 +0000263 if compiler != 'clang-3.4':
armvixldb644342015-07-21 11:37:10 +0100264 env.Append(CPPFLAGS = ['-Wunreachable-code'])
265
266 # GCC 4.8 has a bug which produces a warning saying that an anonymous Operand
267 # object might be used uninitialized:
268 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57045
269 # The bug does not seem to appear in GCC 4.7, or in debug builds with GCC 4.8.
270 if env['mode'] == 'release':
Pierre Langloisf737e0a2016-11-02 13:08:11 +0000271 if compiler == 'gcc-4.8':
armvixldb644342015-07-21 11:37:10 +0100272 env.Append(CPPFLAGS = ['-Wno-maybe-uninitialized'])
Pierre Langloisf737e0a2016-11-02 13:08:11 +0000273
Pierre Langloisc1253072016-06-15 14:36:10 +0100274 # When compiling with c++98 (the default), allow long long constants.
armvixl0f35e362016-05-10 13:57:58 +0100275 if 'std' not in env or env['std'] == 'c++98':
Pierre Langloisc1253072016-06-15 14:36:10 +0100276 env.Append(CPPFLAGS = ['-Wno-long-long'])
Pierre Langlois3fac43c2016-10-31 13:38:47 +0000277 # When compiling with c++11, suggest missing override keywords on methods.
278 if 'std' in env and env['std'] in ['c++11', 'c++14']:
Pierre Langloisf737e0a2016-11-02 13:08:11 +0000279 if compiler >= 'gcc-5':
Pierre Langlois3fac43c2016-10-31 13:38:47 +0000280 env.Append(CPPFLAGS = ['-Wsuggest-override'])
Pierre Langloisf737e0a2016-11-02 13:08:11 +0000281 elif compiler >= 'clang-3.6':
Pierre Langlois3fac43c2016-10-31 13:38:47 +0000282 env.Append(CPPFLAGS = ['-Winconsistent-missing-override'])
armvixldb644342015-07-21 11:37:10 +0100283
284
285def ConfigureEnvironment(env):
286 RetrieveEnvironmentVariables(env)
Pierre Langloisa3b21462016-08-04 16:01:51 +0100287 env['host_arch'] = util.GetHostArch(env['CXX'])
armvixldb644342015-07-21 11:37:10 +0100288 ProcessBuildOptions(env)
289 if 'std' in env:
290 env.Append(CPPFLAGS = ['-std=' + env['std']])
291 std_path = env['std']
292 ConfigureEnvironmentForCompiler(env)
293
294
295def TargetBuildDir(env):
296 # Build-time option values are embedded in the build path to avoid requiring a
297 # full build when an option changes.
298 build_dir = config.dir_build
299 for option in options_influencing_build_path:
300 option_value = env[option] if option in env else ''
301 build_dir = join(build_dir, option + '_'+ option_value)
302 return build_dir
303
304
305def PrepareVariantDir(location, build_dir):
306 location_build_dir = join(build_dir, location)
307 VariantDir(location_build_dir, location)
308 return location_build_dir
309
310
311def VIXLLibraryTarget(env):
312 build_dir = TargetBuildDir(env)
313 # Create a link to the latest build directory.
Alexandre Rames4e241932016-06-08 21:32:03 +0100314 # Use `-r` to avoid failure when `latest` exists and is a directory.
315 subprocess.check_call(["rm", "-rf", config.dir_build_latest])
armvixldb644342015-07-21 11:37:10 +0100316 util.ensure_dir(build_dir)
317 subprocess.check_call(["ln", "-s", build_dir, config.dir_build_latest])
Alexandre Ramesd3832962016-07-04 15:03:43 +0100318 # Source files are in `src` and in `src/aarch64/`.
Alexandre Rames39c32a62016-05-23 15:47:22 +0100319 variant_dir_vixl = PrepareVariantDir(join('src'), build_dir)
Pierre Langloisa3b21462016-08-04 16:01:51 +0100320 sources = [Glob(join(variant_dir_vixl, '*.cc'))]
321 if env['target_arch'] in ['aarch32', 'both']:
322 variant_dir_aarch32 = PrepareVariantDir(join('src', 'aarch32'), build_dir)
323 sources.append(Glob(join(variant_dir_aarch32, '*.cc')))
324 if env['target_arch'] in ['aarch64', 'both']:
325 variant_dir_aarch64 = PrepareVariantDir(join('src', 'aarch64'), build_dir)
326 sources.append(Glob(join(variant_dir_aarch64, '*.cc')))
armvixldb644342015-07-21 11:37:10 +0100327 return env.Library(join(build_dir, 'vixl'), sources)
328
329
330
331# Build ------------------------------------------------------------------------
332
333# The VIXL library, built by default.
334env = Environment(variables = vars)
Alexandre Ramesf5de33d2016-10-25 09:51:11 +0100335# Abort the build if any command line option is unknown or invalid.
336unknown_build_options = vars.UnknownVariables()
337if unknown_build_options:
338 print 'Unknown build options:', unknown_build_options.keys()
339 Exit(1)
340
armvixldb644342015-07-21 11:37:10 +0100341ConfigureEnvironment(env)
armvixldb644342015-07-21 11:37:10 +0100342Help(vars.GenerateHelpText(env))
343libvixl = VIXLLibraryTarget(env)
344Default(libvixl)
345env.Alias('libvixl', libvixl)
346top_level_targets.Add('', 'Build the VIXL library.')
347
armvixl4a102ba2014-07-14 09:02:40 +0100348
Pierre Langloisa3b21462016-08-04 16:01:51 +0100349# Common test code.
armvixldb644342015-07-21 11:37:10 +0100350test_build_dir = PrepareVariantDir('test', TargetBuildDir(env))
Pierre Langlois88c46b82016-06-02 18:15:32 +0100351test_objects = [env.Object(Glob(join(test_build_dir, '*.cc')))]
352
Pierre Langloisa3b21462016-08-04 16:01:51 +0100353# AArch32 support
354if env['target_arch'] in ['aarch32', 'both']:
355 # The examples.
356 aarch32_example_names = util.ListCCFilesWithoutExt(config.dir_aarch32_examples)
357 aarch32_examples_build_dir = PrepareVariantDir('examples/aarch32', TargetBuildDir(env))
358 aarch32_example_targets = []
359 for example in aarch32_example_names:
360 prog = env.Program(join(aarch32_examples_build_dir, example),
361 join(aarch32_examples_build_dir, example + '.cc'),
362 LIBS=[libvixl])
363 aarch32_example_targets.append(prog)
364 env.Alias('aarch32_examples', aarch32_example_targets)
365 top_level_targets.Add('aarch32_examples', 'Build the examples for AArch32.')
Pierre Langlois88c46b82016-06-02 18:15:32 +0100366
Vincent Belliard32cf2542016-07-14 10:04:09 -0700367 # The benchmarks
368 aarch32_benchmark_names = util.ListCCFilesWithoutExt(config.dir_aarch32_benchmarks)
369 aarch32_benchmarks_build_dir = PrepareVariantDir('benchmarks/aarch32', TargetBuildDir(env))
370 aarch32_benchmark_targets = []
371 for bench in aarch32_benchmark_names:
372 prog = env.Program(join(aarch32_benchmarks_build_dir, bench),
373 join(aarch32_benchmarks_build_dir, bench + '.cc'),
374 LIBS=[libvixl])
375 aarch32_benchmark_targets.append(prog)
376 env.Alias('aarch32_benchmarks', aarch32_benchmark_targets)
377 top_level_targets.Add('aarch32_benchmarks', 'Build the benchmarks for AArch32.')
378
Pierre Langloisa3b21462016-08-04 16:01:51 +0100379 # The tests.
380 test_aarch32_build_dir = PrepareVariantDir(join('test', 'aarch32'), TargetBuildDir(env))
381 test_objects.append(env.Object(
382 Glob(join(test_aarch32_build_dir, '*.cc')),
383 CPPPATH = env['CPPPATH'] + [config.dir_tests]))
Pierre Langlois88c46b82016-06-02 18:15:32 +0100384
Pierre Langloisa3b21462016-08-04 16:01:51 +0100385# AArch64 support
386if env['target_arch'] in ['aarch64', 'both']:
387 # The benchmarks.
388 aarch64_benchmark_names = util.ListCCFilesWithoutExt(config.dir_aarch64_benchmarks)
389 aarch64_benchmarks_build_dir = PrepareVariantDir('benchmarks/aarch64', TargetBuildDir(env))
390 aarch64_benchmark_targets = []
391 for bench in aarch64_benchmark_names:
392 prog = env.Program(join(aarch64_benchmarks_build_dir, bench),
393 join(aarch64_benchmarks_build_dir, bench + '.cc'),
394 LIBS=[libvixl])
395 aarch64_benchmark_targets.append(prog)
396 env.Alias('aarch64_benchmarks', aarch64_benchmark_targets)
397 top_level_targets.Add('aarch64_benchmarks', 'Build the benchmarks for AArch64.')
398
399 # The examples.
400 aarch64_example_names = util.ListCCFilesWithoutExt(config.dir_aarch64_examples)
401 aarch64_examples_build_dir = PrepareVariantDir('examples/aarch64', TargetBuildDir(env))
402 aarch64_example_targets = []
403 for example in aarch64_example_names:
404 prog = env.Program(join(aarch64_examples_build_dir, example),
405 join(aarch64_examples_build_dir, example + '.cc'),
406 LIBS=[libvixl])
407 aarch64_example_targets.append(prog)
408 env.Alias('aarch64_examples', aarch64_example_targets)
409 top_level_targets.Add('aarch64_examples', 'Build the examples for AArch64.')
410
411 # The tests.
412 test_aarch64_build_dir = PrepareVariantDir(join('test', 'aarch64'), TargetBuildDir(env))
413 test_objects.append(env.Object(
414 Glob(join(test_aarch64_build_dir, '*.cc')),
415 CPPPATH = env['CPPPATH'] + [config.dir_tests]))
416
417 # The test requires building the example files with specific options, so we
418 # create a separate variant dir for the example objects built this way.
419 test_aarch64_examples_vdir = join(TargetBuildDir(env), 'test', 'aarch64', 'test_examples')
420 VariantDir(test_aarch64_examples_vdir, '.')
421 test_aarch64_examples_obj = env.Object(
422 [Glob(join(test_aarch64_examples_vdir, join('test', 'aarch64', 'examples/aarch64', '*.cc'))),
423 Glob(join(test_aarch64_examples_vdir, join('examples/aarch64', '*.cc')))],
424 CCFLAGS = env['CCFLAGS'] + ['-DTEST_EXAMPLES'],
425 CPPPATH = env['CPPPATH'] + [config.dir_aarch64_examples] + [config.dir_tests])
426 test_objects.append(test_aarch64_examples_obj)
Pierre Langlois88c46b82016-06-02 18:15:32 +0100427
428test = env.Program(join(test_build_dir, 'test-runner'), test_objects,
armvixldb644342015-07-21 11:37:10 +0100429 LIBS=[libvixl])
430env.Alias('tests', test)
431top_level_targets.Add('tests', 'Build the tests.')
armvixl4a102ba2014-07-14 09:02:40 +0100432
armvixl4a102ba2014-07-14 09:02:40 +0100433
armvixldb644342015-07-21 11:37:10 +0100434env.Alias('all', top_level_targets.targets)
435top_level_targets.Add('all', 'Build all the targets above.')
436
437Help('\n\nAvailable top level targets:\n' + top_level_targets.Help())