blob: 291a7a55555f48c04983a7777fc050de0c42e8e8 [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:
45common_env = env.Clone()
46vars.Update(common_env)
47
48Help(new_options.GenerateHelpText(common_env))
49
Pablo Telloc6cb35a2017-06-21 15:39:47 +010050if env['os'] in ['android', 'bare_metal'] or env['standalone']:
51 Import('arm_compute_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052 common_env.Append(LIBS = [arm_compute_a])
53 arm_compute_lib = arm_compute_a
54else:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010055 Import('arm_compute_so')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056 common_env.Append(LIBS = ["arm_compute"])
57 arm_compute_lib = arm_compute_so
58
Anthony Barbier6ff3b192017-09-04 18:44:23 +010059#FIXME Delete before release
60if common_env['internal_only']:
61 common_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
62
63common_env.Append(CPPPATH = [".", "#3rdparty/include"])
64common_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
65common_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
66common_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
67common_env.Append(LIBS = ['boost_program_options'])
68common_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers'])
69
70validation_env = common_env.Clone()
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071
72validation_env.Append(CPPDEFINES=['BOOST'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010073
74files = Glob('*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010075files = [f for f in files if "DatasetManager" not in os.path.basename(str(f))]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010076
77common_objects = [ common_env.StaticObject( f ) for f in files ]
78
79validation_env.Append(LIBS = ['boost_unit_test_framework'])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080
81files_validation = Glob('validation/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082
83# Add unit tests
84files_validation += Glob('validation/UNIT/*.cpp')
85files_validation += Glob('validation/UNIT/*/*.cpp')
86
87if env['opencl']:
88 Import('opencl')
89
Anthony Barbier6ff3b192017-09-04 18:44:23 +010090 files_validation += Glob('validation/CL/*.cpp')
91 files_validation += Glob('validation/CL/*/*.cpp')
92 files_validation += Glob('validation/system_tests/CL/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010093
94 validation_env.Append(LIBS = "OpenCL")
Anthony Barbier6ff3b192017-09-04 18:44:23 +010095
96if env['neon']:
97 files_validation += Glob('validation/NEON/*.cpp')
98 files_validation += Glob('validation/NEON/*/*.cpp')
99 files_validation += Glob('validation/system_tests/NEON/*.cpp')
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100100
101if env['os'] == 'android':
102 validation_env.Append(LIBS = ["log"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100103
104if common_env['validation_tests']:
105 arm_compute_validation = validation_env.Program('arm_compute_validation',
106 files_validation + common_objects)
107 Depends(arm_compute_validation, arm_compute_lib)
108 if env['opencl']:
109 Depends(arm_compute_validation, opencl)
110 Default(arm_compute_validation)
111 Export('arm_compute_validation')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100112
113#######################################################################
114# Using new framework
115#######################################################################
116
117# Clone the environment to make sure we're not polluting the arm_compute one:
118benchmark_env = env.Clone()
119# Workaround to build both test systems in parallel
120benchmark_env.VariantDir("new", ".", duplicate=0)
121
122if env['os'] in ['android', 'bare_metal'] or env['standalone']:
123 Import("arm_compute_a")
124 benchmark_env.Append(LIBS = [arm_compute_a])
125 arm_compute_lib = arm_compute_a
126else:
127 Import('arm_compute_so')
128 benchmark_env.Append(LIBS = ["arm_compute"])
129 arm_compute_lib = arm_compute_so
130
131#FIXME Delete before release
132if common_env['internal_only']:
133 benchmark_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
134
135benchmark_env.Append(CPPPATH = [".", "#3rdparty/include"])
136benchmark_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
137benchmark_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
138benchmark_env.Append(LIBPATH = ["#build/%s/framework" % env['build_dir']])
139benchmark_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
140
141Import("arm_compute_test_framework")
142benchmark_env.Append(LIBS = ['arm_compute_test_framework'])
143
144files_benchmark = Glob('new/DatasetManager.cpp')
145files_benchmark += Glob('new/TensorLibrary.cpp')
146files_benchmark += Glob('new/RawTensor.cpp')
147files_benchmark += Glob('new/benchmark_new/*.cpp')
148
149# Add unit tests
150if env['opencl']:
151 Import('opencl')
152
153 benchmark_env.Append(CPPDEFINES=['OPENCL'])
154
155 files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp')
156 files_benchmark += Glob('new/benchmark_new/CL/*.cpp')
157
158 benchmark_env.Append(LIBS = "OpenCL")
159
160if env['neon']:
161 files_benchmark += Glob('new/benchmark_new/NEON/*/*.cpp')
162 files_benchmark += Glob('new/benchmark_new/NEON/*.cpp')
163
164if env['os'] == 'android':
165 benchmark_env.Append(LIBS = ["log"])
166else:
167 benchmark_env.Append(LIBS = ["rt"])
168
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100169if common_env['benchmark_tests']:
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100170 arm_compute_benchmark = benchmark_env.Program('arm_compute_benchmark', files_benchmark)
171 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100172 Depends(arm_compute_benchmark, arm_compute_lib)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100173
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100174 if env['opencl']:
175 Depends(arm_compute_benchmark, opencl)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100176
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100177 Default(arm_compute_benchmark)
178 Export('arm_compute_benchmark')