blob: 8da1d2fa334353d9ce877ac7d74be06ae8eb3add [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')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027
28# vars is imported from arm_compute:
29variables = [
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 Barbier79c61782017-06-23 11:48:24 +010034 BoolVariable("benchmark_tests", "Build benchmark test programs", True)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035]
36
37# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
38new_options = Variables('scons')
39
40for 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:
45common_env = env.Clone()
46vars.Update(common_env)
47
48Help(new_options.GenerateHelpText(common_env))
49
Pablo Telloc6cb35a2017-06-21 15:39:47 +010050if env['os'] in ['android', 'bare_metal'] or env['standalone']:
51 Import('arm_compute_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052 common_env.Append(LIBS = [arm_compute_a])
53 arm_compute_lib = arm_compute_a
54else:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010055 Import('arm_compute_so')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056 common_env.Append(LIBS = ["arm_compute"])
57 arm_compute_lib = arm_compute_so
58
Anthony Barbier6ff3b192017-09-04 18:44:23 +010059#FIXME Delete before release
60if common_env['internal_only']:
61 common_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
62
63common_env.Append(CPPPATH = [".", "#3rdparty/include"])
64common_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
65common_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
66common_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
67common_env.Append(LIBS = ['boost_program_options'])
68common_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers'])
69
70validation_env = common_env.Clone()
71benchmark_env = common_env.Clone()
72
73validation_env.Append(CPPDEFINES=['BOOST'])
74# overloaded virtual function "benchmark::Fixture::SetUp" is only partially overridden
75benchmark_env.Append(CPPFLAGS=['-Wno-overloaded-virtual'])
76
77files = Glob('*.cpp')
78
79common_objects = [ common_env.StaticObject( f ) for f in files ]
80
81validation_env.Append(LIBS = ['boost_unit_test_framework'])
82benchmark_env.Append(LIBS = ['benchmark'])
83
84files_validation = Glob('validation/*.cpp')
85files_benchmark = Glob('benchmark/*.cpp')
86
87if env['os'] == 'android' or not common_env['pmu']:
88 if env['os'] == 'android' and common_env['pmu']:
89 if env['Werror']:
90 print("pmu=1 is not supported for os=android")
91 Exit(1)
92 else:
93 print("pmu=1 is not supported for os=android")
94
95 files_benchmark = [f for f in files_benchmark if "PMU" not in os.path.basename(str(f))]
96
97# Add unit tests
98files_validation += Glob('validation/UNIT/*.cpp')
99files_validation += Glob('validation/UNIT/*/*.cpp')
100
101if env['opencl']:
102 Import('opencl')
103
104 benchmark_env.Append(CPPDEFINES=['OPENCL'])
105
106 files_validation += Glob('validation/CL/*.cpp')
107 files_validation += Glob('validation/CL/*/*.cpp')
108 files_validation += Glob('validation/system_tests/CL/*.cpp')
109 files_benchmark += Glob('benchmark/CL/*/*.cpp')
110 files_benchmark += Glob('benchmark/CL/*.cpp')
111 files_benchmark += Glob('benchmark/system_tests/CL/*.cpp')
112
113 validation_env.Append(LIBS = "OpenCL")
114 benchmark_env.Append(LIBS = "OpenCL")
115
116if env['neon']:
117 files_validation += Glob('validation/NEON/*.cpp')
118 files_validation += Glob('validation/NEON/*/*.cpp')
119 files_validation += Glob('validation/system_tests/NEON/*.cpp')
120 files_benchmark += Glob('benchmark/NEON/*/*.cpp')
121 files_benchmark += Glob('benchmark/NEON/*.cpp')
122 files_benchmark += Glob('benchmark/system_tests/NEON/*.cpp')
123
124if env['os'] == 'android':
125 validation_env.Append(LIBS = ["log"])
126 benchmark_env.Append(LIBS = ["log"])
127else:
128 benchmark_env.Append(LIBS = ["rt"])
129
130if common_env['validation_tests']:
131 arm_compute_validation = validation_env.Program('arm_compute_validation',
132 files_validation + common_objects)
133 Depends(arm_compute_validation, arm_compute_lib)
134 if env['opencl']:
135 Depends(arm_compute_validation, opencl)
136 Default(arm_compute_validation)
137 Export('arm_compute_validation')
138if common_env['benchmark_tests']:
139 arm_compute_benchmark = benchmark_env.Program('arm_compute_benchmark',
140 files_benchmark + common_objects)
141 Depends(arm_compute_benchmark, arm_compute_lib)
142 if env['opencl']:
143 Depends(arm_compute_benchmark, opencl)
144 Default(arm_compute_benchmark)
145 Export('arm_compute_benchmark')
146