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 | |
| 28 | # vars is imported from arm_compute: |
| 29 | variables = [ |
| 30 | #FIXME Remove before release (And remove all references to INTERNAL_ONLY) |
| 31 | BoolVariable("internal_only", "Enable ARM internal only tests", True), |
| 32 | BoolVariable("pmu", "Enable PMU counters", False), |
| 33 | BoolVariable("validation_tests", "Build validation test programs", True), |
Anthony Barbier | 79c6178 | 2017-06-23 11:48:24 +0100 | [diff] [blame] | 34 | BoolVariable("benchmark_tests", "Build benchmark test programs", True) |
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 | |
| 44 | # 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] | 45 | old_validation_env = env.Clone() |
| 46 | vars.Update(old_validation_env) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 48 | Help(new_options.GenerateHelpText(old_validation_env)) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 49 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 50 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
| 51 | Import('arm_compute_a') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 52 | old_validation_env.Append(LIBS = [arm_compute_a]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 53 | arm_compute_lib = arm_compute_a |
| 54 | else: |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 55 | Import('arm_compute_so') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 56 | old_validation_env.Append(LIBS = ["arm_compute"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 57 | arm_compute_lib = arm_compute_so |
| 58 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 59 | #FIXME Delete before release |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 60 | if old_validation_env['internal_only']: |
| 61 | old_validation_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 62 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 63 | old_validation_env.Append(CPPPATH = [".", "#3rdparty/include"]) |
| 64 | old_validation_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 65 | old_validation_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
| 66 | old_validation_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
| 67 | old_validation_env.Append(LIBS = ['boost_program_options']) |
| 68 | old_validation_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) |
| 69 | old_validation_env.Append(CPPDEFINES=['BOOST']) |
| 70 | old_validation_env.Append(LIBS = ['boost_unit_test_framework']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 71 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 72 | old_files_validation = Glob('*.cpp') |
| 73 | old_files_validation = [f for f in old_files_validation if "main.cpp" not in os.path.basename(str(f))] |
| 74 | old_files_validation += Glob('validation/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 75 | |
| 76 | # Add unit tests |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 77 | old_files_validation += Glob('validation/UNIT/*.cpp') |
| 78 | old_files_validation += Glob('validation/UNIT/*/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 79 | |
| 80 | if env['opencl']: |
| 81 | Import('opencl') |
| 82 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 83 | old_files_validation += Glob('validation/CL/*.cpp') |
| 84 | old_files_validation += Glob('validation/CL/*/*.cpp') |
| 85 | old_files_validation += Glob('validation/system_tests/CL/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 86 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 87 | old_validation_env.Append(LIBS = "OpenCL") |
| 88 | old_validation_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 89 | |
| 90 | if env['neon']: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 91 | old_files_validation += Glob('validation/NEON/*.cpp') |
| 92 | old_files_validation += Glob('validation/NEON/*/*.cpp') |
| 93 | old_files_validation += Glob('validation/system_tests/NEON/*.cpp') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 94 | |
| 95 | if env['os'] == 'android': |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 96 | old_validation_env.Append(LIBS = ["log"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 97 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 98 | if old_validation_env['validation_tests']: |
| 99 | arm_compute_validation = old_validation_env.Program('arm_compute_validation', old_files_validation) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 100 | Depends(arm_compute_validation, arm_compute_lib) |
| 101 | if env['opencl']: |
| 102 | Depends(arm_compute_validation, opencl) |
| 103 | Default(arm_compute_validation) |
| 104 | Export('arm_compute_validation') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 105 | |
| 106 | ####################################################################### |
| 107 | # Using new framework |
| 108 | ####################################################################### |
| 109 | |
| 110 | # 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] | 111 | test_env = env.Clone() |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 112 | # Workaround to build both test systems in parallel |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 113 | test_env.VariantDir("new", ".", duplicate=0) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 114 | |
| 115 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
| 116 | Import("arm_compute_a") |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 117 | test_env.Append(LIBS = [arm_compute_a]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 118 | arm_compute_lib = arm_compute_a |
| 119 | else: |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 120 | Import("arm_compute_so") |
| 121 | test_env.Append(LIBS = ["arm_compute"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 122 | arm_compute_lib = arm_compute_so |
| 123 | |
| 124 | #FIXME Delete before release |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 125 | if old_validation_env['internal_only']: |
| 126 | test_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 127 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 128 | test_env.Append(CPPPATH = [".", "#3rdparty/include"]) |
| 129 | test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 130 | test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
| 131 | test_env.Append(LIBPATH = ["#build/%s/framework" % env['build_dir']]) |
| 132 | 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] | 133 | |
| 134 | Import("arm_compute_test_framework") |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 135 | test_env.Append(LIBS = arm_compute_test_framework) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 136 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 137 | common_files = Glob('new/AssetsLibrary.cpp') |
| 138 | common_files += Glob('new/RawTensor.cpp') |
| 139 | common_files += Glob('new/main.cpp') |
| 140 | |
| 141 | common_objects = [test_env.StaticObject(f) for f in common_files] |
| 142 | |
| 143 | files_benchmark = Glob('new/benchmark_new/*.cpp') |
| 144 | files_validation = Glob('new/validation_new/*.cpp') |
| 145 | |
| 146 | # Always compile reference for validation |
| 147 | files_validation += Glob('new/validation_new/CPP/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 148 | |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 149 | if env['opencl']: |
| 150 | Import('opencl') |
| 151 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 152 | test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) |
| 153 | test_env.Append(LIBS = ["OpenCL"]) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 154 | |
| 155 | files_benchmark += Glob('new/benchmark_new/CL/*/*.cpp') |
| 156 | files_benchmark += Glob('new/benchmark_new/CL/*.cpp') |
| 157 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 158 | files_validation += Glob('new/validation_new/CL/*/*.cpp') |
| 159 | files_validation += Glob('new/validation_new/CL/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 160 | |
| 161 | if env['neon']: |
| 162 | files_benchmark += Glob('new/benchmark_new/NEON/*/*.cpp') |
| 163 | files_benchmark += Glob('new/benchmark_new/NEON/*.cpp') |
| 164 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 165 | files_validation += Glob('new/validation_new/NEON/*/*.cpp') |
| 166 | files_validation += Glob('new/validation_new/NEON/*.cpp') |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 167 | |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 168 | if env['os'] == 'android': |
| 169 | test_env.Append(LIBS = ["log"]) |
| 170 | else: |
| 171 | test_env.Append(LIBS = ["rt"]) |
| 172 | |
| 173 | if old_validation_env['benchmark_tests']: |
| 174 | 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] | 175 | Depends(arm_compute_benchmark, arm_compute_test_framework) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 176 | Depends(arm_compute_benchmark, arm_compute_lib) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 177 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 178 | if env['opencl']: |
| 179 | Depends(arm_compute_benchmark, opencl) |
Moritz Pflanzer | ee493ae | 2017-07-05 10:52:21 +0100 | [diff] [blame] | 180 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 181 | Default(arm_compute_benchmark) |
| 182 | Export('arm_compute_benchmark') |
Moritz Pflanzer | c7d1503 | 2017-07-18 16:21:16 +0100 | [diff] [blame] | 183 | |
| 184 | if old_validation_env['validation_tests']: |
| 185 | arm_compute_validation_new = test_env.Program('arm_compute_validation_new', files_validation + common_objects) |
| 186 | Depends(arm_compute_validation_new, arm_compute_test_framework) |
| 187 | Depends(arm_compute_validation_new, arm_compute_lib) |
| 188 | |
| 189 | if env['opencl']: |
| 190 | Depends(arm_compute_validation_new, opencl) |
| 191 | |
| 192 | Default(arm_compute_validation_new) |
| 193 | Export('arm_compute_validation_new') |