blob: 2a037859ef33dfb1f056a2daad3ace46195c8796 [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
Anthony Barbier7068f992017-10-26 15:23:08 +010039if env['gles_compute'] and env['os'] != 'android':
40 examples_env.Append(LIBPATH = ["#build/%s/opengles-3.1/stubs" % env['build_dir']])
41
Anthony Barbier6ff3b192017-09-04 18:44:23 +010042# Build examples
43utils = examples_env.Object("../utils/Utils.cpp")
44
Georgios Pinitas9873ea32017-12-05 15:28:55 +000045if env['os'] in ['android', 'bare_metal'] or env['standalone']:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010046 Import('arm_compute_a')
Anthony Barbierb2881fc2017-09-29 17:12:12 +010047 Import('arm_compute_core_a')
48 arm_compute_libs = [ arm_compute_a, arm_compute_core_a ]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049 arm_compute_dependency = arm_compute_a
50else:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010051 Import('arm_compute_so')
Anthony Barbierb2881fc2017-09-29 17:12:12 +010052 arm_compute_libs = ["arm_compute", "arm_compute_core"]
Anthony Barbier6ff3b192017-09-04 18:44:23 +010053 arm_compute_dependency = arm_compute_so
54
55if env['opencl'] and env['neon']:
56 for file in Glob("./neoncl_*.cpp"):
57 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbierb2881fc2017-09-29 17:12:12 +010058 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 +010059 Depends(prog, [arm_compute_dependency, opencl])
60 alias = examples_env.Alias(example, prog)
61 Default(alias)
Georgios Pinitas9873ea32017-12-05 15:28:55 +000062 if env['os'] == 'android':
63 Import('arm_compute_graph_a')
64 Import('arm_compute_core_a')
65 Import('arm_compute_a')
Georgios Pinitasa58b61e2017-12-13 19:07:22 +000066 arm_compute_graph_libs = [ arm_compute_a, arm_compute_core_a, "OpenCL"]
Georgios Pinitas9873ea32017-12-05 15:28:55 +000067 graph_dependency = arm_compute_graph_a
68 else:
69 Import('arm_compute_graph_so')
70 arm_compute_graph_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"]
71 graph_dependency = arm_compute_graph_so
Anthony Barbier2a07e182017-08-04 18:20:27 +010072
73 graph_utils = examples_env.Object("../utils/GraphUtils.cpp")
74 for file in Glob("./graph_*.cpp"):
75 example = os.path.basename(os.path.splitext(str(file))[0])
Georgios Pinitas9873ea32017-12-05 15:28:55 +000076 prog = None
77 if env['os'] == 'android':
Georgios Pinitasa58b61e2017-12-13 19:07:22 +000078 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 +000079 Depends(prog, [graph_dependency, opencl])
80 else:
81 #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies
82 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] )
83 Depends(prog, graph_dependency)
Anthony Barbier2a07e182017-08-04 18:20:27 +010084 alias = examples_env.Alias(example, prog)
85 Default(alias)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010086
87if env['opencl']:
88 for file in Glob("./cl_*.cpp"):
89 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbierb2881fc2017-09-29 17:12:12 +010090 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 +010091 Depends(prog, [arm_compute_dependency, opencl])
92 alias = examples_env.Alias(example, prog)
93 Default(alias)
94
95if env['neon']:
96 for file in Glob("./neon_*.cpp"):
97 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbierb2881fc2017-09-29 17:12:12 +010098 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = arm_compute_libs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010099 Depends(prog, arm_compute_dependency)
100 alias = examples_env.Alias(example, prog)
101 Default(alias)
Anthony Barbier7068f992017-10-26 15:23:08 +0100102
103if env['gles_compute']:
104 for file in Glob("./gc_*.cpp"):
105 example = os.path.basename(os.path.splitext(str(file))[0])
106 if env['os'] != 'android':
107 examples_env.Append(CPPPATH = ["#opengles-3.1/include", "#opengles-3.1/mali_include"])
108 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"])
109 Depends(prog, [arm_compute_dependency, egl, glesv2])
110 else:
111 if env['arch'] != 'armv7a':
112 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv3"])
113 else:
114 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"])
115 Depends(prog, [arm_compute_dependency])
116 alias = examples_env.Alias(example, prog)
117 Default(alias)