blob: add3022056e1538467ebf0a9e212b18c2f59df23 [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']:
Anthony Barbier7fb7b612018-05-16 11:58:52 +010060 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 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)
SiCong Li240b79d2019-09-24 15:50:34 +010094 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, gemm_tuner_common_options], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = examples_libs + arm_compute_libs)
SiCong Li8b4c7302019-09-19 12:18:15 +010095 Depends(prog, arm_compute_dependency)
96 prog = install_bin(prog)
97 alias = examples_env.Alias(example, prog)
98 Default(alias)
99
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100100if env['neon']:
101 for file in Glob("./neon_*.cpp"):
102 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +0100103 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100104 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100105 prog = install_bin(prog)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100106 alias = examples_env.Alias(example, prog)
107 Default(alias)
Anthony Barbier7068f992017-10-26 15:23:08 +0100108
109if env['gles_compute']:
110 for file in Glob("./gc_*.cpp"):
111 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +0100112 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 +0100113 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100114 prog = install_bin(prog)
Anthony Barbier7068f992017-10-26 15:23:08 +0100115 alias = examples_env.Alias(example, prog)
116 Default(alias)
Georgios Pinitas33893c32018-05-18 16:54:54 +0100117
118#FIXME Delete 3rdparty builds before release
119for file in Glob("#3rdparty/examples/graph_*.cpp"):
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000120 example = os.path.basename(os.path.splitext(str(file))[0])
121 prog = None
Georgios Pinitas33893c32018-05-18 16:54:54 +0100122
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000123 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
124 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'])
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000125 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100126 prog = install_bin(prog)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000127 else:
128 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
129 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 +0000130 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100131 prog = install_bin(prog)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000132 alias = examples_env.Alias(example, prog)
133 Default(alias)