Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | # 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. |
| 22 | import SCons |
| 23 | import os.path |
| 24 | |
| 25 | Import('env') |
| 26 | Import('vars') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 28 | SConscript('./framework/SConscript', duplicate=0) |
| 29 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | # vars is imported from arm_compute: |
| 31 | variables = [ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 32 | BoolVariable("validation_tests", "Build validation test programs", True), |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 33 | BoolVariable("benchmark_tests", "Build benchmark test programs", True), |
| 34 | ("test_filter", "Pattern to specify the tests' filenames to be compiled", "*.cpp") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | ] |
| 36 | |
| 37 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 38 | new_options = Variables('scons') |
| 39 | |
| 40 | for v in variables: |
| 41 | new_options.Add(v) |
| 42 | vars.Add(v) |
| 43 | |
Gian Marco Iodice | f239953 | 2017-09-13 14:16:41 +0100 | [diff] [blame] | 44 | # Disable floating-point expression contraction (e.g. fused multiply-add operations) |
| 45 | env.Append(CXXFLAGS = ['-ffp-contract=off']) |
| 46 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | # 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] | 48 | test_env = env.Clone() |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 49 | vars.Update(test_env) |
| 50 | |
| 51 | Help(new_options.GenerateHelpText(test_env)) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 52 | |
Isabella Gottardi | b28f29d | 2017-11-09 17:05:07 +0000 | [diff] [blame] | 53 | if env['os'] in ['bare_metal'] or env['standalone']: |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 54 | Import("arm_compute_a") |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 55 | Import("arm_compute_core_a") |
| 56 | test_env.Append(LIBS = [arm_compute_a, arm_compute_core_a]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 57 | arm_compute_lib = arm_compute_a |
| 58 | else: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 59 | Import("arm_compute_so") |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 60 | test_env.Append(LIBS = ["arm_compute", "arm_compute_core"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 61 | arm_compute_lib = arm_compute_so |
| 62 | |
| 63 | #FIXME Delete before release |
Anthony Barbier | a4e5e1e | 2017-10-05 14:55:34 +0100 | [diff] [blame] | 64 | if env['internal_only']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 65 | test_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 66 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 67 | test_env.Append(CPPPATH = ["#3rdparty/include"]) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 68 | test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 69 | test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 70 | test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 71 | if env['gles_compute'] and env['os'] != 'android': |
| 72 | test_env.Append(LIBPATH = ["#build/%s/opengles-3.1/stubs" % env['build_dir']]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 73 | |
| 74 | Import("arm_compute_test_framework") |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 75 | test_env.Append(LIBS = arm_compute_test_framework) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 76 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 77 | common_files = Glob('*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 78 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 79 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 80 | files_benchmark = Glob('benchmark/*.cpp') |
| 81 | files_validation = Glob('validation/*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 82 | |
| 83 | # Always compile reference for validation |
Georgios Pinitas | 5a7e776 | 2017-12-01 16:27:29 +0000 | [diff] [blame] | 84 | files_validation += Glob('validation/reference/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 85 | |
Abe Mbise | 925ca0f | 2017-10-02 19:16:33 +0100 | [diff] [blame] | 86 | # Add unit tests |
| 87 | files_validation += Glob('validation/UNIT/*/*.cpp') |
| 88 | files_validation += Glob('validation/UNIT/*.cpp') |
| 89 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 90 | if env['opencl']: |
| 91 | Import('opencl') |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 92 | filter_pattern = test_env['test_filter'] |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 93 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 94 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
| 95 | test_env.Append(LIBS = ["OpenCL"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 96 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 97 | files_benchmark += Glob('benchmark/CL/*/' + filter_pattern) |
| 98 | files_benchmark += Glob('benchmark/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 99 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 100 | files_validation += Glob('validation/CL/*/' + filter_pattern) |
| 101 | files_validation += Glob('validation/CL/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 102 | |
| 103 | if env['neon']: |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 104 | filter_pattern = test_env['test_filter'] |
| 105 | files_benchmark += Glob('benchmark/NEON/*/' + filter_pattern) |
| 106 | files_benchmark += Glob('benchmark/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 107 | |
Pablo Tello | ea1c950 | 2017-11-09 11:49:18 +0000 | [diff] [blame] | 108 | files_validation += Glob('validation/NEON/*/' + filter_pattern) |
| 109 | files_validation += Glob('validation/NEON/' + filter_pattern) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 110 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 111 | if env['gles_compute']: |
| 112 | if env['os'] != 'android': |
| 113 | Import('egl') |
| 114 | Import('glesv2') |
| 115 | |
| 116 | test_env.Append(CPPPATH = ["#opengles-3.1/include", "#opengles-3.1/mali_include"]) |
| 117 | test_env.Append(LIBS = ["EGL", "GLESv2"]) |
| 118 | else: |
| 119 | if env['arch'] != 'armv7a': |
| 120 | test_env.Append(LIBS = ["EGL", "GLESv3"]) |
| 121 | else: |
| 122 | test_env.Append(LIBS = ["EGL", "GLESv2"]) |
| 123 | |
| 124 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_GC']) |
| 125 | |
| 126 | files_benchmark += Glob('benchmark/GLES_COMPUTE/*/*.cpp') |
| 127 | files_benchmark += Glob('benchmark/GLES_COMPUTE/*.cpp') |
| 128 | |
| 129 | files_validation += Glob('validation/GLES_COMPUTE/*/*.cpp') |
| 130 | files_validation += Glob('validation/GLES_COMPUTE/*.cpp') |
| 131 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 132 | if env['os'] == 'android': |
| 133 | test_env.Append(LIBS = ["log"]) |
| 134 | else: |
| 135 | test_env.Append(LIBS = ["rt"]) |
| 136 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 137 | if test_env['benchmark_tests']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 138 | arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 139 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 140 | Depends(arm_compute_benchmark, arm_compute_lib) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 141 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 142 | if env['opencl']: |
| 143 | Depends(arm_compute_benchmark, opencl) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 144 | if env['gles_compute'] and env['os'] != 'android': |
| 145 | Depends(arm_compute_benchmark, egl) |
| 146 | Depends(arm_compute_benchmark, glesv2) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 147 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 148 | Default(arm_compute_benchmark) |
| 149 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 150 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 151 | if test_env['validation_tests']: |
| 152 | arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects) |
| 153 | Depends(arm_compute_validation, arm_compute_test_framework) |
| 154 | Depends(arm_compute_validation, arm_compute_lib) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 155 | |
| 156 | if env['opencl']: |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 157 | Depends(arm_compute_validation, opencl) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 158 | if env['gles_compute'] and env['os'] != 'android': |
| 159 | Depends(arm_compute_validation, egl) |
| 160 | Depends(arm_compute_validation, glesv2) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 161 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 162 | Default(arm_compute_validation) |
| 163 | Export('arm_compute_validation') |