blob: 37c96d2f22656ac22d9c1b7b764156ef72147fcc [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
53if env['os'] in ['android', 'bare_metal'] or env['standalone']:
54 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']])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010071
72Import("arm_compute_test_framework")
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010073test_env.Append(LIBS = arm_compute_test_framework)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010074
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010075common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010076common_objects = [test_env.StaticObject(f) for f in common_files]
77
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010078files_benchmark = Glob('benchmark/*.cpp')
79files_validation = Glob('validation/*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010080
John Richardson70f946b2017-10-02 16:52:16 +010081# Add unit tests
82files_validation += Glob('validation/UNIT/*.cpp')
83
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010084# 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')
Pablo Telloea1c9502017-11-09 11:49:18 +000093 filter_pattern = test_env['test_filter']
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010094
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010095 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
96 test_env.Append(LIBS = ["OpenCL"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010097
Pablo Telloea1c9502017-11-09 11:49:18 +000098 files_benchmark += Glob('benchmark/CL/*/' + filter_pattern)
99 files_benchmark += Glob('benchmark/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100100
Pablo Telloea1c9502017-11-09 11:49:18 +0000101 files_validation += Glob('validation/CL/*/' + filter_pattern)
102 files_validation += Glob('validation/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100103
104if env['neon']:
Pablo Telloea1c9502017-11-09 11:49:18 +0000105 filter_pattern = test_env['test_filter']
106 files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern)
107 files_benchmark += Glob('benchmark/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100108
Pablo Telloea1c9502017-11-09 11:49:18 +0000109 files_validation += Glob('validation/NEON/*/' + filter_pattern)
110 files_validation += Glob('validation/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100111
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100112if env['os'] == 'android':
113 test_env.Append(LIBS = ["log"])
114else:
115 test_env.Append(LIBS = ["rt"])
116
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100117if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100118 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100119 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100120 Depends(arm_compute_benchmark, arm_compute_lib)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100121
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100122 if env['opencl']:
123 Depends(arm_compute_benchmark, opencl)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100124
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100125 Default(arm_compute_benchmark)
126 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100127
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100128if test_env['validation_tests']:
129 arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects)
130 Depends(arm_compute_validation, arm_compute_test_framework)
131 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100132
133 if env['opencl']:
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100134 Depends(arm_compute_validation, opencl)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100135
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100136 Default(arm_compute_validation)
137 Export('arm_compute_validation')