@@ -40,7 +40,7 @@ vars.AddVariables(
4040 BoolVariable ("debug" , "Debug" , False ),
4141 BoolVariable ("asserts" , "Enable asserts (this flag is forced to 1 for debug=1)" , False ),
4242 BoolVariable ("logging" , "Logging (this flag is forced to 1 for debug=1)" , False ),
43- EnumVariable ("arch" , "Target Architecture" , "armv7a" , allowed_values = ("armv7a" , "arm64-v8a" , "arm64-v8.2-a" , "x86_32" , "x86_64" )),
43+ EnumVariable ("arch" , "Target Architecture" , "armv7a" , allowed_values = ("armv7a" , "arm64-v8a" , "arm64-v8.2-a" , "arm64-v8.2-a-sve" , " x86_32" , "x86_64" )),
4444 EnumVariable ("os" , "Target OS" , "linux" , allowed_values = ("linux" , "android" , "bare_metal" )),
4545 EnumVariable ("build" , "Build type" , "cross_compile" , allowed_values = ("native" , "cross_compile" , "embed_only" )),
4646 BoolVariable ("examples" , "Build example programs" , True ),
@@ -54,21 +54,52 @@ vars.AddVariables(
5454 BoolVariable ("openmp" , "Enable OpenMP backend" , False ),
5555 BoolVariable ("cppthreads" , "Enable C++11 threads backend" , True ),
5656 PathVariable ("build_dir" , "Specify sub-folder for the build" , "." , PathVariable .PathAccept ),
57+ PathVariable ("install_dir" , "Specify sub-folder for the install" , "" , PathVariable .PathAccept ),
5758 ("extra_cxx_flags" , "Extra CXX flags to be appended to the build command" , "" ),
59+ ("extra_link_flags" , "Extra LD flags to be appended to the build command" , "" ),
5860 ("compiler_cache" , "Command to prefix to the C and C++ compiler (e.g ccache)" , "" )
5961)
6062
6163env = Environment (platform = "posix" , variables = vars , ENV = os .environ )
62- env .Append (LIBPATH = ["#build/%s" % env ['build_dir' ]])
64+ build_path = env ['build_dir' ]
65+ # If build_dir is a relative path then add a #build/ prefix:
66+ if not env ['build_dir' ].startswith ('/' ):
67+ SConsignFile ('build/%s/.scons' % build_path )
68+ build_path = "#build/%s" % build_path
69+ else :
70+ SConsignFile ('%s/.scons' % build_path )
71+
72+ install_path = env ['install_dir' ]
73+ #If the install_dir is a relative path then assume it's from inside build_dir
74+ if not env ['install_dir' ].startswith ('/' ) and install_path != "" :
75+ install_path = "%s/%s" % (build_path , install_path )
76+
77+ env .Append (LIBPATH = [build_path ])
6378Export ('env' )
6479Export ('vars' )
6580
66- SConsignFile ('build/.%s' % env ['build_dir' ])
81+ def install_lib ( lib ):
82+ # If there is no install folder, then there is nothing to do:
83+ if install_path == "" :
84+ return lib
85+ return env .Install ( "%s/lib/" % install_path , lib )
86+ def install_bin ( bin ):
87+ # If there is no install folder, then there is nothing to do:
88+ if install_path == "" :
89+ return bin
90+ return env .Install ( "%s/bin/" % install_path , bin )
91+ def install_include ( inc ):
92+ if install_path == "" :
93+ return inc
94+ return env .Install ( "%s/include/" % install_path , inc )
95+
96+ Export ('install_lib' )
97+ Export ('install_bin' )
6798
6899Help (vars .GenerateHelpText (env ))
69100
70101if env ['build' ] == "embed_only" :
71- SConscript ('./SConscript' , variant_dir = '#build/%s' % env [ 'build_dir' ] , duplicate = 0 )
102+ SConscript ('./SConscript' , variant_dir = build_path , duplicate = 0 )
72103 Return ()
73104
74105if env ['neon' ] and 'x86' in env ['arch' ]:
@@ -142,17 +173,23 @@ elif env['arch'] == 'arm64-v8a':
142173 prefix = "aarch64-linux-android-"
143174 if 'clang++' in cpp_compiler :
144175 env .Append (CXXFLAGS = ['-no-integrated-as' ])
145- elif env ['arch' ] == 'arm64-v8.2-a' :
146- env .Append (CXXFLAGS = ['-march=armv8.2-a+fp16' ]) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
176+ elif 'arm64-v8.2-a' in env ['arch' ]:
177+ if env ['arch' ] == 'arm64-v8.2-a-sve' :
178+ if env ['os' ] != 'bare_metal' :
179+ print ("Only bare metal SVE is supported at the moment" )
180+ Exit (1 )
181+ env .Append (CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod' ])
182+ else :
183+ env .Append (CXXFLAGS = ['-march=armv8.2-a+fp16' ]) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
184+ if env ['os' ] == 'linux' :
185+ prefix = "aarch64-linux-gnu-"
186+ elif env ['os' ] == 'bare_metal' :
187+ prefix = "aarch64-elf-"
188+ elif env ['os' ] == 'android' :
189+ prefix = "aarch64-linux-android-"
147190 env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8_2' ,'NO_DOT_IN_TOOLCHAIN' ])
148191 if 'clang++' in cpp_compiler :
149192 env .Append (CXXFLAGS = ['-no-integrated-as' ])
150- if env ['os' ] == 'linux' :
151- prefix = "aarch64-linux-gnu-"
152- elif env ['os' ] == 'bare_metal' :
153- prefix = "aarch64-elf-"
154- elif env ['os' ] == 'android' :
155- prefix = "aarch64-linux-android-"
156193elif env ['arch' ] == 'x86_32' :
157194 env .Append (CCFLAGS = ['-m32' ])
158195 env .Append (LINKFLAGS = ['-m32' ])
@@ -242,20 +279,24 @@ if env['logging']:
242279
243280env .Append (CPPPATH = ['#/include' , "#" ])
244281env .Append (CXXFLAGS = env ['extra_cxx_flags' ])
282+ env .Append (LINKFLAGS = env ['extra_link_flags' ])
283+
284+ Default ( install_include ("arm_compute" ))
285+ Default ( install_include ("support" ))
245286
246287Export ('version_at_least' )
247288
248289if env ['opencl' ]:
249- SConscript ("./opencl-1.2-stubs/SConscript" , variant_dir = "build/ %s/opencl-1.2-stubs" % env [ 'build_dir' ] , duplicate = 0 )
290+ SConscript ("./opencl-1.2-stubs/SConscript" , variant_dir = "%s/opencl-1.2-stubs" % build_path , duplicate = 0 )
250291
251292if env ['gles_compute' ] and env ['os' ] != 'android' :
252293 env .Append (CPPPATH = ['#/include/linux' ])
253- SConscript ("./opengles-3.1-stubs/SConscript" , variant_dir = "build/ %s/opengles-3.1-stubs" % env [ 'build_dir' ] , duplicate = 0 )
294+ SConscript ("./opengles-3.1-stubs/SConscript" , variant_dir = "%s/opengles-3.1-stubs" % build_path , duplicate = 0 )
254295
255- SConscript ('./SConscript' , variant_dir = '#build/%s' % env [ 'build_dir' ] , duplicate = 0 )
296+ SConscript ('./SConscript' , variant_dir = build_path , duplicate = 0 )
256297
257298if env ['examples' ] and env ['os' ] != 'bare_metal' :
258- SConscript ('./examples/SConscript' , variant_dir = '#build/ %s/examples' % env [ 'build_dir' ] , duplicate = 0 )
299+ SConscript ('./examples/SConscript' , variant_dir = '%s/examples' % build_path , duplicate = 0 )
259300
260301if env ['os' ] != 'bare_metal' :
261- SConscript ('./tests/SConscript' , variant_dir = '#build/ %s/tests' % env [ 'build_dir' ] , duplicate = 0 )
302+ SConscript ('./tests/SConscript' , variant_dir = '%s/tests' % build_path , duplicate = 0 )
0 commit comments