diff --git a/bin/trick-ify b/bin/trick-ify index f92ad9f1..dfe214bb 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -13,7 +13,8 @@ $name = "trickified" ; # Name $build_type = "o" ; # Type of library to be built (o, a , so) $debug = 0 ; # Debug info flag #$work_dir = "./trickify/" ; # Directory to dump work artifacts -$work_dir = "./" ; # Directory to dump work artifacts +$work_dir = "./" ; # Directory to dump work artifacts +$trick_home = $my_path . ".." ; # Trick directory to use for building $skip_arg = 0 ; foreach $argnum (0 .. $#ARGV) @@ -73,7 +74,8 @@ foreach $argnum (0 .. $#ARGV) } else { - print "Invalid build type {$val}, valid build types are {o, a, so}\n" + print "Invalid build type {$val}, valid build types are {o, a, so}\n" ; + exit 1 ; } $skip_arg = 1 ; } @@ -86,6 +88,11 @@ foreach $argnum (0 .. $#ARGV) #$work_dir = $ARGV[$argnum + 1] . "/trickify/" ; $skip_arg = 1 ; } + elsif($arg eq "-th") # Set trick home directory + { + $trick_home = $ARGV[$argnum + 1] ; + $skip_arg = 1 ; + } else { print "Unrecognized argument: $arg\n" ; @@ -94,7 +101,7 @@ foreach $argnum (0 .. $#ARGV) } #Set Environment Variables -$ENV{'TRICKIFY_CXX_FLAGS'} = "-I $source_dir" ; #TODO: Test with multiple dirs passed in at once +$ENV{'TRICKIFY_CXX_FLAGS'} = "-I $source_dir -I $trick_home" . "/include" ; #TODO: Test with multiple dirs passed in at once $ENV{'TRICKIFY_OBJECT_NAME'} = "$name.$build_type" ; $ENV{'TRICKIFY_SOURCE'} = "$source_dir" ; $ENV{'TRICKIFY_HEADER'} = "$header_dir" ; @@ -146,9 +153,8 @@ print "Building object files\n" ; foreach $src (@src_files) { $file = $src ; - #TODO double check this works on different boxes - $file =~ s/$\Q.cpp\E// ; - $file =~ s/$\Q.c\E// ; + $file =~ s/\Q.cpp\E$// ; + $file =~ s/\Q.c$\E$// ; $cmd = "g++ -c $src -o $file.o" ; if($debug) { @@ -186,7 +192,8 @@ if($debug) { full_build = $full_build name = $name build_type = $build_type - work_dir = $work_dir\n" ; + 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? diff --git a/share/trick/makefiles/build_trickify.py b/share/trick/makefiles/build_trickify.py index f9b30045..f83c64d8 100644 --- a/share/trick/makefiles/build_trickify.py +++ b/share/trick/makefiles/build_trickify.py @@ -13,16 +13,12 @@ def build_S_source(): loc = "" if "TRICKIFY_HEADER" in os.environ: loc = os.getenv("TRICKIFY_HEADER") - work_dir = "" - if "TRICKIFY_WORK_DIR" in os.environ: - work_dir = os.getenv("TRICKIFY_WORK_DIR") - s_source = open(work_dir + "S_source.hh", 'w') + 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 "' + work_dir + "/../" + str(files[i]) + '"\n') - s_source.write('#include "' + work_dir + str(files[i]) + '"\n') + s_source.write('#include "' + str(files[i]) + '"\n') def build_obj_list(): loc = "" diff --git a/test/SIM_trickified/trickified_project/testing/testing.hh b/test/SIM_trickified/trickified_project/testing/testing.hh index 3bc95fc0..584c80e5 100644 --- a/test/SIM_trickified/trickified_project/testing/testing.hh +++ b/test/SIM_trickified/trickified_project/testing/testing.hh @@ -17,3 +17,5 @@ class test_class int b; int c; }; + +int some_function(); \ No newline at end of file diff --git a/test/SIM_trickified/trickified_project/testing/testing_main.cpp b/test/SIM_trickified/trickified_project/testing/testing_main.cpp index f51da2aa..116715a3 100644 --- a/test/SIM_trickified/trickified_project/testing/testing_main.cpp +++ b/test/SIM_trickified/trickified_project/testing/testing_main.cpp @@ -1,6 +1,6 @@ #include "testing.hh" -int main() +int some_function() { test_class test ; std::cout << test.a << ", " << test.b << ", " << test.c << std::endl ; diff --git a/test/SIM_trickified/trickified_project/trickified/Makefile b/test/SIM_trickified/trickified_project/trickified/Makefile index c039494f..5fd890ce 100644 --- a/test/SIM_trickified/trickified_project/trickified/Makefile +++ b/test/SIM_trickified/trickified_project/trickified/Makefile @@ -2,13 +2,11 @@ LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) include $(LOCAL_DIR)/myproject_vars.mk all: - #@$(MAKE) -s -f $(TRICK_HOME)/share/trick/makefiles/trickify.mk - #@trick-ify -d "/users/plherrin/trick/test/SIM_trickified/trickified_project/include" -b a -n trickified_myproject - @trick-ify -d "/users/plherrin/trick/test/SIM_trickified/trickified_project/testing" -b a -n trickified_myproject + @echo MAKE LOCAL_DIR $(LOCAL_DIR) + @trick-ify -d "$(LOCAL_DIR)/../include" -b o -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 /users/plherrin/trick/test/SIM_trickified/trickified_project/testing/*.o diff --git a/test/SIM_trickified/trickified_project/trickified/S_source.hh b/test/SIM_trickified/trickified_project/trickified/S_source.hh index cef5a8e0..a410df75 100644 --- a/test/SIM_trickified/trickified_project/trickified/S_source.hh +++ b/test/SIM_trickified/trickified_project/trickified/S_source.hh @@ -1 +1,2 @@ -#include "/users/plherrin/trick/test/SIM_trickified/trickified_project/testing/testing.hh" +#include "/home/patrick/trick/test/SIM_trickified/trickified_project/trickified/../include/Foo.hh" +#include "/home/patrick/trick/test/SIM_trickified/trickified_project/trickified/../include/Bar.hh"