Skip to content

Commit

Permalink
[xpcc] Separate XPCC generator from :build:scons module
Browse files Browse the repository at this point in the history
This adds the submodule :communication:xpcc:generator which copies the
tools/xpcc_generator python tools for generating the XPCC communication.

Before the `:build:scons` module copied these files iff the
`:build:scons:xpcc.source` option was set, which was weird when using a
custom SConscript, and having to set this to a `dummy.xml` source just
to get these files copied.
  • Loading branch information
salkinium committed Aug 8, 2018
2 parents 1b98940 + be3a65a commit cbbf3f6
Show file tree
Hide file tree
Showing 89 changed files with 100 additions and 80 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
command: |
python2 tools/scripts/authors.py --handles --count --shoutout --since 2017-01-01
python3 tools/scripts/authors.py --handles --count --shoutout --since 2017-01-01
python2 tools/system_design/builder/system_layout.py examples/communication/xml/communication.xml -o /tmp
python3 tools/system_design/builder/system_layout.py examples/communication/xml/communication.xml -o /tmp
python2 tools/xpcc_generator/builder/system_layout.py examples/xpcc/xml/communication.xml -o /tmp
python3 tools/xpcc_generator/builder/system_layout.py examples/xpcc/xml/communication.xml -o /tmp
stm32f0-f1-examples:
docker:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ CMakeLists.txt
examples/**/modm
examples/**/SConstruct
examples/**/Makefile
examples/**/generated
1 change: 0 additions & 1 deletion examples/avr/communication/receiver/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/avr/communication/sender/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <modm/communication/xpcc/abstract_component.hpp>

#include "communication/packets.hpp"
#include <packets.hpp>

namespace component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ using systemClock = SystemClock;

#include "component_receiver/receiver.hpp"

#include "communication/postman.hpp"
#include "communication/identifier.hpp"
#include <postman.hpp>
#include <identifier.hpp>

// ----------------------------------------------------------------------------
// Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<options>
<option name=":target">atmega644</option>
<option name=":platform:clock:f_cpu">14745600</option>
<option name=":build:build.path">../../../../build/avr/communication/sender</option>
<option name=":build:scons:xpcc.source">../../../communication/xml/communication.xml</option>
<option name=":build:scons:xpcc.container">sender</option>
<option name=":build:build.path">../../../../build/avr/xpcc/receiver</option>
<option name="::xpcc:generator:source">../../../xpcc/xml/communication.xml</option>
<option name="::xpcc:generator:container">receiver</option>
</options>
<modules>
<module>:communication:xpcc</module>
<module>:communication:xpcc:generator</module>
<module>:debug</module>
<module>:driver:mcp2515</module>
<module>:platform:clock</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#undef MODM_LOG_LEVEL
#define MODM_LOG_LEVEL modm::log::DEBUG

#include "communication/identifier.hpp"
#include "communication/packets.hpp"
#include <identifier.hpp>
#include <packets.hpp>

#include "sender.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <modm/communication/xpcc/abstract_component.hpp>
#include <modm/processing/timer.hpp>

#include "communication/packets.hpp"
#include <packets.hpp>

namespace component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ using systemClock = SystemClock;

#include "component_sender/sender.hpp"

#include "communication/postman.hpp"
#include "communication/identifier.hpp"
#include <postman.hpp>
#include <identifier.hpp>

// ----------------------------------------------------------------------------
// Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<options>
<option name=":target">atmega644</option>
<option name=":platform:clock:f_cpu">14745600</option>
<option name=":build:build.path">../../../../build/avr/communication/receiver</option>
<option name=":build:scons:xpcc.source">../../../communication/xml/communication.xml</option>
<option name=":build:scons:xpcc.container">receiver</option>
<option name=":build:build.path">../../../../build/avr/xpcc/sender</option>
<option name="::xpcc:generator:source">../../../xpcc/xml/communication.xml</option>
<option name="::xpcc:generator:container">sender</option>
</options>
<modules>
<module>:communication:xpcc</module>
<module>:communication:xpcc:generator</module>
<module>:debug</module>
<module>:driver:mcp2515</module>
<module>:platform:clock</module>
Expand Down
1 change: 0 additions & 1 deletion examples/linux/communication/basic/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <modm/communication/xpcc/abstract_component.hpp>

#include "communication/packets.hpp"
#include <packets.hpp>

namespace component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#undef MODM_LOG_LEVEL
#define MODM_LOG_LEVEL modm::log::DEBUG

#include "communication/identifier.hpp"
#include "communication/packets.hpp"
#include <identifier.hpp>

#include "sender.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <modm/communication/xpcc/abstract_component.hpp>
#include <modm/processing/timer.hpp>

#include "communication/packets.hpp"
#include <packets.hpp>

namespace component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "component_receiver/receiver.hpp"
#include "component_sender/sender.hpp"

#include "communication/postman.hpp"
#include "communication/identifier.hpp"
#include <postman.hpp>
#include <identifier.hpp>

// Use TIPC on Linux only
// xpcc::TipcConnector connector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

<options>
<option name=":target">hosted-linux</option>
<option name=":build:build.path">../../../../build/linux/communication/basic</option>
<option name=":build:scons:xpcc.source">../../../communication/xml/communication.xml</option>
<option name=":build:scons:xpcc.container">sender receiver</option>
<option name=":build:build.path">../../../../build/linux/xpcc/basic</option>
<option name=":communication:xpcc:generator:source">../../../xpcc/xml/communication.xml</option>
<option name=":communication:xpcc:generator:container">sender receiver</option>
</options>
<modules>
<module>:platform:core</module>
<module>:communication:xpcc</module>
<module>:communication:xpcc:generator</module>
<module>:debug</module>
<module>:build:scons</module>
</modules>
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion examples/zmq/1_stm32/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/zmq/1_stm32/component_odometry/odometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#undef MODM_LOG_LEVEL
#define MODM_LOG_LEVEL modm::log::DISABLED

#include "communication/identifier.hpp"
#include "communication/packets.hpp"
#include "communication/communication.hpp"
#include <identifier.hpp>
#include <packets.hpp>
#include <communication.hpp>

#include "odometry.hpp"

Expand Down
2 changes: 1 addition & 1 deletion examples/zmq/1_stm32/component_odometry/odometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <modm/communication/xpcc/abstract_component.hpp>
#include <modm/processing/timer.hpp>

#include "communication/packets.hpp"
#include <packets.hpp>

namespace component
{
Expand Down
4 changes: 2 additions & 2 deletions examples/zmq/1_stm32/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include "component_odometry/odometry.hpp"

#include "communication/postman.hpp"
#include "communication/identifier.hpp"
#include <postman.hpp>
#include <identifier.hpp>

using namespace Board;

Expand Down
6 changes: 3 additions & 3 deletions examples/zmq/1_stm32/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<extends>../../../src/modm/board/disco_f407vg/board.xml</extends>
<options>
<option name=":build:build.path">../../../build/zmq/1_stm32</option>
<option name=":build:scons:xpcc.source">../../communication/xml/communication.xml</option>
<option name=":build:scons:xpcc.container">odometry</option>
<option name=":communication:xpcc:generator:source">../../xpcc/xml/communication.xml</option>
<option name=":communication:xpcc:generator:container">odometry</option>
</options>
<modules>
<module>:communication:xpcc</module>
<module>:communication:xpcc:generator</module>
<module>:platform:can:1</module>
<module>:platform:gpio</module>
<module>:platform:timer:1</module>
Expand Down
1 change: 0 additions & 1 deletion examples/zmq/3_zmq_app/.gitignore

This file was deleted.

6 changes: 3 additions & 3 deletions examples/zmq/3_zmq_app/component_gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include <modm/debug/logger.hpp>

#include "communication/identifier.hpp"
#include "communication/packets.hpp"
#include "communication/communication.hpp"
#include <identifier.hpp>
#include <packets.hpp>
#include <communication.hpp>

#include "gui.hpp"

Expand Down
2 changes: 1 addition & 1 deletion examples/zmq/3_zmq_app/component_gui/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <modm/communication/xpcc/abstract_component.hpp>
#include <modm/processing/timer.hpp>

#include "communication/packets.hpp"
#include <packets.hpp>

namespace component
{
Expand Down
4 changes: 2 additions & 2 deletions examples/zmq/3_zmq_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "component_gui/gui.hpp"

#include "communication/postman.hpp"
#include "communication/identifier.hpp"
#include <postman.hpp>
#include <identifier.hpp>

/**
* Simple subscriber with zeromq.
Expand Down
6 changes: 3 additions & 3 deletions examples/zmq/3_zmq_app/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<options>
<option name=":target">hosted-linux</option>
<option name=":build:build.path">../../../build/zmq/3_zmq_app</option>
<option name=":build:scons:xpcc.source">../../communication/xml/communication.xml</option>
<option name=":build:scons:xpcc.container">gui</option>
<option name=":communication:xpcc:generator:source">../../xpcc/xml/communication.xml</option>
<option name=":communication:xpcc:generator:container">gui</option>
</options>
<modules>
<module>:communication:xpcc</module>
<module>:communication:xpcc:generator</module>
<module>:debug</module>
<module>:platform:core</module>
<module>:build:scons</module>
Expand Down
26 changes: 8 additions & 18 deletions tools/build_script_generator/scons/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,6 @@ def prepare(module, options):
module.add_option(
StringOption(name="image.source", default="",
description="Path to the image folder"))
module.add_option(
StringOption(name="xpcc.source", default="",
description="Path to the XPCC source file"))
module.add_option(
StringOption(name="xpcc.container", default="",
description="Name of the XPCC container to generate for"))
module.add_option(
StringOption(name="xpcc.generate", default="communication",
description="Path to the XPCC generated folder"))
module.add_option(
StringOption(name="xpcc.namespace", default="robot",
description="Namespace of the generated XPCC communications"))

module.add_option(
EnumerationOption(name="info.git", default="Disabled",
enumeration=["Disabled", "Info", "Info+Status"],
Expand Down Expand Up @@ -76,6 +63,7 @@ def build(env):

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

target = env["modm:target"]
Expand All @@ -89,8 +77,8 @@ def post_build(env, buildlog):
"cmake_wrapper",
"qtcreator",
]
if len(env[":::xpcc.source"]):
build_tools += ["system_design"]
if has_xpcc_generator:
build_tools += ["xpcc_generator"]
if has_image_source:
build_tools += ["bitmap"]
if env[":::info.git"] != "Disabled" or env[":::info.build"]:
Expand Down Expand Up @@ -119,6 +107,11 @@ def post_build(env, buildlog):
"is_unittest": is_unittest,
"has_image_source": has_image_source,
"image_source": env[":::image.source"],
"has_xpcc_generator": has_xpcc_generator,
"generator_source": env.get_option(":communication:xpcc:generator:source", ""),
"generator_container": env.get_option(":communication:xpcc:generator:container", ""),
"generator_path": env.get_option(":communication:xpcc:generator:path", ""),
"generator_namespace": env.get_option(":communication:xpcc:generator:namespace", ""),
})
# Set these substitutions for all templates
env.substitutions = subs
Expand All @@ -140,9 +133,6 @@ def post_build(env, buildlog):
# Copy the scons-build-tools
env.copy(repopath("ext/dlr/scons-build-tools"), "ext/dlr/scons-build-tools")
env.copy("site_tools", "scons/site_tools")
# Copy XPCC tools
if "system_design" in build_tools:
env.copy(repopath("tools/system_design"), "tools/system_design")

# these are the ONLY files that are allowed to NOT be namespaced with modm!
env.outbasepath = "."
Expand Down
2 changes: 1 addition & 1 deletion tools/build_script_generator/scons/resources/SConscript.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ env.SetDefault(CONFIG_OPENOCD_COMMANDS = [
%% endif

# XPCC generator tool path
env["XPCC_SYSTEM_DESIGN"] = join(abspath("."), "tools", "system_design")
env["XPCC_SYSTEM_DESIGN"] = join(abspath("."), "tools", "xpcc_generator")

# Toolchain configuration
%% macro generate_flags_for_profile(name, profile, append=False)
Expand Down
14 changes: 7 additions & 7 deletions tools/build_script_generator/scons/resources/SConstruct.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ for image in env.FindFiles("{{ image_source }}", ".pbm"):
source, _ = env.Bitmap(str(image))
sources.append(source)
%% endif
%% if options[":::xpcc.source"] != ""
%% if has_xpcc_generator
# Generating XPCC sources
env.Append(CPPPATH="{{ options[":::xpcc.generate"] }}")
ignored.append("{{ options[":::xpcc.generate"] }}")
env.Append(CPPPATH="{{ generator_path }}")
ignored.append("{{ generator_path }}")
sources += env.XpccCommunication(
xmlfile=abspath("{{ options[":::xpcc.source"] }}"),
container="{{ options[":::xpcc.container"] }}",
path=abspath("{{ options[":::xpcc.generate"] }}"),
namespace="{{ options[":::xpcc.namespace"] }}")
xmlfile=abspath("{{ generator_source }}"),
container="{{ generator_container }}",
path=abspath("{{ generator_path }}"),
namespace="{{ generator_namespace }}")
%% endif

%% if not is_unittest
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class SystemLayoutBuilder(builder_base.Builder):
$ python3 system_layout.py ../../../../roboter/2012_captain/software/global/xml/robot.xml -o /tmp -s simulator -s "drive simulation" -s "External"
# 2015
$ python3 system_layout.py ../../../../season/common/robot.xml --dtdpath ../../../tools/system_design/xml/dtd -o /tmp
$ python3 system_layout.py ../../../../season/common/robot.xml --dtdpath ../../../tools/system_design/xml/dtd -o /tmp -s "drive big simulation" -s "drive little simulation" -s "External" -s "simulator" -s "drive big"
$ python3 system_layout.py ../../../../season/common/robot.xml --dtdpath ../../../tools/xpcc_generator/xml/dtd -o /tmp
$ python3 system_layout.py ../../../../season/common/robot.xml --dtdpath ../../../tools/xpcc_generator/xml/dtd -o /tmp -s "drive big simulation" -s "drive little simulation" -s "External" -s "simulator" -s "drive big"
A PDF called system.pdf is generated in /tmp/system.pdf.
If you want to display callable actions for each component add the -a switch.
Expand Down
Loading

0 comments on commit cbbf3f6

Please sign in to comment.