mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 12:56:26 +00:00
Checkpoint
This commit is contained in:
parent
7152e92d8b
commit
b6fa735f58
@ -3,9 +3,10 @@
|
||||
$my_path = $0 ;
|
||||
$my_path =~ s/trick-ify// ;
|
||||
|
||||
$source_dir = "" ; # Base path to build header from.
|
||||
$header_dir = "" ; # Base path to find header files.
|
||||
$source_dir = "" ; # Base path to build header from
|
||||
$header_dir = "" ; # Base path to find header files
|
||||
$source_make_call = "" ; # Make call to build object files
|
||||
$source_make_args = "" ; # Args to pass into default object make
|
||||
$trickify_make_args = "" ; # Arguments to pass into the trickify make
|
||||
$trickify_make_path = "$my_path../share/trick/makefiles/trickify.mk" ; # Path of the trickify make file
|
||||
$build_s_source = 1 ; # Whether to generate a S_source
|
||||
@ -64,6 +65,11 @@ foreach $argnum (0 .. $#ARGV)
|
||||
$source_make_call = $ARGV[$argnum + 1] ;
|
||||
$skip_arg = 1 ;
|
||||
}
|
||||
elsif($arg eq "-ma") # Default make call args to build object files
|
||||
{
|
||||
$source_make_args = $ARGV[$argnum + 1] ;
|
||||
$skip_arg = 1 ;
|
||||
}
|
||||
elsif($arg eq "-tm") # Trickify make args
|
||||
{
|
||||
$trickify_make_args = $ARGV[$argnum + 1] ;
|
||||
@ -189,7 +195,7 @@ if ($full_build)
|
||||
$file = $src ;
|
||||
$file =~ s/\Q.cpp\E$// ;
|
||||
$file =~ s/\Q.c$\E$// ;
|
||||
$cmd = "g++ -I $trick_home" . "/include -c $src -o $file.o" ;
|
||||
$cmd = "g++ $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ;
|
||||
if($debug)
|
||||
{
|
||||
print "Building obj file: $cmd\n" ;
|
||||
|
@ -0,0 +1,15 @@
|
||||
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
include $(LOCAL_DIR)/myproject_vars.mk
|
||||
|
||||
all:
|
||||
@echo MAKE LOCAL_DIR $(LOCAL_DIR)
|
||||
@trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b a -n trickified_myproject -v
|
||||
|
||||
clean:
|
||||
@rm -rf build python trick $(TRICKIFY_OBJECT_NAME)
|
||||
@rm -rf $(MYPROJECT_TRICK)
|
||||
@rm -rf trickify_obj_list
|
||||
@rm -rf trickify_src_list
|
||||
@rm -rf S_source.hh
|
||||
@rm -rf ../include_foo/*.o
|
||||
@rm -rf ../include_bar/*.o
|
@ -0,0 +1,28 @@
|
||||
# We know this file's position relative to the root directory of the project,
|
||||
# and MAKEFILE_LIST will give us the full path to this file no matter where the
|
||||
# user has installed this project.
|
||||
export MYPROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
|
||||
|
||||
# Specify include paths for your headers.
|
||||
MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include_foo
|
||||
|
||||
# Users may set different flags for C and C++, so you should really modify both
|
||||
# to be safe.
|
||||
TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
|
||||
export TRICKIFY_OBJECT_NAME := trickified_myproject.a
|
||||
MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME)
|
||||
|
||||
# Tell Trick the headers and source at this location are part of a
|
||||
# Trickified project
|
||||
TRICK_EXT_LIB_DIRS += :$(MYPROJECT_HOME)
|
||||
|
||||
# Tell Trick where to find the Python modules generated by SWIG
|
||||
TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python
|
||||
|
||||
# Tell SWIG where to find py_*.i files
|
||||
TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified
|
||||
|
||||
# Link in the Trickified object
|
||||
TRICK_LDFLAGS += $(MYPROJECT_TRICK)
|
4
test/SIM_trickified_object/RUN_test/unit_test.py
Normal file
4
test/SIM_trickified_object/RUN_test/unit_test.py
Normal file
@ -0,0 +1,4 @@
|
||||
sandbox.foo.i = 5
|
||||
assert sandbox.foo.i == 5
|
||||
foo = trick.Foo()
|
||||
trick.stop(10)
|
21
test/SIM_trickified_object/S_define
Normal file
21
test/SIM_trickified_object/S_define
Normal file
@ -0,0 +1,21 @@
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
##include "Foo.hh"
|
||||
##include "Bar.hh"
|
||||
##include "Baz.hh"
|
||||
|
||||
class Sandbox : public Trick::SimObject {
|
||||
|
||||
public:
|
||||
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
Baz baz;
|
||||
|
||||
Sandbox() {
|
||||
(1, "scheduled") foo.foo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Sandbox sandbox;
|
4
test/SIM_trickified_object/S_overrides.mk
Normal file
4
test/SIM_trickified_object/S_overrides.mk
Normal file
@ -0,0 +1,4 @@
|
||||
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
TRICK_CXXFLAGS += -I$(LOCAL_DIR)/models
|
||||
include $(CURDIR)/trickified_project/trickified/myproject.mk
|
9
test/SIM_trickified_object/models/Baz.hh
Normal file
9
test/SIM_trickified_object/models/Baz.hh
Normal file
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
class Baz {
|
||||
|
||||
public:
|
||||
int i;
|
||||
int j;
|
||||
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "Bar.hh"
|
||||
|
||||
|
||||
void Bar::add() {}
|
||||
void Bar::remove() {}
|
||||
void Bar::restart() {}
|
||||
|
@ -0,0 +1,17 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "trick/Event.hh"
|
||||
|
||||
/**
|
||||
* Induce an `%import sim_services` statement in this class's Python module by inheriting from a
|
||||
* Trick class. This allows us to test if `sys.path` contains the correct path to `sim_services.py`
|
||||
* (and other modules generated during a sim build) for Trickified projects.
|
||||
*/
|
||||
class Bar : public Trick::Event {
|
||||
|
||||
int process(long long) {return 0;}
|
||||
void add();
|
||||
void remove();
|
||||
void restart();
|
||||
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "Foo.hh"
|
||||
|
||||
|
||||
|
||||
void Foo::foo() {
|
||||
std::cout << i++ << '\n';
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Foo {
|
||||
|
||||
public:
|
||||
|
||||
int i;
|
||||
|
||||
void foo();
|
||||
|
||||
};
|
4
test/SIM_trickified_object/trickified_project/trickified/.gitignore
vendored
Normal file
4
test/SIM_trickified_object/trickified_project/trickified/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
build
|
||||
python
|
||||
trick
|
||||
*.o
|
@ -11,3 +11,5 @@ clean:
|
||||
@rm -rf trickify_obj_list
|
||||
@rm -rf trickify_src_list
|
||||
@rm -rf S_source.hh
|
||||
@rm -rf ../include_foo/*.o
|
||||
@rm -rf ../include_bar/*.o
|
@ -0,0 +1,14 @@
|
||||
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
include $(LOCAL_DIR)/myproject_vars.mk
|
||||
|
||||
# Append a prerequisite to the $(SWIG_SRC) target. This will build the
|
||||
# Trickified library along with the sim if it does not already exist. Using
|
||||
# $(SWIG_SRC) ensures that all Trickified .i files are created before SWIG is
|
||||
# run on any simulation .i files, which may %import them. Note that this does
|
||||
# NOT cause the Trickified library to be rebuilt if it already exists, even if
|
||||
# the Trickified source code has changed.
|
||||
$(SWIG_SRC): $(MYPROJECT_TRICK)
|
||||
|
||||
$(MYPROJECT_TRICK):
|
||||
@$(MAKE) -s -C $(MYPROJECT_HOME)/trickified
|
4
test/SIM_trickified_shared/RUN_test/unit_test.py
Normal file
4
test/SIM_trickified_shared/RUN_test/unit_test.py
Normal file
@ -0,0 +1,4 @@
|
||||
sandbox.foo.i = 5
|
||||
assert sandbox.foo.i == 5
|
||||
foo = trick.Foo()
|
||||
trick.stop(10)
|
21
test/SIM_trickified_shared/S_define
Normal file
21
test/SIM_trickified_shared/S_define
Normal file
@ -0,0 +1,21 @@
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
##include "Foo.hh"
|
||||
##include "Bar.hh"
|
||||
##include "Baz.hh"
|
||||
|
||||
class Sandbox : public Trick::SimObject {
|
||||
|
||||
public:
|
||||
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
Baz baz;
|
||||
|
||||
Sandbox() {
|
||||
(1, "scheduled") foo.foo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Sandbox sandbox;
|
4
test/SIM_trickified_shared/S_overrides.mk
Normal file
4
test/SIM_trickified_shared/S_overrides.mk
Normal file
@ -0,0 +1,4 @@
|
||||
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
TRICK_CXXFLAGS += -I$(LOCAL_DIR)/models
|
||||
include $(CURDIR)/trickified_project/trickified/myproject.mk
|
9
test/SIM_trickified_shared/models/Baz.hh
Normal file
9
test/SIM_trickified_shared/models/Baz.hh
Normal file
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
class Baz {
|
||||
|
||||
public:
|
||||
int i;
|
||||
int j;
|
||||
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "Bar.hh"
|
||||
|
||||
|
||||
void Bar::add() {}
|
||||
void Bar::remove() {}
|
||||
void Bar::restart() {}
|
||||
|
@ -0,0 +1,17 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "trick/Event.hh"
|
||||
|
||||
/**
|
||||
* Induce an `%import sim_services` statement in this class's Python module by inheriting from a
|
||||
* Trick class. This allows us to test if `sys.path` contains the correct path to `sim_services.py`
|
||||
* (and other modules generated during a sim build) for Trickified projects.
|
||||
*/
|
||||
class Bar : public Trick::Event {
|
||||
|
||||
int process(long long) {return 0;}
|
||||
void add();
|
||||
void remove();
|
||||
void restart();
|
||||
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "Foo.hh"
|
||||
|
||||
|
||||
|
||||
void Foo::foo() {
|
||||
std::cout << i++ << '\n';
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Foo {
|
||||
|
||||
public:
|
||||
|
||||
int i;
|
||||
|
||||
void foo();
|
||||
|
||||
};
|
4
test/SIM_trickified_shared/trickified_project/trickified/.gitignore
vendored
Normal file
4
test/SIM_trickified_shared/trickified_project/trickified/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
build
|
||||
python
|
||||
trick
|
||||
*.o
|
@ -0,0 +1,15 @@
|
||||
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
include $(LOCAL_DIR)/myproject_vars.mk
|
||||
|
||||
all:
|
||||
@echo MAKE LOCAL_DIR $(LOCAL_DIR)
|
||||
@trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v -ma "-fPIC"
|
||||
|
||||
clean:
|
||||
@rm -rf build python trick $(TRICKIFY_OBJECT_NAME)
|
||||
@rm -rf $(MYPROJECT_TRICK)
|
||||
@rm -rf trickify_obj_list
|
||||
@rm -rf trickify_src_list
|
||||
@rm -rf S_source.hh
|
||||
@rm -rf ../include_foo/*.o
|
||||
@rm -rf ../include_bar/*.o
|
@ -0,0 +1,14 @@
|
||||
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
include $(LOCAL_DIR)/myproject_vars.mk
|
||||
|
||||
# Append a prerequisite to the $(SWIG_SRC) target. This will build the
|
||||
# Trickified library along with the sim if it does not already exist. Using
|
||||
# $(SWIG_SRC) ensures that all Trickified .i files are created before SWIG is
|
||||
# run on any simulation .i files, which may %import them. Note that this does
|
||||
# NOT cause the Trickified library to be rebuilt if it already exists, even if
|
||||
# the Trickified source code has changed.
|
||||
$(SWIG_SRC): $(MYPROJECT_TRICK)
|
||||
|
||||
$(MYPROJECT_TRICK):
|
||||
@$(MAKE) -s -C $(MYPROJECT_HOME)/trickified
|
@ -0,0 +1,28 @@
|
||||
# We know this file's position relative to the root directory of the project,
|
||||
# and MAKEFILE_LIST will give us the full path to this file no matter where the
|
||||
# user has installed this project.
|
||||
export MYPROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
|
||||
|
||||
# Specify include paths for your headers.
|
||||
MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include_foo
|
||||
|
||||
# Users may set different flags for C and C++, so you should really modify both
|
||||
# to be safe.
|
||||
TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
|
||||
export TRICKIFY_OBJECT_NAME := trickified_myproject.so
|
||||
MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME)
|
||||
|
||||
# Tell Trick the headers and source at this location are part of a
|
||||
# Trickified project
|
||||
TRICK_EXT_LIB_DIRS += :$(MYPROJECT_HOME)
|
||||
|
||||
# Tell Trick where to find the Python modules generated by SWIG
|
||||
TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python
|
||||
|
||||
# Tell SWIG where to find py_*.i files
|
||||
TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified
|
||||
|
||||
# Link in the Trickified object
|
||||
TRICK_LDFLAGS += $(MYPROJECT_TRICK)
|
Loading…
Reference in New Issue
Block a user