Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +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 | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 26 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 27 | examples_env = env.Clone() |
| 28 | |
| 29 | examples_env.Append(CPPPATH = ["#"]) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 30 | |
| 31 | # Build examples |
| 32 | utils = examples_env.Object("../utils/Utils.cpp") |
| 33 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 34 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 35 | Import('arm_compute_graph_a') |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 36 | Import('arm_compute_a') |
Kaizen | bf8b01d | 2017-10-12 14:26:51 +0100 | [diff] [blame] | 37 | Import('arm_compute_core_a') |
| 38 | arm_compute_libs = [ arm_compute_a, arm_compute_core_a ] |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame^] | 39 | arm_compute_graph_libs = arm_compute_libs # The graph library needs to be linked separately with --whole-archive |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 40 | arm_compute_dependency = arm_compute_a |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 41 | graph_dependency = [arm_compute_graph_a] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 42 | else: |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 43 | Import('arm_compute_graph_so') |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 44 | Import('arm_compute_so') |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame^] | 45 | arm_compute_libs = ["arm_compute", "arm_compute_core"] |
| 46 | arm_compute_graph_libs = [ "arm_compute_graph" ] + arm_compute_libs |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 47 | arm_compute_dependency = arm_compute_so |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 48 | graph_dependency = [arm_compute_graph_so] |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 49 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 50 | # Build graph examples |
| 51 | graph_utils = examples_env.Object("../utils/GraphUtils.cpp") |
Jenkins | 52ba29e | 2018-08-29 15:32:11 +0000 | [diff] [blame^] | 52 | graph_utils += examples_env.Object("../utils/CommonGraphOptions.cpp") |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 53 | examples_libs = examples_env.get("LIBS",[]) |
| 54 | for file in Glob("./graph_*.cpp"): |
| 55 | example = os.path.basename(os.path.splitext(str(file))[0]) |
| 56 | prog = None |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 57 | |
| 58 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
| 59 | 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']) |
| 60 | Depends(prog, graph_dependency) |
| 61 | else: |
| 62 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
| 63 | 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'] ) |
| 64 | Depends(prog, graph_dependency) |
| 65 | alias = examples_env.Alias(example, prog) |
| 66 | Default(alias) |
| 67 | |
| 68 | if env['opencl'] and env['neon']: |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 69 | for file in Glob("./neoncl_*.cpp"): |
| 70 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 71 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs) |
| 72 | Depends(prog, arm_compute_dependency) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 73 | alias = examples_env.Alias(example, prog) |
| 74 | Default(alias) |
| 75 | |
| 76 | if env['opencl']: |
| 77 | for file in Glob("./cl_*.cpp"): |
| 78 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 79 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs) |
| 80 | Depends(prog, arm_compute_dependency) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 81 | alias = examples_env.Alias(example, prog) |
| 82 | Default(alias) |
| 83 | |
| 84 | if env['neon']: |
| 85 | for file in Glob("./neon_*.cpp"): |
| 86 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 87 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 88 | Depends(prog, arm_compute_dependency) |
| 89 | alias = examples_env.Alias(example, prog) |
| 90 | Default(alias) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 91 | |
| 92 | if env['gles_compute']: |
| 93 | for file in Glob("./gc_*.cpp"): |
| 94 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 95 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = examples_libs + arm_compute_libs) |
| 96 | Depends(prog, arm_compute_dependency) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 97 | alias = examples_env.Alias(example, prog) |
| 98 | Default(alias) |