Skip to content

Commit

Permalink
Clean up include path
Browse files Browse the repository at this point in the history
This makes the code more readable and makes the program architecture
easier to extend.
  • Loading branch information
Tony Cheneau committed Aug 5, 2013
1 parent 5ad5979 commit 310c1e4
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ env.Append(LIBPATH = [os.path.join(boost_prefix, "lib")])
env.Append(CCFLAGS = "-O3")
app = env.Program(target = "wiredto154", source = "wiredto154.cpp",
LIBS = libs + [ models_lib, core_lib, network_lib ],
CPPPATH=["core", "models", "network"],
CPPPATH=["."],
LIBPATH = [ 'models', 'network', 'core' ],
# the following line is a workaround to solve circular dependencies issues when linking the program
LINKFLAGS = "-Wl,-\(")
Expand Down
2 changes: 1 addition & 1 deletion core/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Import('network_lib')

libs = [ models_lib, network_lib ]

core_lib = local_env.StaticLibrary("core", Split("simulation.cpp"), CPPPATH=["../core", "../models", "../network"], LIBS= libs + ["pthread", "boost_system-mt"])
core_lib = local_env.StaticLibrary("core", Split("simulation.cpp"), CPPPATH=["..", "."], LIBS= libs + ["pthread", "boost_system-mt"])
Export('core_lib')
2 changes: 1 addition & 1 deletion core/simulation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "simulation.hpp"

#include "tools.hpp"
#include "models/tools.hpp"

#ifdef DEBUG
#include <boost/lexical_cast.hpp>
Expand Down
14 changes: 7 additions & 7 deletions core/simulation.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef WIREDTO154_MODELS_SIMULATION_H
#define WIREDTO154_MODELS_SIMULATION_H

#include "coordinate.hpp"
#include "modulation.hpp"
#include "IEEE802154.hpp"
#include "frame.hpp"
#include "node.hpp"
#include "pathlossmodel.hpp"
#include "server.hpp"
#include "types.hpp"
#include "models/coordinate.hpp"
#include "models/IEEE802154.hpp"
#include "models/modulation.hpp"
#include "models/node.hpp"
#include "models/pathlossmodel.hpp"
#include "network/frame.hpp"
#include "network/server.hpp"

#include <cstdlib>
#include <boost/asio.hpp>
Expand Down
2 changes: 1 addition & 1 deletion models/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local_env = env.Clone()

models_lib = StaticLibrary("models",
Split("coordinate.cpp pathlossmodel.cpp modulation.cpp IEEE802154.cpp"),
CPPPATH = [ "../core", "../network", "."])
CPPPATH = [ "..", "."])
Export('models_lib')

local_env = Environment()
Expand Down
3 changes: 2 additions & 1 deletion models/pathlossmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include "exception.hpp"
#include "modulation.hpp"
#include "node.hpp"
#include "types.hpp"

#include "core/types.hpp"

#include <boost/random/mersenne_twister.hpp>
#include <boost/random/normal_distribution.hpp>
Expand Down
2 changes: 1 addition & 1 deletion network/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Import('models_lib')

network_lib = local_env.StaticLibrary("network",
Split("server.cpp dispatcher.cpp frame.cpp"),
CPPPATH=["../core", "../models", "../network"],
CPPPATH=["..", "."],
LIBS=[ models_lib, "pthread", "boost_system-mt" ])

Export('network_lib')
4 changes: 2 additions & 2 deletions network/dispatcher.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef WIREDTO154_NETWORK_DISPATCHER_HPP
#define WIREDTO154_NETWORK_DISPATCHER_HPP

#include "node.hpp"
#include "simulation.hpp"
#include "core/simulation.hpp"
#include "models/node.hpp"

#include <boost/asio.hpp>
#include <boost/system/error_code.hpp>
Expand Down
2 changes: 1 addition & 1 deletion network/frame.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef WIREDTO154_NETWORK_FRAME_HPP
#define WIREDTO154_NETWORK_FRAME_HPP

#include "node.hpp"
#include "models/node.hpp"

#include <boost/asio.hpp>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion tests/IEEE802154-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

#include "IEEE802154.hpp"
#include "models/IEEE802154.hpp"

BOOST_AUTO_TEST_CASE( test ) {
Phy_IEEE802154_OQPSK modulation;
Expand Down
4 changes: 1 addition & 3 deletions tests/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ libs = [ 'boost_unit_test_framework', models_lib ]
local_env.Append(CPPPATH = [os.path.join(boost_prefix, "include")])
local_env.Append(LIBPATH = [os.path.join(boost_prefix, "lib")])

local_env.Append(CPPPATH= "../models")
local_env.Append(CPPPATH= ["..", "."])

app = local_env.Program(source = "coordinate-test.cpp", LIBS = libs, LIBPATH = [ "../models" ])
app2 = local_env.Program(source = "IEEE802154-test.cpp", LIBS = libs, LIBPATH = [ "../models" ])
app3 = local_env.Program(source = "simulation-test.cpp",
CPPPATH=["../core", "../models", "../network"],
LIBS = libs + [ core_lib, network_lib ] + ["pugixml", "pthread", "boost_system-mt", "boost_program_options"],
# the following line is a workaround to solve circular dependencies issues when linking the program
LINKFLAGS = "-Wl,-\(")
app4 = local_env.Program(source = "pathloss-test.cpp",
CPPPATH=["../core", "../models", "../network"],
LIBS = libs + ["boost_program_options"],
LIBPATH = [ "../models" ])
local_env.Default([app, app2, app3, app4])
Expand Down
2 changes: 1 addition & 1 deletion tests/coordinate-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using boost::test_tools::output_test_stream;
#define BOOST_TEST_MODULE coordinate test

#include "coordinate.hpp"
#include "models/coordinate.hpp"

#include <ostream>

Expand Down
6 changes: 3 additions & 3 deletions tests/pathloss-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <boost/test/unit_test.hpp>
#include <boost/random/mersenne_twister.hpp>

#include "coordinate.hpp"
#include "node.hpp"
#include "pathlossmodel.hpp"
#include "models/coordinate.hpp"
#include "models/node.hpp"
#include "models/pathlossmodel.hpp"

#include <string>

Expand Down
2 changes: 1 addition & 1 deletion tests/simulation-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <boost/test/unit_test.hpp>
#define BOOST_TEST_MODULE simulation test

#include "simulation.hpp"
#include "core/simulation.hpp"

BOOST_AUTO_TEST_CASE( loading_test ) {
Simulation & sim = Simulation::get();
Expand Down

0 comments on commit 310c1e4

Please sign in to comment.