blob: 3b2be1176676272f9980e3f27224cc7e07bfc592 [file] [log] [blame]
Jenkins18b685f2020-08-21 10:26:22 +01001# Copyright (c) 2016, 2017 Arm Limited.
Anthony Barbier871448e2017-03-24 14:54:29 +00002#
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
Anthony Barbierdbdab852017-06-23 15:42:00 +010023import SCons
Anthony Barbier46d59272017-05-04 09:15:15 +010024import os
Anthony Barbierdbdab852017-06-23 15:42:00 +010025import subprocess
26
27def version_at_least(version, required):
Anthony Barbierdbdab852017-06-23 15:42:00 +010028
Jenkins49b8f902020-11-27 12:49:11 +000029 version_list = version.split('.')
30 required_list = required.split('.')
31 end = min(len(version_list), len(required_list))
32 for i in range(0, end):
33 if int(version_list[i]) < int(required_list[i]):
Anthony Barbierdbdab852017-06-23 15:42:00 +010034 return False
Jenkins49b8f902020-11-27 12:49:11 +000035 elif int(version_list[i]) > int(required_list[i]):
Anthony Barbierdbdab852017-06-23 15:42:00 +010036 return True
37
38 return True
Anthony Barbier46d59272017-05-04 09:15:15 +010039
40vars = Variables("scons")
41vars.AddVariables(
42 BoolVariable("debug", "Debug", False),
43 BoolVariable("asserts", "Enable asserts (this flag is forced to 1 for debug=1)", False),
Anthony Barbier8140e1e2017-12-14 23:48:46 +000044 BoolVariable("logging", "Logging (this flag is forced to 1 for debug=1)", False),
Jenkins36ccc902020-02-21 11:10:48 +000045 EnumVariable("arch", "Target Architecture", "armv7a",
46 allowed_values=("armv7a", "arm64-v8a", "arm64-v8.2-a", "arm64-v8.2-a-sve", "x86_32", "x86_64",
Jenkins49b8f902020-11-27 12:49:11 +000047 "armv8a", "armv8.2-a", "armv8.2-a-sve", "armv8.6-a", "armv8.6-a-sve", "x86")),
Jenkins36ccc902020-02-21 11:10:48 +000048 EnumVariable("estate", "Execution State", "auto", allowed_values=("auto", "32", "64")),
Jenkins6a7771e2020-05-28 11:28:36 +010049 EnumVariable("os", "Target OS", "linux", allowed_values=("linux", "android", "tizen", "bare_metal")),
Anthony Barbier06ea0482018-02-22 15:45:35 +000050 EnumVariable("build", "Build type", "cross_compile", allowed_values=("native", "cross_compile", "embed_only")),
Anthony Barbierdbdab852017-06-23 15:42:00 +010051 BoolVariable("examples", "Build example programs", True),
Jenkins0e205f72019-11-28 16:53:35 +000052 BoolVariable("gemm_tuner", "Build gemm_tuner programs", True),
Anthony Barbier46d59272017-05-04 09:15:15 +010053 BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True),
Kaizen8938bd32017-09-28 14:38:23 +010054 BoolVariable("standalone", "Builds the tests as standalone executables, links statically with libgcc, libstdc++ and libarm_compute", False),
Anthony Barbier46d59272017-05-04 09:15:15 +010055 BoolVariable("opencl", "Enable OpenCL support", True),
56 BoolVariable("neon", "Enable Neon support", False),
Anthony Barbier8140e1e2017-12-14 23:48:46 +000057 BoolVariable("gles_compute", "Enable OpenGL ES Compute Shader support", False),
Anthony Barbierf45d5a92018-01-24 16:23:15 +000058 BoolVariable("embed_kernels", "Embed OpenCL kernels and OpenGL ES compute shaders in library binary", True),
Anthony Barbier46d59272017-05-04 09:15:15 +010059 BoolVariable("set_soname", "Set the library's soname and shlibversion (requires SCons 2.4 or above)", False),
Jenkins6a7771e2020-05-28 11:28:36 +010060 BoolVariable("tracing", "Enable runtime tracing", False),
Anthony Barbier46d59272017-05-04 09:15:15 +010061 BoolVariable("openmp", "Enable OpenMP backend", False),
62 BoolVariable("cppthreads", "Enable C++11 threads backend", True),
Anthony Barbierdbdab852017-06-23 15:42:00 +010063 PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathAccept),
Jenkinsb9abeae2018-11-22 11:58:08 +000064 PathVariable("install_dir", "Specify sub-folder for the install", "", PathVariable.PathAccept),
Jenkins514be652019-02-28 12:25:18 +000065 BoolVariable("exceptions", "Enable/disable C++ exception support", True),
Jenkins36ccc902020-02-21 11:10:48 +000066 PathVariable("linker_script", "Use an external linker script", "", PathVariable.PathAccept),
Jenkins49b8f902020-11-27 12:49:11 +000067 ListVariable("custom_options", "Custom options that can be used to turn on/off features", "none", ["disable_mmla_fp"]),
68 ListVariable("data_type_support", "Enable a list of data types to support", "all", ["qasymm8", "qasymm8_signed", "qsymm16", "fp16", "fp32"]),
Jenkins514be652019-02-28 12:25:18 +000069 ("toolchain_prefix", "Override the toolchain prefix", ""),
Jenkins36ccc902020-02-21 11:10:48 +000070 ("compiler_prefix", "Override the compiler prefix", ""),
Jenkinsb3a371b2018-05-23 11:36:53 +010071 ("extra_cxx_flags", "Extra CXX flags to be appended to the build command", ""),
Jenkinsb9abeae2018-11-22 11:58:08 +000072 ("extra_link_flags", "Extra LD flags to be appended to the build command", ""),
Jenkinsb3a371b2018-05-23 11:36:53 +010073 ("compiler_cache", "Command to prefix to the C and C++ compiler (e.g ccache)", "")
Anthony Barbier46d59272017-05-04 09:15:15 +010074)
75
Anthony Barbierdbdab852017-06-23 15:42:00 +010076env = Environment(platform="posix", variables=vars, ENV = os.environ)
Jenkinsb9abeae2018-11-22 11:58:08 +000077build_path = env['build_dir']
78# If build_dir is a relative path then add a #build/ prefix:
79if not env['build_dir'].startswith('/'):
80 SConsignFile('build/%s/.scons' % build_path)
81 build_path = "#build/%s" % build_path
82else:
83 SConsignFile('%s/.scons' % build_path)
84
85install_path = env['install_dir']
86#If the install_dir is a relative path then assume it's from inside build_dir
87if not env['install_dir'].startswith('/') and install_path != "":
88 install_path = "%s/%s" % (build_path, install_path)
89
90env.Append(LIBPATH = [build_path])
Anthony Barbier06ea0482018-02-22 15:45:35 +000091Export('env')
92Export('vars')
Anthony Barbierdbdab852017-06-23 15:42:00 +010093
Jenkinsb9abeae2018-11-22 11:58:08 +000094def install_lib( lib ):
95 # If there is no install folder, then there is nothing to do:
96 if install_path == "":
97 return lib
98 return env.Install( "%s/lib/" % install_path, lib)
99def install_bin( bin ):
100 # If there is no install folder, then there is nothing to do:
101 if install_path == "":
102 return bin
103 return env.Install( "%s/bin/" % install_path, bin)
104def install_include( inc ):
105 if install_path == "":
106 return inc
107 return env.Install( "%s/include/" % install_path, inc)
108
109Export('install_lib')
110Export('install_bin')
Anthony Barbier46d59272017-05-04 09:15:15 +0100111
112Help(vars.GenerateHelpText(env))
113
Jenkins36ccc902020-02-21 11:10:48 +0000114if env['linker_script'] and env['os'] != 'bare_metal':
115 print("Linker script is only supported for bare_metal builds")
116 Exit(1)
117
Anthony Barbier06ea0482018-02-22 15:45:35 +0000118if env['build'] == "embed_only":
Jenkinsb9abeae2018-11-22 11:58:08 +0000119 SConscript('./SConscript', variant_dir=build_path, duplicate=0)
Anthony Barbier06ea0482018-02-22 15:45:35 +0000120 Return()
121
Anthony Barbierdbdab852017-06-23 15:42:00 +0100122if env['neon'] and 'x86' in env['arch']:
ggardete2542c92018-06-29 17:01:01 +0200123 print("Cannot compile NEON for x86")
Anthony Barbierdbdab852017-06-23 15:42:00 +0100124 Exit(1)
125
126if env['set_soname'] and not version_at_least(SCons.__version__, "2.4"):
ggardete2542c92018-06-29 17:01:01 +0200127 print("Setting the library's SONAME / SHLIBVERSION requires SCons 2.4 or above")
128 print("Update your version of SCons or use set_soname=0")
Anthony Barbierdbdab852017-06-23 15:42:00 +0100129 Exit(1)
130
131if env['os'] == 'bare_metal':
132 if env['cppthreads'] or env['openmp']:
133 print("ERROR: OpenMP and C++11 threads not supported in bare_metal. Use cppthreads=0 openmp=0")
134 Exit(1)
135
Jenkins514be652019-02-28 12:25:18 +0000136if not env['exceptions']:
137 if env['opencl'] or env['gles_compute']:
138 print("ERROR: OpenCL and GLES are not supported when building without exceptions. Use opencl=0 gles_compute=0")
139 Exit(1)
140
141 env.Append(CPPDEFINES = ['ARM_COMPUTE_EXCEPTIONS_DISABLED'])
142 env.Append(CXXFLAGS = ['-fno-exceptions'])
143
Jenkins0e205f72019-11-28 16:53:35 +0000144env.Append(CXXFLAGS = ['-Wall','-DARCH_ARM',
145 '-Wextra','-pedantic','-Wdisabled-optimization','-Wformat=2',
Anthony Barbierdbdab852017-06-23 15:42:00 +0100146 '-Winit-self','-Wstrict-overflow=2','-Wswitch-default',
Jenkins36ccc902020-02-21 11:10:48 +0000147 '-std=gnu++11','-Woverloaded-virtual', '-Wformat-security',
Jenkins0e205f72019-11-28 16:53:35 +0000148 '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-overlength-strings'])
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000149
Anthony Barbierdbdab852017-06-23 15:42:00 +0100150env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP'])
151
Anthony Barbierf45d5a92018-01-24 16:23:15 +0000152default_cpp_compiler = 'g++' if env['os'] != 'android' else 'clang++'
153default_c_compiler = 'gcc' if env['os'] != 'android' else 'clang'
154cpp_compiler = os.environ.get('CXX', default_cpp_compiler)
155c_compiler = os.environ.get('CC', default_c_compiler)
156
Jenkinsb3a371b2018-05-23 11:36:53 +0100157if env['os'] == 'android' and ( 'clang++' not in cpp_compiler or 'clang' not in c_compiler ):
ggardete2542c92018-06-29 17:01:01 +0200158 print( "WARNING: Only clang is officially supported to build the Compute Library for Android")
Anthony Barbierf45d5a92018-01-24 16:23:15 +0000159
Jenkinsb3a371b2018-05-23 11:36:53 +0100160if 'clang++' in cpp_compiler:
Jenkins0e205f72019-11-28 16:53:35 +0000161 env.Append(CXXFLAGS = ['-Wno-vla-extension'])
162elif 'armclang' in cpp_compiler:
163 pass
Anthony Barbierdbdab852017-06-23 15:42:00 +0100164else:
Jenkins0e205f72019-11-28 16:53:35 +0000165 env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel'])
Anthony Barbierdbdab852017-06-23 15:42:00 +0100166
167if env['cppthreads']:
168 env.Append(CPPDEFINES = [('ARM_COMPUTE_CPP_SCHEDULER', 1)])
169
170if env['openmp']:
Jenkinsb3a371b2018-05-23 11:36:53 +0100171 if 'clang++' in cpp_compiler:
ggardete2542c92018-06-29 17:01:01 +0200172 print( "Clang does not support OpenMP. Use scheduler=cpp.")
Anthony Barbierdbdab852017-06-23 15:42:00 +0100173 Exit(1)
174
175 env.Append(CPPDEFINES = [('ARM_COMPUTE_OPENMP_SCHEDULER', 1)])
176 env.Append(CXXFLAGS = ['-fopenmp'])
177 env.Append(LINKFLAGS = ['-fopenmp'])
178
Jenkins36ccc902020-02-21 11:10:48 +0000179# Validate and define state
180if env['estate'] == 'auto':
181 if 'v7a' in env['arch']:
182 env['estate'] = '32'
183 else:
184 env['estate'] = '64'
185
186# Map legacy arch
187if 'arm64' in env['arch']:
188 env['estate'] = '64'
189
190if 'v7a' in env['estate'] and env['estate'] == '64':
191 print("ERROR: armv7a architecture has only 32-bit execution state")
192 Exit(1)
193
Jenkins0e205f72019-11-28 16:53:35 +0000194# Add architecture specific flags
Anthony Barbierdbdab852017-06-23 15:42:00 +0100195prefix = ""
Jenkins36ccc902020-02-21 11:10:48 +0000196if 'v7a' in env['arch']:
Anthony Barbierdbdab852017-06-23 15:42:00 +0100197 env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon'])
Jenkins6a7771e2020-05-28 11:28:36 +0100198 if env['os'] == 'android' or env['os'] == 'tizen':
Anthony Barbierdbdab852017-06-23 15:42:00 +0100199 env.Append(CXXFLAGS = ['-mfloat-abi=softfp'])
Jenkinsb9abeae2018-11-22 11:58:08 +0000200 else:
Jenkins36ccc902020-02-21 11:10:48 +0000201 env.Append(CXXFLAGS = ['-mfloat-abi=hard'])
202elif 'v8' in env['arch']:
203 if 'sve' in env['arch']:
204 env.Append(CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod'])
205 elif 'v8.2-a' in env['arch']:
Jenkinsb9abeae2018-11-22 11:58:08 +0000206 env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
Jenkins36ccc902020-02-21 11:10:48 +0000207 else:
208 env.Append(CXXFLAGS = ['-march=armv8-a'])
209
210 if 'v8.6-a' in env['arch']:
Jenkins49b8f902020-11-27 12:49:11 +0000211 env.Append(CPPDEFINES = ['MMLA_INT8', 'V8P6', 'V8P6_BF', 'ARM_COMPUTE_FORCE_BF16'])
212 if "disable_mmla_fp" not in env['custom_options']:
213 env.Append(CPPDEFINES = ['MMLA_FP32'])
Jenkins36ccc902020-02-21 11:10:48 +0000214
215elif 'x86' in env['arch']:
216 if env['estate'] == '32':
217 env.Append(CCFLAGS = ['-m32'])
218 env.Append(LINKFLAGS = ['-m32'])
219 else:
220 env.Append(CXXFLAGS = ['-fPIC'])
221 env.Append(CCFLAGS = ['-m64'])
222 env.Append(LINKFLAGS = ['-m64'])
223
224# Define toolchain
225prefix = ""
226if 'x86' not in env['arch']:
227 if env['estate'] == '32':
228 if env['os'] == 'linux':
229 prefix = "arm-linux-gnueabihf-" if 'v7' in env['arch'] else "armv8l-linux-gnueabihf-"
230 elif env['os'] == 'bare_metal':
231 prefix = "arm-eabi-"
232 elif env['os'] == 'android':
233 prefix = "arm-linux-androideabi-"
Jenkins6a7771e2020-05-28 11:28:36 +0100234 elif env['os'] == 'tizen':
235 prefix = "armv7l-tizen-linux-gnueabi-"
Jenkins36ccc902020-02-21 11:10:48 +0000236 elif env['estate'] == '64' and 'v8' in env['arch']:
237 if env['os'] == 'linux':
238 prefix = "aarch64-linux-gnu-"
239 elif env['os'] == 'bare_metal':
240 prefix = "aarch64-elf-"
241 elif env['os'] == 'android':
242 prefix = "aarch64-linux-android-"
Jenkins6a7771e2020-05-28 11:28:36 +0100243 elif env['os'] == 'tizen':
244 prefix = "aarch64-tizen-linux-gnu-"
Anthony Barbierdbdab852017-06-23 15:42:00 +0100245
246if env['build'] == 'native':
247 prefix = ""
248
Jenkins514be652019-02-28 12:25:18 +0000249if env["toolchain_prefix"] != "":
250 prefix = env["toolchain_prefix"]
251
Jenkins36ccc902020-02-21 11:10:48 +0000252compiler_prefix = prefix
253if env["compiler_prefix"] != "":
254 compiler_prefix = env["compiler_prefix"]
255
256env['CC'] = env['compiler_cache']+ " " + compiler_prefix + c_compiler
257env['CXX'] = env['compiler_cache']+ " " + compiler_prefix + cpp_compiler
Anthony Barbierdbdab852017-06-23 15:42:00 +0100258env['LD'] = prefix + "ld"
259env['AS'] = prefix + "as"
260env['AR'] = prefix + "ar"
261env['RANLIB'] = prefix + "ranlib"
Anthony Barbier46d59272017-05-04 09:15:15 +0100262
263if not GetOption("help"):
Anthony Barbierdbdab852017-06-23 15:42:00 +0100264 try:
Jenkins49b8f902020-11-27 12:49:11 +0000265 compiler_ver = subprocess.check_output(env['CXX'].split() + ["-dumpversion"]).decode().strip()
Anthony Barbierdbdab852017-06-23 15:42:00 +0100266 except OSError:
267 print("ERROR: Compiler '%s' not found" % env['CXX'])
268 Exit(1)
269
Jenkins0e205f72019-11-28 16:53:35 +0000270 if 'armclang' in cpp_compiler:
271 pass
272 elif 'clang++' not in cpp_compiler:
Anthony Barbierdbdab852017-06-23 15:42:00 +0100273 if env['arch'] == 'arm64-v8.2-a' and not version_at_least(compiler_ver, '6.2.1'):
ggardete2542c92018-06-29 17:01:01 +0200274 print("GCC 6.2.1 or newer is required to compile armv8.2-a code")
Anthony Barbierdbdab852017-06-23 15:42:00 +0100275 Exit(1)
276 elif env['arch'] == 'arm64-v8a' and not version_at_least(compiler_ver, '4.9'):
ggardete2542c92018-06-29 17:01:01 +0200277 print("GCC 4.9 or newer is required to compile NEON code for AArch64")
Anthony Barbierdbdab852017-06-23 15:42:00 +0100278 Exit(1)
279
280 if version_at_least(compiler_ver, '6.1'):
281 env.Append(CXXFLAGS = ['-Wno-ignored-attributes'])
282
283 if compiler_ver == '4.8.3':
284 env.Append(CXXFLAGS = ['-Wno-array-bounds'])
285
Jenkins49b8f902020-11-27 12:49:11 +0000286 if not version_at_least(compiler_ver, '7.0.0') and env['os'] == 'bare_metal':
287 env.Append(LINKFLAGS = ['-fstack-protector-strong'])
288
289if env['data_type_support']:
290 if any(i in env['data_type_support'] for i in ['all', 'fp16']):
291 env.Append(CXXFLAGS = ['-DENABLE_FP16_KERNELS'])
292 if any(i in env['data_type_support'] for i in ['all', 'fp32']):
293 env.Append(CXXFLAGS = ['-DENABLE_FP32_KERNELS'])
294 if any(i in env['data_type_support'] for i in ['all', 'qasymm8']):
295 env.Append(CXXFLAGS = ['-DENABLE_QASYMM8_KERNELS'])
296 if any(i in env['data_type_support'] for i in ['all', 'qasymm8_signed']):
297 env.Append(CXXFLAGS = ['-DENABLE_QASYMM8_SIGNED_KERNELS'])
298 if any(i in env['data_type_support'] for i in ['all', 'qsymm16']):
299 env.Append(CXXFLAGS = ['-DENABLE_QSYMM16_KERNELS'])
300
Kaizen8938bd32017-09-28 14:38:23 +0100301if env['standalone']:
302 env.Append(CXXFLAGS = ['-fPIC'])
303 env.Append(LINKFLAGS = ['-static-libgcc','-static-libstdc++'])
304
Anthony Barbierdbdab852017-06-23 15:42:00 +0100305if env['Werror']:
306 env.Append(CXXFLAGS = ['-Werror'])
307
308if env['os'] == 'android':
309 env.Append(CPPDEFINES = ['ANDROID'])
Jenkins36ccc902020-02-21 11:10:48 +0000310 env.Append(LINKFLAGS = ['-pie', '-static-libstdc++', '-ldl'])
Anthony Barbierdbdab852017-06-23 15:42:00 +0100311elif env['os'] == 'bare_metal':
312 env.Append(LINKFLAGS = ['-static'])
Kaizen8938bd32017-09-28 14:38:23 +0100313 env.Append(LINKFLAGS = ['-specs=rdimon.specs'])
Anthony Barbierdbdab852017-06-23 15:42:00 +0100314 env.Append(CXXFLAGS = ['-fPIC'])
315 env.Append(CPPDEFINES = ['NO_MULTI_THREADING'])
Kaizen8938bd32017-09-28 14:38:23 +0100316 env.Append(CPPDEFINES = ['BARE_METAL'])
Jenkins49b8f902020-11-27 12:49:11 +0000317if env['os'] == 'linux' and env['arch'] == 'armv7a':
318 env.Append(CXXFLAGS = [ '-Wno-psabi' ])
Anthony Barbierdbdab852017-06-23 15:42:00 +0100319
320if env['opencl']:
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000321 if env['os'] in ['bare_metal'] or env['standalone']:
Jenkinsb3a371b2018-05-23 11:36:53 +0100322 print("Cannot link OpenCL statically, which is required for bare metal / standalone builds")
Anthony Barbierdbdab852017-06-23 15:42:00 +0100323 Exit(1)
324
Jenkinsb3a371b2018-05-23 11:36:53 +0100325if env['gles_compute']:
326 if env['os'] in ['bare_metal'] or env['standalone']:
327 print("Cannot link OpenGLES statically, which is required for bare metal / standalone builds")
328 Exit(1)
329
330if env["os"] not in ["android", "bare_metal"] and (env['opencl'] or env['cppthreads']):
331 env.Append(LIBS = ['pthread'])
332
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000333if env['opencl'] or env['gles_compute']:
Anthony Barbierdbdab852017-06-23 15:42:00 +0100334 if env['embed_kernels']:
335 env.Append(CPPDEFINES = ['EMBEDDED_KERNELS'])
336
337if env['debug']:
338 env['asserts'] = True
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000339 env['logging'] = True
Anthony Barbierdbdab852017-06-23 15:42:00 +0100340 env.Append(CXXFLAGS = ['-O0','-g','-gdwarf-2'])
341 env.Append(CPPDEFINES = ['ARM_COMPUTE_DEBUG_ENABLED'])
342else:
Jenkins975dfe12019-09-02 11:47:54 +0100343 env.Append(CXXFLAGS = ['-O3'])
Anthony Barbierdbdab852017-06-23 15:42:00 +0100344
345if env['asserts']:
346 env.Append(CPPDEFINES = ['ARM_COMPUTE_ASSERTS_ENABLED'])
Kaizen8938bd32017-09-28 14:38:23 +0100347 env.Append(CXXFLAGS = ['-fstack-protector-strong'])
Anthony Barbierdbdab852017-06-23 15:42:00 +0100348
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000349if env['logging']:
350 env.Append(CPPDEFINES = ['ARM_COMPUTE_LOGGING_ENABLED'])
351
Anthony Barbierdbdab852017-06-23 15:42:00 +0100352env.Append(CPPPATH = ['#/include', "#"])
353env.Append(CXXFLAGS = env['extra_cxx_flags'])
Jenkinsb9abeae2018-11-22 11:58:08 +0000354env.Append(LINKFLAGS = env['extra_link_flags'])
355
356Default( install_include("arm_compute"))
357Default( install_include("support"))
Jenkins4ba87db2019-05-23 17:11:51 +0100358Default( install_include("utils"))
359for dirname in os.listdir("./include"):
360 Default( install_include("include/%s" % dirname))
Anthony Barbierdbdab852017-06-23 15:42:00 +0100361
Anthony Barbierdbdab852017-06-23 15:42:00 +0100362Export('version_at_least')
363
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000364if env['gles_compute'] and env['os'] != 'android':
365 env.Append(CPPPATH = ['#/include/linux'])
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000366
Jenkinsb9abeae2018-11-22 11:58:08 +0000367SConscript('./SConscript', variant_dir=build_path, duplicate=0)
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000368
Jenkins36ccc902020-02-21 11:10:48 +0000369if env['examples'] and env['exceptions']:
370 if env['os'] == 'bare_metal' and env['arch'] == 'armv7a':
371 print("WARNING: Building examples for bare metal and armv7a is not supported. Use examples=0")
372 Return()
Jenkinsb9abeae2018-11-22 11:58:08 +0000373 SConscript('./examples/SConscript', variant_dir='%s/examples' % build_path, duplicate=0)
Anthony Barbierdbdab852017-06-23 15:42:00 +0100374
Jenkins36ccc902020-02-21 11:10:48 +0000375if env['exceptions']:
376 if env['os'] == 'bare_metal' and env['arch'] == 'armv7a':
377 print("WARNING: Building tests for bare metal and armv7a is not supported")
378 Return()
Jenkinsb9abeae2018-11-22 11:58:08 +0000379 SConscript('./tests/SConscript', variant_dir='%s/tests' % build_path, duplicate=0)