blob: 098dd5b85e7fdb844a5eb23cf76ad0473a84fddd [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 Barbier6ff3b192017-09-04 18:44:23 +010026
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027examples_env = env.Clone()
28
29examples_env.Append(CPPPATH = ["#"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030
31# Build examples
32utils = examples_env.Object("../utils/Utils.cpp")
33
Georgios Pinitas9873ea32017-12-05 15:28:55 +000034if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010035 Import('arm_compute_graph_a')
Pablo Telloc6cb35a2017-06-21 15:39:47 +010036 Import('arm_compute_a')
Anthony Barbierb2881fc2017-09-29 17:12:12 +010037 Import('arm_compute_core_a')
38 arm_compute_libs = [ arm_compute_a, arm_compute_core_a ]
Anthony Barbier8ddab142018-07-13 11:52:37 +010039 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 +010040 arm_compute_dependency = arm_compute_a
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010041 graph_dependency = [arm_compute_graph_a]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042else:
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010043 Import('arm_compute_graph_so')
Pablo Telloc6cb35a2017-06-21 15:39:47 +010044 Import('arm_compute_so')
Anthony Barbier8ddab142018-07-13 11:52:37 +010045 arm_compute_libs = ["arm_compute", "arm_compute_core"]
46 arm_compute_graph_libs = [ "arm_compute_graph" ] + arm_compute_libs
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047 arm_compute_dependency = arm_compute_so
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010048 graph_dependency = [arm_compute_graph_so]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010050# Build graph examples
51graph_utils = examples_env.Object("../utils/GraphUtils.cpp")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010052graph_utils += examples_env.Object("../utils/CommonGraphOptions.cpp")
Anthony Barbier7fb7b612018-05-16 11:58:52 +010053examples_libs = examples_env.get("LIBS",[])
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010054for file in Glob("./graph_*.cpp"):
55 example = os.path.basename(os.path.splitext(str(file))[0])
56 prog = None
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010057
Anthony Barbier9fb0cac2018-04-20 15:46:21 +010058 if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Anthony Barbier7fb7b612018-05-16 11:58:52 +010059 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 +010060 Depends(prog, graph_dependency)
61 else:
62 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
Anthony Barbier7fb7b612018-05-16 11:58:52 +010063 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 +010064 Depends(prog, graph_dependency)
65 alias = examples_env.Alias(example, prog)
66 Default(alias)
67
68if env['opencl'] and env['neon']:
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069 for file in Glob("./neoncl_*.cpp"):
70 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010071 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 +010072 Depends(prog, arm_compute_dependency)
Anthony Barbier2a07e182017-08-04 18:20:27 +010073 alias = examples_env.Alias(example, prog)
74 Default(alias)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075
76if env['opencl']:
77 for file in Glob("./cl_*.cpp"):
78 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010079 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 +010080 Depends(prog, arm_compute_dependency)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010081 alias = examples_env.Alias(example, prog)
82 Default(alias)
83
84if env['neon']:
85 for file in Glob("./neon_*.cpp"):
86 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010087 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = examples_libs + arm_compute_libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010088 Depends(prog, arm_compute_dependency)
89 alias = examples_env.Alias(example, prog)
90 Default(alias)
Anthony Barbier7068f992017-10-26 15:23:08 +010091
92if env['gles_compute']:
93 for file in Glob("./gc_*.cpp"):
94 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier7fb7b612018-05-16 11:58:52 +010095 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 +010096 Depends(prog, arm_compute_dependency)
Anthony Barbier7068f992017-10-26 15:23:08 +010097 alias = examples_env.Alias(example, prog)
98 Default(alias)