blob: 853a1bb514b23dca76e1cae5ce97569abc8746f2 [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
30examples_env = env.Clone()
31
32examples_env.Append(CPPPATH = ["#"])
33examples_env.Append(LIBPATH = ["#build/%s" % env['build_dir']])
34examples_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']])
35
36# Build examples
37utils = examples_env.Object("../utils/Utils.cpp")
38
Pablo Telloc6cb35a2017-06-21 15:39:47 +010039if env['os'] in ['android', 'bare_metal'] or env['standalone']:
40 Import('arm_compute_a')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041 arm_compute_lib = arm_compute_a
42 arm_compute_dependency = arm_compute_a
43else:
Pablo Telloc6cb35a2017-06-21 15:39:47 +010044 Import('arm_compute_so')
Anthony Barbier6ff3b192017-09-04 18:44:23 +010045 arm_compute_lib = "arm_compute"
46 arm_compute_dependency = arm_compute_so
47
48if env['opencl'] and env['neon']:
49 for file in Glob("./neoncl_*.cpp"):
50 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier15d5ac82017-07-17 15:22:17 +010051 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = [arm_compute_lib, "OpenCL"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052 Depends(prog, [arm_compute_dependency, opencl])
53 alias = examples_env.Alias(example, prog)
54 Default(alias)
Anthony Barbier2a07e182017-08-04 18:20:27 +010055 Import('arm_compute_graph_a')
56 Import('arm_compute_graph_so')
57 if env['os'] == 'android':
58 arm_compute_graph_lib = arm_compute_graph_a
59 else:
60 arm_compute_graph_lib = "arm_compute_graph"
61
62 graph_utils = examples_env.Object("../utils/GraphUtils.cpp")
63 for file in Glob("./graph_*.cpp"):
64 example = os.path.basename(os.path.splitext(str(file))[0])
65 prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = [arm_compute_graph_lib, "OpenCL"])
66 Depends(prog, [arm_compute_dependency, opencl])
67 alias = examples_env.Alias(example, prog)
68 Default(alias)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069
70if env['opencl']:
71 for file in Glob("./cl_*.cpp"):
72 example = os.path.basename(os.path.splitext(str(file))[0])
Anthony Barbier15d5ac82017-07-17 15:22:17 +010073 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = [arm_compute_lib, "OpenCL"])
Anthony Barbier6ff3b192017-09-04 18:44:23 +010074 Depends(prog, [arm_compute_dependency, opencl])
75 alias = examples_env.Alias(example, prog)
76 Default(alias)
77
78if env['neon']:
79 for file in Glob("./neon_*.cpp"):
80 example = os.path.basename(os.path.splitext(str(file))[0])
81 prog = examples_env.Program(example, ["{}.cpp".format(example), utils], LIBS = [arm_compute_lib])
82 Depends(prog, arm_compute_dependency)
83 alias = examples_env.Alias(example, prog)
84 Default(alias)