blob: 34720aae634a56564ba2b7de87b18cf1984e4010 [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
Isabella Gottardibade5f42019-02-12 14:22:49 +000034 BoolVariable("validation_tests", "Build validation test programs", False),
35 BoolVariable("benchmark_tests", "Build benchmark test programs", False),
Pablo Telloea1c9502017-11-09 11:49:18 +000036 ("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
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010074common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010075common_objects = [test_env.StaticObject(f) for f in common_files]
76
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010077files_benchmark = Glob('benchmark/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010078
Abe Mbise925ca0f2017-10-02 19:16:33 +010079# Add unit tests
Anthony Barbier979dc4f2018-03-07 09:27:48 +000080files_validation = Glob('validation/UNIT/*/*.cpp')
Abe Mbise925ca0f2017-10-02 19:16:33 +010081files_validation += Glob('validation/UNIT/*.cpp')
82
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000083# Add CPP tests
84filter_pattern = test_env['test_filter']
85files_validation += Glob('validation/CPP/' + filter_pattern)
86
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010087if env['opencl']:
Pablo Telloea1c9502017-11-09 11:49:18 +000088 filter_pattern = test_env['test_filter']
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010089
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010090 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010091
Pablo Telloea1c9502017-11-09 11:49:18 +000092 files_benchmark += Glob('benchmark/CL/*/' + filter_pattern)
93 files_benchmark += Glob('benchmark/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010094
Pablo Telloea1c9502017-11-09 11:49:18 +000095 files_validation += Glob('validation/CL/*/' + filter_pattern)
96 files_validation += Glob('validation/CL/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010097
98if env['neon']:
Pablo Telloea1c9502017-11-09 11:49:18 +000099 filter_pattern = test_env['test_filter']
100 files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern)
101 files_benchmark += Glob('benchmark/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100102
Pablo Telloea1c9502017-11-09 11:49:18 +0000103 files_validation += Glob('validation/NEON/*/' + filter_pattern)
104 files_validation += Glob('validation/NEON/' + filter_pattern)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100105
Anthony Barbier7068f992017-10-26 15:23:08 +0100106if env['gles_compute']:
Anthony Barbier7068f992017-10-26 15:23:08 +0100107 test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC'])
108
109 files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp')
110 files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp')
111
112 files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp')
113 files_validation += Glob('validation/GLES_COMPUTE/*.cpp')
114
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100115if env['os'] == 'android':
116 test_env.Append(LIBS = ["log"])
Georgios Pinitas421405b2018-10-26 19:05:32 +0100117elif env['os'] != 'bare_metal':
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100118 test_env.Append(LIBS = ["rt"])
119
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100120if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100121 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000122 arm_compute_benchmark = install_bin(arm_compute_benchmark)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100123 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100124 Depends(arm_compute_benchmark, arm_compute_lib)
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']:
Anthony Barbier069818d2018-07-13 14:45:37 +0100129 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 +0100130 Depends(arm_compute_validation_framework , arm_compute_test_framework)
131 Depends(arm_compute_validation_framework , arm_compute_core_a)
132
Anthony Barbier069818d2018-07-13 14:45:37 +0100133 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 +0000134 arm_compute_validation = install_bin(arm_compute_validation)
Anthony Barbier2df1f992018-07-11 13:37:23 +0100135 Depends(arm_compute_validation, arm_compute_validation_framework)
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100136 Depends(arm_compute_validation, arm_compute_test_framework)
137 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100138
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100139 Default(arm_compute_validation)
Isabella Gottardi5cca9cb2019-02-12 11:42:33 +0000140 Export('arm_compute_validation')