blob: 049113aba266ea60405219a3149137f42905ef5e [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001# 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.
22import SCons
23import os.path
24
25Import('env')
26Import('vars')
27Import('arm_compute_a')
28Import('arm_compute_so')
29
30# vars is imported from arm_compute:
31variables = [
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)
40new_options = Variables('scons')
41
42for 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:
47common_env = env.Clone()
48vars.Update(common_env)
49
50Help(new_options.GenerateHelpText(common_env))
51
52if env['os'] in ['android', 'bare_metal']:
53 common_env.Append(LIBS = [arm_compute_a])
54 arm_compute_lib = arm_compute_a
55else:
56 common_env.Append(LIBS = ["arm_compute"])
57 arm_compute_lib = arm_compute_so
58
59if 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
64if common_env['internal_only']:
65 common_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
66
67common_env.Append(CPPPATH = [".", "#3rdparty/include"])
68common_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
69common_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
70common_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
71common_env.Append(LIBS = ['boost_program_options'])
72common_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers'])
73
74validation_env = common_env.Clone()
75benchmark_env = common_env.Clone()
76
77validation_env.Append(CPPDEFINES=['BOOST'])
78# overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden
79benchmark_env.Append(CPPFLAGS=['-Wno-overloaded-virtual'])
80
81files = Glob('*.cpp')
82
83common_objects = [ common_env.StaticObject( f ) for f in files ]
84
85validation_env.Append(LIBS = ['boost_unit_test_framework'])
86benchmark_env.Append(LIBS = ['benchmark'])
87
88files_validation = Glob('validation/*.cpp')
89files_benchmark = Glob('benchmark/*.cpp')
90
91if 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
102files_validation += Glob('validation/UNIT/*.cpp')
103files_validation += Glob('validation/UNIT/*/*.cpp')
104
105if 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
120if 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
128if env['os'] == 'android':
129 validation_env.Append(LIBS = ["log"])
130 benchmark_env.Append(LIBS = ["log"])
131else:
132 benchmark_env.Append(LIBS = ["rt"])
133
134if 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')
142if 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