[Scons-users] C/C++ Object Suffix to include source names
Hua Yanghao
huayanghao at gmail.com
Fri Dec 7 09:35:04 EST 2018
I guess I should better explain the use case scenario here too.
For example, in my build environment, I would like to have an empty source
folder containing only one SConscript:
firmware/path/to/empty/SConscript:
import os
Import("usw_files")
Import("usw_config_dict") # content loaded from ~/.usw_config yaml file,
where user can configure the location of arduino IDE
arduino_base = usw_config_dict['arduino']['usw_root']
cores = "hardware/arduino/avr/cores/arduino"
base = os.path.join(arduino_base, cores)
lib_files = [ "wiring.c", "wiring.S", ....]
lib_files = [os.path.join(base, f) for f in lib_files]
usw_files("elf_static_lib", lib_files, base=base)
With above SConscript, I am now able to have *foreign* C/CPP files compiled
into the variant_dir:
build/configs/avr/test/firmware/path/to/empty/*.{c,cpp,S, ...}.o
The entire emitter code is then:
import os
def targets_change(targets, sources, env):
#return targets, sources
new_targets = []
module_base = env["USW_MODULE_BASE"]
for i in sources:
new_path = os.path.relpath(i.path, module_base)
#print("#"*40)
#print(i.name)
#print(i.path)
#print(new_path)
#print("#"*40)
new = new_path +'.o'
new_targets.append(new)
return new_targets, sources
Hope this could be helpful to someone who might be trying to implement the
same thing.
The idea is to compile the source code out of a existing tools delivery
into the project compilation folder (variant_dir), without the need of
copying the source code. Many projects internally and externally are
delivering source code directly with their toolchain so this can become
quite handy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20181207/b3bd3401/attachment-0001.html>
More information about the Scons-users
mailing list