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 | |
| 30 | #FIXME: Remove before release |
| 31 | SConscript('./validation_old/SConscript', duplicate=0) |
| 32 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | # vars is imported from arm_compute: |
| 34 | variables = [ |
| 35 | #FIXME Remove before release (And remove all references to INTERNAL_ONLY) |
| 36 | BoolVariable("internal_only", "Enable ARM internal only tests", True), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | BoolVariable("validation_tests", "Build validation test programs", True), |
Anthony Barbier | 79c6178 | 2017-06-23 11:48:24 +0100 | [diff] [blame] | 38 | BoolVariable("benchmark_tests", "Build benchmark test programs", True) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | ] |
| 40 | |
| 41 | # We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) |
| 42 | new_options = Variables('scons') |
| 43 | |
| 44 | for v in variables: |
| 45 | new_options.Add(v) |
| 46 | vars.Add(v) |
| 47 | |
Gian Marco Iodice | f239953 | 2017-09-13 14:16:41 +0100 | [diff] [blame] | 48 | # Disable floating-point expression contraction (e.g. fused multiply-add operations) |
| 49 | env.Append(CXXFLAGS = ['-ffp-contract=off']) |
| 50 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 51 | # 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] | 52 | test_env = env.Clone() |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 53 | vars.Update(test_env) |
| 54 | |
| 55 | Help(new_options.GenerateHelpText(test_env)) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 56 | |
| 57 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
| 58 | Import("arm_compute_a") |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 59 | test_env.Append(LIBS = [arm_compute_a]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 60 | arm_compute_lib = arm_compute_a |
| 61 | else: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 62 | Import("arm_compute_so") |
| 63 | test_env.Append(LIBS = ["arm_compute"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 64 | arm_compute_lib = arm_compute_so |
| 65 | |
| 66 | #FIXME Delete before release |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 67 | if test_env['internal_only']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 68 | test_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 69 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 70 | test_env.Append(CPPPATH = ["#3rdparty/include"]) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 71 | test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 72 | test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 73 | test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 74 | |
| 75 | Import("arm_compute_test_framework") |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 76 | test_env.Append(LIBS = arm_compute_test_framework) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 77 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 78 | common_files = Glob('*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 79 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 80 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 81 | files_benchmark = Glob('benchmark/*.cpp') |
| 82 | files_validation = Glob('validation/*.cpp') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 83 | |
| 84 | # Always compile reference for validation |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 85 | files_validation += Glob('validation/CPP/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 86 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 87 | if env['opencl']: |
| 88 | Import('opencl') |
| 89 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 90 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
| 91 | test_env.Append(LIBS = ["OpenCL"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 92 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 93 | files_benchmark += Glob('benchmark/CL/*/*.cpp') |
| 94 | files_benchmark += Glob('benchmark/CL/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 95 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 96 | files_validation += Glob('validation/CL/*/*.cpp') |
| 97 | files_validation += Glob('validation/CL/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 98 | |
| 99 | if env['neon']: |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 100 | files_benchmark += Glob('benchmark/NEON/*/*.cpp') |
| 101 | files_benchmark += Glob('benchmark/NEON/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 102 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 103 | files_validation += Glob('validation/NEON/*/*.cpp') |
| 104 | files_validation += Glob('validation/NEON/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 105 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 106 | if env['os'] == 'android': |
| 107 | test_env.Append(LIBS = ["log"]) |
| 108 | else: |
| 109 | test_env.Append(LIBS = ["rt"]) |
| 110 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 111 | if test_env['benchmark_tests']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 112 | 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] | 113 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 114 | Depends(arm_compute_benchmark, arm_compute_lib) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 115 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 116 | if env['opencl']: |
| 117 | Depends(arm_compute_benchmark, opencl) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 118 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 119 | Default(arm_compute_benchmark) |
| 120 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 121 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 122 | if test_env['validation_tests']: |
| 123 | arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects) |
| 124 | Depends(arm_compute_validation, arm_compute_test_framework) |
| 125 | Depends(arm_compute_validation, arm_compute_lib) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 126 | |
| 127 | if env['opencl']: |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 128 | Depends(arm_compute_validation, opencl) |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 129 | |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 130 | Default(arm_compute_validation) |
| 131 | Export('arm_compute_validation') |