blob: 9c9897ea0ed6073d6dbacb55fa9b36247f029dc9 [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
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010028SConscript('./framework/SConscript', duplicate=0)
29
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030# vars is imported from arm_compute:
31variables = [
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032 BoolVariable("validation_tests", "Build validation test programs", True),
Anthony Barbier79c61782017-06-23 11:48:24 +010033 BoolVariable("benchmark_tests", "Build benchmark test programs", True)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034]
35
36# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
37new_options = Variables('scons')
38
39for v in variables:
40 new_options.Add(v)
41 vars.Add(v)
42
Gian Marco Iodicef2399532017-09-13 14:16:41 +010043# Disable floating-point expression contraction (e.g. fused multiply-add operations)
44env.Append(CXXFLAGS = ['-ffp-contract=off'])
45
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046# Clone the environment to make sure we're not polluting the arm_compute one:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010047test_env = env.Clone()
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010048vars.Update(test_env)
49
50Help(new_options.GenerateHelpText(test_env))
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010051
52if env['os'] in ['android', 'bare_metal'] or env['standalone']:
53 Import("arm_compute_a")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010054 Import("arm_compute_core_a")
55 test_env.Append(LIBS = [arm_compute_a, arm_compute_core_a])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010056 arm_compute_lib = arm_compute_a
57else:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010058 Import("arm_compute_so")
Anthony Barbierb2881fc2017-09-29 17:12:12 +010059 test_env.Append(LIBS = ["arm_compute", "arm_compute_core"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010060 arm_compute_lib = arm_compute_so
61
62#FIXME Delete before release
Anthony Barbiera4e5e1e2017-10-05 14:55:34 +010063if env['internal_only']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010064 test_env.Append(CPPDEFINES=['INTERNAL_ONLY'])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010065
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010066test_env.Append(CPPPATH = ["#3rdparty/include"])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010067test_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])])
68test_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010069test_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010070
71Import("arm_compute_test_framework")
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010072test_env.Append(LIBS = arm_compute_test_framework)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010073
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010074common_files = Glob('*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010075common_objects = [test_env.StaticObject(f) for f in common_files]
76
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010077files_benchmark = Glob('benchmark/*.cpp')
78files_validation = Glob('validation/*.cpp')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010079
John Richardson70f946b2017-10-02 16:52:16 +010080# Add unit tests
81files_validation += Glob('validation/UNIT/*.cpp')
82
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010083# Always compile reference for validation
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010084files_validation += Glob('validation/CPP/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010085
Abe Mbise925ca0f2017-10-02 19:16:33 +010086# Add unit tests
87files_validation += Glob('validation/UNIT/*/*.cpp')
88files_validation += Glob('validation/UNIT/*.cpp')
89
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010090if env['opencl']:
91 Import('opencl')
92
Moritz Pflanzerc7d15032017-07-18 16:21:16 +010093 test_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
94 test_env.Append(LIBS = ["OpenCL"])
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010095
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010096 files_benchmark += Glob('benchmark/CL/*/*.cpp')
97 files_benchmark += Glob('benchmark/CL/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +010098
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010099 files_validation += Glob('validation/CL/*/*.cpp')
100 files_validation += Glob('validation/CL/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100101
102if env['neon']:
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100103 files_benchmark += Glob('benchmark/NEON/*/*.cpp')
104 files_benchmark += Glob('benchmark/NEON/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100105
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100106 files_validation += Glob('validation/NEON/*/*.cpp')
107 files_validation += Glob('validation/NEON/*.cpp')
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100108
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100109if env['os'] == 'android':
110 test_env.Append(LIBS = ["log"])
111else:
112 test_env.Append(LIBS = ["rt"])
113
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100114if test_env['benchmark_tests']:
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100115 arm_compute_benchmark = test_env.Program('arm_compute_benchmark', files_benchmark + common_objects)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100116 Depends(arm_compute_benchmark, arm_compute_test_framework)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100117 Depends(arm_compute_benchmark, arm_compute_lib)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100118
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100119 if env['opencl']:
120 Depends(arm_compute_benchmark, opencl)
Moritz Pflanzeree493ae2017-07-05 10:52:21 +0100121
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100122 Default(arm_compute_benchmark)
123 Export('arm_compute_benchmark')
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100124
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100125if test_env['validation_tests']:
126 arm_compute_validation = test_env.Program('arm_compute_validation', files_validation + common_objects)
127 Depends(arm_compute_validation, arm_compute_test_framework)
128 Depends(arm_compute_validation, arm_compute_lib)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100129
130 if env['opencl']:
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100131 Depends(arm_compute_validation, opencl)
Moritz Pflanzerc7d15032017-07-18 16:21:16 +0100132
Moritz Pflanzera09de0c2017-09-01 20:41:12 +0100133 Default(arm_compute_validation)
134 Export('arm_compute_validation')