Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | # Copyright (c) 2017, 2018 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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. |
| 22 | import SCons |
| 23 | import os.path |
| 24 | |
| 25 | Import('env') |
| 26 | Import('vars') |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 27 | Import('install_bin') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 29 | SConscript('./framework/SConscript', duplicate=0) |
| 30 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | # vars is imported from arm_compute: |
| 32 | variables = [ |
Anthony Barbier | e4904c7 | 2018-02-21 15:57:15 +0000 | [diff] [blame] | 33 | #FIXME Switch the following two options to False before releasing |
Isabella Gottardi | bade5f4 | 2019-02-12 14:22:49 +0000 | [diff] [blame] | 34 | BoolVariable("validation_tests", "Build validation test programs", False), |
| 35 | BoolVariable("benchmark_tests", "Build benchmark test programs", False), |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 36 | ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | ] |
| 38 | |
| 39 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 40 | new_options = Variables('scons') |
| 41 | |
| 42 | for v in variables: |
| 43 | new_options.Add(v) |
| 44 | vars.Add(v) |
| 45 | |
Gian Marco Iodice | f239953 | 2017-09-13 14:16:41 +0100 | [diff] [blame] | 46 | # Disable floating-point expression contraction (e.g. fused multiply-add operations) |
| 47 | env.Append(CXXFLAGS = ['-ffp-contract=off']) |
| 48 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 49 | # Clone the environment to make sure we're not polluting the arm_compute one: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 50 | test_env = env.Clone() |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 51 | vars.Update(test_env) |
| 52 | |
| 53 | Help(new_options.GenerateHelpText(test_env)) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 54 | |
Anthony Barbier | 6db0ff5 | 2018-01-05 10:59:12 +0000 | [diff] [blame] | 55 | Import("arm_compute_test_framework") |
| 56 | test_env.Append(LIBS = arm_compute_test_framework) |
| 57 | |
Georgios Pinitas | f8d8f3a | 2018-06-06 17:57:04 +0100 | [diff] [blame] | 58 | # Remove -Wnoexcept from tests |
| 59 | if 'g++' in test_env['CXX'] and '-Wnoexcept' in test_env['CXXFLAGS']: |
| 60 | test_env['CXXFLAGS'].remove("-Wnoexcept") |
| 61 | |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 62 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 63 | Import("arm_compute_a") |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 64 | Import("arm_compute_core_a") |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 65 | 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 Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 68 | else: |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 69 | Import("arm_compute_graph_so") |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 70 | Import("arm_compute_core_a") |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 71 | test_env.Append(LIBS = ["arm_compute_graph", "arm_compute", "arm_compute_core"]) |
| 72 | arm_compute_lib = arm_compute_graph_so |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 73 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 74 | common_files = Glob('*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 75 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 76 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 77 | files_benchmark = Glob('benchmark/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 78 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 79 | # Add unit tests |
Anthony Barbier | 979dc4f | 2018-03-07 09:27:48 +0000 | [diff] [blame] | 80 | files_validation = Glob('validation/UNIT/*/*.cpp') |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 81 | files_validation += Glob('validation/UNIT/*.cpp') |
| 82 | |
Georgios Pinitas | 8795ffb | 2017-12-01 16:13:40 +0000 | [diff] [blame] | 83 | # Add CPP tests |
| 84 | filter_pattern = test_env['test_filter'] |
| 85 | files_validation += Glob('validation/CPP/' + filter_pattern) |
| 86 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 87 | if env['opencl']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 88 | filter_pattern = test_env['test_filter'] |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 89 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 90 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 91 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 92 | files_benchmark += Glob('benchmark/CL/*/' + filter_pattern) |
| 93 | files_benchmark += Glob('benchmark/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 94 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 95 | files_validation += Glob('validation/CL/*/' + filter_pattern) |
| 96 | files_validation += Glob('validation/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 97 | |
| 98 | if env['neon']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 99 | filter_pattern = test_env['test_filter'] |
| 100 | files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern) |
| 101 | files_benchmark += Glob('benchmark/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 102 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 103 | files_validation += Glob('validation/NEON/*/' + filter_pattern) |
| 104 | files_validation += Glob('validation/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 105 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 106 | if env['gles_compute']: |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 107 | 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 Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 115 | if env['os'] == 'android': |
| 116 | test_env.Append(LIBS = ["log"]) |
Georgios Pinitas | 421405b | 2018-10-26 19:05:32 +0100 | [diff] [blame] | 117 | elif env['os'] != 'bare_metal': |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 118 | test_env.Append(LIBS = ["rt"]) |
| 119 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 120 | if test_env['benchmark_tests']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 121 | arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 122 | arm_compute_benchmark = install_bin(arm_compute_benchmark) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 123 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 124 | Depends(arm_compute_benchmark, arm_compute_lib) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 125 | Default(arm_compute_benchmark) |
| 126 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 127 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 128 | if test_env['validation_tests']: |
Anthony Barbier | 069818d | 2018-07-13 14:45:37 +0100 | [diff] [blame] | 129 | 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 Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 130 | Depends(arm_compute_validation_framework , arm_compute_test_framework) |
| 131 | Depends(arm_compute_validation_framework , arm_compute_core_a) |
| 132 | |
Anthony Barbier | 069818d | 2018-07-13 14:45:37 +0100 | [diff] [blame] | 133 | arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects, LIBS=[arm_compute_validation_framework] + test_env['LIBS']) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 134 | arm_compute_validation = install_bin(arm_compute_validation) |
Anthony Barbier | 2df1f99 | 2018-07-11 13:37:23 +0100 | [diff] [blame] | 135 | Depends(arm_compute_validation, arm_compute_validation_framework) |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 136 | Depends(arm_compute_validation, arm_compute_test_framework) |
| 137 | Depends(arm_compute_validation, arm_compute_lib) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 138 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 139 | Default(arm_compute_validation) |
Isabella Gottardi | 5cca9cb | 2019-02-12 11:42:33 +0000 | [diff] [blame] | 140 | Export('arm_compute_validation') |