blob: 240a8fba45512cd8842a6d4b90bc8370cb6328f7 [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
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030# vars is imported from arm_compute:
31variables = [
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032 BoolVariable("validation_tests", "Build validation test programs", True),
Pablo Telloea1c9502017-11-09 11:49:18 +000033 BoolVariable("benchmark_tests", "Build benchmark test programs", True),
34 ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp")
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
Gian Marco Iodicef2399532017-09-13 14:16:41 +010044# Disable floating-point expression contraction (e.g. fused multiply-add operations)
45env.Append(CXXFLAGS = ['-ffp-contract=off'])
46
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010048test_env = env.Clone()
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010049vars.Update(test_env)
50
51Help(new_options.GenerateHelpText(test_env))
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010052
Isabella Gottardib28f29d2017-11-09 17:05:07 +000053if env['os'] in ['bare_metal'] or env['standalone']:
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010054 Import("arm_compute_a")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010055 Import("arm_compute_core_a")
56 test_env.Append(LIBS = [arm_compute_a, arm_compute_core_a])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010057 arm_compute_lib = arm_compute_a
58else:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010059 Import("arm_compute_so")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010060 test_env.Append(LIBS = ["arm_compute", "arm_compute_core"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010061 arm_compute_lib = arm_compute_so
62
63#FIXME Delete before release
Anthony Barbiera4e5e1e2017-10-05 14:55:34 +010064if env['internal_only']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010065 test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010066
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010067test_env.Append(CPPPATH = ["#3rdparty/include"])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010068test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
69test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010070test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
Anthony Barbier7068f992017-10-26 15:23:08 +010071if env['gles_compute'] and env['os'] != 'android':
72 test_env.Append(LIBPATH = ["#build/%s/opengles-3.1/stubs" % env['build_dir']])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010073
74Import("arm_compute_test_framework")
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010075test_env.Append(LIBS = arm_compute_test_framework)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010076
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010077common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010078common_objects = [test_env.StaticObject(f) for f in common_files]
79
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010080files_benchmark = Glob('benchmark/*.cpp')
81files_validation = Glob('validation/*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010082
83# Always compile reference for validation
Georgios Pinitas5a7e7762017-12-01 16:27:29 +000084files_validation += Glob('validation/reference/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010085
Abe Mbise925ca0f2017-10-02 19:16:33 +010086# Add unit tests
87files_validation += Glob('validation/UNIT/*/*.cpp')
88files_validation += Glob('validation/UNIT/*.cpp')
89
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000090# Add CPP tests
91filter_pattern = test_env['test_filter']
92files_validation += Glob('validation/CPP/' + filter_pattern)
93
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010094if env['opencl']:
95 Import('opencl')
Pablo Telloea1c9502017-11-09 11:49:18 +000096 filter_pattern = test_env['test_filter']
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010097
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010098 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
99 test_env.Append(LIBS = ["OpenCL"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100100
Pablo Telloea1c9502017-11-09 11:49:18 +0000101 files_benchmark += Glob('benchmark/CL/*/' + filter_pattern)
102 files_benchmark += Glob('benchmark/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100103
Pablo Telloea1c9502017-11-09 11:49:18 +0000104 files_validation += Glob('validation/CL/*/' + filter_pattern)
105 files_validation += Glob('validation/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100106
107if env['neon']:
Pablo Telloea1c9502017-11-09 11:49:18 +0000108 filter_pattern = test_env['test_filter']
109 files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern)
110 files_benchmark += Glob('benchmark/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100111
Pablo Telloea1c9502017-11-09 11:49:18 +0000112 files_validation += Glob('validation/NEON/*/' + filter_pattern)
113 files_validation += Glob('validation/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100114
Anthony Barbier7068f992017-10-26 15:23:08 +0100115if env['gles_compute']:
116 if env['os'] != 'android':
117 Import('egl')
118 Import('glesv2')
119
120 test_env.Append(CPPPATH = ["#opengles-3.1/include", "#opengles-3.1/mali_include"])
121 test_env.Append(LIBS = ["EGL", "GLESv2"])
122 else:
123 if env['arch'] != 'armv7a':
124 test_env.Append(LIBS = ["EGL", "GLESv3"])
125 else:
126 test_env.Append(LIBS = ["EGL", "GLESv2"])
127
128 test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC'])
129
130 files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp')
131 files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp')
132
133 files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp')
134 files_validation += Glob('validation/GLES_COMPUTE/*.cpp')
135
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100136if env['os'] == 'android':
137 test_env.Append(LIBS = ["log"])
138else:
139 test_env.Append(LIBS = ["rt"])
140
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100141if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100142 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100143 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100144 Depends(arm_compute_benchmark, arm_compute_lib)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100145
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100146 if env['opencl']:
147 Depends(arm_compute_benchmark, opencl)
Anthony Barbier7068f992017-10-26 15:23:08 +0100148 if env['gles_compute'] and env['os'] != 'android':
149 Depends(arm_compute_benchmark, egl)
150 Depends(arm_compute_benchmark, glesv2)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100151
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100152 Default(arm_compute_benchmark)
153 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100154
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100155if test_env['validation_tests']:
156 arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects)
157 Depends(arm_compute_validation, arm_compute_test_framework)
158 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100159
160 if env['opencl']:
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100161 Depends(arm_compute_validation, opencl)
Anthony Barbier7068f992017-10-26 15:23:08 +0100162 if env['gles_compute'] and env['os'] != 'android':
163 Depends(arm_compute_validation, egl)
164 Depends(arm_compute_validation, glesv2)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100165
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100166 Default(arm_compute_validation)
167 Export('arm_compute_validation')