Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | # Copyright (c) 2016, 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 | |
| 23 | import SCons |
| 24 | import os |
| 25 | import subprocess |
| 26 | |
| 27 | def version_at_least(version, required): |
| 28 | end = min(len(version), len(required)) |
| 29 | |
| 30 | for i in range(0, end, 2): |
| 31 | if int(version[i]) < int(required[i]): |
| 32 | return False |
| 33 | elif int(version[i]) > int(required[i]): |
| 34 | return True |
| 35 | |
| 36 | return True |
| 37 | |
| 38 | vars = Variables("scons") |
| 39 | vars.AddVariables( |
| 40 | BoolVariable("debug", "Debug", False), |
| 41 | BoolVariable("asserts", "Enable asserts (this flag is forced to 1 for debug=1)", False), |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 42 | BoolVariable("logging", "Logging (this flag is forced to 1 for debug=1)", False), |
Georgios Pinitas | 421405b | 2018-10-26 19:05:32 +0100 | [diff] [blame] | 43 | EnumVariable("arch", "Target Architecture", "armv7a", allowed_values=("armv7a", "arm64-v8a", "arm64-v8.2-a", "arm64-v8.2-a-sve", "x86_32", "x86_64")), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 44 | EnumVariable("os", "Target OS", "linux", allowed_values=("linux", "android", "bare_metal")), |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 45 | EnumVariable("build", "Build type", "cross_compile", allowed_values=("native", "cross_compile", "embed_only")), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 46 | BoolVariable("examples", "Build example programs", True), |
| 47 | BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True), |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 48 | BoolVariable("standalone", "Builds the tests as standalone executables, links statically with libgcc, libstdc++ and libarm_compute", False), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 49 | BoolVariable("opencl", "Enable OpenCL support", True), |
| 50 | BoolVariable("neon", "Enable Neon support", False), |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 51 | BoolVariable("gles_compute", "Enable OpenGL ES Compute Shader support", False), |
Anthony Barbier | cc0a80b | 2017-12-15 11:37:29 +0000 | [diff] [blame] | 52 | BoolVariable("embed_kernels", "Embed OpenCL kernels and OpenGL ES compute shaders in library binary", True), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 53 | BoolVariable("set_soname", "Set the library's soname and shlibversion (requires SCons 2.4 or above)", False), |
| 54 | BoolVariable("openmp", "Enable OpenMP backend", False), |
| 55 | BoolVariable("cppthreads", "Enable C++11 threads backend", True), |
| 56 | PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathAccept), |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 57 | PathVariable("install_dir", "Specify sub-folder for the install", "", PathVariable.PathAccept), |
Michalis Spyrou | 323ce0f | 2018-11-30 16:30:43 +0000 | [diff] [blame] | 58 | BoolVariable("exceptions", "Enable/disable C++ exception support", True), |
Anthony Barbier | a4e5e1e | 2017-10-05 14:55:34 +0100 | [diff] [blame] | 59 | #FIXME Remove before release (And remove all references to INTERNAL_ONLY) |
Georgios Pinitas | 3783116 | 2018-08-20 15:41:10 +0100 | [diff] [blame] | 60 | BoolVariable("internal_only", "Enable ARM internal only tests", False), |
Anthony Barbier | 149de5b | 2018-12-06 10:27:37 +0000 | [diff] [blame] | 61 | ("toolchain_prefix", "Override the toolchain prefix", ""), |
Anthony Barbier | 7390e05 | 2018-03-13 09:29:41 +0000 | [diff] [blame] | 62 | ("extra_cxx_flags", "Extra CXX flags to be appended to the build command", ""), |
Georgios Pinitas | 421405b | 2018-10-26 19:05:32 +0100 | [diff] [blame] | 63 | ("extra_link_flags", "Extra LD flags to be appended to the build command", ""), |
Anthony Barbier | 7390e05 | 2018-03-13 09:29:41 +0000 | [diff] [blame] | 64 | ("compiler_cache", "Command to prefix to the C and C++ compiler (e.g ccache)", "") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 65 | ) |
| 66 | |
| 67 | env = Environment(platform="posix", variables=vars, ENV = os.environ) |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 68 | build_path = env['build_dir'] |
| 69 | # If build_dir is a relative path then add a #build/ prefix: |
| 70 | if not env['build_dir'].startswith('/'): |
| 71 | SConsignFile('build/%s/.scons' % build_path) |
| 72 | build_path = "#build/%s" % build_path |
| 73 | else: |
| 74 | SConsignFile('%s/.scons' % build_path) |
| 75 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 76 | install_path = env['install_dir'] |
| 77 | #If the install_dir is a relative path then assume it's from inside build_dir |
| 78 | if not env['install_dir'].startswith('/') and install_path != "": |
| 79 | install_path = "%s/%s" % (build_path, install_path) |
| 80 | |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 81 | env.Append(LIBPATH = [build_path]) |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 82 | Export('env') |
| 83 | Export('vars') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 84 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 85 | def install_lib( lib ): |
| 86 | # If there is no install folder, then there is nothing to do: |
| 87 | if install_path == "": |
| 88 | return lib |
| 89 | return env.Install( "%s/lib/" % install_path, lib) |
| 90 | def install_bin( bin ): |
| 91 | # If there is no install folder, then there is nothing to do: |
| 92 | if install_path == "": |
| 93 | return bin |
| 94 | return env.Install( "%s/bin/" % install_path, bin) |
| 95 | def install_include( inc ): |
| 96 | if install_path == "": |
| 97 | return inc |
| 98 | return env.Install( "%s/include/" % install_path, inc) |
| 99 | |
| 100 | Export('install_lib') |
| 101 | Export('install_bin') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 102 | |
| 103 | Help(vars.GenerateHelpText(env)) |
| 104 | |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 105 | if env['build'] == "embed_only": |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 106 | SConscript('./SConscript', variant_dir=build_path, duplicate=0) |
Anthony Barbier | 6a3daf1 | 2018-02-19 17:24:27 +0000 | [diff] [blame] | 107 | Return() |
| 108 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 109 | if env['neon'] and 'x86' in env['arch']: |
ggardet | 767c9f7 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 110 | print("Cannot compile NEON for x86") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 111 | Exit(1) |
| 112 | |
| 113 | if env['set_soname'] and not version_at_least(SCons.__version__, "2.4"): |
ggardet | 767c9f7 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 114 | print("Setting the library's SONAME / SHLIBVERSION requires SCons 2.4 or above") |
| 115 | print("Update your version of SCons or use set_soname=0") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 116 | Exit(1) |
| 117 | |
| 118 | if env['os'] == 'bare_metal': |
| 119 | if env['cppthreads'] or env['openmp']: |
| 120 | print("ERROR: OpenMP and C++11 threads not supported in bare_metal. Use cppthreads=0 openmp=0") |
| 121 | Exit(1) |
| 122 | |
Michalis Spyrou | 323ce0f | 2018-11-30 16:30:43 +0000 | [diff] [blame] | 123 | if not env['exceptions']: |
| 124 | if env['opencl'] or env['gles_compute']: |
| 125 | print("ERROR: OpenCL and GLES are not supported when building without exceptions. Use opencl=0 gles_compute=0") |
| 126 | Exit(1) |
| 127 | |
| 128 | env.Append(CPPDEFINES = ['ARM_COMPUTE_EXCEPTIONS_DISABLED']) |
| 129 | env.Append(CXXFLAGS = ['-fno-exceptions']) |
| 130 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 131 | env.Append(CXXFLAGS = ['-Wno-deprecated-declarations','-Wall','-DARCH_ARM', |
| 132 | '-Wextra','-Wno-unused-parameter','-pedantic','-Wdisabled-optimization','-Wformat=2', |
| 133 | '-Winit-self','-Wstrict-overflow=2','-Wswitch-default', |
| 134 | '-fpermissive','-std=gnu++11','-Wno-vla','-Woverloaded-virtual', |
Anthony Barbier | 95008d8 | 2018-07-02 09:27:20 +0100 | [diff] [blame] | 135 | '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-format-nonliteral','-Wno-overlength-strings','-Wno-strict-overflow']) |
Isabella Gottardi | b28f29d | 2017-11-09 17:05:07 +0000 | [diff] [blame] | 136 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 137 | env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP']) |
| 138 | |
Anthony Barbier | a026e98 | 2018-01-18 10:57:52 +0000 | [diff] [blame] | 139 | default_cpp_compiler = 'g++' if env['os'] != 'android' else 'clang++' |
| 140 | default_c_compiler = 'gcc' if env['os'] != 'android' else 'clang' |
| 141 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 142 | c_compiler = os.environ.get('CC', default_c_compiler) |
| 143 | |
Anthony Barbier | dd66937 | 2018-03-01 17:08:54 +0000 | [diff] [blame] | 144 | if env['os'] == 'android' and ( 'clang++' not in cpp_compiler or 'clang' not in c_compiler ): |
ggardet | 767c9f7 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 145 | print( "WARNING: Only clang is officially supported to build the Compute Library for Android") |
Anthony Barbier | a026e98 | 2018-01-18 10:57:52 +0000 | [diff] [blame] | 146 | |
Anthony Barbier | dd66937 | 2018-03-01 17:08:54 +0000 | [diff] [blame] | 147 | if 'clang++' in cpp_compiler: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 148 | env.Append(CXXFLAGS = ['-Wno-format-nonliteral','-Wno-deprecated-increment-bool','-Wno-vla-extension','-Wno-mismatched-tags']) |
| 149 | else: |
Georgios Pinitas | 72593c7 | 2018-07-03 11:33:41 +0100 | [diff] [blame] | 150 | env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel','-Wno-implicit-fallthrough']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 151 | |
| 152 | if env['cppthreads']: |
| 153 | env.Append(CPPDEFINES = [('ARM_COMPUTE_CPP_SCHEDULER', 1)]) |
| 154 | |
| 155 | if env['openmp']: |
Anthony Barbier | dd66937 | 2018-03-01 17:08:54 +0000 | [diff] [blame] | 156 | if 'clang++' in cpp_compiler: |
ggardet | 767c9f7 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 157 | print( "Clang does not support OpenMP. Use scheduler=cpp.") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 158 | Exit(1) |
| 159 | |
| 160 | env.Append(CPPDEFINES = [('ARM_COMPUTE_OPENMP_SCHEDULER', 1)]) |
| 161 | env.Append(CXXFLAGS = ['-fopenmp']) |
| 162 | env.Append(LINKFLAGS = ['-fopenmp']) |
| 163 | |
| 164 | prefix = "" |
| 165 | if env['arch'] == 'armv7a': |
| 166 | env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon']) |
| 167 | |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 168 | if env['os'] == 'linux': |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 169 | prefix = "arm-linux-gnueabihf-" |
| 170 | env.Append(CXXFLAGS = ['-mfloat-abi=hard']) |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 171 | elif env['os'] == 'bare_metal': |
Michalis Spyrou | 6e52ba3 | 2017-10-04 15:40:38 +0100 | [diff] [blame] | 172 | prefix = "arm-eabi-" |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 173 | env.Append(CXXFLAGS = ['-mfloat-abi=hard']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 174 | elif env['os'] == 'android': |
| 175 | prefix = "arm-linux-androideabi-" |
| 176 | env.Append(CXXFLAGS = ['-mfloat-abi=softfp']) |
| 177 | elif env['arch'] == 'arm64-v8a': |
| 178 | env.Append(CXXFLAGS = ['-march=armv8-a']) |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 179 | env.Append(CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8A','NO_DOT_IN_TOOLCHAIN']) |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 180 | if env['os'] == 'linux': |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 181 | prefix = "aarch64-linux-gnu-" |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 182 | elif env['os'] == 'bare_metal': |
Michalis Spyrou | 6e52ba3 | 2017-10-04 15:40:38 +0100 | [diff] [blame] | 183 | prefix = "aarch64-elf-" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 184 | elif env['os'] == 'android': |
| 185 | prefix = "aarch64-linux-android-" |
Anthony Barbier | 2539dd2 | 2018-03-15 14:16:52 +0000 | [diff] [blame] | 186 | if 'clang++' in cpp_compiler: |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 187 | env.Append(CXXFLAGS = ['-no-integrated-as']) |
Georgios Pinitas | 421405b | 2018-10-26 19:05:32 +0100 | [diff] [blame] | 188 | elif 'arm64-v8.2-a' in env['arch']: |
| 189 | if env['arch'] == 'arm64-v8.2-a-sve': |
| 190 | if env['os'] != 'bare_metal': |
| 191 | print("Only bare metal SVE is supported at the moment") |
| 192 | Exit(1) |
| 193 | env.Append(CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod']) |
| 194 | else: |
| 195 | env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined |
| 196 | if env['os'] == 'linux': |
| 197 | prefix = "aarch64-linux-gnu-" |
| 198 | elif env['os'] == 'bare_metal': |
| 199 | prefix = "aarch64-elf-" |
| 200 | elif env['os'] == 'android': |
| 201 | prefix = "aarch64-linux-android-" |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 202 | env.Append(CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8_2','NO_DOT_IN_TOOLCHAIN']) |
Anthony Barbier | dd66937 | 2018-03-01 17:08:54 +0000 | [diff] [blame] | 203 | if 'clang++' in cpp_compiler: |
Anthony Barbier | 2539dd2 | 2018-03-15 14:16:52 +0000 | [diff] [blame] | 204 | env.Append(CXXFLAGS = ['-no-integrated-as']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 205 | elif env['arch'] == 'x86_32': |
| 206 | env.Append(CCFLAGS = ['-m32']) |
| 207 | env.Append(LINKFLAGS = ['-m32']) |
| 208 | elif env['arch'] == 'x86_64': |
| 209 | env.Append(CCFLAGS = ['-m64']) |
| 210 | env.Append(LINKFLAGS = ['-m64']) |
| 211 | |
| 212 | if env['build'] == 'native': |
| 213 | prefix = "" |
| 214 | |
Anthony Barbier | 149de5b | 2018-12-06 10:27:37 +0000 | [diff] [blame] | 215 | if env["toolchain_prefix"] != "": |
| 216 | prefix = env["toolchain_prefix"] |
| 217 | |
Anthony Barbier | 7390e05 | 2018-03-13 09:29:41 +0000 | [diff] [blame] | 218 | env['CC'] = env['compiler_cache']+" "+prefix + c_compiler |
| 219 | env['CXX'] = env['compiler_cache']+" "+prefix + cpp_compiler |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 220 | env['LD'] = prefix + "ld" |
| 221 | env['AS'] = prefix + "as" |
| 222 | env['AR'] = prefix + "ar" |
| 223 | env['RANLIB'] = prefix + "ranlib" |
| 224 | |
| 225 | if not GetOption("help"): |
| 226 | try: |
Anthony Barbier | 907dba8 | 2017-08-25 10:11:39 +0100 | [diff] [blame] | 227 | compiler_ver = subprocess.check_output(env['CXX'].split() + ["-dumpversion"]).strip() |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 228 | except OSError: |
| 229 | print("ERROR: Compiler '%s' not found" % env['CXX']) |
| 230 | Exit(1) |
| 231 | |
Anthony Barbier | dd66937 | 2018-03-01 17:08:54 +0000 | [diff] [blame] | 232 | if 'clang++' not in cpp_compiler: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 233 | if env['arch'] == 'arm64-v8.2-a' and not version_at_least(compiler_ver, '6.2.1'): |
ggardet | 767c9f7 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 234 | print("GCC 6.2.1 or newer is required to compile armv8.2-a code") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 235 | Exit(1) |
| 236 | elif env['arch'] == 'arm64-v8a' and not version_at_least(compiler_ver, '4.9'): |
ggardet | 767c9f7 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 237 | print("GCC 4.9 or newer is required to compile NEON code for AArch64") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 238 | Exit(1) |
| 239 | |
| 240 | if version_at_least(compiler_ver, '6.1'): |
| 241 | env.Append(CXXFLAGS = ['-Wno-ignored-attributes']) |
| 242 | |
| 243 | if compiler_ver == '4.8.3': |
| 244 | env.Append(CXXFLAGS = ['-Wno-array-bounds']) |
| 245 | |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 246 | if env['standalone']: |
| 247 | env.Append(CXXFLAGS = ['-fPIC']) |
Anthony Barbier | 665c89b | 2018-07-16 11:40:09 +0100 | [diff] [blame] | 248 | env.Append(LINKFLAGS = ['-static-libgcc','-static-libstdc++']) |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 249 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 250 | if env['Werror']: |
| 251 | env.Append(CXXFLAGS = ['-Werror']) |
| 252 | |
| 253 | if env['os'] == 'android': |
| 254 | env.Append(CPPDEFINES = ['ANDROID']) |
Anthony Barbier | 665c89b | 2018-07-16 11:40:09 +0100 | [diff] [blame] | 255 | env.Append(LINKFLAGS = ['-pie', '-static-libstdc++']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 256 | elif env['os'] == 'bare_metal': |
| 257 | env.Append(LINKFLAGS = ['-static']) |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 258 | env.Append(LINKFLAGS = ['-specs=rdimon.specs']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 259 | env.Append(CXXFLAGS = ['-fPIC']) |
| 260 | env.Append(CPPDEFINES = ['NO_MULTI_THREADING']) |
Michalis Spyrou | 07781ac | 2017-08-31 15:11:41 +0100 | [diff] [blame] | 261 | env.Append(CPPDEFINES = ['BARE_METAL']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 262 | |
| 263 | if env['opencl']: |
Georgios Pinitas | e6032da | 2017-10-26 14:13:35 +0100 | [diff] [blame] | 264 | if env['os'] in ['bare_metal'] or env['standalone']: |
Anthony Barbier | 5f0124d | 2018-04-13 14:05:34 +0100 | [diff] [blame] | 265 | print("Cannot link OpenCL statically, which is required for bare metal / standalone builds") |
| 266 | Exit(1) |
| 267 | |
| 268 | if env['gles_compute']: |
| 269 | if env['os'] in ['bare_metal'] or env['standalone']: |
| 270 | print("Cannot link OpenGLES statically, which is required for bare metal / standalone builds") |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 271 | Exit(1) |
| 272 | |
Anthony Barbier | 9fb0cac | 2018-04-20 15:46:21 +0100 | [diff] [blame] | 273 | if env["os"] not in ["android", "bare_metal"] and (env['opencl'] or env['cppthreads']): |
| 274 | env.Append(LIBS = ['pthread']) |
| 275 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 276 | if env['opencl'] or env['gles_compute']: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 277 | if env['embed_kernels']: |
| 278 | env.Append(CPPDEFINES = ['EMBEDDED_KERNELS']) |
| 279 | |
| 280 | if env['debug']: |
| 281 | env['asserts'] = True |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 282 | env['logging'] = True |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 283 | env.Append(CXXFLAGS = ['-O0','-g','-gdwarf-2']) |
| 284 | env.Append(CPPDEFINES = ['ARM_COMPUTE_DEBUG_ENABLED']) |
| 285 | else: |
| 286 | env.Append(CXXFLAGS = ['-O3','-ftree-vectorize']) |
| 287 | |
| 288 | if env['asserts']: |
| 289 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ASSERTS_ENABLED']) |
Moritz Pflanzer | 8b74c78 | 2017-09-14 14:33:20 +0100 | [diff] [blame] | 290 | env.Append(CXXFLAGS = ['-fstack-protector-strong']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 291 | |
Georgios Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 292 | if env['logging']: |
| 293 | env.Append(CPPDEFINES = ['ARM_COMPUTE_LOGGING_ENABLED']) |
| 294 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 295 | env.Append(CPPPATH = ['#/include', "#"]) |
| 296 | env.Append(CXXFLAGS = env['extra_cxx_flags']) |
Georgios Pinitas | 421405b | 2018-10-26 19:05:32 +0100 | [diff] [blame] | 297 | env.Append(LINKFLAGS = env['extra_link_flags']) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 298 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 299 | Default( install_include("arm_compute")) |
Anthony Barbier | 1056595 | 2018-11-15 09:50:06 +0000 | [diff] [blame] | 300 | Default( install_include("support")) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 301 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 302 | Export('version_at_least') |
| 303 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 304 | if env['opencl']: |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 305 | SConscript("./opencl-1.2-stubs/SConscript", variant_dir="%s/opencl-1.2-stubs" % build_path, duplicate=0) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 306 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 307 | if env['gles_compute'] and env['os'] != 'android': |
Anthony Barbier | 14c86a9 | 2017-12-14 16:27:41 +0000 | [diff] [blame] | 308 | env.Append(CPPPATH = ['#/include/linux']) |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 309 | SConscript("./opengles-3.1-stubs/SConscript", variant_dir="%s/opengles-3.1-stubs" % build_path, duplicate=0) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 310 | |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 311 | SConscript('./SConscript', variant_dir=build_path, duplicate=0) |
Anthony Barbier | 6c0348f | 2017-11-10 18:32:38 +0000 | [diff] [blame] | 312 | |
Michalis Spyrou | 323ce0f | 2018-11-30 16:30:43 +0000 | [diff] [blame] | 313 | if env['examples'] and env['os'] != 'bare_metal' and env['exceptions']: |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 314 | SConscript('./examples/SConscript', variant_dir='%s/examples' % build_path, duplicate=0) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 315 | |
Michalis Spyrou | 323ce0f | 2018-11-30 16:30:43 +0000 | [diff] [blame] | 316 | if env['os'] != 'bare_metal' and env['exceptions']: |
Anthony Barbier | e8a55df | 2018-10-26 09:05:01 +0100 | [diff] [blame] | 317 | SConscript('./tests/SConscript', variant_dir='%s/tests' % build_path, duplicate=0) |