Skip to content

Commit

Permalink
[scons] Fix duplicate compilation for image/xpcc tools
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Aug 8, 2018
1 parent 72c0656 commit 1b98940
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
5 changes: 4 additions & 1 deletion tools/build_script_generator/scons/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def build(env):

def post_build(env, buildlog):
is_unittest = env.has_module(":test")
has_image_source = len(env[":::image.source"])

target = env["modm:target"]
subs = common_target(target)
Expand All @@ -90,7 +91,7 @@ def post_build(env, buildlog):
]
if len(env[":::xpcc.source"]):
build_tools += ["system_design"]
if len(env[":::image.source"]):
if has_image_source:
build_tools += ["bitmap"]
if env[":::info.git"] != "Disabled" or env[":::info.build"]:
build_tools += ["info"]
Expand All @@ -116,6 +117,8 @@ def post_build(env, buildlog):
"metadata": buildlog.metadata,
"build_tools": build_tools,
"is_unittest": is_unittest,
"has_image_source": has_image_source,
"image_source": env[":::image.source"],
})
# Set these substitutions for all templates
env.substitutions = subs
Expand Down
25 changes: 17 additions & 8 deletions tools/build_script_generator/scons/resources/SConstruct.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,43 @@ env.InfoBuild()
headers = env.FindHeaderFiles(join(modm_path, "test"))
sources = env.UnittestRunner(target="main.cpp", source=headers, template="modm/test/runner.cpp.in")
%% else
# Finding application sources
env.Append(CPPPATH=".")
sources = env.FindSourceFiles(".", ignorePaths=["modm", "cmake-build-*", "build"])
ignored = ["modm", "cmake-build-*", "build"]
sources = []
%% endif

%% if options[":::image.source"] != ""
# Finding image sources
for image in env.FindFiles("{{ options[":::image.source"] }}", ".pbm"):
%% if has_image_source
# Generating image sources
env.Append(CPPPATH="{{ image_source }}")
ignored.append("{{ image_source }}")
for image in env.FindFiles("{{ image_source }}", ".pbm"):
source, _ = env.Bitmap(str(image))
sources.append(source)
%% endif
%% if options[":::xpcc.source"] != ""
# Generating XPCC sources
env.Append(CPPPATH="{{ options[":::xpcc.generate"] }}")
ignored.append("{{ options[":::xpcc.generate"] }}")
sources += env.XpccCommunication(
xmlfile=abspath("{{ options[":::xpcc.source"] }}"),
container="{{ options[":::xpcc.container"] }}",
path=abspath("{{ options[":::xpcc.generate"] }}"),
namespace="{{ options[":::xpcc.namespace"] }}")
%% endif

%% if not is_unittest
# Finding application sources
sources += env.FindSourceFiles(".", ignorePaths=ignored)
%% endif

# Building application
program = env.Program(target=project_name+".elf", source=sources)

%% if openocd_file != ""
# Using a custom OpenOCD script
env.Append(CONFIG_OPENOCD_SEARCHDIRS=[abspath("{{openocd_base_dir}}")])
env.Append(CONFIG_OPENOCD_CONFIGFILES=["{{openocd_file}}"])
%% endif
%#
# Building application
program = env.Program(target=project_name+".elf", source=sources)

# SCons functions
env.Alias("cmakewrapper", env.CMakeWrapper())
Expand Down

0 comments on commit 1b98940

Please sign in to comment.