blob: 032fdfc5583dfa0527d2bc5c60924deb0ebe9c43 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001# 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.
22import SCons
23import os.path
24
25Import('env')
Anthony Barbier01bbd5f2018-11-01 15:10:51 +000026Import('install_bin')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028examples_env = env.Clone()
29
30examples_env.Append(CPPPATH = ["#"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031
32# Build examples
33utils = examples_env.Object("../utils/Utils.cpp")
34
Georgios Pinitas9873ea32017-12-05 15:28:55 +000035if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010036 Import('arm_compute_graph_a')
Pablo Telloc6cb35a2017-06-21 15:39:47 +010037 Import('arm_compute_a')
Anthony Barbierb2881fc2017-09-29 17:12:12 +010038 Import('arm_compute_core_a')
39 arm_compute_libs = [ arm_compute_a, arm_compute_core_a ]
Anthony Barbier8ddab142018-07-13 11:52:37 +010040 arm_compute_graph_libs = arm_compute_libs # The graph library needs to be linked separately with --whole-archive
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041 arm_compute_dependency = arm_compute_a
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010042 graph_dependency = [arm_compute_graph_a]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010043else:
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010044 Import('arm_compute_graph_so')
Pablo Telloc6cb35a2017-06-21 15:39:47 +010045 Import('arm_compute_so')
Anthony Barbier8ddab142018-07-13 11:52:37 +010046 arm_compute_libs = ["arm_compute", "arm_compute_core"]
47 arm_compute_graph_libs = [ "arm_compute_graph" ] + arm_compute_libs
Anthony Barbier6ff3b192017-09-04 18:44:23 +010048 arm_compute_dependency = arm_compute_so
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010049 graph_dependency = [arm_compute_graph_so]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010051# Build graph examples
52graph_utils = examples_env.Object("../utils/GraphUtils.cpp")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010053graph_utils += examples_env.Object("../utils/CommonGraphOptions.cpp")
Anthony Barbier7fb7b612018-05-16 11:58:52 +010054examples_libs = examples_env.get("LIBS",[])
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010055for file in Glob("./graph_*.cpp"):
56 example = os.path.basename(os.path.splitext(str(file))[0])
57 prog = None
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010058
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010059 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Michalis Spyrou7d303522020-01-07 12:56:01 +000060 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 Pinitasd9eb2752018-04-03 13:44:29 +010061 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +010062 prog = install_bin(prog)
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010063 else:
64 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
Anthony Barbier7fb7b612018-05-16 11:58:52 +010065 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 Pinitasd9eb2752018-04-03 13:44:29 +010066 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +010067 prog = install_bin(prog)
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010068 alias = examples_env.Alias(example, prog)
69 Default(alias)
70
Georgios Pinitas33893c32018-05-18 16:54:54 +010071if env['opencl'] and env['neon']:
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072 for file in Glob("./neoncl_*.cpp"):
73 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010074 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs)
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010075 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +010076 prog = install_bin(prog)
Anthony Barbier2a07e182017-08-04 18:20:27 +010077 alias = examples_env.Alias(example, prog)
78 Default(alias)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079
80if env['opencl']:
81 for file in Glob("./cl_*.cpp"):
82 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010083 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs)
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010084 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +010085 prog = install_bin(prog)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086 alias = examples_env.Alias(example, prog)
87 Default(alias)
88
SiCong Li8b4c7302019-09-19 12:18:15 +010089if env['gemm_tuner'] and env['opencl']:
SiCong Li240b79d2019-09-24 15:50:34 +010090 gemm_tuner_common_options = examples_env.Object("./gemm_tuner/CommonGemmExampleOptions.cpp")
SiCong Li8b4c7302019-09-19 12:18:15 +010091 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)
Eren Kopuz350099e2020-06-09 15:37:43 +010094 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
95 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, gemm_tuner_common_options], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive', '-fstack-protector-strong'] )
96 Depends(prog, graph_dependency)
97 prog = install_bin(prog)
98 else:
99 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
100 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, gemm_tuner_common_options], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] )
101 Depends(prog, graph_dependency)
102 prog = install_bin(prog)
SiCong Li8b4c7302019-09-19 12:18:15 +0100103 alias = examples_env.Alias(example, prog)
104 Default(alias)
105
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100106if env['neon']:
107 for file in Glob("./neon_*.cpp"):
108 example = os.path.basename(os.path.splitext(str(file))[0])
Michalis Spyrou01833682020-01-09 15:15:13 +0000109
110 prog = None
111 if env['os'] in ['bare_metal']:
112 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LINKFLAGS=examples_env["LINKFLAGS"]+['-fstack-protector'], LIBS = examples_libs + arm_compute_libs)
113 else:
114 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs)
115
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100116 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100117 prog = install_bin(prog)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100118 alias = examples_env.Alias(example, prog)
119 Default(alias)
Anthony Barbier7068f992017-10-26 15:23:08 +0100120
121if env['gles_compute']:
122 for file in Glob("./gc_*.cpp"):
123 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +0100124 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = examples_libs + arm_compute_libs)
Anthony Barbier9fb0cac2018-04-20 15:46:21 +0100125 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100126 prog = install_bin(prog)
Anthony Barbier7068f992017-10-26 15:23:08 +0100127 alias = examples_env.Alias(example, prog)
128 Default(alias)
Georgios Pinitas33893c32018-05-18 16:54:54 +0100129
130#FIXME Delete 3rdparty builds before release
131for file in Glob("#3rdparty/examples/graph_*.cpp"):
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000132 example = os.path.basename(os.path.splitext(str(file))[0])
133 prog = None
Georgios Pinitas33893c32018-05-18 16:54:54 +0100134
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000135 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Michalis Spyrou7d303522020-01-07 12:56:01 +0000136 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 Barbier01bbd5f2018-11-01 15:10:51 +0000137 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100138 prog = install_bin(prog)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000139 else:
140 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
141 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 Barbier01bbd5f2018-11-01 15:10:51 +0000142 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100143 prog = install_bin(prog)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000144 alias = examples_env.Alias(example, prog)
145 Default(alias)