blob: 94b432c0ff189b7ba54ec0fca0b83d2f262709ed [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 = [
Anthony Barbiere4904c72018-02-21 15:57:15 +000033 #FIXME Switch the following two options to False before releasing
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034 BoolVariable("validation_tests", "Build validation test programs", True),
Pablo Telloea1c9502017-11-09 11:49:18 +000035 BoolVariable("benchmark_tests", "Build benchmark test programs", True),
36 ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp")
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037]
38
39# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
40new_options = Variables('scons')
41
42for v in variables:
43 new_options.Add(v)
44 vars.Add(v)
45
Gian Marco Iodicef2399532017-09-13 14:16:41 +010046# Disable floating-point expression contraction (e.g. fused multiply-add operations)
47env.Append(CXXFLAGS = ['-ffp-contract=off'])
48
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010050test_env = env.Clone()
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010051vars.Update(test_env)
52
53Help(new_options.GenerateHelpText(test_env))
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010054
Anthony Barbier6db0ff52018-01-05 10:59:12 +000055Import("arm_compute_test_framework")
56test_env.Append(LIBS = arm_compute_test_framework)
57
Georgios Pinitasf8d8f3a2018-06-06 17:57:04 +010058# Remove -Wnoexcept from tests
59if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']:
60 test_env['CXXFLAGS'].remove("-Wnoexcept")
61
Georgios Pinitas9873ea32017-12-05 15:28:55 +000062if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010063 Import("arm_compute_a")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010064 Import("arm_compute_core_a")
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010065 Import("arm_compute_graph_a")
66 test_env.Append(LIBS = [arm_compute_graph_a, arm_compute_a, arm_compute_core_a])
67 arm_compute_lib = arm_compute_graph_a
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010068else:
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010069 Import("arm_compute_graph_so")
Anthony Barbier2df1f992018-07-11 13:37:23 +010070 Import("arm_compute_core_a")
Georgios Pinitas5c2fb3f2018-05-01 15:26:20 +010071 test_env.Append(LIBS = ["arm_compute_graph", "arm_compute", "arm_compute_core"])
72 arm_compute_lib = arm_compute_graph_so
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010073
74#FIXME Delete before release
Anthony Barbiera4e5e1e2017-10-05 14:55:34 +010075if env['internal_only']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010076 test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010077
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010078common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010079common_objects = [test_env.StaticObject(f) for f in common_files]
80
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010081files_benchmark = Glob('benchmark/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010082
Abe Mbise925ca0f2017-10-02 19:16:33 +010083# Add unit tests
Anthony Barbier979dc4f2018-03-07 09:27:48 +000084files_validation = Glob('validation/UNIT/*/*.cpp')
Abe Mbise925ca0f2017-10-02 19:16:33 +010085files_validation += Glob('validation/UNIT/*.cpp')
86
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000087# Add CPP tests
88filter_pattern = test_env['test_filter']
89files_validation += Glob('validation/CPP/' + filter_pattern)
90
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010091if env['opencl']:
Pablo Telloea1c9502017-11-09 11:49:18 +000092 filter_pattern = test_env['test_filter']
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010093
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010094 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010095
Pablo Telloea1c9502017-11-09 11:49:18 +000096 files_benchmark += Glob('benchmark/CL/*/' + filter_pattern)
97 files_benchmark += Glob('benchmark/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010098
Pablo Telloea1c9502017-11-09 11:49:18 +000099 files_validation += Glob('validation/CL/*/' + filter_pattern)
100 files_validation += Glob('validation/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100101
102if env['neon']:
Pablo Telloea1c9502017-11-09 11:49:18 +0000103 filter_pattern = test_env['test_filter']
104 files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern)
105 files_benchmark += Glob('benchmark/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100106
Pablo Telloea1c9502017-11-09 11:49:18 +0000107 files_validation += Glob('validation/NEON/*/' + filter_pattern)
108 files_validation += Glob('validation/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100109
Anthony Barbier7068f992017-10-26 15:23:08 +0100110if env['gles_compute']:
Anthony Barbier7068f992017-10-26 15:23:08 +0100111 test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC'])
112
113 files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp')
114 files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp')
115
116 files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp')
117 files_validation += Glob('validation/GLES_COMPUTE/*.cpp')
118
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100119if env['os'] == 'android':
120 test_env.Append(LIBS = ["log"])
Georgios Pinitas421405b2018-10-26 19:05:32 +0100121elif env['os'] != 'bare_metal':
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100122 test_env.Append(LIBS = ["rt"])
123
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100124if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100125 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000126 arm_compute_benchmark = install_bin(arm_compute_benchmark)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100127 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100128 Depends(arm_compute_benchmark, arm_compute_lib)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100129 Default(arm_compute_benchmark)
130 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100131
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100132if test_env['validation_tests']:
Anthony Barbier069818d2018-07-13 14:45:37 +0100133 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 +0100134 Depends(arm_compute_validation_framework , arm_compute_test_framework)
135 Depends(arm_compute_validation_framework , arm_compute_core_a)
136
Anthony Barbier069818d2018-07-13 14:45:37 +0100137 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 +0000138 arm_compute_validation = install_bin(arm_compute_validation)
Anthony Barbier2df1f992018-07-11 13:37:23 +0100139 Depends(arm_compute_validation, arm_compute_validation_framework)
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100140 Depends(arm_compute_validation, arm_compute_test_framework)
141 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100142
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100143 Default(arm_compute_validation)
Isabella Gottardi5cca9cb2019-02-12 11:42:33 +0000144 Export('arm_compute_validation')