blob: d08aa9da7cf40b31c3267cb7465c7d1e870220fe [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
89if env['neon']:
90 for file in Glob("./neon_*.cpp"):
91 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010092 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010093 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +010094 prog = install_bin(prog)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010095 alias = examples_env.Alias(example, prog)
96 Default(alias)
Anthony Barbier7068f992017-10-26 15:23:08 +010097
98if env['gles_compute']:
99 for file in Glob("./gc_*.cpp"):
100 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +0100101 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 +0100102 Depends(prog, arm_compute_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100103 prog = install_bin(prog)
Anthony Barbier7068f992017-10-26 15:23:08 +0100104 alias = examples_env.Alias(example, prog)
105 Default(alias)
Georgios Pinitas33893c32018-05-18 16:54:54 +0100106
107#FIXME Delete 3rdparty builds before release
108for file in Glob("#3rdparty/examples/graph_*.cpp"):
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000109 example = os.path.basename(os.path.splitext(str(file))[0])
110 prog = None
Georgios Pinitas33893c32018-05-18 16:54:54 +0100111
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000112 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
113 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 +0000114 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100115 prog = install_bin(prog)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000116 else:
117 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
118 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 +0000119 Depends(prog, graph_dependency)
Michalis Spyrou165308c2019-04-10 10:10:21 +0100120 prog = install_bin(prog)
Anthony Barbier01bbd5f2018-11-01 15:10:51 +0000121 alias = examples_env.Alias(example, prog)
122 Default(alias)