blob: d1f72ba737e6b79c5a312ec9f1f0f64b6328109e [file] [log] [blame]
Georgios Pinitasd8734b52017-12-22 15:27:52 +00001# Copyright (c) 2017, 2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01002#
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 Barbier01bbd5f2018-11-01 15:10:51 +000027Import('install_bin')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010029SConscript('./framework/SConscript', duplicate=0)
30
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031# vars is imported from arm_compute:
32variables = [
Gian Marco Iodice36f02462019-08-14 12:49:51 +010033 BoolVariable("validation_tests", "Build validation test programs", False),
34 BoolVariable("benchmark_tests", "Build benchmark test programs", False),
Pablo Telloea1c9502017-11-09 11:49:18 +000035 ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp")
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036]
37
38# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
39new_options = Variables('scons')
40
41for v in variables:
42 new_options.Add(v)
43 vars.Add(v)
44
Gian Marco Iodicef2399532017-09-13 14:16:41 +010045# Disable floating-point expression contraction (e.g. fused multiply-add operations)
46env.Append(CXXFLAGS = ['-ffp-contract=off'])
47
Anthony Barbier6ff3b192017-09-04 18:44:23 +010048# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010049test_env = env.Clone()
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010050vars.Update(test_env)
51
52Help(new_options.GenerateHelpText(test_env))
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010053
Anthony Barbier6db0ff52018-01-05 10:59:12 +000054Import("arm_compute_test_framework")
55test_env.Append(LIBS = arm_compute_test_framework)
56
Georgios Pinitas98b85112019-07-10 16:44:45 +010057# Remove warnings from tests
58warnings_to_remove = ['-Wno-deprecated-declarations']
59for warning in warnings_to_remove:
60 if warning in test_env['CXXFLAGS']:
61 test_env['CXXFLAGS'].remove(warning)
62
Georgios Pinitasf8d8f3a2018-06-06 17:57:04 +010063# Remove -Wnoexcept from tests
64if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']:
65 test_env['CXXFLAGS'].remove("-Wnoexcept")
66
Georgios Pinitas9873ea32017-12-05 15:28:55 +000067if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010068 Import("arm_compute_a")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010069 Import("arm_compute_core_a")
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010070 Import("arm_compute_graph_a")
71 test_env.Append(LIBS = [arm_compute_graph_a, arm_compute_a, arm_compute_core_a])
72 arm_compute_lib = arm_compute_graph_a
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010073else:
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010074 Import("arm_compute_graph_so")
Anthony Barbier2df1f992018-07-11 13:37:23 +010075 Import("arm_compute_core_a")
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010076 test_env.Append(LIBS = ["arm_compute_graph", "arm_compute", "arm_compute_core"])
77 arm_compute_lib = arm_compute_graph_so
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010078
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010079common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010080common_objects = [test_env.StaticObject(f) for f in common_files]
81
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010082files_benchmark = Glob('benchmark/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010083
Abe Mbise925ca0f2017-10-02 19:16:33 +010084# Add unit tests
Anthony Barbier979dc4f2018-03-07 09:27:48 +000085files_validation = Glob('validation/UNIT/*/*.cpp')
Abe Mbise925ca0f2017-10-02 19:16:33 +010086files_validation += Glob('validation/UNIT/*.cpp')
87
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000088# Add CPP tests
89filter_pattern = test_env['test_filter']
90files_validation += Glob('validation/CPP/' + filter_pattern)
91
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010092if env['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'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010096
Pablo Telloea1c9502017-11-09 11:49:18 +000097 files_benchmark += Glob('benchmark/CL/*/' + filter_pattern)
98 files_benchmark += Glob('benchmark/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010099
Pablo Telloea1c9502017-11-09 11:49:18 +0000100 files_validation += Glob('validation/CL/*/' + filter_pattern)
101 files_validation += Glob('validation/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100102
103if env['neon']:
Pablo Telloea1c9502017-11-09 11:49:18 +0000104 filter_pattern = test_env['test_filter']
105 files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern)
106 files_benchmark += Glob('benchmark/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100107
Pablo Telloea1c9502017-11-09 11:49:18 +0000108 files_validation += Glob('validation/NEON/*/' + filter_pattern)
109 files_validation += Glob('validation/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100110
Anthony Barbier7068f992017-10-26 15:23:08 +0100111if env['gles_compute']:
Anthony Barbier7068f992017-10-26 15:23:08 +0100112 test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC'])
113
114 files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp')
115 files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp')
116
117 files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp')
118 files_validation += Glob('validation/GLES_COMPUTE/*.cpp')
119
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100120if env['os'] == 'android':
121 test_env.Append(LIBS = ["log"])
Georgios Pinitas421405b2018-10-26 19:05:32 +0100122elif env['os'] != 'bare_metal':
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100123 test_env.Append(LIBS = ["rt"])
124
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100125if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100126 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000127 arm_compute_benchmark = install_bin(arm_compute_benchmark)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100128 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100129 Depends(arm_compute_benchmark, arm_compute_lib)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100130 Default(arm_compute_benchmark)
131 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100132
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100133if test_env['validation_tests']:
Anthony Barbier069818d2018-07-13 14:45:37 +0100134 arm_compute_validation_framework = env.StaticLibrary('arm_compute_validation_framework', Glob('validation/reference/*.cpp') + Glob('validation/*.cpp'), LIBS= [ arm_compute_test_framework, arm_compute_core_a])
Anthony Barbier2df1f992018-07-11 13:37:23 +0100135 Depends(arm_compute_validation_framework , arm_compute_test_framework)
136 Depends(arm_compute_validation_framework , arm_compute_core_a)
137
Anthony Barbier069818d2018-07-13 14:45:37 +0100138 arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects, LIBS=[arm_compute_validation_framework] + test_env['LIBS'])
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000139 arm_compute_validation = install_bin(arm_compute_validation)
Anthony Barbier2df1f992018-07-11 13:37:23 +0100140 Depends(arm_compute_validation, arm_compute_validation_framework)
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100141 Depends(arm_compute_validation, arm_compute_test_framework)
142 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100143
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100144 Default(arm_compute_validation)
145 Export('arm_compute_validation')
Anthony Barbier6db0ff52018-01-05 10:59:12 +0000146