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 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | examples_env = env.Clone() |
| 28 | |
| 29 | examples_env.Append(CPPPATH = ["#"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | |
| 31 | # Build examples |
| 32 | utils = examples_env.Object("../utils/Utils.cpp") |
| 33 | |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 34 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 35 | Import('arm_compute_graph_a') |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 36 | Import('arm_compute_a') |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 37 | Import('arm_compute_core_a') |
| 38 | arm_compute_libs = [ arm_compute_a, arm_compute_core_a ] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | arm_compute_dependency = arm_compute_a |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 40 | graph_dependency = [arm_compute_graph_a] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 41 | else: |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 42 | Import('arm_compute_graph_so') |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 43 | Import('arm_compute_so') |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 44 | arm_compute_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 45 | arm_compute_dependency = arm_compute_so |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 46 | graph_dependency = [arm_compute_graph_so] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 48 | # Build graph examples |
| 49 | graph_utils = examples_env.Object("../utils/GraphUtils.cpp") |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 50 | examples_libs = examples_env.get("LIBS",[]) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 51 | for file in Glob("./graph_*.cpp"): |
| 52 | example = os.path.basename(os.path.splitext(str(file))[0]) |
| 53 | prog = None |
| 54 | arm_compute_graph_libs = arm_compute_libs |
| 55 | |
Anthony Barbier | 9fb0cac | 2018-04-20 15:46:21 +0100 | [diff] [blame] | 56 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 57 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = examples_libs + arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive']) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 58 | Depends(prog, graph_dependency) |
| 59 | else: |
| 60 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 61 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = examples_libs + arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 62 | Depends(prog, graph_dependency) |
| 63 | alias = examples_env.Alias(example, prog) |
| 64 | Default(alias) |
| 65 | |
| 66 | if env['opencl'] and env['neon']: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 67 | for file in Glob("./neoncl_*.cpp"): |
| 68 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 69 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 70 | Depends(prog, arm_compute_dependency) |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 71 | alias = examples_env.Alias(example, prog) |
| 72 | Default(alias) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 73 | |
| 74 | if env['opencl']: |
| 75 | for file in Glob("./cl_*.cpp"): |
| 76 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 77 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 78 | Depends(prog, arm_compute_dependency) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 79 | alias = examples_env.Alias(example, prog) |
| 80 | Default(alias) |
| 81 | |
| 82 | if env['neon']: |
| 83 | for file in Glob("./neon_*.cpp"): |
| 84 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 85 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 86 | Depends(prog, arm_compute_dependency) |
| 87 | alias = examples_env.Alias(example, prog) |
| 88 | Default(alias) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 89 | |
| 90 | if env['gles_compute']: |
| 91 | for file in Glob("./gc_*.cpp"): |
| 92 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 93 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = examples_libs + arm_compute_libs) |
Anthony Barbier | 9fb0cac | 2018-04-20 15:46:21 +0100 | [diff] [blame] | 94 | Depends(prog, arm_compute_dependency) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 95 | alias = examples_env.Alias(example, prog) |
| 96 | Default(alias) |