blob: 9be9fa9d9a3495f03d8a48b9e9d5c6cfd9b140f1 [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
27if env['opencl']:
28 Import('opencl')
29
Anthony Barbier7068f992017-10-26 15:23:08 +010030if env['gles_compute'] and env['os'] != 'android':
31 Import('egl')
32 Import('glesv2')
33
Anthony Barbier6ff3b192017-09-04 18:44:23 +010034examples_env = env.Clone()
35
36examples_env.Append(CPPPATH = ["#"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037examples_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
38
39# Build examples
40utils = examples_env.Object("../utils/Utils.cpp")
41
Georgios Pinitas9873ea32017-12-05 15:28:55 +000042if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010043 Import('arm_compute_a')
Anthony Barbierb2881fc2017-09-29 17:12:12 +010044 Import('arm_compute_core_a')
45 arm_compute_libs = [ arm_compute_a, arm_compute_core_a ]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010046 arm_compute_dependency = arm_compute_a
47else:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010048 Import('arm_compute_so')
Anthony Barbierb2881fc2017-09-29 17:12:12 +010049 arm_compute_libs = ["arm_compute", "arm_compute_core"]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050 arm_compute_dependency = arm_compute_so
51
52if env['opencl'] and env['neon']:
53 for file in Glob("./neoncl_*.cpp"):
54 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbierb2881fc2017-09-29 17:12:12 +010055 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs +["OpenCL"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010056 Depends(prog, [arm_compute_dependency, opencl])
57 alias = examples_env.Alias(example, prog)
58 Default(alias)
Georgios Pinitas9873ea32017-12-05 15:28:55 +000059 if env['os'] == 'android':
60 Import('arm_compute_graph_a')
61 Import('arm_compute_core_a')
62 Import('arm_compute_a')
Georgios Pinitasa58b61e2017-12-13 19:07:22 +000063 arm_compute_graph_libs = [ arm_compute_a, arm_compute_core_a, "OpenCL"]
Georgios Pinitas9873ea32017-12-05 15:28:55 +000064 graph_dependency = arm_compute_graph_a
65 else:
66 Import('arm_compute_graph_so')
67 arm_compute_graph_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"]
68 graph_dependency = arm_compute_graph_so
Anthony Barbier2a07e182017-08-04 18:20:27 +010069
70 graph_utils = examples_env.Object("../utils/GraphUtils.cpp")
71 for file in Glob("./graph_*.cpp"):
72 example = os.path.basename(os.path.splitext(str(file))[0])
Georgios Pinitas9873ea32017-12-05 15:28:55 +000073 prog = None
74 if env['os'] == 'android':
Georgios Pinitasa58b61e2017-12-13 19:07:22 +000075 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs + ["OpenCL"], LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive'])
Georgios Pinitas9873ea32017-12-05 15:28:55 +000076 Depends(prog, [graph_dependency, opencl])
77 else:
78 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
79 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] )
80 Depends(prog, graph_dependency)
Anthony Barbier2a07e182017-08-04 18:20:27 +010081 alias = examples_env.Alias(example, prog)
82 Default(alias)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010083
84if env['opencl']:
85 for file in Glob("./cl_*.cpp"):
86 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbierb2881fc2017-09-29 17:12:12 +010087 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs +["OpenCL"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010088 Depends(prog, [arm_compute_dependency, opencl])
89 alias = examples_env.Alias(example, prog)
90 Default(alias)
91
92if env['neon']:
93 for file in Glob("./neon_*.cpp"):
94 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbierb2881fc2017-09-29 17:12:12 +010095 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = arm_compute_libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010096 Depends(prog, arm_compute_dependency)
97 alias = examples_env.Alias(example, prog)
98 Default(alias)
Anthony Barbier7068f992017-10-26 15:23:08 +010099
100if env['gles_compute']:
101 for file in Glob("./gc_*.cpp"):
102 example = os.path.basename(os.path.splitext(str(file))[0])
103 if env['os'] != 'android':
Anthony Barbier7068f992017-10-26 15:23:08 +0100104 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"])
105 Depends(prog, [arm_compute_dependency, egl, glesv2])
106 else:
107 if env['arch'] != 'armv7a':
108 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv3"])
109 else:
110 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"])
111 Depends(prog, [arm_compute_dependency])
112 alias = examples_env.Alias(example, prog)
113 Default(alias)