Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | # 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. |
| 22 | import SCons |
| 23 | import os.path |
| 24 | |
| 25 | Import('env') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
| 27 | if env['opencl']: |
| 28 | Import('opencl') |
| 29 | |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 30 | if env['gles_compute'] and env['os'] != 'android': |
| 31 | Import('egl') |
| 32 | Import('glesv2') |
| 33 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 34 | examples_env = env.Clone() |
| 35 | |
| 36 | examples_env.Append(CPPPATH = ["#"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | examples_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) |
| 38 | |
| 39 | # Build examples |
| 40 | utils = examples_env.Object("../utils/Utils.cpp") |
| 41 | |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 42 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 43 | Import('arm_compute_a') |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 44 | Import('arm_compute_core_a') |
| 45 | arm_compute_libs = [ arm_compute_a, arm_compute_core_a ] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 46 | arm_compute_dependency = arm_compute_a |
| 47 | else: |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 48 | Import('arm_compute_so') |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 49 | arm_compute_libs = ["arm_compute", "arm_compute_core"] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | arm_compute_dependency = arm_compute_so |
| 51 | |
| 52 | if env['opencl'] and env['neon']: |
| 53 | for file in Glob("./neoncl_*.cpp"): |
| 54 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 55 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs +["OpenCL"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 56 | Depends(prog, [arm_compute_dependency, opencl]) |
| 57 | alias = examples_env.Alias(example, prog) |
| 58 | Default(alias) |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 59 | if env['os'] == 'android': |
| 60 | Import('arm_compute_graph_a') |
| 61 | Import('arm_compute_core_a') |
| 62 | Import('arm_compute_a') |
Georgios Pinitas | a58b61e | 2017-12-13 19:07:22 +0000 | [diff] [blame] | 63 | arm_compute_graph_libs = [ arm_compute_a, arm_compute_core_a, "OpenCL"] |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 64 | graph_dependency = arm_compute_graph_a |
| 65 | else: |
| 66 | Import('arm_compute_graph_so') |
| 67 | arm_compute_graph_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"] |
| 68 | graph_dependency = arm_compute_graph_so |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 69 | |
| 70 | graph_utils = examples_env.Object("../utils/GraphUtils.cpp") |
| 71 | for file in Glob("./graph_*.cpp"): |
| 72 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 73 | prog = None |
| 74 | if env['os'] == 'android': |
Georgios Pinitas | a58b61e | 2017-12-13 19:07:22 +0000 | [diff] [blame] | 75 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs + ["OpenCL"], LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive']) |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 76 | Depends(prog, [graph_dependency, opencl]) |
| 77 | else: |
| 78 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
| 79 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) |
| 80 | Depends(prog, graph_dependency) |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 81 | alias = examples_env.Alias(example, prog) |
| 82 | Default(alias) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 83 | |
| 84 | if env['opencl']: |
| 85 | for file in Glob("./cl_*.cpp"): |
| 86 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 87 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs +["OpenCL"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 88 | Depends(prog, [arm_compute_dependency, opencl]) |
| 89 | alias = examples_env.Alias(example, prog) |
| 90 | Default(alias) |
| 91 | |
| 92 | if env['neon']: |
| 93 | for file in Glob("./neon_*.cpp"): |
| 94 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 95 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = arm_compute_libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 96 | Depends(prog, arm_compute_dependency) |
| 97 | alias = examples_env.Alias(example, prog) |
| 98 | Default(alias) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 99 | |
| 100 | if env['gles_compute']: |
| 101 | for file in Glob("./gc_*.cpp"): |
| 102 | example = os.path.basename(os.path.splitext(str(file))[0]) |
| 103 | if env['os'] != 'android': |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 104 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"]) |
| 105 | Depends(prog, [arm_compute_dependency, egl, glesv2]) |
| 106 | else: |
| 107 | if env['arch'] != 'armv7a': |
| 108 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv3"]) |
| 109 | else: |
| 110 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"]) |
| 111 | Depends(prog, [arm_compute_dependency]) |
| 112 | alias = examples_env.Alias(example, prog) |
| 113 | Default(alias) |