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 | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 26 | Import('install_bin') |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | examples_env = env.Clone() |
| 29 | |
| 30 | examples_env.Append(CPPPATH = ["#"]) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | |
| 32 | # Build examples |
| 33 | utils = examples_env.Object("../utils/Utils.cpp") |
| 34 | |
Georgios Pinitas | 9873ea3 | 2017-12-05 15:28:55 +0000 | [diff] [blame] | 35 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 36 | Import('arm_compute_graph_a') |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 37 | Import('arm_compute_a') |
Anthony Barbier | b2881fc | 2017-09-29 17:12:12 +0100 | [diff] [blame] | 38 | Import('arm_compute_core_a') |
| 39 | arm_compute_libs = [ arm_compute_a, arm_compute_core_a ] |
Anthony Barbier | 8ddab14 | 2018-07-13 11:52:37 +0100 | [diff] [blame] | 40 | arm_compute_graph_libs = arm_compute_libs # The graph library needs to be linked separately with --whole-archive |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 41 | arm_compute_dependency = arm_compute_a |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 42 | graph_dependency = [arm_compute_graph_a] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 43 | else: |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 44 | Import('arm_compute_graph_so') |
Pablo Tello | c6cb35a | 2017-06-21 15:39:47 +0100 | [diff] [blame] | 45 | Import('arm_compute_so') |
Anthony Barbier | 8ddab14 | 2018-07-13 11:52:37 +0100 | [diff] [blame] | 46 | arm_compute_libs = ["arm_compute", "arm_compute_core"] |
| 47 | arm_compute_graph_libs = [ "arm_compute_graph" ] + arm_compute_libs |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 48 | arm_compute_dependency = arm_compute_so |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 49 | graph_dependency = [arm_compute_graph_so] |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 51 | # Build graph examples |
| 52 | graph_utils = examples_env.Object("../utils/GraphUtils.cpp") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 53 | graph_utils += examples_env.Object("../utils/CommonGraphOptions.cpp") |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 54 | examples_libs = examples_env.get("LIBS",[]) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 55 | for file in Glob("./graph_*.cpp"): |
| 56 | example = os.path.basename(os.path.splitext(str(file))[0]) |
| 57 | prog = None |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 58 | |
Anthony Barbier | 9fb0cac | 2018-04-20 15:46:21 +0100 | [diff] [blame] | 59 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Michalis Spyrou | 7d30352 | 2020-01-07 12:56:01 +0000 | [diff] [blame] | 60 | 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', '-fstack-protector-strong']) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 61 | Depends(prog, graph_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 62 | prog = install_bin(prog) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 63 | else: |
| 64 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 65 | 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] | 66 | Depends(prog, graph_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 67 | prog = install_bin(prog) |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 68 | alias = examples_env.Alias(example, prog) |
| 69 | Default(alias) |
| 70 | |
Georgios Pinitas | 33893c3 | 2018-05-18 16:54:54 +0100 | [diff] [blame] | 71 | if env['opencl'] and env['neon']: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 72 | for file in Glob("./neoncl_*.cpp"): |
| 73 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 74 | 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] | 75 | Depends(prog, arm_compute_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 76 | prog = install_bin(prog) |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 77 | alias = examples_env.Alias(example, prog) |
| 78 | Default(alias) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 79 | |
| 80 | if env['opencl']: |
| 81 | for file in Glob("./cl_*.cpp"): |
| 82 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 83 | 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] | 84 | Depends(prog, arm_compute_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 85 | prog = install_bin(prog) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 86 | alias = examples_env.Alias(example, prog) |
| 87 | Default(alias) |
| 88 | |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 89 | if env['gemm_tuner'] and env['opencl']: |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 90 | gemm_tuner_common_options = examples_env.Object("./gemm_tuner/CommonGemmExampleOptions.cpp") |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 91 | for file in Glob("./gemm_tuner/cl_*.cpp"): |
| 92 | example = os.path.basename(os.path.splitext(str(file))[0]) |
| 93 | example = os.path.join("gemm_tuner", example) |
SiCong Li | 240b79d | 2019-09-24 15:50:34 +0100 | [diff] [blame] | 94 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils, gemm_tuner_common_options], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs) |
SiCong Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 95 | Depends(prog, arm_compute_dependency) |
| 96 | prog = install_bin(prog) |
| 97 | alias = examples_env.Alias(example, prog) |
| 98 | Default(alias) |
| 99 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 100 | if env['neon']: |
| 101 | for file in Glob("./neon_*.cpp"): |
| 102 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Michalis Spyrou | 0183368 | 2020-01-09 15:15:13 +0000 | [diff] [blame] | 103 | |
| 104 | prog = None |
| 105 | if env['os'] in ['bare_metal']: |
| 106 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LINKFLAGS=examples_env["LINKFLAGS"]+['-fstack-protector'], LIBS = examples_libs + arm_compute_libs) |
| 107 | else: |
| 108 | prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs) |
| 109 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 110 | Depends(prog, arm_compute_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 111 | prog = install_bin(prog) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 112 | alias = examples_env.Alias(example, prog) |
| 113 | Default(alias) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 114 | |
| 115 | if env['gles_compute']: |
| 116 | for file in Glob("./gc_*.cpp"): |
| 117 | example = os.path.basename(os.path.splitext(str(file))[0]) |
Anthony Barbier | 7fb7b61 | 2018-05-16 11:58:52 +0100 | [diff] [blame] | 118 | 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] | 119 | Depends(prog, arm_compute_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 120 | prog = install_bin(prog) |
Anthony Barbier | 7068f99 | 2017-10-26 15:23:08 +0100 | [diff] [blame] | 121 | alias = examples_env.Alias(example, prog) |
| 122 | Default(alias) |
Georgios Pinitas | 33893c3 | 2018-05-18 16:54:54 +0100 | [diff] [blame] | 123 | |
| 124 | #FIXME Delete 3rdparty builds before release |
| 125 | for file in Glob("#3rdparty/examples/graph_*.cpp"): |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 126 | example = os.path.basename(os.path.splitext(str(file))[0]) |
| 127 | prog = None |
Georgios Pinitas | 33893c3 | 2018-05-18 16:54:54 +0100 | [diff] [blame] | 128 | |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 129 | if env['os'] in ['android', 'bare_metal'] or env['standalone']: |
Michalis Spyrou | 7d30352 | 2020-01-07 12:56:01 +0000 | [diff] [blame] | 130 | prog = examples_env.Program(example, [examples_env.Object(source=file, target=example), utils, graph_utils], LIBS = examples_libs + arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive', '-fstack-protector-strong']) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 131 | Depends(prog, graph_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 132 | prog = install_bin(prog) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 133 | else: |
| 134 | #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies |
| 135 | prog = examples_env.Program(example, [examples_env.Object(source=file, target=example), utils, graph_utils], LIBS = examples_libs + arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 136 | Depends(prog, graph_dependency) |
Michalis Spyrou | 165308c | 2019-04-10 10:10:21 +0100 | [diff] [blame] | 137 | prog = install_bin(prog) |
Anthony Barbier | 01bbd5f | 2018-11-01 15:10:51 +0000 | [diff] [blame] | 138 | alias = examples_env.Alias(example, prog) |
| 139 | Default(alias) |