blob: 92a8b59d298cbebb138eba9ac5618505bc47669f [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
28# vars is imported from arm_compute:
29variables = [
30 #FIXME Remove before release (And remove all references to INTERNAL_ONLY)
31 BoolVariable("internal_only", "Enable ARM internal only tests", True),
32 BoolVariable("pmu", "Enable PMU counters", False),
33 BoolVariable("validation_tests", "Build validation test programs", True),
Anthony Barbier79c61782017-06-23 11:48:24 +010034 BoolVariable("benchmark_tests", "Build benchmark test programs", True)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035]
36
37# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
38new_options = Variables('scons')
39
40for v in variables:
41 new_options.Add(v)
42 vars.Add(v)
43
44# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010045old_validation_env = env.Clone()
46vars.Update(old_validation_env)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010048Help(new_options.GenerateHelpText(old_validation_env))
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049
Pablo Telloc6cb35a2017-06-21 15:39:47 +010050if env['os'] in ['android', 'bare_metal'] or env['standalone']:
51 Import('arm_compute_a')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010052 old_validation_env.Append(LIBS = [arm_compute_a])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010053 arm_compute_lib = arm_compute_a
54else:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010055 Import('arm_compute_so')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010056 old_validation_env.Append(LIBS = ["arm_compute"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010057 arm_compute_lib = arm_compute_so
58
Anthony Barbier6ff3b192017-09-04 18:44:23 +010059#FIXME Delete before release
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010060if old_validation_env['internal_only']:
61 old_validation_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010062
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010063old_validation_env.Append(CPPPATH = [".", "#3rdparty/include"])
64old_validation_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
65old_validation_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
66old_validation_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
67old_validation_env.Append(LIBS = ['boost_program_options'])
68old_validation_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers'])
69old_validation_env.Append(CPPDEFINES=['BOOST'])
70old_validation_env.Append(LIBS = ['boost_unit_test_framework'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010072old_files_validation = Glob('*.cpp')
73old_files_validation = [f for f in old_files_validation if "main.cpp" not in os.path.basename(str(f))]
74old_files_validation += Glob('validation/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075
76# Add unit tests
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010077old_files_validation += Glob('validation/UNIT/*.cpp')
78old_files_validation += Glob('validation/UNIT/*/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079
80if env['opencl']:
81 Import('opencl')
82
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010083 old_files_validation += Glob('validation/CL/*.cpp')
84 old_files_validation += Glob('validation/CL/*/*.cpp')
85 old_files_validation += Glob('validation/system_tests/CL/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010087 old_validation_env.Append(LIBS = "OpenCL")
88 old_validation_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010089
90if env['neon']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010091 old_files_validation += Glob('validation/NEON/*.cpp')
92 old_files_validation += Glob('validation/NEON/*/*.cpp')
93 old_files_validation += Glob('validation/system_tests/NEON/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010094
95if env['os'] == 'android':
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010096 old_validation_env.Append(LIBS = ["log"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010097
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010098if old_validation_env['validation_tests']:
99 arm_compute_validation = old_validation_env.Program('arm_compute_validation', old_files_validation)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100100 Depends(arm_compute_validation, arm_compute_lib)
101 if env['opencl']:
102 Depends(arm_compute_validation, opencl)
103 Default(arm_compute_validation)
104 Export('arm_compute_validation')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100105
106#######################################################################
107# Using new framework
108#######################################################################
109
110# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100111test_env = env.Clone()
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100112# Workaround to build both test systems in parallel
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100113test_env.VariantDir("new", ".", duplicate=0)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100114
115if env['os'] in ['android', 'bare_metal'] or env['standalone']:
116 Import("arm_compute_a")
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100117 test_env.Append(LIBS = [arm_compute_a])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100118 arm_compute_lib = arm_compute_a
119else:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100120 Import("arm_compute_so")
121 test_env.Append(LIBS = ["arm_compute"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100122 arm_compute_lib = arm_compute_so
123
124#FIXME Delete before release
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100125if old_validation_env['internal_only']:
126 test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100127
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100128test_env.Append(CPPPATH = [".", "#3rdparty/include"])
129test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
130test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
131test_env.Append(LIBPATH = ["#build/%s/framework" % env['build_dir']])
132test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100133
134Import("arm_compute_test_framework")
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100135test_env.Append(LIBS = arm_compute_test_framework)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100136
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100137common_files = Glob('new/AssetsLibrary.cpp')
138common_files += Glob('new/RawTensor.cpp')
139common_files += Glob('new/main.cpp')
140
141common_objects = [test_env.StaticObject(f) for f in common_files]
142
143files_benchmark = Glob('new/benchmark_new/*.cpp')
144files_validation = Glob('new/validation_new/*.cpp')
145
146# Always compile reference for validation
147files_validation += Glob('new/validation_new/CPP/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100148
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100149if env['opencl']:
150 Import('opencl')
151
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100152 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
153 test_env.Append(LIBS = ["OpenCL"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100154
155 files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp')
156 files_benchmark += Glob('new/benchmark_new/CL/*.cpp')
157
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100158 files_validation += Glob('new/validation_new/CL/*/*.cpp')
159 files_validation += Glob('new/validation_new/CL/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100160
161if env['neon']:
162 files_benchmark += Glob('new/benchmark_new/NEON/*/*.cpp')
163 files_benchmark += Glob('new/benchmark_new/NEON/*.cpp')
164
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100165 files_validation += Glob('new/validation_new/NEON/*/*.cpp')
166 files_validation += Glob('new/validation_new/NEON/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100167
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100168if env['os'] == 'android':
169 test_env.Append(LIBS = ["log"])
170else:
171 test_env.Append(LIBS = ["rt"])
172
173if old_validation_env['benchmark_tests']:
174 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100175 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100176 Depends(arm_compute_benchmark, arm_compute_lib)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100177
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100178 if env['opencl']:
179 Depends(arm_compute_benchmark, opencl)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100180
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100181 Default(arm_compute_benchmark)
182 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100183
184if old_validation_env['validation_tests']:
185 arm_compute_validation_new = test_env.Program('arm_compute_validation_new', files_validation + common_objects)
186 Depends(arm_compute_validation_new, arm_compute_test_framework)
187 Depends(arm_compute_validation_new, arm_compute_lib)
188
189 if env['opencl']:
190 Depends(arm_compute_validation_new, opencl)
191
192 Default(arm_compute_validation_new)
193 Export('arm_compute_validation_new')