Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [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 | import collections |
| 23 | import os.path |
| 24 | import re |
| 25 | import subprocess |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 26 | import SCons |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 27 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 28 | VERSION = "v17.05" |
| 29 | SONAME_VERSION="2.0.0" |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 30 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 31 | Import('env') |
| 32 | Import('vars') |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 33 | |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 34 | def version_at_least(version, required): |
| 35 | end = min(len(version), len(required)) |
| 36 | |
| 37 | for i in range(0, end, 2): |
| 38 | if int(version[i]) < int(required[i]): |
| 39 | return False |
| 40 | elif int(version[i]) > int(required[i]): |
| 41 | return True |
| 42 | |
| 43 | return True |
| 44 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 45 | def build_library(name, sources, libs, static=False): |
| 46 | if static: |
| 47 | obj = env.StaticLibrary(name, source = sources, LIBS=libs ) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 48 | else: |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 49 | if env['set_soname']: |
| 50 | obj = env.SharedLibrary(name, source = sources, LIBS=libs, SHLIBVERSION=SONAME_VERSION) |
| 51 | symlinks = [] |
| 52 | # Manually delete symlinks or SCons will get confused: |
| 53 | directory = os.path.dirname( obj[0].path ) |
| 54 | library_prefix = obj[0].path[:-(1+len(SONAME_VERSION))] |
| 55 | real_lib="%s.%s" % (library_prefix, SONAME_VERSION) |
| 56 | for f in Glob( "#%s*" % library_prefix): |
| 57 | if str(f) != real_lib: |
| 58 | symlinks.append("%s/%s" % (directory,str(f))) |
| 59 | clean = env.Command('clean-%s' % str(obj[0]), [], Delete(symlinks)) |
| 60 | Default(clean) |
| 61 | Depends(obj, clean) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 62 | else: |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 63 | obj = env.SharedLibrary(name, source = sources, LIBS=libs) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 64 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 65 | Default(obj) |
| 66 | return obj |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 67 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 68 | def resolve_includes(target, source, env): |
| 69 | # File collection |
| 70 | FileEntry = collections.namedtuple('FileEntry', 'target_name file_contents') |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 71 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 72 | # Include pattern |
| 73 | pattern = re.compile("#include \"(.*)\"") |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 74 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 75 | # Get file contents |
| 76 | files = [] |
| 77 | for s in source: |
| 78 | name = s.rstr().split("/")[-1] |
| 79 | contents = s.get_contents().splitlines() |
| 80 | embed_target_name = s.abspath + "embed" |
| 81 | entry = FileEntry(target_name=embed_target_name, file_contents=contents) |
| 82 | files.append((name,entry)) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 83 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 84 | # Create dictionary of tupled list |
| 85 | files_dict = dict(files) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 86 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 87 | # Check for includes (can only be files in the same folder) |
| 88 | final_files = [] |
| 89 | for file in files: |
| 90 | done = False |
| 91 | tmp_file = file[1].file_contents |
| 92 | while not done: |
| 93 | file_count = 0 |
| 94 | updated_file = [] |
| 95 | for line in tmp_file: |
| 96 | found = pattern.search(line) |
| 97 | if found: |
| 98 | include_file = found.group(1) |
| 99 | data = files_dict[include_file].file_contents |
| 100 | updated_file.extend(data) |
| 101 | else: |
| 102 | updated_file.append(line) |
| 103 | file_count += 1 |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 104 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 105 | # Check if all include are replaced. |
| 106 | if file_count == len(tmp_file): |
| 107 | done = True |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 108 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 109 | # Update temp file |
| 110 | tmp_file = updated_file |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 111 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 112 | # Append and prepend string literal identifiers and add expanded file to final list |
| 113 | tmp_file.insert(0, "R\"(\n") |
| 114 | tmp_file.append("\n)\"") |
| 115 | entry = FileEntry(target_name=file[1].target_name, file_contents=tmp_file) |
| 116 | final_files.append((file[0], entry)) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 117 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 118 | # Write output files |
| 119 | for file in final_files: |
| 120 | with open(file[1].target_name, 'w+') as out_file: |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 121 | contents = file[1].file_contents |
| 122 | for line in contents: |
| 123 | out_file.write("%s\n" % line) |
| 124 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 125 | if GetOption("help"): |
| 126 | Exit(0) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 127 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 128 | flags = ['-D_GLIBCXX_USE_NANOSLEEP','-Wno-deprecated-declarations','-Wall','-DARCH_ARM', |
| 129 | '-Wextra','-Wno-unused-parameter','-pedantic','-Wdisabled-optimization','-Wformat=2', |
| 130 | '-Winit-self','-Wstrict-overflow=2','-Wswitch-default', |
| 131 | '-fpermissive','-std=gnu++11','-Wno-vla','-Woverloaded-virtual', |
| 132 | '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-format-nonliteral','-Wno-overlength-strings','-Wno-strict-overflow'] |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 133 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 134 | if env['neon'] and 'x86' in env['arch']: |
| 135 | print "Cannot compile NEON for x86" |
| 136 | Exit(1) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 137 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 138 | if env['set_soname'] and not version_at_least(SCons.__version__, "2.4"): |
| 139 | print "Setting the library's SONAME / SHLIBVERSION requires SCons 2.4 or above" |
| 140 | print "Update your version of SCons or use set_soname=0" |
| 141 | Exit(1) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 142 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 143 | if os.environ.get('CXX','g++') == 'clang++': |
| 144 | flags += ['-Wno-format-nonliteral','-Wno-deprecated-increment-bool','-Wno-vla-extension','-Wno-mismatched-tags'] |
| 145 | else: |
| 146 | flags += ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel'] |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 147 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 148 | if env['cppthreads']: |
| 149 | flags += ['-DARM_COMPUTE_CPP_SCHEDULER=1'] |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 150 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 151 | if env['openmp']: |
| 152 | if os.environ.get('CXX','g++') == 'clang++': |
| 153 | print "Clang does not support OpenMP. Use scheduler=cpp." |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 154 | Exit(1) |
| 155 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 156 | flags += ['-DARM_COMPUTE_OPENMP_SCHEDULER=1','-fopenmp'] |
| 157 | env.Append(LINKFLAGS=['-fopenmp']) |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 158 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 159 | files_to_delete = [] |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 160 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 161 | # Generate string with build options library version to embed in the library: |
| 162 | try: |
| 163 | git_hash = subprocess.check_output(["git", "rev-parse","HEAD"]) |
| 164 | except (OSError, subbprocess.CalledProcessError): |
| 165 | git_hash="unknown" |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 166 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 167 | version_filename = "%s/arm_compute_version.embed" % os.path.dirname(Glob("src/core/*")[0].rstr()) |
| 168 | build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (VERSION, vars.args, git_hash.strip()) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 169 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 170 | with open(version_filename, "w") as fd: |
| 171 | fd.write(build_info) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 172 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 173 | files_to_delete.append(version_filename) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 174 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 175 | core_libs = ['dl'] |
| 176 | libs = ['dl'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 177 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 178 | prefix="" |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 179 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 180 | if env['arch'] == 'armv7a': |
| 181 | flags += ['-march=armv7-a','-mthumb','-mfpu=neon'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 182 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 183 | if env['os'] in ['linux','bare_metal']: |
| 184 | prefix = "arm-linux-gnueabihf-" |
| 185 | flags += ['-mfloat-abi=hard'] |
| 186 | elif env['os'] == 'android': |
| 187 | prefix = "arm-linux-androideabi-" |
| 188 | flags += ['-mfloat-abi=softfp'] |
| 189 | elif env['arch'] == 'arm64-v8a': |
| 190 | flags += ['-march=armv8-a'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 191 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 192 | if env['os'] in ['linux','bare_metal']: |
| 193 | prefix = "aarch64-linux-gnu-" |
| 194 | elif env['os'] == 'android': |
| 195 | prefix = "aarch64-linux-android-" |
| 196 | elif env['arch'] == 'arm64-v8.2-a': |
| 197 | flags += ['-march=armv8.2-a+fp16+simd'] |
| 198 | flags += ['-DARM_COMPUTE_ENABLE_FP16'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 199 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 200 | if env['os'] in ['linux','bare_metal']: |
| 201 | prefix = "aarch64-linux-gnu-" |
| 202 | elif env['os'] == 'android': |
| 203 | prefix = "aarch64-linux-android-" |
| 204 | elif env['arch'] == 'x86_32': |
| 205 | flags += ['-m32'] |
| 206 | elif env['arch'] == 'x86_64': |
| 207 | flags += ['-m64'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 208 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 209 | if env['build'] == 'native': |
| 210 | prefix = "" |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 211 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 212 | env['CC'] = prefix + os.environ.get('CC','gcc') |
| 213 | env['CXX'] = prefix + os.environ.get('CXX','g++') |
| 214 | env['LD'] = prefix + "ld" |
| 215 | env['AS'] = prefix + "as" |
| 216 | env['AR'] = prefix + "ar" |
| 217 | env['RANLIB'] = prefix + "ranlib" |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 218 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 219 | try: |
| 220 | compiler_ver = subprocess.check_output( [env['CXX'] , "-dumpversion"] ).strip() |
| 221 | except OSError: |
| 222 | print "ERROR: Compiler '%s' not found" % env['CXX'] |
| 223 | Exit(1) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 224 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 225 | if os.environ.get('CXX','g++') == 'g++': |
| 226 | if env['arch'] == 'arm64-v8.2-a' and not version_at_least(compiler_ver, '6.2.1'): |
| 227 | print "GCC 6.2.1 or newer is required to compile armv8.2-a code" |
| 228 | Exit(1) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 229 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 230 | if env['arch'] == 'arm64-v8a' and not version_at_least(compiler_ver, '4.9'): |
| 231 | print "GCC 4.9 or newer is required to compile NEON code for AArch64" |
| 232 | Exit(1) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 233 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 234 | if version_at_least(compiler_ver, '6.1'): |
| 235 | flags += ['-Wno-ignored-attributes'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 236 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 237 | if compiler_ver == '4.8.3': |
| 238 | flags += ['-Wno-array-bounds'] |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 239 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 240 | if env['Werror']: |
| 241 | flags += ['-Werror'] |
| 242 | |
| 243 | example_libs = [] |
| 244 | |
| 245 | if env['os'] == 'android': |
| 246 | flags += ['-DANDROID'] |
| 247 | env.Append(LINKFLAGS=['-pie','-static-libstdc++']) |
| 248 | example_libs = ['arm_compute-static'] |
| 249 | elif env['os'] == 'bare_metal': |
| 250 | env.Append(LINKFLAGS=['-static']) |
| 251 | flags += ['-fPIC','-DNO_MULTI_THREADING'] |
| 252 | example_libs = ['arm_compute-static'] |
| 253 | else: |
| 254 | libs += ['pthread'] |
| 255 | example_libs = ['arm_compute'] |
| 256 | |
| 257 | if env['opencl']: |
| 258 | if env['os'] == 'bare_metal': |
| 259 | raise Exception("Cannot link OpenCL statically, which is required on bare metal") |
| 260 | if env['embed_kernels']: |
| 261 | flags += ['-DEMBEDDED_KERNELS'] |
| 262 | |
| 263 | if env['debug']: |
| 264 | env['asserts'] = True |
| 265 | flags += ['-O0','-g','-gdwarf-2'] |
| 266 | else: |
| 267 | flags += ['-O3','-ftree-vectorize'] |
| 268 | |
| 269 | if env['asserts']: |
| 270 | flags += ['-DARM_COMPUTE_ASSERTS_ENABLED'] |
| 271 | |
| 272 | env.Append(CPPPATH=['.','#include']) |
| 273 | env.Append(LIBPATH=['#build/%s' % env['build_dir'],'.']) |
| 274 | env.Append(CXXFLAGS=flags) |
| 275 | env.Append(CXXFLAGS=env['extra_cxx_flags']) |
| 276 | |
| 277 | core_files = Glob('src/core/*.cpp') |
| 278 | core_files += Glob('src/core/CPP/*.cpp') |
| 279 | |
| 280 | files = Glob('src/runtime/*.cpp') |
| 281 | |
| 282 | embed_files = [] |
| 283 | core_files += Glob('src/core/CPP/kernels/*.cpp') |
| 284 | # CLHarrisCorners uses the Scheduler to run CPP kernels |
| 285 | files += Glob('src/runtime/CPP/SingleThreadScheduler.cpp') |
| 286 | |
| 287 | if env['os'] == 'bare_metal': |
| 288 | if env['cppthreads'] or env['openmp']: |
| 289 | print "ERROR: OpenMP and C++11 threads not supported in bare_metal. Use cppthreads=0 openmp=0" |
| 290 | Exit(1) |
| 291 | else: |
| 292 | if env['cppthreads']: |
| 293 | files += Glob('src/runtime/CPP/CPPScheduler.cpp') |
| 294 | if env['openmp']: |
| 295 | files += Glob('src/runtime/OMP/OMPScheduler.cpp') |
| 296 | |
| 297 | if env['opencl']: |
| 298 | core_files += Glob('src/core/CL/*.cpp') |
| 299 | core_files += Glob('src/core/CL/kernels/*.cpp') |
| 300 | files += Glob('src/runtime/CL/*.cpp') |
| 301 | files += Glob('src/runtime/CL/functions/*.cpp') |
| 302 | |
| 303 | # Generate embed files |
| 304 | if env['embed_kernels']: |
| 305 | cl_files = Glob('src/core/CL/cl_kernels/*.cl') + Glob('src/core/CL/cl_kernels/*.h') |
| 306 | source_list = [] |
| 307 | for file in cl_files: |
| 308 | source_name = file.rstr() |
| 309 | source_list.append(source_name) |
| 310 | embed_files.append(source_name + "embed") |
| 311 | generate_embed = env.Command(embed_files, source_list, action=resolve_includes) |
| 312 | Default(generate_embed) |
| 313 | files_to_delete += embed_files |
| 314 | |
| 315 | if env['neon']: |
| 316 | core_files += Glob('src/core/NEON/*.cpp') |
| 317 | core_files += Glob('src/core/NEON/kernels/*.cpp') |
| 318 | files += Glob('src/runtime/NEON/*.cpp') |
| 319 | files += Glob('src/runtime/NEON/functions/*.cpp') |
| 320 | |
| 321 | objects=[] |
| 322 | static_core_objects = [ env.StaticObject( f ) for f in core_files ] |
| 323 | shared_core_objects = [ env.SharedObject( f ) for f in core_files ] |
| 324 | |
| 325 | arm_compute_core_a = build_library('arm_compute_core-static', static_core_objects, core_libs, static=True) |
| 326 | objects.append(arm_compute_core_a) |
| 327 | Export('arm_compute_core_a') |
| 328 | |
| 329 | if env['os'] != 'bare_metal': |
| 330 | arm_compute_core_so = build_library('arm_compute_core', shared_core_objects, core_libs, static=False) |
| 331 | objects.append(arm_compute_core_so) |
| 332 | Export('arm_compute_core_so') |
| 333 | |
| 334 | shared_objects = [ env.SharedObject( f ) for f in files ] |
| 335 | static_objects = [ env.StaticObject( f ) for f in files ] |
| 336 | |
| 337 | arm_compute_a = build_library('arm_compute-static', static_core_objects + static_objects, libs, static=True) |
| 338 | objects.append(arm_compute_a) |
| 339 | Export('arm_compute_a') |
| 340 | |
| 341 | if env['os'] != 'bare_metal': |
| 342 | arm_compute_so = build_library('arm_compute', shared_core_objects + shared_objects, libs, static=False) |
| 343 | objects.append(arm_compute_so) |
| 344 | Export('arm_compute_so') |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 345 | |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 346 | # Delete produced embed files |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 347 | clean_embed = env.Command('clean-embed', [], Delete(files_to_delete)) |
| 348 | Default(clean_embed) |
| 349 | env.Depends(clean_embed, objects) |
| 350 | alias = env.Alias("arm_compute",objects) |
| 351 | Default(alias) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 352 | |
Anthony Barbier | a437638 | 2017-04-12 15:12:46 +0100 | [diff] [blame] | 353 | # Build examples |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 354 | |
Andrew Anderson | d619a8a | 2017-05-18 13:50:38 +0100 | [diff] [blame^] | 355 | if env['examples']: |
| 356 | test_helpers = env.Object("test_helpers/Utils.cpp") |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 357 | |
Andrew Anderson | d619a8a | 2017-05-18 13:50:38 +0100 | [diff] [blame^] | 358 | if env['opencl'] and env['neon']: |
| 359 | for file in Glob("examples/neoncl_*.cpp"): |
| 360 | example = os.path.basename( os.path.splitext(str(file))[0]) |
| 361 | prog = env.Program(example, ['examples/%s.cpp' % example, test_helpers], LIBS=example_libs+['OpenCL']) |
| 362 | alias = env.Alias(example, prog) |
| 363 | Depends(prog, objects) |
| 364 | Default( alias ) |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 365 | |
Andrew Anderson | d619a8a | 2017-05-18 13:50:38 +0100 | [diff] [blame^] | 366 | if env['opencl']: |
| 367 | for file in Glob("examples/cl_*.cpp"): |
| 368 | example = os.path.basename( os.path.splitext(str(file))[0]) |
| 369 | prog = env.Program(example, ['examples/%s.cpp' % example, test_helpers], LIBS=example_libs+['OpenCL']) |
| 370 | alias = env.Alias(example, prog) |
| 371 | Depends(prog, objects) |
| 372 | Default( alias ) |
| 373 | |
| 374 | if env['neon']: |
| 375 | for file in Glob("examples/neon_*.cpp"): |
| 376 | example = os.path.basename( os.path.splitext(str(file))[0]) |
| 377 | prog = env.Program(example, ['examples/%s.cpp' % example, test_helpers], LIBS=example_libs) |
| 378 | alias = env.Alias(example, prog) |
| 379 | Depends(prog, objects) |
| 380 | Default( alias ) |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 381 | |
| 382 | Export('env') |