blob: 9e6da9367d22fe11f92fe255d73d05116eb922d4 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001# Copyright (c) 2017 ARM Limited.
2#
3# SPDX-License-Identifier: MIT
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to
7# deal in the Software without restriction, including without limitation the
8# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9# sell copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in all
13# copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
22import SCons
23import os.path
24
25Import('env')
26Import('vars')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010028SConscript('./framework/SConscript', duplicate=0)
29
30#FIXME: Remove before release
Anthony Barbiera4e5e1e2017-10-05 14:55:34 +010031if env['internal_only']:
32 SConscript('./validation_old/SConscript', duplicate=0)
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010033
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034# vars is imported from arm_compute:
35variables = [
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036 BoolVariable("validation_tests", "Build validation test programs", True),
Anthony Barbier79c61782017-06-23 11:48:24 +010037 BoolVariable("benchmark_tests", "Build benchmark test programs", True)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010038]
39
40# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
41new_options = Variables('scons')
42
43for v in variables:
44 new_options.Add(v)
45 vars.Add(v)
46
Gian Marco Iodicef2399532017-09-13 14:16:41 +010047# Disable floating-point expression contraction (e.g. fused multiply-add operations)
48env.Append(CXXFLAGS = ['-ffp-contract=off'])
49
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010051test_env = env.Clone()
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010052vars.Update(test_env)
53
54Help(new_options.GenerateHelpText(test_env))
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010055
56if env['os'] in ['android', 'bare_metal'] or env['standalone']:
57 Import("arm_compute_a")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010058 Import("arm_compute_core_a")
59 test_env.Append(LIBS = [arm_compute_a, arm_compute_core_a])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010060 arm_compute_lib = arm_compute_a
61else:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010062 Import("arm_compute_so")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010063 test_env.Append(LIBS = ["arm_compute", "arm_compute_core"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010064 arm_compute_lib = arm_compute_so
65
66#FIXME Delete before release
Anthony Barbiera4e5e1e2017-10-05 14:55:34 +010067if env['internal_only']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010068 test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010069
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010070test_env.Append(CPPPATH = ["#3rdparty/include"])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010071test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
72test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010073test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010074
75Import("arm_compute_test_framework")
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010076test_env.Append(LIBS = arm_compute_test_framework)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010077
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010078common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010079common_objects = [test_env.StaticObject(f) for f in common_files]
80
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010081files_benchmark = Glob('benchmark/*.cpp')
82files_validation = Glob('validation/*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010083
84# Always compile reference for validation
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010085files_validation += Glob('validation/CPP/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010086
Abe Mbise925ca0f2017-10-02 19:16:33 +010087# Add unit tests
88files_validation += Glob('validation/UNIT/*/*.cpp')
89files_validation += Glob('validation/UNIT/*.cpp')
90
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010091if env['opencl']:
92 Import('opencl')
93
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010094 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
95 test_env.Append(LIBS = ["OpenCL"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010096
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010097 files_benchmark += Glob('benchmark/CL/*/*.cpp')
98 files_benchmark += Glob('benchmark/CL/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010099
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100100 files_validation += Glob('validation/CL/*/*.cpp')
101 files_validation += Glob('validation/CL/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100102
103if env['neon']:
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100104 files_benchmark += Glob('benchmark/NEON/*/*.cpp')
105 files_benchmark += Glob('benchmark/NEON/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100106
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100107 files_validation += Glob('validation/NEON/*/*.cpp')
108 files_validation += Glob('validation/NEON/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100109
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100110if env['os'] == 'android':
111 test_env.Append(LIBS = ["log"])
112else:
113 test_env.Append(LIBS = ["rt"])
114
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100115if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100116 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100117 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100118 Depends(arm_compute_benchmark, arm_compute_lib)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100119
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100120 if env['opencl']:
121 Depends(arm_compute_benchmark, opencl)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100122
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100123 Default(arm_compute_benchmark)
124 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100125
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100126if test_env['validation_tests']:
127 arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects)
128 Depends(arm_compute_validation, arm_compute_test_framework)
129 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100130
131 if env['opencl']:
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100132 Depends(arm_compute_validation, opencl)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100133
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100134 Default(arm_compute_validation)
135 Export('arm_compute_validation')