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') |
| 27 | Import('arm_compute_a') |
| 28 | Import('arm_compute_so') |
| 29 | |
| 30 | # vars is imported from arm_compute: |
| 31 | variables = [ |
| 32 | #FIXME Remove before release (And remove all references to INTERNAL_ONLY) |
| 33 | BoolVariable("internal_only", "Enable ARM internal only tests", True), |
| 34 | BoolVariable("pmu", "Enable PMU counters", False), |
| 35 | BoolVariable("validation_tests", "Build validation test programs", True), |
| 36 | BoolVariable("benchmark_tests", "Build validation test programs", True) |
| 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 | |
| 46 | # Clone the environment to make sure we're not polluting the arm_compute one: |
| 47 | common_env = env.Clone() |
| 48 | vars.Update(common_env) |
| 49 | |
| 50 | Help(new_options.GenerateHelpText(common_env)) |
| 51 | |
| 52 | if env['os'] in ['android', 'bare_metal']: |
| 53 | common_env.Append(LIBS = [arm_compute_a]) |
| 54 | arm_compute_lib = arm_compute_a |
| 55 | else: |
| 56 | common_env.Append(LIBS = ["arm_compute"]) |
| 57 | arm_compute_lib = arm_compute_so |
| 58 | |
| 59 | if env['arch'] == 'arm64-v8.2-a' and ( common_env['validation_tests'] or common_env['benchmark_tests']): |
| 60 | print("validation_tests=1 and benchmark_tests=1 are not currently supported for arch=arm64-v8.2-a") |
| 61 | Exit(1) |
| 62 | |
| 63 | #FIXME Delete before release |
| 64 | if common_env['internal_only']: |
| 65 | common_env.Append(CPPDEFINES=['INTERNAL_ONLY']) |
| 66 | |
| 67 | common_env.Append(CPPPATH = [".", "#3rdparty/include"]) |
| 68 | common_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) |
| 69 | common_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) |
| 70 | common_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
| 71 | common_env.Append(LIBS = ['boost_program_options']) |
| 72 | common_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) |
| 73 | |
| 74 | validation_env = common_env.Clone() |
| 75 | benchmark_env = common_env.Clone() |
| 76 | |
| 77 | validation_env.Append(CPPDEFINES=['BOOST']) |
| 78 | # overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden |
| 79 | benchmark_env.Append(CPPFLAGS=['-Wno-overloaded-virtual']) |
| 80 | |
| 81 | files = Glob('*.cpp') |
| 82 | |
| 83 | common_objects = [ common_env.StaticObject( f ) for f in files ] |
| 84 | |
| 85 | validation_env.Append(LIBS = ['boost_unit_test_framework']) |
| 86 | benchmark_env.Append(LIBS = ['benchmark']) |
| 87 | |
| 88 | files_validation = Glob('validation/*.cpp') |
| 89 | files_benchmark = Glob('benchmark/*.cpp') |
| 90 | |
| 91 | if env['os'] == 'android' or not common_env['pmu']: |
| 92 | if env['os'] == 'android' and common_env['pmu']: |
| 93 | if env['Werror']: |
| 94 | print("pmu=1 is not supported for os=android") |
| 95 | Exit(1) |
| 96 | else: |
| 97 | print("pmu=1 is not supported for os=android") |
| 98 | |
| 99 | files_benchmark = [f for f in files_benchmark if "PMU" not in os.path.basename(str(f))] |
| 100 | |
| 101 | # Add unit tests |
| 102 | files_validation += Glob('validation/UNIT/*.cpp') |
| 103 | files_validation += Glob('validation/UNIT/*/*.cpp') |
| 104 | |
| 105 | if env['opencl']: |
| 106 | Import('opencl') |
| 107 | |
| 108 | benchmark_env.Append(CPPDEFINES=['OPENCL']) |
| 109 | |
| 110 | files_validation += Glob('validation/CL/*.cpp') |
| 111 | files_validation += Glob('validation/CL/*/*.cpp') |
| 112 | files_validation += Glob('validation/system_tests/CL/*.cpp') |
| 113 | files_benchmark += Glob('benchmark/CL/*/*.cpp') |
| 114 | files_benchmark += Glob('benchmark/CL/*.cpp') |
| 115 | files_benchmark += Glob('benchmark/system_tests/CL/*.cpp') |
| 116 | |
| 117 | validation_env.Append(LIBS = "OpenCL") |
| 118 | benchmark_env.Append(LIBS = "OpenCL") |
| 119 | |
| 120 | if env['neon']: |
| 121 | files_validation += Glob('validation/NEON/*.cpp') |
| 122 | files_validation += Glob('validation/NEON/*/*.cpp') |
| 123 | files_validation += Glob('validation/system_tests/NEON/*.cpp') |
| 124 | files_benchmark += Glob('benchmark/NEON/*/*.cpp') |
| 125 | files_benchmark += Glob('benchmark/NEON/*.cpp') |
| 126 | files_benchmark += Glob('benchmark/system_tests/NEON/*.cpp') |
| 127 | |
| 128 | if env['os'] == 'android': |
| 129 | validation_env.Append(LIBS = ["log"]) |
| 130 | benchmark_env.Append(LIBS = ["log"]) |
| 131 | else: |
| 132 | benchmark_env.Append(LIBS = ["rt"]) |
| 133 | |
| 134 | if common_env['validation_tests']: |
| 135 | arm_compute_validation = validation_env.Program('arm_compute_validation', |
| 136 | files_validation + common_objects) |
| 137 | Depends(arm_compute_validation, arm_compute_lib) |
| 138 | if env['opencl']: |
| 139 | Depends(arm_compute_validation, opencl) |
| 140 | Default(arm_compute_validation) |
| 141 | Export('arm_compute_validation') |
| 142 | if common_env['benchmark_tests']: |
| 143 | arm_compute_benchmark = benchmark_env.Program('arm_compute_benchmark', |
| 144 | files_benchmark + common_objects) |
| 145 | Depends(arm_compute_benchmark, arm_compute_lib) |
| 146 | if env['opencl']: |
| 147 | Depends(arm_compute_benchmark, opencl) |
| 148 | Default(arm_compute_benchmark) |
| 149 | Export('arm_compute_benchmark') |
| 150 | |