mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Checkpoint
This commit is contained in:
parent
2f43db8e2e
commit
f2dfa218a2
@ -5,6 +5,7 @@ $my_path =~ s/trick-ify// ;
|
||||
|
||||
$source_dir = "." ; # Base path to build header from. Default to working directory
|
||||
$header_dir = "." ; # Base path to build source from. Default to working directory
|
||||
$source_make_call = "" ; # Make call to build object files
|
||||
$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
|
||||
@ -60,6 +61,11 @@ foreach $argnum (0 .. $#ARGV)
|
||||
{
|
||||
$full_build = 0 ;
|
||||
}
|
||||
elsif($arg eq "-m") # Make call to build object files
|
||||
{
|
||||
$source_make_call = $ARGV[$argnum + 1] ;
|
||||
$skip_arg = 1 ;
|
||||
}
|
||||
elsif($arg eq "-tm") # Trickify make args
|
||||
{
|
||||
$trickify_make_args = $ARGV[$argnum + 1] ;
|
||||
@ -111,11 +117,17 @@ foreach $argnum (0 .. $#ARGV)
|
||||
}
|
||||
|
||||
#Set Environment Variables
|
||||
if ( $full_build )
|
||||
if ($full_build)
|
||||
{
|
||||
$ENV{'FULL_TRICKIFY_BUILD'} = "1" ;
|
||||
}
|
||||
$ENV{'TRICKIFY_CXX_FLAGS'} = "-I $source_dir -I $trick_home" . "/include" ; #TODO: Test with multiple dirs passed in at once
|
||||
my @src_dirs = split ' ', $source_dir ;
|
||||
$source_dir_arg = "" ;
|
||||
foreach $dir (@src_dirs)
|
||||
{
|
||||
$source_dir_arg .= "-I " . $dir . " ";
|
||||
}
|
||||
$ENV{'TRICKIFY_CXX_FLAGS'} = "$source_dir_args -I $trick_home" . "/include" ;
|
||||
$ENV{'TRICKIFY_OBJECT_NAME'} = "$name.$build_type" ;
|
||||
$ENV{'TRICKIFY_SOURCE'} = "$source_dir" ;
|
||||
$ENV{'TRICKIFY_HEADER'} = "$header_dir" ;
|
||||
@ -143,62 +155,58 @@ if ($build_s_source)
|
||||
}
|
||||
|
||||
#Build source file list, only if trickifying the entire library
|
||||
#TODO: Move build artifacts into build? Maybe?
|
||||
if ($build_trickify_src_list)
|
||||
if ($build_trickify_src_list and $full_build)
|
||||
{
|
||||
print "Building trickify_src_list\n" ;
|
||||
if($full_build)
|
||||
{
|
||||
$make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ;
|
||||
print(`$make_src_list`) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
open (fh, ">", "$work_dir"."trickify_src_list") ;
|
||||
close (fh) ;
|
||||
}
|
||||
$make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ;
|
||||
print(`$make_src_list`) ;
|
||||
}
|
||||
|
||||
#Build array of source files
|
||||
open ($fh, "$work_dir"."trickify_src_list") or die "Could not open trickify_src_list: $!" ;
|
||||
@src_files ;
|
||||
while (my $line = <$fh>)
|
||||
if ($full_build)
|
||||
{
|
||||
chomp $line ;
|
||||
push @src_files, $line ;
|
||||
open ($fh, "$work_dir"."trickify_src_list") or die "Could not open trickify_src_list: $!" ;
|
||||
@src_files ;
|
||||
while (my $line = <$fh>)
|
||||
{
|
||||
chomp $line ;
|
||||
push @src_files, $line ;
|
||||
}
|
||||
close (fh) ;
|
||||
}
|
||||
close (fh) ;
|
||||
|
||||
#Build object files from source file list
|
||||
if ($build_trickify_src_list)
|
||||
if ($full_build)
|
||||
{
|
||||
print "Building object files\n" ;
|
||||
foreach $src (@src_files)
|
||||
if($source_make_call eq "")
|
||||
{
|
||||
$file = $src ;
|
||||
$file =~ s/\Q.cpp\E$// ;
|
||||
$file =~ s/\Q.c$\E$// ;
|
||||
$cmd = "g++ -c $src -o $file.o" ;
|
||||
if($debug)
|
||||
foreach $src (@src_files)
|
||||
{
|
||||
print "Building obj file: $cmd\n" ;
|
||||
$file = $src ;
|
||||
$file =~ s/\Q.cpp\E$// ;
|
||||
$file =~ s/\Q.c$\E$// ;
|
||||
$cmd = "g++ -c $src -o $file.o" ;
|
||||
if($debug)
|
||||
{
|
||||
print "Building obj file: $cmd\n" ;
|
||||
}
|
||||
print(`$cmd`) ;
|
||||
}
|
||||
print(`$cmd`) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
print(`$source_make_call`) ;
|
||||
}
|
||||
}
|
||||
|
||||
#Build object file list, only if trickifying the entire library
|
||||
print "Building trickify_obj_list\n" ;
|
||||
if($full_build)
|
||||
if($build_trickify_obj_list and $full_build)
|
||||
{
|
||||
print "Building trickify_obj_list\n" ;
|
||||
$make_obj_list = "python3 $my_path../share/trick/makefiles/build_trickify_obj_list.py" ;
|
||||
print(`$make_obj_list`) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
open (fh, ">", "$work_dir"."trickify_obj_list") ;
|
||||
close (fh) ;
|
||||
}
|
||||
|
||||
#Build trickify call
|
||||
print "Begin Trickification...\n" ;
|
||||
@ -209,7 +217,8 @@ if($debug) {
|
||||
print
|
||||
"TRICKIFY BUILD INFO:
|
||||
header_dir = $header_dir
|
||||
source_dir = $source_dir
|
||||
source_dir = $source_dir_arg
|
||||
source_make_call = $source_make_call
|
||||
trickify_make_args = $trickify_make_args
|
||||
trickify_make_path = $trickify_make_path
|
||||
build_s_source = $build_s_source
|
||||
@ -219,6 +228,3 @@ if($debug) {
|
||||
work_dir = $work_dir
|
||||
trick_home = $trick_home\n" ;
|
||||
}
|
||||
|
||||
#TODO: Can't run trickify neutrally, must set source dir/output dir or conflicts will occur. Should fix or just document?
|
||||
#TODO: Can we change build dir path?
|
||||
|
@ -13,38 +13,39 @@ def build_S_source():
|
||||
loc = ""
|
||||
if "TRICKIFY_HEADER" in os.environ:
|
||||
loc = os.getenv("TRICKIFY_HEADER")
|
||||
dirs = loc.split()
|
||||
|
||||
s_source = open("S_source.hh", 'w')
|
||||
for ext in def_header_ext:
|
||||
files = find_files_by_extension(loc, ext)
|
||||
for i in range(len(files)):
|
||||
s_source.write('#include "' + str(files[i]) + '"\n')
|
||||
|
||||
for path in dirs:
|
||||
for ext in def_header_ext:
|
||||
files = find_files_by_extension(path, ext)
|
||||
for i in range(len(files)):
|
||||
s_source.write('#include "' + str(files[i]) + '"\n')
|
||||
|
||||
def build_obj_list():
|
||||
loc = ""
|
||||
if "TRICKIFY_SOURCE" in os.environ:
|
||||
loc = os.getenv("TRICKIFY_SOURCE")
|
||||
work_dir = ""
|
||||
if "TRICKIFY_WORK_DIR" in os.environ:
|
||||
work_dir = os.getenv("TRICKIFY_WORK_DIR")
|
||||
dirs = loc.split()
|
||||
|
||||
files = find_files_by_extension(loc, "o")
|
||||
s_source = open(work_dir + "trickify_obj_list", 'w')
|
||||
for i in range(len(files)):
|
||||
#s_source.write(work_dir + "/../" + str(files[i]) + '\n')
|
||||
s_source.write(work_dir + str(files[i]) + '\n')
|
||||
obj_list = open("trickify_obj_list", 'w')
|
||||
|
||||
for path in dirs:
|
||||
files = find_files_by_extension(path, "o")
|
||||
for i in range(len(files)):
|
||||
obj_list.write(str(files[i]) + '\n')
|
||||
|
||||
def build_src_list():
|
||||
loc = ""
|
||||
if "TRICKIFY_SOURCE" in os.environ:
|
||||
loc = os.getenv("TRICKIFY_SOURCE")
|
||||
work_dir = ""
|
||||
if "TRICKIFY_WORK_DIR" in os.environ:
|
||||
work_dir = os.getenv("TRICKIFY_WORK_DIR")
|
||||
dirs = loc.split()
|
||||
|
||||
for ext in def_src_ext:
|
||||
files = find_files_by_extension(loc, ext)
|
||||
s_source = open(work_dir + "trickify_src_list", 'w')
|
||||
for i in range(len(files)):
|
||||
#s_source.write(work_dir + "/../" + str(files[i]) + '\n')
|
||||
s_source.write(work_dir + str(files[i]) + '\n')
|
||||
src_list = open("trickify_src_list", 'w')
|
||||
|
||||
for path in dirs:
|
||||
for ext in def_src_ext:
|
||||
files = find_files_by_extension(path, ext)
|
||||
for i in range(len(files)):
|
||||
src_list.write(str(files[i]) + '\n')
|
||||
|
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "Bar.hh"
|
||||
|
||||
|
||||
void Bar::add() {}
|
||||
void Bar::remove() {}
|
||||
void Bar::restart() {}
|
||||
|
@ -10,8 +10,8 @@
|
||||
class Bar : public Trick::Event {
|
||||
|
||||
int process(long long) {return 0;}
|
||||
void add() {}
|
||||
void remove() {}
|
||||
void restart() {}
|
||||
void add();
|
||||
void remove();
|
||||
void restart();
|
||||
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "Foo.hh"
|
||||
|
||||
|
||||
|
||||
void Foo::foo() {
|
||||
std::cout << i++ << '\n';
|
||||
}
|
@ -8,8 +8,6 @@ class Foo {
|
||||
|
||||
int i;
|
||||
|
||||
void foo() {
|
||||
std::cout << i++ << '\n';
|
||||
}
|
||||
void foo();
|
||||
|
||||
};
|
@ -3,7 +3,7 @@ include $(LOCAL_DIR)/myproject_vars.mk
|
||||
|
||||
all:
|
||||
@echo MAKE LOCAL_DIR $(LOCAL_DIR)
|
||||
@trick-ify -d "$(LOCAL_DIR)/../include" -b o -n trickified_myproject -v
|
||||
@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)
|
||||
|
@ -12,7 +12,7 @@ TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
|
||||
export TRICKIFY_BUILD_TYPE := STATIC
|
||||
export TRICKIFY_OBJECT_NAME := trickified_myproject.o
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user