Re: C/C++ Object Suffix to include source names

Hua Yanghao <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <CAPTzt1BANfJagYjrC88Mzfexw3u6SSd2S+ww08ks6vjetkKOcQ@mail.gmail.com>
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.

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.