blob: 65fd5d5b77ae3e1c4bcf1a9dbfd14e36849a0f45 [file] [log] [blame]
Michalis Spyroua8caa022022-05-18 17:43:39 +01001#!/usr/bin/python
Michele Di Giorgio33f41fa2021-03-09 14:09:08 +00002# -*- coding: utf-8 -*-
3
Quoc Khanh Leea6c6d42024-05-17 14:39:49 +01004# Copyright (c) 2017-2022, 2024 Arm Limited.
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +01005#
6# SPDX-License-Identifier: MIT
7#
8# Permission is hereby granted, free of charge, to any person obtaining a copy
9# of this software and associated documentation files (the "Software"), to
10# deal in the Software without restriction, including without limitation the
11# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12# sell copies of the Software, and to permit persons to whom the Software is
13# furnished to do so, subject to the following conditions:
14#
15# The above copyright notice and this permission notice shall be included in all
16# copies or substantial portions of the Software.
17#
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24# SOFTWARE.
25import SCons
26import os.path
27
28Import('env')
29Import('vars')
30
31# vars is imported from arm_compute:
32variables = [
Michalis Spyroua3f7cd22022-07-04 15:32:02 +010033 BoolVariable("pmu", "Enable the PMU cycle counter to measure execution time in benchmark tests. (Your device needs to support it)", False),
34 BoolVariable("mali", "Enable the collection of Arm® Mali™ hardware counters to measure execution time in benchmark tests. (Your device needs to have a Arm® Mali™ driver that supports it)", False),
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010035]
36
37# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice)
38new_options = Variables('scons')
39
40for v in variables:
41 new_options.Add(v)
42 vars.Add(v)
43
44# Clone the environment to make sure we're not polluting the arm_compute one:
45framework_env = env.Clone()
46vars.Update(framework_env)
47
48Help(new_options.GenerateHelpText(framework_env))
49
Moritz Pflanzer47752c92017-07-18 13:38:47 +010050if(env['opencl']):
51 framework_env.Append(CPPDEFINES=['ARM_COMPUTE_CL'])
52
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010053framework_env.Append(CPPPATH = ["."])
54framework_env.Append(CPPFLAGS=['-Wno-overloaded-virtual'])
55
56files = Glob('*.cpp')
57files += Glob('command_line/*.cpp')
58files += Glob('printers/*.cpp')
59files += Glob('datasets/*.cpp')
60files += Glob('instruments/*.cpp')
61
62if not framework_env['pmu']:
63 # Remove PMU files
64 files = [f for f in files if "PMU" not in os.path.basename(str(f))]
65else:
66 framework_env.Append(CPPDEFINES = ['PMU_ENABLED'])
67
Anthony Barbiere8895f82017-11-23 16:58:52 +000068if not env['opencl']:
Anthony Barbier6e433492017-11-09 15:52:00 +000069 # Remove OpenCLTimer files
Anthony Barbier35aa6a32018-04-23 16:12:12 +010070 files = [f for f in files if "OpenCL" not in os.path.basename(str(f))]
Anthony Barbier6e433492017-11-09 15:52:00 +000071
Moritz Pflanzer45634b42017-08-30 12:48:18 +010072if not framework_env['mali']:
Michele Di Giorgio33f41fa2021-03-09 14:09:08 +000073 # Remove Arm® Mali™ files
Moritz Pflanzer45634b42017-08-30 12:48:18 +010074 files = [f for f in files if "MaliCounter" not in os.path.basename(str(f))]
75else:
76 framework_env.Append(CPPDEFINES = ['MALI_ENABLED'])
77
Quoc Khanh Leea6c6d42024-05-17 14:39:49 +010078#Set up to use temp file for long command when building and linking libraries
79framework_env['TEMPFILE'] = SCons.Platform.TempFileMunge
80
81#To use temp file for any command, the following pattern should be used:
82# env['COMMAND'] = "{$TEMPFILE('$COMMANDSTRING')}"
83#See: https://github.com/SCons/scons/blob/05f2992377844bbfec9bcd4a9c7f5479c634b91b/SCons/Platform/__init__.py#L147
84#The commands' string are taken from https://github.com/SCons/scons
85#The commands' explanations are taken from Scons userguide
86
87#The command line used to compile C++ source file to an object file
88framework_env['CXXCOM'] = "${TEMPFILE('"+ framework_env['CXXCOM'] + "')}"
89#The command line used to generate a static library from object files
90framework_env['ARCOM'] = "${TEMPFILE('"+ framework_env['ARCOM'] + "')}"
91#The command line used to index a static library archive
92framework_env['RANLIBCOM'] = "${TEMPFILE('"+ framework_env['RANLIBCOM'] + "')}"
93#Set up directory for temp files. To prevent permission issue, the temp files are in the same directory with output files
94framework_env['TEMPFILEDIR'] = framework_env['build_dir']
95
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010096arm_compute_test_framework = framework_env.StaticLibrary('arm_compute_test_framework', files)
97
98Default(arm_compute_test_framework)
99Export('arm_compute_test_framework')