From be8a77236296823a197864c2d924ce3a161829c7 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 25 Nov 2024 13:21:25 -0600 Subject: [PATCH 01/40] Implmented trick-ify --- bin/trick-ify | 238 ++++++++++++++++++ share/trick/makefiles/build_trickify.py | 51 ++++ .../makefiles/build_trickify_S_source_hh.py | 10 + .../makefiles/build_trickify_obj_list.py | 10 + .../makefiles/build_trickify_src_list.py | 10 + share/trick/makefiles/trickify.mk | 15 +- test/Makefile | 13 +- test/SIM_trickified/S_overrides.mk | 2 - .../trickified_project/trickified/Makefile | 11 - .../trickified_project/trickified/S_source.hh | 2 - .../RUN_test/unit_test.py | 0 .../S_define | 0 test/SIM_trickified_archive/S_overrides.mk | 4 + .../models/Baz.hh | 0 .../trickified_project/include_bar/Bar.cpp | 9 + .../trickified_project/include_bar}/Bar.hh | 6 +- .../trickified_project/include_foo/Foo.cpp | 9 + .../trickified_project/include_foo}/Foo.hh | 4 +- .../trickified_project/trickified/.gitignore | 0 .../trickified_project/trickified/Makefile | 15 ++ .../trickified/myproject.mk | 14 ++ .../trickified/myproject_vars.mk} | 16 +- .../RUN_test/unit_test.py | 4 + test/SIM_trickified_object/S_define | 21 ++ test/SIM_trickified_object/S_overrides.mk | 4 + test/SIM_trickified_object/models/Baz.hh | 9 + .../trickified_project/include_bar/Bar.cpp | 9 + .../trickified_project/include_bar/Bar.hh | 17 ++ .../trickified_project/include_foo/Foo.cpp | 9 + .../trickified_project/include_foo/Foo.hh | 13 + .../trickified_project/trickified/.gitignore | 4 + .../trickified_project/trickified/Makefile | 15 ++ .../trickified/myproject.mk | 14 ++ .../trickified/myproject_vars.mk | 28 +++ .../RUN_test/unit_test.py | 4 + test/SIM_trickified_shared/S_define | 21 ++ test/SIM_trickified_shared/S_overrides.mk | 4 + test/SIM_trickified_shared/models/Baz.hh | 9 + .../trickified_project/include_bar/Bar.cpp | 9 + .../trickified_project/include_bar/Bar.hh | 17 ++ .../trickified_project/include_foo/Foo.cpp | 9 + .../trickified_project/include_foo/Foo.hh | 13 + .../trickified_project/trickified/.gitignore | 4 + .../trickified_project/trickified/Makefile | 15 ++ .../trickified/myproject.mk | 14 ++ .../trickified/myproject_vars.mk | 28 +++ test_sims.yml | 20 +- 47 files changed, 710 insertions(+), 43 deletions(-) create mode 100755 bin/trick-ify create mode 100644 share/trick/makefiles/build_trickify.py create mode 100644 share/trick/makefiles/build_trickify_S_source_hh.py create mode 100644 share/trick/makefiles/build_trickify_obj_list.py create mode 100644 share/trick/makefiles/build_trickify_src_list.py delete mode 100644 test/SIM_trickified/S_overrides.mk delete mode 100644 test/SIM_trickified/trickified_project/trickified/Makefile delete mode 100644 test/SIM_trickified/trickified_project/trickified/S_source.hh rename test/{SIM_trickified => SIM_trickified_archive}/RUN_test/unit_test.py (100%) rename test/{SIM_trickified => SIM_trickified_archive}/S_define (100%) create mode 100644 test/SIM_trickified_archive/S_overrides.mk rename test/{SIM_trickified => SIM_trickified_archive}/models/Baz.hh (100%) create mode 100644 test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp rename test/{SIM_trickified/trickified_project/include => SIM_trickified_archive/trickified_project/include_bar}/Bar.hh (87%) create mode 100644 test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp rename test/{SIM_trickified/trickified_project/include => SIM_trickified_archive/trickified_project/include_foo}/Foo.hh (61%) rename test/{SIM_trickified => SIM_trickified_archive}/trickified_project/trickified/.gitignore (100%) create mode 100644 test/SIM_trickified_archive/trickified_project/trickified/Makefile create mode 100644 test/SIM_trickified_archive/trickified_project/trickified/myproject.mk rename test/{SIM_trickified/trickified_project/trickified/myproject.mk => SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk} (59%) create mode 100644 test/SIM_trickified_object/RUN_test/unit_test.py create mode 100644 test/SIM_trickified_object/S_define create mode 100644 test/SIM_trickified_object/S_overrides.mk create mode 100644 test/SIM_trickified_object/models/Baz.hh create mode 100644 test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp create mode 100644 test/SIM_trickified_object/trickified_project/include_bar/Bar.hh create mode 100644 test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp create mode 100644 test/SIM_trickified_object/trickified_project/include_foo/Foo.hh create mode 100644 test/SIM_trickified_object/trickified_project/trickified/.gitignore create mode 100644 test/SIM_trickified_object/trickified_project/trickified/Makefile create mode 100644 test/SIM_trickified_object/trickified_project/trickified/myproject.mk create mode 100644 test/SIM_trickified_object/trickified_project/trickified/myproject_vars.mk create mode 100644 test/SIM_trickified_shared/RUN_test/unit_test.py create mode 100644 test/SIM_trickified_shared/S_define create mode 100644 test/SIM_trickified_shared/S_overrides.mk create mode 100644 test/SIM_trickified_shared/models/Baz.hh create mode 100644 test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp create mode 100644 test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh create mode 100644 test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp create mode 100644 test/SIM_trickified_shared/trickified_project/include_foo/Foo.hh create mode 100644 test/SIM_trickified_shared/trickified_project/trickified/.gitignore create mode 100644 test/SIM_trickified_shared/trickified_project/trickified/Makefile create mode 100644 test/SIM_trickified_shared/trickified_project/trickified/myproject.mk create mode 100644 test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk diff --git a/bin/trick-ify b/bin/trick-ify new file mode 100755 index 000000000..9e503fc32 --- /dev/null +++ b/bin/trick-ify @@ -0,0 +1,238 @@ +#!/usr/bin/perl + +$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_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 +$build_trickify_src_list = 1 ; # Whether to generate a trickify_src_list +$build_trickify_obj_list = 1 ; # Whether to generate a trickify_obj_list +$full_build = 1 ; # Whether to build only ICG/Swig artifacts or entire source +$name = "trickified" ; # Name of the library +$build_type = "o" ; # Type of library to be built (o, a , so) +$debug = 0 ; # Debug info flag +$trick_home = $my_path . ".." ; # Trick directory to use for building + +$skip_arg = 0 ; +foreach $argnum (0 .. $#ARGV) +{ + if($skip_arg) + { + $skip_arg = 0 ; + next ; + } + + $arg = $ARGV[$argnum] ; + if($arg eq "-d") # Set both source and header directory + { + $source_dir = $ARGV[$argnum + 1] ; + $header_dir = $source_dir ; + $skip_arg = 1 ; + } + elsif($arg eq "-s") # Set source directory + { + $source_dir = $ARGV[$argnum + 1] ; + $skip_arg = 1 ; + } + elsif($arg eq "-h") # Set header directory + { + $header_dir = $ARGV[$argnum + 1] ; + $skip_arg = 1 ; + } + elsif($arg eq "-ph") # Preserve S_source.hh + { + $build_s_source = 0 ; + } + elsif($arg eq "-ps") # Preserve trickify_src_list + { + $build_trickify_src_list = 0 ; + } + elsif($arg eq "-po") # Preserve trickify_obj_list + { + $build_trickify_obj_list = 0 ; + } + elsif($arg eq "-t") # Build trick artifacts only + { + $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 "-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] ; + $skip_arg = 1 ; + } + elsif($arg eq "-tp") # Set trickify make path + { + $trickify_make_path = $ARGV[$argnum + 1] ; + $skip_arg = 1 ; + } + elsif($arg eq "-n") # Set the library name + { + $name = $ARGV[$argnum + 1] ; + $skip_arg = 1 ; + } + elsif($arg eq "-b") # Set library build type + { + $val = $ARGV[$argnum + 1] ; + if( ($val eq "o") or ($val eq "a") or ($val eq "so") ) + { + $build_type = $ARGV[$argnum + 1] ; + } + else + { + print "Invalid build type {$val}, valid build types are {o, a, so}\n" ; + exit 1 ; + } + $skip_arg = 1 ; + } + elsif($arg eq "-v") # Verbose, print debug info + { + $debug = 1 ; + } + elsif($arg eq "-th") # Set trick home directory + { + $trick_home = $ARGV[$argnum + 1] ; + $skip_arg = 1 ; + } + else + { + print "Unrecognized argument: $arg\n" ; + exit 1 ; + } +} + +if($header_dir eq "") +{ + print "Must set a header directory\n" ; + exit 1 ; +} + +if($source_dir eq "" and $full_build) +{ + print "Must set a source directory\n" ; + exit 1 ; +} + +#Set Environment Variables +if ($full_build) +{ + $ENV{'FULL_TRICKIFY_BUILD'} = "1" ; +} +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" ; +if ( $build_type eq o ) +{ + $ENV{'TRICKIFY_BUILD_TYPE'} = PLO ; +} +elsif ( $build_type eq a ) +{ + $ENV{'TRICKIFY_BUILD_TYPE'} = STATIC ; +} +elsif ( $build_type eq so ) +{ + $ENV{'TRICKIFY_BUILD_TYPE'} = SHARED ; +} + +#Build the S_source.hh +if ($build_s_source) +{ + print "Building S_source.hh\n" ; + $make_s_source = "python3 $my_path../share/trick/makefiles/build_trickify_S_source_hh.py" ; + print(`$make_s_source`) ; +} + +#Build source file list, only if trickifying the entire library +if ($build_trickify_src_list and $full_build) +{ + print "Building trickify_src_list\n" ; + $make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ; + print(`$make_src_list`) ; +} + +#Build array of source files +if ($full_build) +{ + open ($fh, "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) ; +} + +#Build object files from source file list +if ($full_build) +{ + print "Building object files\n" ; + if($source_make_call eq "") + { + foreach $src (@src_files) + { + $file = $src ; + $file =~ s/\Q.cpp\E$// ; + $file =~ s/\Q.c$\E$// ; + $cmd = "g++ $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ; + if($debug) + { + print "Building obj file: $cmd\n" ; + } + print(`$cmd`) ; + } + } + else + { + print(`$source_make_call`) ; + } +} + +#Build object file list, only if trickifying the entire library +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`) ; +} + +#Build trickify call +print "Begin Trickification...\n" ; +$trickify_make_call = "make $trickify_make_args -f $trickify_make_path" ; +print(`$trickify_make_call`) ; + +if($debug) { + print + "TRICKIFY BUILD INFO: + header_dir = $header_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 + full_build = $full_build + name = $name + build_type = $build_type + trick_home = $trick_home\n" ; +} diff --git a/share/trick/makefiles/build_trickify.py b/share/trick/makefiles/build_trickify.py new file mode 100644 index 000000000..897b5932c --- /dev/null +++ b/share/trick/makefiles/build_trickify.py @@ -0,0 +1,51 @@ +from pathlib import Path +import os + +def_header_ext = ["h", "hh", "hpp", "H", "hxx", "h++"] +def_src_ext = ["cpp", "c"] + +def find_files_by_extension(loc, ext): + path = Path(loc) + files = list(path.rglob(f'*.{ext}')) + return files + +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 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") + dirs = loc.split() + + 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") + dirs = loc.split() + + 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') diff --git a/share/trick/makefiles/build_trickify_S_source_hh.py b/share/trick/makefiles/build_trickify_S_source_hh.py new file mode 100644 index 000000000..92242d433 --- /dev/null +++ b/share/trick/makefiles/build_trickify_S_source_hh.py @@ -0,0 +1,10 @@ +import os + +path = "" +if "TRICK_HOME" in os.environ: + path = os.getenv("TRICK_HOME") +path += "/share/trick/makefiles/build_trickify.py" + +exec(open(path).read()) + +build_S_source() diff --git a/share/trick/makefiles/build_trickify_obj_list.py b/share/trick/makefiles/build_trickify_obj_list.py new file mode 100644 index 000000000..0fa24786b --- /dev/null +++ b/share/trick/makefiles/build_trickify_obj_list.py @@ -0,0 +1,10 @@ +import os + +path = "" +if "TRICK_HOME" in os.environ: + path = os.getenv("TRICK_HOME") +path += "/share/trick/makefiles/build_trickify.py" + +exec(open(path).read()) + +build_obj_list() diff --git a/share/trick/makefiles/build_trickify_src_list.py b/share/trick/makefiles/build_trickify_src_list.py new file mode 100644 index 000000000..164733d65 --- /dev/null +++ b/share/trick/makefiles/build_trickify_src_list.py @@ -0,0 +1,10 @@ +import os + +path = "" +if "TRICK_HOME" in os.environ: + path = os.getenv("TRICK_HOME") +path += "/share/trick/makefiles/build_trickify.py" + +exec(open(path).read()) + +build_src_list() diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 68aa90e87..74c9fdcbe 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -50,6 +50,8 @@ # The file into which generated Python modules are zipped. The default # value is python (in the current directory). # +# TRICKIFY_SOURCE +# # ----------------------------------------------------------------------------- # # EXAMPLE: @@ -105,17 +107,22 @@ include $(dir $(lastword $(MAKEFILE_LIST)))Makefile.common BUILD_DIR := $(dir $(MAKE_OUT)) PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list -LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) +OBJ_LINK_LIST := trickify_obj_list +ifdef FULL_TRICKIFY_BUILD + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) +else + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) +endif ifneq ($(wildcard $(BUILD_DIR)),) - SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) - IO_OBJECTS := $(shell cat $(IO_LINK_LIST)) + SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) + IO_OBJECTS := $(shell cat $(IO_LINK_LIST)) endif TRICK_CFLAGS += $(TRICKIFY_CXX_FLAGS) TRICK_CXXFLAGS += $(TRICKIFY_CXX_FLAGS) # Ensure we can process all headers -TRICK_EXT_LIB_DIRS := $(TRICKIFY_EXT_LIB_DIRS) +TRICK_EXT_LIB_DIRS := .PHONY: all all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) diff --git a/test/Makefile b/test/Makefile index f60dd2730..5f15e1e60 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,8 +6,19 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common SIM_DIRECTORIES = $(wildcard SIM_*) UNIT_TEST_RESULTS = $(addprefix $(TRICK_HOME)/trick_test/, $(addsuffix .xml, $(SIM_DIRECTORIES))) +# The auto-generated makefile for each test does not know to call other makefiles the user may have included. +# User generated clean calls must be directly called here +# Otherwise build artifacts may not be cleaned and give misleading test results +clean_trickify: + for i in $(SIM_DIRECTORIES) ; do \ + if [ -f "$$i/trickified_project/trickified/"[Mm]"akefile" ] ; then \ + $(MAKE) -C $$i/trickified_project/trickified/ clean ; \ + elif [ -f "$$i/models/trickified/"[Mm]"akefile" ] ; then \ + $(MAKE) -C $$i/models/trickified/ clean ; \ + fi \ + done -clean: +clean: clean_trickify rm -f $(UNIT_TEST_RESULTS) - for i in $(SIM_DIRECTORIES) ; do \ if [ -f "$$i/"[Mm]"akefile" ] ; then \ diff --git a/test/SIM_trickified/S_overrides.mk b/test/SIM_trickified/S_overrides.mk deleted file mode 100644 index ad3448327..000000000 --- a/test/SIM_trickified/S_overrides.mk +++ /dev/null @@ -1,2 +0,0 @@ -include trickified_project/trickified/myproject.mk -TRICK_CXXFLAGS += -I$(CURDIR)/models diff --git a/test/SIM_trickified/trickified_project/trickified/Makefile b/test/SIM_trickified/trickified_project/trickified/Makefile deleted file mode 100644 index ae6eb3103..000000000 --- a/test/SIM_trickified/trickified_project/trickified/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -PROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) -TRICK_HOME := $(abspath $(PROJECT_HOME)/../../..) - -export TRICKIFY_OBJECT_NAME := trickified_myproject.o -export TRICKIFY_CXX_FLAGS := -I$(PROJECT_HOME)/include -I$(TRICK_HOME)/include - -all: - @$(MAKE) -s -f $(TRICK_HOME)/share/trick/makefiles/trickify.mk - -clean: - @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified/trickified_project/trickified/S_source.hh b/test/SIM_trickified/trickified_project/trickified/S_source.hh deleted file mode 100644 index a6dab172f..000000000 --- a/test/SIM_trickified/trickified_project/trickified/S_source.hh +++ /dev/null @@ -1,2 +0,0 @@ -#include "Foo.hh" -#include "Bar.hh" diff --git a/test/SIM_trickified/RUN_test/unit_test.py b/test/SIM_trickified_archive/RUN_test/unit_test.py similarity index 100% rename from test/SIM_trickified/RUN_test/unit_test.py rename to test/SIM_trickified_archive/RUN_test/unit_test.py diff --git a/test/SIM_trickified/S_define b/test/SIM_trickified_archive/S_define similarity index 100% rename from test/SIM_trickified/S_define rename to test/SIM_trickified_archive/S_define diff --git a/test/SIM_trickified_archive/S_overrides.mk b/test/SIM_trickified_archive/S_overrides.mk new file mode 100644 index 000000000..e17d8690e --- /dev/null +++ b/test/SIM_trickified_archive/S_overrides.mk @@ -0,0 +1,4 @@ +LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +TRICK_CXXFLAGS += -I$(LOCAL_DIR)/models +include $(CURDIR)/trickified_project/trickified/myproject.mk diff --git a/test/SIM_trickified/models/Baz.hh b/test/SIM_trickified_archive/models/Baz.hh similarity index 100% rename from test/SIM_trickified/models/Baz.hh rename to test/SIM_trickified_archive/models/Baz.hh diff --git a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp new file mode 100644 index 000000000..55a07a844 --- /dev/null +++ b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +#include "Bar.hh" + + +void Bar::add() {} +void Bar::remove() {} +void Bar::restart() {} + diff --git a/test/SIM_trickified/trickified_project/include/Bar.hh b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh similarity index 87% rename from test/SIM_trickified/trickified_project/include/Bar.hh rename to test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh index 5640bfb02..5c4972624 100644 --- a/test/SIM_trickified/trickified_project/include/Bar.hh +++ b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh @@ -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(); }; diff --git a/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp b/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp new file mode 100644 index 000000000..f8c4fe602 --- /dev/null +++ b/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +#include "Foo.hh" + + + +void Foo::foo() { + std::cout << i++ << '\n'; +} diff --git a/test/SIM_trickified/trickified_project/include/Foo.hh b/test/SIM_trickified_archive/trickified_project/include_foo/Foo.hh similarity index 61% rename from test/SIM_trickified/trickified_project/include/Foo.hh rename to test/SIM_trickified_archive/trickified_project/include_foo/Foo.hh index be7e761a2..a29d07194 100644 --- a/test/SIM_trickified/trickified_project/include/Foo.hh +++ b/test/SIM_trickified_archive/trickified_project/include_foo/Foo.hh @@ -8,8 +8,6 @@ class Foo { int i; - void foo() { - std::cout << i++ << '\n'; - } + void foo(); }; diff --git a/test/SIM_trickified/trickified_project/trickified/.gitignore b/test/SIM_trickified_archive/trickified_project/trickified/.gitignore similarity index 100% rename from test/SIM_trickified/trickified_project/trickified/.gitignore rename to test/SIM_trickified_archive/trickified_project/trickified/.gitignore diff --git a/test/SIM_trickified_archive/trickified_project/trickified/Makefile b/test/SIM_trickified_archive/trickified_project/trickified/Makefile new file mode 100644 index 000000000..4cf635735 --- /dev/null +++ b/test/SIM_trickified_archive/trickified_project/trickified/Makefile @@ -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 diff --git a/test/SIM_trickified_archive/trickified_project/trickified/myproject.mk b/test/SIM_trickified_archive/trickified_project/trickified/myproject.mk new file mode 100644 index 000000000..f2f61e8f9 --- /dev/null +++ b/test/SIM_trickified_archive/trickified_project/trickified/myproject.mk @@ -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 diff --git a/test/SIM_trickified/trickified_project/trickified/myproject.mk b/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk similarity index 59% rename from test/SIM_trickified/trickified_project/trickified/myproject.mk rename to test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk index 7abe9af1e..4454d8a71 100644 --- a/test/SIM_trickified/trickified_project/trickified/myproject.mk +++ b/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk @@ -4,14 +4,15 @@ export MYPROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) # Specify include paths for your headers. -MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include +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) -MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/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 # Trickified project @@ -25,14 +26,3 @@ TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified # Link in the Trickified object TRICK_LDFLAGS += $(MYPROJECT_TRICK) - -# 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 diff --git a/test/SIM_trickified_object/RUN_test/unit_test.py b/test/SIM_trickified_object/RUN_test/unit_test.py new file mode 100644 index 000000000..f74fee0bf --- /dev/null +++ b/test/SIM_trickified_object/RUN_test/unit_test.py @@ -0,0 +1,4 @@ +sandbox.foo.i = 5 +assert sandbox.foo.i == 5 +foo = trick.Foo() +trick.stop(10) diff --git a/test/SIM_trickified_object/S_define b/test/SIM_trickified_object/S_define new file mode 100644 index 000000000..f770e2a73 --- /dev/null +++ b/test/SIM_trickified_object/S_define @@ -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; diff --git a/test/SIM_trickified_object/S_overrides.mk b/test/SIM_trickified_object/S_overrides.mk new file mode 100644 index 000000000..e17d8690e --- /dev/null +++ b/test/SIM_trickified_object/S_overrides.mk @@ -0,0 +1,4 @@ +LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +TRICK_CXXFLAGS += -I$(LOCAL_DIR)/models +include $(CURDIR)/trickified_project/trickified/myproject.mk diff --git a/test/SIM_trickified_object/models/Baz.hh b/test/SIM_trickified_object/models/Baz.hh new file mode 100644 index 000000000..fc91c1b21 --- /dev/null +++ b/test/SIM_trickified_object/models/Baz.hh @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +class Baz { + + public: + int i; + int j; + +}; diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp new file mode 100644 index 000000000..55a07a844 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +#include "Bar.hh" + + +void Bar::add() {} +void Bar::remove() {} +void Bar::restart() {} + diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.hh b/test/SIM_trickified_object/trickified_project/include_bar/Bar.hh new file mode 100644 index 000000000..5c4972624 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/include_bar/Bar.hh @@ -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(); + +}; diff --git a/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp b/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp new file mode 100644 index 000000000..f8c4fe602 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +#include "Foo.hh" + + + +void Foo::foo() { + std::cout << i++ << '\n'; +} diff --git a/test/SIM_trickified_object/trickified_project/include_foo/Foo.hh b/test/SIM_trickified_object/trickified_project/include_foo/Foo.hh new file mode 100644 index 000000000..a29d07194 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/include_foo/Foo.hh @@ -0,0 +1,13 @@ +// @trick_parse{everything} + +#include <iostream> + +class Foo { + + public: + + int i; + + void foo(); + +}; diff --git a/test/SIM_trickified_object/trickified_project/trickified/.gitignore b/test/SIM_trickified_object/trickified_project/trickified/.gitignore new file mode 100644 index 000000000..0259157ce --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/trickified/.gitignore @@ -0,0 +1,4 @@ +build +python +trick +*.o diff --git a/test/SIM_trickified_object/trickified_project/trickified/Makefile b/test/SIM_trickified_object/trickified_project/trickified/Makefile new file mode 100644 index 000000000..f087848ed --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/trickified/Makefile @@ -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 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 S_source.hh + @rm -rf ../include_foo/*.o + @rm -rf ../include_bar/*.o diff --git a/test/SIM_trickified_object/trickified_project/trickified/myproject.mk b/test/SIM_trickified_object/trickified_project/trickified/myproject.mk new file mode 100644 index 000000000..f2f61e8f9 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/trickified/myproject.mk @@ -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 diff --git a/test/SIM_trickified_object/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_object/trickified_project/trickified/myproject_vars.mk new file mode 100644 index 000000000..3f5624226 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/trickified/myproject_vars.mk @@ -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.o +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) diff --git a/test/SIM_trickified_shared/RUN_test/unit_test.py b/test/SIM_trickified_shared/RUN_test/unit_test.py new file mode 100644 index 000000000..f74fee0bf --- /dev/null +++ b/test/SIM_trickified_shared/RUN_test/unit_test.py @@ -0,0 +1,4 @@ +sandbox.foo.i = 5 +assert sandbox.foo.i == 5 +foo = trick.Foo() +trick.stop(10) diff --git a/test/SIM_trickified_shared/S_define b/test/SIM_trickified_shared/S_define new file mode 100644 index 000000000..f770e2a73 --- /dev/null +++ b/test/SIM_trickified_shared/S_define @@ -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; diff --git a/test/SIM_trickified_shared/S_overrides.mk b/test/SIM_trickified_shared/S_overrides.mk new file mode 100644 index 000000000..e17d8690e --- /dev/null +++ b/test/SIM_trickified_shared/S_overrides.mk @@ -0,0 +1,4 @@ +LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +TRICK_CXXFLAGS += -I$(LOCAL_DIR)/models +include $(CURDIR)/trickified_project/trickified/myproject.mk diff --git a/test/SIM_trickified_shared/models/Baz.hh b/test/SIM_trickified_shared/models/Baz.hh new file mode 100644 index 000000000..fc91c1b21 --- /dev/null +++ b/test/SIM_trickified_shared/models/Baz.hh @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +class Baz { + + public: + int i; + int j; + +}; diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp new file mode 100644 index 000000000..55a07a844 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +#include "Bar.hh" + + +void Bar::add() {} +void Bar::remove() {} +void Bar::restart() {} + diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh new file mode 100644 index 000000000..5c4972624 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh @@ -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(); + +}; diff --git a/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp b/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp new file mode 100644 index 000000000..f8c4fe602 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +#include "Foo.hh" + + + +void Foo::foo() { + std::cout << i++ << '\n'; +} diff --git a/test/SIM_trickified_shared/trickified_project/include_foo/Foo.hh b/test/SIM_trickified_shared/trickified_project/include_foo/Foo.hh new file mode 100644 index 000000000..a29d07194 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/include_foo/Foo.hh @@ -0,0 +1,13 @@ +// @trick_parse{everything} + +#include <iostream> + +class Foo { + + public: + + int i; + + void foo(); + +}; diff --git a/test/SIM_trickified_shared/trickified_project/trickified/.gitignore b/test/SIM_trickified_shared/trickified_project/trickified/.gitignore new file mode 100644 index 000000000..0259157ce --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/trickified/.gitignore @@ -0,0 +1,4 @@ +build +python +trick +*.o diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile new file mode 100644 index 000000000..f40134411 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -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 diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject.mk new file mode 100644 index 000000000..f2f61e8f9 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject.mk @@ -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 diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk new file mode 100644 index 000000000..8f3a556b0 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -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) diff --git a/test_sims.yml b/test_sims.yml index a6f56dea9..cefeeceac 100644 --- a/test_sims.yml +++ b/test_sims.yml @@ -21,8 +21,6 @@ SIM_parse_s_define: path: test/SIM_parse_s_define SIM_target_specific_variables: path: test/SIM_target_specific_variables -SIM_swig_template_scoping: - path: test/SIM_swig_template_scoping SIM_test_abstract: path: test/SIM_test_abstract SIM_test_inherit: @@ -114,8 +112,22 @@ SIM_threads: runs: RUN_test/unit_test.py: returns: 0 -SIM_trickified: - path: test/SIM_trickified +SIM_trickified_object: + path: test/SIM_trickified_object + build_args: "-t" + binary: "T_main_{cpu}_test.exe" + runs: + RUN_test/unit_test.py: + returns: 0 +SIM_trickified_archive: + path: test/SIM_trickified_archive + build_args: "-t" + binary: "T_main_{cpu}_test.exe" + runs: + RUN_test/unit_test.py: + returns: 0 +SIM_trickified_shared: + path: test/SIM_trickified_shared build_args: "-t" binary: "T_main_{cpu}_test.exe" runs: From ba693dc6426141bbdf69887d9066a977f708ba16 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 25 Nov 2024 13:46:03 -0600 Subject: [PATCH 02/40] Cleaning up code --- bin/trick-ify | 2 +- share/trick/makefiles/trickify.mk | 4 +--- test/Makefile | 6 +++--- .../trickified_project/include_bar/Bar.cpp | 2 -- .../trickified_project/include_foo/Foo.cpp | 2 -- .../trickified_project/include_bar/Bar.cpp | 2 -- .../trickified_project/include_foo/Foo.cpp | 2 -- .../trickified_project/include_bar/Bar.cpp | 2 -- .../trickified_project/include_foo/Foo.cpp | 2 -- test_sims.yml | 2 ++ 10 files changed, 7 insertions(+), 19 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index 9e503fc32..039c18d92 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -3,7 +3,7 @@ $my_path = $0 ; $my_path =~ s/trick-ify// ; -$source_dir = "" ; # Base path to build header from +$source_dir = "" ; # Base path to build source 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 diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 74c9fdcbe..a0de4be6d 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -50,8 +50,6 @@ # The file into which generated Python modules are zipped. The default # value is python (in the current directory). # -# TRICKIFY_SOURCE -# # ----------------------------------------------------------------------------- # # EXAMPLE: @@ -122,7 +120,7 @@ TRICK_CFLAGS += $(TRICKIFY_CXX_FLAGS) TRICK_CXXFLAGS += $(TRICKIFY_CXX_FLAGS) # Ensure we can process all headers -TRICK_EXT_LIB_DIRS := +TRICK_EXT_LIB_DIRS := $(TRICKIFY_EXT_LIB_DIRS) .PHONY: all all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) diff --git a/test/Makefile b/test/Makefile index 5f15e1e60..da0b999fd 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,9 +6,9 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common SIM_DIRECTORIES = $(wildcard SIM_*) UNIT_TEST_RESULTS = $(addprefix $(TRICK_HOME)/trick_test/, $(addsuffix .xml, $(SIM_DIRECTORIES))) -# The auto-generated makefile for each test does not know to call other makefiles the user may have included. -# User generated clean calls must be directly called here -# Otherwise build artifacts may not be cleaned and give misleading test results +# The auto-generated makefile for each test does not know to call other makefiles the developer may have included. +# Developer generated clean calls must be directly called here, +# Otherwise build artifacts may not be cleaned and give misleading test results. clean_trickify: for i in $(SIM_DIRECTORIES) ; do \ if [ -f "$$i/trickified_project/trickified/"[Mm]"akefile" ] ; then \ diff --git a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp index 55a07a844..b46af6616 100644 --- a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp +++ b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp @@ -1,5 +1,3 @@ -// @trick_parse{everything} - #include "Bar.hh" diff --git a/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp b/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp index f8c4fe602..115138369 100644 --- a/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp +++ b/test/SIM_trickified_archive/trickified_project/include_foo/Foo.cpp @@ -1,5 +1,3 @@ -// @trick_parse{everything} - #include "Foo.hh" diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp index 55a07a844..b46af6616 100644 --- a/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp +++ b/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp @@ -1,5 +1,3 @@ -// @trick_parse{everything} - #include "Bar.hh" diff --git a/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp b/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp index f8c4fe602..115138369 100644 --- a/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp +++ b/test/SIM_trickified_object/trickified_project/include_foo/Foo.cpp @@ -1,5 +1,3 @@ -// @trick_parse{everything} - #include "Foo.hh" diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp index 55a07a844..b46af6616 100644 --- a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp +++ b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp @@ -1,5 +1,3 @@ -// @trick_parse{everything} - #include "Bar.hh" diff --git a/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp b/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp index f8c4fe602..115138369 100644 --- a/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp +++ b/test/SIM_trickified_shared/trickified_project/include_foo/Foo.cpp @@ -1,5 +1,3 @@ -// @trick_parse{everything} - #include "Foo.hh" diff --git a/test_sims.yml b/test_sims.yml index cefeeceac..d0ec3077d 100644 --- a/test_sims.yml +++ b/test_sims.yml @@ -21,6 +21,8 @@ SIM_parse_s_define: path: test/SIM_parse_s_define SIM_target_specific_variables: path: test/SIM_target_specific_variables +SIM_swig_template_scoping: + path: test/SIM_swig_template_scoping SIM_test_abstract: path: test/SIM_test_abstract SIM_test_inherit: From 1e7f5db6390ad31cd3cb1371893b8942a37ddd84 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 25 Nov 2024 14:31:01 -0600 Subject: [PATCH 03/40] CI Fix --- .../trickified_project/trickified/Makefile | 3 ++- .../trickified_project/trickified/Makefile | 3 ++- .../trickified_project/trickified/Makefile | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/SIM_trickified_archive/trickified_project/trickified/Makefile b/test/SIM_trickified_archive/trickified_project/trickified/Makefile index 4cf635735..d7f088015 100644 --- a/test/SIM_trickified_archive/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_archive/trickified_project/trickified/Makefile @@ -1,9 +1,10 @@ LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +TRICK_HOME := $(abspath $(LOCAL_DIR)/../../../..) 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 + @$(TRICK_HOME)/bin/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) diff --git a/test/SIM_trickified_object/trickified_project/trickified/Makefile b/test/SIM_trickified_object/trickified_project/trickified/Makefile index f087848ed..5a1c7c56d 100644 --- a/test/SIM_trickified_object/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_object/trickified_project/trickified/Makefile @@ -1,9 +1,10 @@ LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +TRICK_HOME := $(abspath $(LOCAL_DIR)/../../../..) 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 o -n trickified_myproject -v + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b o -n trickified_myproject -v clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index f40134411..227112b17 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -1,9 +1,10 @@ LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +TRICK_HOME := $(abspath $(LOCAL_DIR)/../../../..) 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" + @$(TRICK_HOME)/bin/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) From 377e8c8647d6e44d59513e52a5ed175942b08717 Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Tue, 26 Nov 2024 12:23:10 -0600 Subject: [PATCH 04/40] Shared library test fix --- .../trickified_project/trickified/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index 227112b17..95d9d2500 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v -ma "-fPIC" + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v -ma "-fPIC -fvisibility=default" clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) From d290eebdd6e879abfcb1faf18113b7b8886a8ac8 Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Tue, 26 Nov 2024 15:00:06 -0600 Subject: [PATCH 05/40] CI Fix --- .../trickified_project/trickified/Makefile | 2 +- .../trickified_project/trickified/myproject_vars.mk | 2 +- .../trickified_project/trickified/Makefile | 2 +- .../trickified_project/trickified/myproject_vars.mk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/SIM_trickified_archive/trickified_project/trickified/Makefile b/test/SIM_trickified_archive/trickified_project/trickified/Makefile index d7f088015..5a1c7c56d 100644 --- a/test/SIM_trickified_archive/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_archive/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b a -n trickified_myproject -v + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b o -n trickified_myproject -v clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk index 4454d8a71..3f5624226 100644 --- a/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk @@ -11,7 +11,7 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -export TRICKIFY_OBJECT_NAME := trickified_myproject.a +export TRICKIFY_OBJECT_NAME := trickified_myproject.o MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME) # Tell Trick the headers and source at this location are part of a diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index 95d9d2500..e5341c6e4 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v -ma "-fPIC -fvisibility=default" + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b o -n trickified_myproject -v -ma "-fPIC -fvisibility=default" clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk index 8f3a556b0..3f5624226 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -11,7 +11,7 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -export TRICKIFY_OBJECT_NAME := trickified_myproject.so +export TRICKIFY_OBJECT_NAME := trickified_myproject.o MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME) # Tell Trick the headers and source at this location are part of a From 8afa83a60eb6edddcbdd353c1c59b6c3ed6e4527 Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Tue, 26 Nov 2024 15:44:16 -0600 Subject: [PATCH 06/40] CI Fix --- .../trickified_project/trickified/Makefile | 2 +- .../trickified_project/trickified/myproject_vars.mk | 2 +- .../trickified_project/trickified/Makefile | 2 +- .../trickified_project/trickified/myproject_vars.mk | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/SIM_trickified_archive/trickified_project/trickified/Makefile b/test/SIM_trickified_archive/trickified_project/trickified/Makefile index 5a1c7c56d..d7f088015 100644 --- a/test/SIM_trickified_archive/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_archive/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b o -n trickified_myproject -v + @$(TRICK_HOME)/bin/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) diff --git a/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk index 3f5624226..4454d8a71 100644 --- a/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_archive/trickified_project/trickified/myproject_vars.mk @@ -11,7 +11,7 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -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 diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index e5341c6e4..95d9d2500 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b o -n trickified_myproject -v -ma "-fPIC -fvisibility=default" + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v -ma "-fPIC -fvisibility=default" clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk index 3f5624226..8f3a556b0 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -11,7 +11,7 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -export TRICKIFY_OBJECT_NAME := trickified_myproject.o +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 From 973a473c0ea135c0bf922e2c0fb0f80877d7091a Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Tue, 26 Nov 2024 17:18:58 -0600 Subject: [PATCH 07/40] Added old trickify test --- test/SIM_trickified/RUN_test/unit_test.py | 4 ++ test/SIM_trickified/S_define | 21 ++++++++++ test/SIM_trickified/S_overrides.mk | 2 + test/SIM_trickified/models/Baz.hh | 9 +++++ .../trickified_project/include/Bar.hh | 17 +++++++++ .../trickified_project/include/Foo.hh | 15 ++++++++ .../trickified_project/trickified/.gitignore | 4 ++ .../trickified_project/trickified/Makefile | 11 ++++++ .../trickified/myproject.mk | 38 +++++++++++++++++++ test_sims.yml | 7 ++++ 10 files changed, 128 insertions(+) create mode 100644 test/SIM_trickified/RUN_test/unit_test.py create mode 100644 test/SIM_trickified/S_define create mode 100644 test/SIM_trickified/S_overrides.mk create mode 100644 test/SIM_trickified/models/Baz.hh create mode 100644 test/SIM_trickified/trickified_project/include/Bar.hh create mode 100644 test/SIM_trickified/trickified_project/include/Foo.hh create mode 100644 test/SIM_trickified/trickified_project/trickified/.gitignore create mode 100644 test/SIM_trickified/trickified_project/trickified/Makefile create mode 100644 test/SIM_trickified/trickified_project/trickified/myproject.mk diff --git a/test/SIM_trickified/RUN_test/unit_test.py b/test/SIM_trickified/RUN_test/unit_test.py new file mode 100644 index 000000000..f74fee0bf --- /dev/null +++ b/test/SIM_trickified/RUN_test/unit_test.py @@ -0,0 +1,4 @@ +sandbox.foo.i = 5 +assert sandbox.foo.i == 5 +foo = trick.Foo() +trick.stop(10) diff --git a/test/SIM_trickified/S_define b/test/SIM_trickified/S_define new file mode 100644 index 000000000..f770e2a73 --- /dev/null +++ b/test/SIM_trickified/S_define @@ -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; diff --git a/test/SIM_trickified/S_overrides.mk b/test/SIM_trickified/S_overrides.mk new file mode 100644 index 000000000..ad3448327 --- /dev/null +++ b/test/SIM_trickified/S_overrides.mk @@ -0,0 +1,2 @@ +include trickified_project/trickified/myproject.mk +TRICK_CXXFLAGS += -I$(CURDIR)/models diff --git a/test/SIM_trickified/models/Baz.hh b/test/SIM_trickified/models/Baz.hh new file mode 100644 index 000000000..fc91c1b21 --- /dev/null +++ b/test/SIM_trickified/models/Baz.hh @@ -0,0 +1,9 @@ +// @trick_parse{everything} + +class Baz { + + public: + int i; + int j; + +}; diff --git a/test/SIM_trickified/trickified_project/include/Bar.hh b/test/SIM_trickified/trickified_project/include/Bar.hh new file mode 100644 index 000000000..5640bfb02 --- /dev/null +++ b/test/SIM_trickified/trickified_project/include/Bar.hh @@ -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() {} + +}; diff --git a/test/SIM_trickified/trickified_project/include/Foo.hh b/test/SIM_trickified/trickified_project/include/Foo.hh new file mode 100644 index 000000000..be7e761a2 --- /dev/null +++ b/test/SIM_trickified/trickified_project/include/Foo.hh @@ -0,0 +1,15 @@ +// @trick_parse{everything} + +#include <iostream> + +class Foo { + + public: + + int i; + + void foo() { + std::cout << i++ << '\n'; + } + +}; diff --git a/test/SIM_trickified/trickified_project/trickified/.gitignore b/test/SIM_trickified/trickified_project/trickified/.gitignore new file mode 100644 index 000000000..0259157ce --- /dev/null +++ b/test/SIM_trickified/trickified_project/trickified/.gitignore @@ -0,0 +1,4 @@ +build +python +trick +*.o diff --git a/test/SIM_trickified/trickified_project/trickified/Makefile b/test/SIM_trickified/trickified_project/trickified/Makefile new file mode 100644 index 000000000..ae6eb3103 --- /dev/null +++ b/test/SIM_trickified/trickified_project/trickified/Makefile @@ -0,0 +1,11 @@ +PROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) +TRICK_HOME := $(abspath $(PROJECT_HOME)/../../..) + +export TRICKIFY_OBJECT_NAME := trickified_myproject.o +export TRICKIFY_CXX_FLAGS := -I$(PROJECT_HOME)/include -I$(TRICK_HOME)/include + +all: + @$(MAKE) -s -f $(TRICK_HOME)/share/trick/makefiles/trickify.mk + +clean: + @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified/trickified_project/trickified/myproject.mk b/test/SIM_trickified/trickified_project/trickified/myproject.mk new file mode 100644 index 000000000..7abe9af1e --- /dev/null +++ b/test/SIM_trickified/trickified_project/trickified/myproject.mk @@ -0,0 +1,38 @@ +# 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 + +# 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) + +MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.o + +# 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) + +# 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 diff --git a/test_sims.yml b/test_sims.yml index d0ec3077d..e30d9cf5c 100644 --- a/test_sims.yml +++ b/test_sims.yml @@ -114,6 +114,13 @@ SIM_threads: runs: RUN_test/unit_test.py: returns: 0 +SIM_trickified: + path: test/SIM_trickified + build_args: "-t" + binary: "T_main_{cpu}_test.exe" + runs: + RUN_test/unit_test.py: + returns: 0 SIM_trickified_object: path: test/SIM_trickified_object build_args: "-t" From f285e2a1fa41b0d1ff7f34ed70ca2d6d971e7417 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 2 Dec 2024 10:10:57 -0600 Subject: [PATCH 08/40] Added S_source.hh --- test/SIM_trickified/trickified_project/trickified/S_source.hh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test/SIM_trickified/trickified_project/trickified/S_source.hh diff --git a/test/SIM_trickified/trickified_project/trickified/S_source.hh b/test/SIM_trickified/trickified_project/trickified/S_source.hh new file mode 100644 index 000000000..a6dab172f --- /dev/null +++ b/test/SIM_trickified/trickified_project/trickified/S_source.hh @@ -0,0 +1,2 @@ +#include "Foo.hh" +#include "Bar.hh" From df19738cad7b94b129e62049ca66fca98c7630eb Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 2 Dec 2024 12:29:08 -0600 Subject: [PATCH 09/40] Changed old trickified test to generate an archive --- test/SIM_trickified/trickified_project/trickified/Makefile | 3 ++- test/SIM_trickified/trickified_project/trickified/myproject.mk | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/SIM_trickified/trickified_project/trickified/Makefile b/test/SIM_trickified/trickified_project/trickified/Makefile index ae6eb3103..459c4c0ca 100644 --- a/test/SIM_trickified/trickified_project/trickified/Makefile +++ b/test/SIM_trickified/trickified_project/trickified/Makefile @@ -1,7 +1,8 @@ PROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) TRICK_HOME := $(abspath $(PROJECT_HOME)/../../..) -export TRICKIFY_OBJECT_NAME := trickified_myproject.o +export TRICKIFY_BUILD_TYPE := STATIC +export TRICKIFY_OBJECT_NAME := trickified_myproject.a export TRICKIFY_CXX_FLAGS := -I$(PROJECT_HOME)/include -I$(TRICK_HOME)/include all: diff --git a/test/SIM_trickified/trickified_project/trickified/myproject.mk b/test/SIM_trickified/trickified_project/trickified/myproject.mk index 7abe9af1e..f08a541ca 100644 --- a/test/SIM_trickified/trickified_project/trickified/myproject.mk +++ b/test/SIM_trickified/trickified_project/trickified/myproject.mk @@ -11,7 +11,7 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.o +MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.a # Tell Trick the headers and source at this location are part of a # Trickified project From 59605006305d7122989a72985b8a598115f11a43 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 2 Dec 2024 13:43:48 -0600 Subject: [PATCH 10/40] Added support for archive trickify builds on mac --- share/trick/makefiles/trickify.mk | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index a0de4be6d..50349c29f 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -122,6 +122,15 @@ TRICK_CXXFLAGS += $(TRICKIFY_CXX_FLAGS) # Ensure we can process all headers TRICK_EXT_LIB_DIRS := $(TRICKIFY_EXT_LIB_DIRS) +UNAME := $(shell uname) +ifeq ($(UNAME), Linux) + SHARED_OPTIONS := -shared +else ifeq ($(UNAME), Darwin) + SHARED_OPTIONS := -dynamiclib +else + SHARED_OPTIONS := -shared +endif + .PHONY: all all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) @@ -130,7 +139,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT ifeq ($(TRICKIFY_BUILD_TYPE),PLO) $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) - $(call ECHO_AND_LOG,$(TRICK_CXX) -shared -o $@ $(LINK_LISTS)) + $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif From ffb2e342404884b9e486d244e12cbe8a0e89e903 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 3 Dec 2024 10:51:03 -0600 Subject: [PATCH 11/40] Trickify MAC fixes --- share/trick/makefiles/trickify.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 50349c29f..d364a7bbf 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -126,7 +126,7 @@ UNAME := $(shell uname) ifeq ($(UNAME), Linux) SHARED_OPTIONS := -shared else ifeq ($(UNAME), Darwin) - SHARED_OPTIONS := -dynamiclib + SHARED_OPTIONS := -dynamiclib -fPIC else SHARED_OPTIONS := -shared endif @@ -135,12 +135,16 @@ endif all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) + echo "Enterting trickify.mk" $(info $(call COLOR,Linking) $@) ifeq ($(TRICKIFY_BUILD_TYPE),PLO) + echo "Building PLO" $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) + echo "Building SHARED" $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) + echo "Building STATIC" $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif From 573211e09c1088d0185a0e8a54d1d40fb20afbe6 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 3 Dec 2024 12:49:04 -0600 Subject: [PATCH 12/40] Trickify shared on mac fix --- share/trick/makefiles/trickify.mk | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index d364a7bbf..b092529b6 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -135,16 +135,12 @@ endif all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) - echo "Enterting trickify.mk" $(info $(call COLOR,Linking) $@) ifeq ($(TRICKIFY_BUILD_TYPE),PLO) - echo "Building PLO" $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) - echo "Building SHARED" - $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS)) + $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) - echo "Building STATIC" $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif From d0316b5688106add2cf2a459e8c42d9b19befa10 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 9 Dec 2024 14:59:29 -0600 Subject: [PATCH 13/40] Moved the py files to their appropriate directory --- bin/trick-ify | 6 +++--- share/trick/{makefiles => pymods/trick}/build_trickify.py | 0 .../trick}/build_trickify_S_source_hh.py | 2 +- .../{makefiles => pymods/trick}/build_trickify_obj_list.py | 2 +- .../{makefiles => pymods/trick}/build_trickify_src_list.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename share/trick/{makefiles => pymods/trick}/build_trickify.py (100%) rename share/trick/{makefiles => pymods/trick}/build_trickify_S_source_hh.py (70%) rename share/trick/{makefiles => pymods/trick}/build_trickify_obj_list.py (70%) rename share/trick/{makefiles => pymods/trick}/build_trickify_src_list.py (70%) diff --git a/bin/trick-ify b/bin/trick-ify index 039c18d92..cc8ae71cb 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -159,7 +159,7 @@ elsif ( $build_type eq so ) if ($build_s_source) { print "Building S_source.hh\n" ; - $make_s_source = "python3 $my_path../share/trick/makefiles/build_trickify_S_source_hh.py" ; + $make_s_source = "python3 $my_path../share/trick/pymods/trick/build_trickify_S_source_hh.py" ; print(`$make_s_source`) ; } @@ -167,7 +167,7 @@ if ($build_s_source) if ($build_trickify_src_list and $full_build) { print "Building trickify_src_list\n" ; - $make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ; + $make_src_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_src_list.py" ; print(`$make_src_list`) ; } @@ -213,7 +213,7 @@ 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" ; + $make_obj_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_obj_list.py" ; print(`$make_obj_list`) ; } diff --git a/share/trick/makefiles/build_trickify.py b/share/trick/pymods/trick/build_trickify.py similarity index 100% rename from share/trick/makefiles/build_trickify.py rename to share/trick/pymods/trick/build_trickify.py diff --git a/share/trick/makefiles/build_trickify_S_source_hh.py b/share/trick/pymods/trick/build_trickify_S_source_hh.py similarity index 70% rename from share/trick/makefiles/build_trickify_S_source_hh.py rename to share/trick/pymods/trick/build_trickify_S_source_hh.py index 92242d433..fb9316b61 100644 --- a/share/trick/makefiles/build_trickify_S_source_hh.py +++ b/share/trick/pymods/trick/build_trickify_S_source_hh.py @@ -3,7 +3,7 @@ path = "" if "TRICK_HOME" in os.environ: path = os.getenv("TRICK_HOME") -path += "/share/trick/makefiles/build_trickify.py" +path += "/share/trick/pymods/trick/build_trickify.py" exec(open(path).read()) diff --git a/share/trick/makefiles/build_trickify_obj_list.py b/share/trick/pymods/trick/build_trickify_obj_list.py similarity index 70% rename from share/trick/makefiles/build_trickify_obj_list.py rename to share/trick/pymods/trick/build_trickify_obj_list.py index 0fa24786b..6a878671b 100644 --- a/share/trick/makefiles/build_trickify_obj_list.py +++ b/share/trick/pymods/trick/build_trickify_obj_list.py @@ -3,7 +3,7 @@ path = "" if "TRICK_HOME" in os.environ: path = os.getenv("TRICK_HOME") -path += "/share/trick/makefiles/build_trickify.py" +path += "/share/trick/pymods/trick/build_trickify.py" exec(open(path).read()) diff --git a/share/trick/makefiles/build_trickify_src_list.py b/share/trick/pymods/trick/build_trickify_src_list.py similarity index 70% rename from share/trick/makefiles/build_trickify_src_list.py rename to share/trick/pymods/trick/build_trickify_src_list.py index 164733d65..f79903be1 100644 --- a/share/trick/makefiles/build_trickify_src_list.py +++ b/share/trick/pymods/trick/build_trickify_src_list.py @@ -3,7 +3,7 @@ path = "" if "TRICK_HOME" in os.environ: path = os.getenv("TRICK_HOME") -path += "/share/trick/makefiles/build_trickify.py" +path += "/share/trick/pymods/trick/build_trickify.py" exec(open(path).read()) From c5e044a0a8b4ebe938aa1241d2b4806dc8892c44 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Thu, 2 Jan 2025 10:27:35 -0600 Subject: [PATCH 14/40] CI fix --- share/trick/makefiles/trickify.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index b092529b6..08db4bc6f 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -139,7 +139,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT ifeq ($(TRICKIFY_BUILD_TYPE),PLO) $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) - $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) -o $@ $(LINK_LISTS)) + $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) -fPIC -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif From 2b4054f73c0ddef56dcded5a8b1fee7f6f7af3c7 Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Fri, 3 Jan 2025 17:17:10 -0600 Subject: [PATCH 15/40] Improved trick-ify arguments --- bin/trick-ify | 141 +++++------------- share/trick/makefiles/trickify.mk | 8 +- .../trickified_project/trickified/Makefile | 2 +- 3 files changed, 46 insertions(+), 105 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index cc8ae71cb..0871598b3 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -1,118 +1,59 @@ #!/usr/bin/perl +use Getopt::Long; + $my_path = $0 ; $my_path =~ s/trick-ify// ; +$dirs = "" ; # If set, use for both source and header files $source_dir = "" ; # Base path to build source 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 -$build_trickify_src_list = 1 ; # Whether to generate a trickify_src_list -$build_trickify_obj_list = 1 ; # Whether to generate a trickify_obj_list $full_build = 1 ; # Whether to build only ICG/Swig artifacts or entire source $name = "trickified" ; # Name of the library $build_type = "o" ; # Type of library to be built (o, a , so) $debug = 0 ; # Debug info flag $trick_home = $my_path . ".." ; # Trick directory to use for building +$no_source_build = 0 ; # Arg to disable building source files +$no_clean_obj = 0 ; # Don't rebuild trickify_obj_list +$no_clean_src = 0 ; # Don't rebuild trickify_src_list +$no_clean_s_source = 0 ; # Don't rebuild S_source.hh + +GetOptions +( + "d=s" => \$dirs, # Set source and header directory + "s=s" => \$source_dir, # Set source directory + "h=s" => \$header_dir, # Set header directory + "no_clean_s_source" => \$no_clean_s_source, # Don't rebuild S_source.hh + "no_clean_src_list" => \$no_clean_src, # Don't rebuild trickify_src_list + "no_clean_obj_list" => \$no_clean_obj, # Don't rebuild trickify_obj_list + "no_source" => \$no_source_build, # Arg to disable building source files + "source_make=s" => \$source_make_call, # Make call to build object files + "source_args=s" => \$source_make_args, # Default make call args to build object files + "trickify_args=s" => \$trickify_make_args, # Trickify make args + "trickify_make=s" => \$trickify_make_path, # Set trickify make path + "n=s" => \$name, # Set the library name + "b=s" => \$build_type, # Set library build type + "v" => \$debug, # Verbose, print debug info + "trick_home=s" => \$trick_home # Set trick home directory +) ; + +$full_build = !$no_source_build ; -$skip_arg = 0 ; -foreach $argnum (0 .. $#ARGV) +$val = $ARGV[$argnum + 1] ; +if( !(($build_type eq "o") or ($build_type eq "a") or ($build_type eq "so")) ) { - if($skip_arg) - { - $skip_arg = 0 ; - next ; - } - - $arg = $ARGV[$argnum] ; - if($arg eq "-d") # Set both source and header directory - { - $source_dir = $ARGV[$argnum + 1] ; - $header_dir = $source_dir ; - $skip_arg = 1 ; - } - elsif($arg eq "-s") # Set source directory - { - $source_dir = $ARGV[$argnum + 1] ; - $skip_arg = 1 ; - } - elsif($arg eq "-h") # Set header directory - { - $header_dir = $ARGV[$argnum + 1] ; - $skip_arg = 1 ; - } - elsif($arg eq "-ph") # Preserve S_source.hh - { - $build_s_source = 0 ; - } - elsif($arg eq "-ps") # Preserve trickify_src_list - { - $build_trickify_src_list = 0 ; - } - elsif($arg eq "-po") # Preserve trickify_obj_list - { - $build_trickify_obj_list = 0 ; - } - elsif($arg eq "-t") # Build trick artifacts only - { - $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 "-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] ; - $skip_arg = 1 ; - } - elsif($arg eq "-tp") # Set trickify make path - { - $trickify_make_path = $ARGV[$argnum + 1] ; - $skip_arg = 1 ; - } - elsif($arg eq "-n") # Set the library name - { - $name = $ARGV[$argnum + 1] ; - $skip_arg = 1 ; - } - elsif($arg eq "-b") # Set library build type - { - $val = $ARGV[$argnum + 1] ; - if( ($val eq "o") or ($val eq "a") or ($val eq "so") ) - { - $build_type = $ARGV[$argnum + 1] ; - } - else - { - print "Invalid build type {$val}, valid build types are {o, a, so}\n" ; - exit 1 ; - } - $skip_arg = 1 ; - } - elsif($arg eq "-v") # Verbose, print debug info - { - $debug = 1 ; - } - elsif($arg eq "-th") # Set trick home directory - { - $trick_home = $ARGV[$argnum + 1] ; - $skip_arg = 1 ; - } - else - { - print "Unrecognized argument: $arg\n" ; - exit 1 ; - } + print "Invalid build type {$build_type}, valid build types are {o, a, so}\n" ; + exit 1 ; +} + +if($dirs ne "") +{ + $header_dir = $dirs ; + $source_dir = $dirs ; } if($header_dir eq "") @@ -156,7 +97,7 @@ elsif ( $build_type eq so ) } #Build the S_source.hh -if ($build_s_source) +if (!$no_clean_s_source) { print "Building S_source.hh\n" ; $make_s_source = "python3 $my_path../share/trick/pymods/trick/build_trickify_S_source_hh.py" ; @@ -164,7 +105,7 @@ if ($build_s_source) } #Build source file list, only if trickifying the entire library -if ($build_trickify_src_list and $full_build) +if (!$no_clean_src and $full_build) { print "Building trickify_src_list\n" ; $make_src_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_src_list.py" ; @@ -210,7 +151,7 @@ if ($full_build) } #Build object file list, only if trickifying the entire library -if($build_trickify_obj_list and $full_build) +if(!$no_clean_obj and $full_build) { print "Building trickify_obj_list\n" ; $make_obj_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_obj_list.py" ; diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 08db4bc6f..5b39dc661 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -124,11 +124,11 @@ TRICK_EXT_LIB_DIRS := $(TRICKIFY_EXT_LIB_DIRS) UNAME := $(shell uname) ifeq ($(UNAME), Linux) - SHARED_OPTIONS := -shared + SHARED_OPTIONS := -fPIC else ifeq ($(UNAME), Darwin) - SHARED_OPTIONS := -dynamiclib -fPIC + SHARED_OPTIONS := -fPIC else - SHARED_OPTIONS := -shared + SHARED_OPTIONS := endif .PHONY: all @@ -139,7 +139,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT ifeq ($(TRICKIFY_BUILD_TYPE),PLO) $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) - $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) -fPIC -o $@ $(LINK_LISTS)) + $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index 95d9d2500..9cb1723e2 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v -ma "-fPIC -fvisibility=default" + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v --source_args -fPIC clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) From fc964811b95ae3891385df00dc77c4aa1d5da74f Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 6 Jan 2025 12:44:05 -0600 Subject: [PATCH 16/40] CI --- share/trick/makefiles/trickify.mk | 5 +++++ test/SIM_trickified/trickified_project/trickified/Makefile | 4 ++-- .../trickified_project/trickified/myproject.mk | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 5b39dc661..421ca5184 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -141,6 +141,11 @@ ifeq ($(TRICKIFY_BUILD_TYPE),PLO) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) + @echo "-----Printing LS-----" + @ls + @echo "-----Printing LS build-----" + @ls build + @echo "-----Ending LS-----" $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif diff --git a/test/SIM_trickified/trickified_project/trickified/Makefile b/test/SIM_trickified/trickified_project/trickified/Makefile index 459c4c0ca..ed9a8dd12 100644 --- a/test/SIM_trickified/trickified_project/trickified/Makefile +++ b/test/SIM_trickified/trickified_project/trickified/Makefile @@ -1,8 +1,8 @@ PROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) TRICK_HOME := $(abspath $(PROJECT_HOME)/../../..) -export TRICKIFY_BUILD_TYPE := STATIC -export TRICKIFY_OBJECT_NAME := trickified_myproject.a +export TRICKIFY_BUILD_TYPE := PLO +export TRICKIFY_OBJECT_NAME := trickified_myproject.o export TRICKIFY_CXX_FLAGS := -I$(PROJECT_HOME)/include -I$(TRICK_HOME)/include all: diff --git a/test/SIM_trickified/trickified_project/trickified/myproject.mk b/test/SIM_trickified/trickified_project/trickified/myproject.mk index f08a541ca..7abe9af1e 100644 --- a/test/SIM_trickified/trickified_project/trickified/myproject.mk +++ b/test/SIM_trickified/trickified_project/trickified/myproject.mk @@ -11,7 +11,7 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.a +MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.o # Tell Trick the headers and source at this location are part of a # Trickified project From 1e9a2e1e0ca3659608af1778068cf78a212e9573 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 6 Jan 2025 15:31:56 -0600 Subject: [PATCH 17/40] CI --- share/trick/makefiles/trickify.mk | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 421ca5184..a56fd85de 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -106,10 +106,23 @@ BUILD_DIR := $(dir $(MAKE_OUT)) PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list OBJ_LINK_LIST := trickify_obj_list +UNAME := $(shell uname) ifdef FULL_TRICKIFY_BUILD - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) + ifeq ($(UNAME), Linux) + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) + else ifeq ($(UNAME), Darwin) + LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) $(OBJ_LINK_LIST) + else + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) + endif else - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) + ifeq ($(UNAME), Linux) + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) + else ifeq ($(UNAME), Darwin) + LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) + else + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) + endif endif ifneq ($(wildcard $(BUILD_DIR)),) SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) @@ -122,7 +135,6 @@ TRICK_CXXFLAGS += $(TRICKIFY_CXX_FLAGS) # Ensure we can process all headers TRICK_EXT_LIB_DIRS := $(TRICKIFY_EXT_LIB_DIRS) -UNAME := $(shell uname) ifeq ($(UNAME), Linux) SHARED_OPTIONS := -fPIC else ifeq ($(UNAME), Darwin) From f420dcafdf7d8e9a7f14f8dc81df315734ac15e5 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 7 Jan 2025 09:34:11 -0600 Subject: [PATCH 18/40] CI --- share/trick/makefiles/trickify.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index a56fd85de..f34ae8a8d 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -111,7 +111,7 @@ ifdef FULL_TRICKIFY_BUILD ifeq ($(UNAME), Linux) LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) else ifeq ($(UNAME), Darwin) - LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) $(OBJ_LINK_LIST) + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) else LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) endif @@ -119,7 +119,7 @@ else ifeq ($(UNAME), Linux) LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) else ifeq ($(UNAME), Darwin) - LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) else LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) endif From e25aaa30aad74b89bc4f4b91dd2477321ffc5ebc Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 7 Jan 2025 12:38:47 -0600 Subject: [PATCH 19/40] CI --- share/trick/makefiles/trickify.mk | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index f34ae8a8d..0a8195a77 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -111,7 +111,11 @@ ifdef FULL_TRICKIFY_BUILD ifeq ($(UNAME), Linux) LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) else ifeq ($(UNAME), Darwin) - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) + ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) + LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) $(OBJ_LINK_LIST) + else + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) + endif else LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) endif @@ -119,7 +123,11 @@ else ifeq ($(UNAME), Linux) LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) else ifeq ($(UNAME), Darwin) - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) + ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) + LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) + else + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) + endif else LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) endif From c3cd94ea994685e30e5453960eac4d21ae26533c Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Thu, 9 Jan 2025 09:39:42 -0600 Subject: [PATCH 20/40] CI --- share/trick/makefiles/trickify.mk | 54 +++++++++++-------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 0a8195a77..cae9e9863 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -108,29 +108,9 @@ IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list OBJ_LINK_LIST := trickify_obj_list UNAME := $(shell uname) ifdef FULL_TRICKIFY_BUILD - ifeq ($(UNAME), Linux) - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) - else ifeq ($(UNAME), Darwin) - ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) - LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) $(OBJ_LINK_LIST) - else - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) - endif - else - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) - endif + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) else - ifeq ($(UNAME), Linux) - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) - else ifeq ($(UNAME), Darwin) - ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) - LINK_LISTS := $(IO_LINK_LIST) $(PY_LINK_LIST) - else - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) - endif - else - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) - endif + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) endif ifneq ($(wildcard $(BUILD_DIR)),) SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) @@ -155,19 +135,23 @@ endif all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) - $(info $(call COLOR,Linking) $@) -ifeq ($(TRICKIFY_BUILD_TYPE),PLO) - $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) -else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) - $(call ECHO_AND_LOG,$(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS)) -else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) - @echo "-----Printing LS-----" - @ls - @echo "-----Printing LS build-----" - @ls build - @echo "-----Ending LS-----" - $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) -endif + @if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ] ; then \ + $(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS) ; \ + elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ] ; then \ + $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS) ; \ + elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ] ; then \ + export FILES= ; \ + while read -r line ; do \ + export FILES="$$FILES $$line" ; \ + done < $(PY_LINK_LIST) ; \ + while read -r line ; do \ + export FILES="$$FILES $$line" ; \ + done < $(IO_LINK_LIST) ; \ + while read -r line ; do \ + export FILES="$$FILES $$line" ; \ + done < $(OBJ_LINK_LIST) ; \ + ar rcs $@ $ $$FILES ; \ + fi $(dir $(TRICKIFY_OBJECT_NAME)) $(BUILD_DIR) $(dir $(TRICKIFY_PYTHON_DIR)) .trick: @mkdir -p $@ From a2d445548006b190734fc5246740edd2141405c6 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 13 Jan 2025 11:28:26 -0600 Subject: [PATCH 21/40] CI --- share/trick/makefiles/trickify.mk | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index cae9e9863..61ea9adda 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -106,11 +106,10 @@ BUILD_DIR := $(dir $(MAKE_OUT)) PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list OBJ_LINK_LIST := trickify_obj_list -UNAME := $(shell uname) ifdef FULL_TRICKIFY_BUILD - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) + FULL_TRICKIFY_BUILD = "1" else - LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) + FULL_TRICKIFY_BUILD = "0" endif ifneq ($(wildcard $(BUILD_DIR)),) SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) @@ -123,6 +122,7 @@ TRICK_CXXFLAGS += $(TRICKIFY_CXX_FLAGS) # Ensure we can process all headers TRICK_EXT_LIB_DIRS := $(TRICKIFY_EXT_LIB_DIRS) +UNAME := $(shell uname) ifeq ($(UNAME), Linux) SHARED_OPTIONS := -fPIC else ifeq ($(UNAME), Darwin) @@ -134,22 +134,24 @@ endif .PHONY: all all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) +.ONESHELL: $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) + @while read -r line ; do \ + export FILES="$$FILES $$line" ; \ + done < $(PY_LINK_LIST) + @while read -r line ; do \ + export FILES="$$FILES $$line" ; \ + done < $(IO_LINK_LIST) + @if [ "$(FULL_TRICKIFY_BUILD)" = "1" ] ; then \ + while read -r line ; do \ + export FILES="$$FILES $$line" ; \ + done < $(OBJ_LINK_LIST) + fi @if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ] ; then \ - $(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS) ; \ + $(LD) $(LD_PARTIAL) -o $@ $$FILES ; \ elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ] ; then \ - $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $(LINK_LISTS) ; \ + $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $$FILES ; \ elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ] ; then \ - export FILES= ; \ - while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(PY_LINK_LIST) ; \ - while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(IO_LINK_LIST) ; \ - while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(OBJ_LINK_LIST) ; \ ar rcs $@ $ $$FILES ; \ fi From 04c0fea046b563a0975b390364d2df840e7faa6d Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 13 Jan 2025 12:09:13 -0600 Subject: [PATCH 22/40] CI --- share/trick/makefiles/trickify.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 61ea9adda..056fa8568 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -126,7 +126,7 @@ UNAME := $(shell uname) ifeq ($(UNAME), Linux) SHARED_OPTIONS := -fPIC else ifeq ($(UNAME), Darwin) - SHARED_OPTIONS := -fPIC + SHARED_OPTIONS := -fPIC -lgcov else SHARED_OPTIONS := endif From 74c75123aa424c28fe6baf1b64360d7c1bf9f397 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 14 Jan 2025 13:19:55 -0600 Subject: [PATCH 23/40] Added C support --- bin/trick-ify | 13 ++++++++++--- test/SIM_trickified_archive/S_define | 3 +-- .../trickified_project/include_bar/Bar.c | 6 ++++++ .../trickified_project/include_bar/Bar.cpp | 7 ------- .../trickified_project/include_bar/Bar.h | 16 ++++++++++++++++ .../trickified_project/include_bar/Bar.hh | 17 ----------------- test/SIM_trickified_object/S_define | 3 +-- .../trickified_project/include_bar/Bar.c | 6 ++++++ .../trickified_project/include_bar/Bar.cpp | 7 ------- .../trickified_project/include_bar/Bar.h | 16 ++++++++++++++++ .../trickified_project/include_bar/Bar.hh | 17 ----------------- test/SIM_trickified_shared/S_define | 3 +-- .../trickified_project/include_bar/Bar.c | 6 ++++++ .../trickified_project/include_bar/Bar.cpp | 7 ------- .../trickified_project/include_bar/Bar.h | 16 ++++++++++++++++ .../trickified_project/include_bar/Bar.hh | 17 ----------------- 16 files changed, 79 insertions(+), 81 deletions(-) create mode 100644 test/SIM_trickified_archive/trickified_project/include_bar/Bar.c delete mode 100644 test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp create mode 100644 test/SIM_trickified_archive/trickified_project/include_bar/Bar.h delete mode 100644 test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh create mode 100644 test/SIM_trickified_object/trickified_project/include_bar/Bar.c delete mode 100644 test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp create mode 100644 test/SIM_trickified_object/trickified_project/include_bar/Bar.h delete mode 100644 test/SIM_trickified_object/trickified_project/include_bar/Bar.hh create mode 100644 test/SIM_trickified_shared/trickified_project/include_bar/Bar.c delete mode 100644 test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp create mode 100644 test/SIM_trickified_shared/trickified_project/include_bar/Bar.h delete mode 100644 test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh diff --git a/bin/trick-ify b/bin/trick-ify index 0871598b3..d5c7d2b7d 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -134,9 +134,16 @@ if ($full_build) foreach $src (@src_files) { $file = $src ; - $file =~ s/\Q.cpp\E$// ; - $file =~ s/\Q.c$\E$// ; - $cmd = "g++ $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ; + if($file =~ /\S*(\Q.c\E)$/) + { + $file =~ s/\Q.c\E$// ; + $cmd = "gcc $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ; + } + else + { + $file =~ s/\Q.cpp\E$// ; + $cmd = "g++ $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ; + } if($debug) { print "Building obj file: $cmd\n" ; diff --git a/test/SIM_trickified_archive/S_define b/test/SIM_trickified_archive/S_define index f770e2a73..1c86251ed 100644 --- a/test/SIM_trickified_archive/S_define +++ b/test/SIM_trickified_archive/S_define @@ -1,6 +1,6 @@ #include "sim_objects/default_trick_sys.sm" ##include "Foo.hh" -##include "Bar.hh" +##include "Bar.h" ##include "Baz.hh" class Sandbox : public Trick::SimObject { @@ -8,7 +8,6 @@ class Sandbox : public Trick::SimObject { public: Foo foo; - Bar bar; Baz baz; Sandbox() { diff --git a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.c b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.c new file mode 100644 index 000000000..cf5649184 --- /dev/null +++ b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.c @@ -0,0 +1,6 @@ +#include "Bar.h" + +int process(long long x) {return 0;} +void add() {} +void remove_Bar() {} +void restart() {} diff --git a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp deleted file mode 100644 index b46af6616..000000000 --- a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Bar.hh" - - -void Bar::add() {} -void Bar::remove() {} -void Bar::restart() {} - diff --git a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.h b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.h new file mode 100644 index 000000000..b8c3677c6 --- /dev/null +++ b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.h @@ -0,0 +1,16 @@ +// @trick_parse{everything} + +#include "trick/exec_proto.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void add(); +void remove_Bar(); +void restart(); + +#ifdef __cplusplus +} +#endif diff --git a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh b/test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh deleted file mode 100644 index 5c4972624..000000000 --- a/test/SIM_trickified_archive/trickified_project/include_bar/Bar.hh +++ /dev/null @@ -1,17 +0,0 @@ -// @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(); - -}; diff --git a/test/SIM_trickified_object/S_define b/test/SIM_trickified_object/S_define index f770e2a73..1c86251ed 100644 --- a/test/SIM_trickified_object/S_define +++ b/test/SIM_trickified_object/S_define @@ -1,6 +1,6 @@ #include "sim_objects/default_trick_sys.sm" ##include "Foo.hh" -##include "Bar.hh" +##include "Bar.h" ##include "Baz.hh" class Sandbox : public Trick::SimObject { @@ -8,7 +8,6 @@ class Sandbox : public Trick::SimObject { public: Foo foo; - Bar bar; Baz baz; Sandbox() { diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.c b/test/SIM_trickified_object/trickified_project/include_bar/Bar.c new file mode 100644 index 000000000..cf5649184 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/include_bar/Bar.c @@ -0,0 +1,6 @@ +#include "Bar.h" + +int process(long long x) {return 0;} +void add() {} +void remove_Bar() {} +void restart() {} diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp deleted file mode 100644 index b46af6616..000000000 --- a/test/SIM_trickified_object/trickified_project/include_bar/Bar.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Bar.hh" - - -void Bar::add() {} -void Bar::remove() {} -void Bar::restart() {} - diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.h b/test/SIM_trickified_object/trickified_project/include_bar/Bar.h new file mode 100644 index 000000000..b8c3677c6 --- /dev/null +++ b/test/SIM_trickified_object/trickified_project/include_bar/Bar.h @@ -0,0 +1,16 @@ +// @trick_parse{everything} + +#include "trick/exec_proto.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void add(); +void remove_Bar(); +void restart(); + +#ifdef __cplusplus +} +#endif diff --git a/test/SIM_trickified_object/trickified_project/include_bar/Bar.hh b/test/SIM_trickified_object/trickified_project/include_bar/Bar.hh deleted file mode 100644 index 5c4972624..000000000 --- a/test/SIM_trickified_object/trickified_project/include_bar/Bar.hh +++ /dev/null @@ -1,17 +0,0 @@ -// @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(); - -}; diff --git a/test/SIM_trickified_shared/S_define b/test/SIM_trickified_shared/S_define index f770e2a73..1c86251ed 100644 --- a/test/SIM_trickified_shared/S_define +++ b/test/SIM_trickified_shared/S_define @@ -1,6 +1,6 @@ #include "sim_objects/default_trick_sys.sm" ##include "Foo.hh" -##include "Bar.hh" +##include "Bar.h" ##include "Baz.hh" class Sandbox : public Trick::SimObject { @@ -8,7 +8,6 @@ class Sandbox : public Trick::SimObject { public: Foo foo; - Bar bar; Baz baz; Sandbox() { diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.c b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.c new file mode 100644 index 000000000..cf5649184 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.c @@ -0,0 +1,6 @@ +#include "Bar.h" + +int process(long long x) {return 0;} +void add() {} +void remove_Bar() {} +void restart() {} diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp deleted file mode 100644 index b46af6616..000000000 --- a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Bar.hh" - - -void Bar::add() {} -void Bar::remove() {} -void Bar::restart() {} - diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.h b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.h new file mode 100644 index 000000000..b8c3677c6 --- /dev/null +++ b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.h @@ -0,0 +1,16 @@ +// @trick_parse{everything} + +#include "trick/exec_proto.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void add(); +void remove_Bar(); +void restart(); + +#ifdef __cplusplus +} +#endif diff --git a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh b/test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh deleted file mode 100644 index 5c4972624..000000000 --- a/test/SIM_trickified_shared/trickified_project/include_bar/Bar.hh +++ /dev/null @@ -1,17 +0,0 @@ -// @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(); - -}; From 4af3fc3b346e106e710928a578e12af4b9e564a5 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Wed, 15 Jan 2025 15:02:41 -0600 Subject: [PATCH 24/40] Removed trickified shared test from MAC CI --- trickops.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/trickops.py b/trickops.py index 901105d9d..cbe466e89 100644 --- a/trickops.py +++ b/trickops.py @@ -38,6 +38,11 @@ def run( self ): phases = [-1, 0, 1, 2, 3] analysis_jobs = self.get_jobs(kind='analyze') + if platform == "darwin": + for job in build_jobs: + if job.name == "Build test/SIM_trickified_shared" : + print("REMOVING JOB: " + job.name) + build_jobs.remove(job) builds_status = self.execute_jobs(build_jobs, max_concurrent=self.cpus, header='Executing all sim builds.') jobs = build_jobs @@ -45,6 +50,11 @@ def run( self ): run_status = 0 for phase in phases: run_jobs = self.get_jobs(kind='run', phase=phase) + if platform == "darwin": + for job in run_jobs: + if job.name == "Run test/SIM_trickified_shared RUN_test/unit_test.py" : + print("REMOVING JOB: " + job.name) + run_jobs.remove(job) this_status = self.execute_jobs(run_jobs, max_concurrent=self.cpus, header="Executing phase " + str(phase) + " runs.", job_timeout=1000) run_status = run_status or this_status jobs += run_jobs From ae866402d10ba4fcb3391b0671ffa688f0d51f2e Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Wed, 22 Jan 2025 16:33:37 -0600 Subject: [PATCH 25/40] Start of trickify GUI --- trick_source/java/pom.xml | 16 ++ .../trick/trickify/TrickifyApplication.java | 181 ++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java diff --git a/trick_source/java/pom.xml b/trick_source/java/pom.xml index ee69706ca..3abc3590d 100644 --- a/trick_source/java/pom.xml +++ b/trick_source/java/pom.xml @@ -154,6 +154,22 @@ <finalName>SimControl</finalName> </configuration> </execution> + + <execution> + <id>trickify</id> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>trick.trickify.TrickifyApplication</mainClass> + </transformer> + </transformers> + <finalName>Trickify</finalName> + </configuration> + </execution> <execution> <id>sniffer</id> diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java new file mode 100644 index 000000000..ddb4e3c08 --- /dev/null +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java @@ -0,0 +1,181 @@ +package trick.trickify; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.ParameterizedType; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.AbstractButton; +import javax.swing.Box; +import javax.swing.ButtonGroup; +import javax.swing.ImageIcon; +import javax.swing.JCheckBox; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JRadioButton; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.JSplitPane; +import javax.swing.JToolBar; +import javax.swing.KeyStroke; +import javax.swing.SwingWorker; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.tree.TreePath; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.namespace.QName; +import javax.xml.transform.stream.StreamSource; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; + +import org.jdesktop.application.Application; +import org.jdesktop.application.View; +import org.jdesktop.swingx.JXButton; +import org.jdesktop.swingx.JXFrame; +import org.jdesktop.swingx.JXLabel; +import org.jdesktop.swingx.JXPanel; +import org.jdesktop.swingx.JXTextField; +import org.xml.sax.InputSource; + +import trick.common.RunTimeTrickApplication; +import trick.common.TrickApplication; +import trick.common.utils.UnitType; +import trick.common.utils.UnitType.Unit; +import trick.common.utils.VariableServerConnection; +import trick.common.utils.vs.VSLong; +import trick.common.utils.vs.Variable; +import trick.common.utils.vs.VariableListener; +import trick.common.utils.vs.VariableTracker; + +public class TrickifyApplication extends RunTimeTrickApplication +{ + JXLabel timeLabel; + String defaultDirectory; + JXTextField manualField; + JFileChooser fileChooser; + + protected AbstractAction newAction = new AbstractAction("New", + new ImageIcon(TrickApplication.class.getResource("resources/filenew.gif"))) { + { + } + public void actionPerformed(ActionEvent actionEvent) + { + } + }; + + @Override + @SuppressWarnings("unchecked") + protected void startup() + { + JFrame mainFrame = getMainFrame(); + } + + @Override + @SuppressWarnings("unchecked") + protected JComponent createMainPanel() + { + return new JPanel(); + } + + public static void main(String[] args) + { + JFrame frame = new JFrame(); + frame.setSize(500, 600); + + JFileChooser src_dirs_chooser = new JFileChooser(); + src_dirs_chooser.setBounds(0, 0, 400, 250); + frame.add(src_dirs_chooser); + + int checkbox_x = 0; + int checkbox_y = 300; + int checkbox_width = 250; + int checkbox_offset = 20; + int checkbox_relative_offset = 0; + + JCheckBox full_build_box = new JCheckBox(" Full library build"); + full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + checkbox_relative_offset += checkbox_offset; + frame.add(full_build_box); + + JCheckBox no_clean_obj_box = new JCheckBox(" Don't rebuild object file list"); + no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + checkbox_relative_offset += checkbox_offset; + frame.add(no_clean_obj_box); + + JCheckBox no_clean_src_box = new JCheckBox(" Don't rebuild source file list"); + no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + checkbox_relative_offset += checkbox_offset; + frame.add(no_clean_src_box); + + JCheckBox no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh"); + no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + checkbox_relative_offset += checkbox_offset; + frame.add(no_clean_s_source_box); + + JCheckBox debug_box = new JCheckBox(" Debug info"); + debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + checkbox_relative_offset += checkbox_offset; + frame.add(debug_box); + + + frame.setLayout(null); + frame.setVisible(true); + //Application.launch(TrickifyApplication.class, args); + } + +} From 2e46a84495a244cd56b95632654e415706042740 Mon Sep 17 00:00:00 2001 From: Patrick Herrington <pherring04@gmail.com> Date: Wed, 22 Jan 2025 17:42:49 -0600 Subject: [PATCH 26/40] Checkpoint --- bin/trick-trickify | 8 ++++++++ .../java/trick/trickify/TrickifyApplication.java | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100755 bin/trick-trickify diff --git a/bin/trick-trickify b/bin/trick-trickify new file mode 100755 index 000000000..062aca1a4 --- /dev/null +++ b/bin/trick-trickify @@ -0,0 +1,8 @@ +#!/usr/bin/perl + +use FindBin qw($RealBin); +use lib ("$RealBin/../libexec/trick/pm", "$RealBin/../lib/trick/pm") ; +use launch_java ; + +launch_java("Trickify", "Trickify") ; + diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java index ddb4e3c08..844a37144 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java @@ -137,9 +137,19 @@ public static void main(String[] args) JFrame frame = new JFrame(); frame.setSize(500, 600); - JFileChooser src_dirs_chooser = new JFileChooser(); - src_dirs_chooser.setBounds(0, 0, 400, 250); - frame.add(src_dirs_chooser); + JButton src_dirs_button = new JButton(); + src_dirs_button.setBounds(0, 0, 50, 20); + src_dirs_button.setText("Choose"); + src_dirs_button.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + JFileChooser src_dirs_chooser = new JFileChooser(); + src_dirs_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + src_dirs_chooser.showSaveDialog(null); + } + } ); + frame.add(src_dirs_button); int checkbox_x = 0; int checkbox_y = 300; From e30ebf80ce594ef6ffa444f8cccb0516604cd8a2 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 3 Feb 2025 11:44:39 -0600 Subject: [PATCH 27/40] Trickify GUI --- bin/trick-ify | 2 +- .../main/java/trick/trickify/DirSelect.java | 168 +++++++ .../java/trick/trickify/LabeledTextField.java | 94 ++++ .../trick/trickify/TrickifyApplication.java | 185 +------- .../java/trick/trickify/TrickifyFrame.java | 421 ++++++++++++++++++ 5 files changed, 686 insertions(+), 184 deletions(-) create mode 100644 trick_source/java/src/main/java/trick/trickify/DirSelect.java create mode 100644 trick_source/java/src/main/java/trick/trickify/LabeledTextField.java create mode 100644 trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java diff --git a/bin/trick-ify b/bin/trick-ify index d5c7d2b7d..514ce6ef9 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -32,7 +32,7 @@ GetOptions "no_clean_obj_list" => \$no_clean_obj, # Don't rebuild trickify_obj_list "no_source" => \$no_source_build, # Arg to disable building source files "source_make=s" => \$source_make_call, # Make call to build object files - "source_args=s" => \$source_make_args, # Default make call args to build object files + "source_make_args=s" => \$source_make_args, # Default make call args to build object files "trickify_args=s" => \$trickify_make_args, # Trickify make args "trickify_make=s" => \$trickify_make_path, # Set trickify make path "n=s" => \$name, # Set the library name diff --git a/trick_source/java/src/main/java/trick/trickify/DirSelect.java b/trick_source/java/src/main/java/trick/trickify/DirSelect.java new file mode 100644 index 000000000..fe8ba9790 --- /dev/null +++ b/trick_source/java/src/main/java/trick/trickify/DirSelect.java @@ -0,0 +1,168 @@ +package trick.trickify; + +import java.awt.event.*; +import java.io.*; +import javax.swing.*; + +public class DirSelect +{ + private int pos_x = 0; + private int pos_y = 0; + + private JLabel label; + private int label_pos_x = pos_x; + private int label_pos_y = pos_y; + private int label_width = 200; + private int label_height = 20; + + private JTextField textfield; + private int textfield_pos_x = pos_x; + private int textfield_pos_y = pos_y + label_height; + private int textfield_width = 800; + private int textfield_height = 20; + + private JButton button; + private int button_pos_x = textfield_pos_x + textfield_width; + private int button_pos_y = textfield_pos_y; + private int button_width = 100; + private int button_height = 20; + + private JFileChooser browser; + + private boolean multiDir = false; + + private void updatePosition() + { + label_pos_x = pos_x; + label_pos_y = pos_y; + + textfield_pos_x = pos_x; + textfield_pos_y = pos_y + label_height; + + button_pos_x = textfield_pos_x + textfield_width; + button_pos_y = textfield_pos_y; + } + + private void redraw() + { + label.setBounds(label_pos_x, label_pos_y, label_width, label_height); + textfield.setBounds(textfield_pos_x, textfield_pos_y, textfield_width, textfield_height); + button.setBounds(button_pos_x, button_pos_y, button_width, button_height); + } + + public void setPosition(int x, int y) + { + pos_x = x; + pos_y = y; + + updatePosition(); + redraw(); + } + + public void setLabel(String text) + { + label.setText(text); + } + + public void setToolTipText(String tip) + { + textfield.setToolTipText(tip); + } + + public void setButtonText(String text) + { + button.setText(text); + } + + public void addToPanel(JPanel panel) + { + panel.add(label); + panel.add(textfield); + panel.add(button); + } + + public void addToFrame(JFrame frame) + { + frame.add(label); + frame.add(textfield); + frame.add(button); + } + + public void allowMultiple(boolean b) + { + browser.setMultiSelectionEnabled(b); + multiDir = b; + } + + public void selectFile(boolean b) + { + if(b) + { + browser.setFileSelectionMode(JFileChooser.FILES_ONLY); + } + else + { + browser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + } + } + + public String getDirs() + { + return textfield.getText(); + } + + void setDirs(String txt) + { + textfield.setText(txt); + } + + public DirSelect() + { + label = new JLabel(); + label_width = 200; + label_height = 20; + + textfield = new JTextField(); + textfield_width = 800; + textfield_height = 20; + + button = new JButton(); + button_width = 100; + button_height = 20; + + browser = new JFileChooser(); + browser.setCurrentDirectory(new File(System.getProperty("user.dir"))); + browser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + setPosition(pos_x, pos_y); + + button.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + int result = browser.showOpenDialog(null); + if(result == JFileChooser.CANCEL_OPTION) + { + return; + } + String filename = ""; + if(multiDir) + { + File[] files = browser.getSelectedFiles(); + for(int i = 0; i < files.length; ++i) + { + filename += files[i].getAbsolutePath() + " "; + } + textfield.setText(textfield.getText() + filename); + } + else + { + File file = browser.getSelectedFile(); + filename = file.getAbsolutePath(); + textfield.setText(filename); + } + } + } ); + } + +} diff --git a/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java b/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java new file mode 100644 index 000000000..ea77503f0 --- /dev/null +++ b/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java @@ -0,0 +1,94 @@ +package trick.trickify; + +import java.awt.event.*; +import java.io.*; +import javax.swing.*; + +public class LabeledTextField +{ + private int pos_x = 0; + private int pos_y = 0; + + private JLabel label; + private int label_pos_x = pos_x; + private int label_pos_y = pos_y; + private int label_width = 200; + private int label_height = 20; + + private JTextField textfield; + private int textfield_pos_x = pos_x; + private int textfield_pos_y = pos_y + label_height; + private int textfield_width = 800; + private int textfield_height = 20; + + private void updatePosition() + { + label_pos_x = pos_x; + label_pos_y = pos_y; + + textfield_pos_x = pos_x; + textfield_pos_y = pos_y + label_height; + } + + private void redraw() + { + label.setBounds(label_pos_x, label_pos_y, label_width, label_height); + textfield.setBounds(textfield_pos_x, textfield_pos_y, textfield_width, textfield_height); + } + + public void setPosition(int x, int y) + { + pos_x = x; + pos_y = y; + + updatePosition(); + redraw(); + } + + public void setLabel(String text) + { + label.setText(text); + } + + public void setToolTipText(String tip) + { + textfield.setToolTipText(tip); + } + + + public void addToPanel(JPanel panel) + { + panel.add(label); + panel.add(textfield); + } + + public void addToFrame(JFrame frame) + { + frame.add(label); + frame.add(textfield); + } + + public String getText() + { + return textfield.getText(); + } + + void setText(String txt) + { + textfield.setText(txt); + } + + public LabeledTextField() + { + label = new JLabel(); + label_width = 200; + label_height = 20; + + textfield = new JTextField(); + textfield_width = 800; + textfield_height = 20; + + setPosition(pos_x, pos_y); + } + +} diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java index 844a37144..7304e54c5 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java @@ -1,191 +1,10 @@ package trick.trickify; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.*; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.ParameterizedType; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.*; -import javax.swing.AbstractAction; -import javax.swing.AbstractButton; -import javax.swing.Box; -import javax.swing.ButtonGroup; -import javax.swing.ImageIcon; -import javax.swing.JCheckBox; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButton; -import javax.swing.JRootPane; -import javax.swing.JScrollPane; -import javax.swing.JSeparator; -import javax.swing.JSplitPane; -import javax.swing.JToolBar; -import javax.swing.KeyStroke; -import javax.swing.SwingWorker; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EmptyBorder; -import javax.swing.border.TitledBorder; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.tree.TreePath; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.namespace.QName; -import javax.xml.transform.stream.StreamSource; - -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; - -import org.jdesktop.application.Application; -import org.jdesktop.application.View; -import org.jdesktop.swingx.JXButton; -import org.jdesktop.swingx.JXFrame; -import org.jdesktop.swingx.JXLabel; -import org.jdesktop.swingx.JXPanel; -import org.jdesktop.swingx.JXTextField; -import org.xml.sax.InputSource; - -import trick.common.RunTimeTrickApplication; -import trick.common.TrickApplication; -import trick.common.utils.UnitType; -import trick.common.utils.UnitType.Unit; -import trick.common.utils.VariableServerConnection; -import trick.common.utils.vs.VSLong; -import trick.common.utils.vs.Variable; -import trick.common.utils.vs.VariableListener; -import trick.common.utils.vs.VariableTracker; - -public class TrickifyApplication extends RunTimeTrickApplication +public class TrickifyApplication { - JXLabel timeLabel; - String defaultDirectory; - JXTextField manualField; - JFileChooser fileChooser; - - protected AbstractAction newAction = new AbstractAction("New", - new ImageIcon(TrickApplication.class.getResource("resources/filenew.gif"))) { - { - } - public void actionPerformed(ActionEvent actionEvent) - { - } - }; - - @Override - @SuppressWarnings("unchecked") - protected void startup() - { - JFrame mainFrame = getMainFrame(); - } - - @Override - @SuppressWarnings("unchecked") - protected JComponent createMainPanel() - { - return new JPanel(); - } - public static void main(String[] args) { - JFrame frame = new JFrame(); - frame.setSize(500, 600); - - JButton src_dirs_button = new JButton(); - src_dirs_button.setBounds(0, 0, 50, 20); - src_dirs_button.setText("Choose"); - src_dirs_button.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - JFileChooser src_dirs_chooser = new JFileChooser(); - src_dirs_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - src_dirs_chooser.showSaveDialog(null); - } - } ); - frame.add(src_dirs_button); - - int checkbox_x = 0; - int checkbox_y = 300; - int checkbox_width = 250; - int checkbox_offset = 20; - int checkbox_relative_offset = 0; - - JCheckBox full_build_box = new JCheckBox(" Full library build"); - full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - checkbox_relative_offset += checkbox_offset; - frame.add(full_build_box); - - JCheckBox no_clean_obj_box = new JCheckBox(" Don't rebuild object file list"); - no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - checkbox_relative_offset += checkbox_offset; - frame.add(no_clean_obj_box); - - JCheckBox no_clean_src_box = new JCheckBox(" Don't rebuild source file list"); - no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - checkbox_relative_offset += checkbox_offset; - frame.add(no_clean_src_box); - - JCheckBox no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh"); - no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - checkbox_relative_offset += checkbox_offset; - frame.add(no_clean_s_source_box); - - JCheckBox debug_box = new JCheckBox(" Debug info"); - debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - checkbox_relative_offset += checkbox_offset; - frame.add(debug_box); - - - frame.setLayout(null); - frame.setVisible(true); - //Application.launch(TrickifyApplication.class, args); + TrickifyFrame trickifyFrame = new TrickifyFrame(); } } diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java b/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java new file mode 100644 index 000000000..049550c75 --- /dev/null +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java @@ -0,0 +1,421 @@ +package trick.trickify; + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; +import java.util.ArrayList; + +public class TrickifyFrame +{ + private String defaultDirectory; + + private JFrame mainFrame; + private int mainFrameWidth = 1000; + private int mainFrameHeight = 600; + + private JPanel mainPanel; + private DirSelect src_dirs; + private DirSelect trick_home_dirs; + private DirSelect build_path_dirs; + private DirSelect trickify_path_dirs; + private DirSelect source_make_dirs; + private DirSelect log_dirs; + private LabeledTextField name_field; + private LabeledTextField trickify_args_field; + private LabeledTextField source_make_args_field; + private int fields_x = 50; + private int fields_y = 0; + private int fields_offset = 50; + + private JCheckBox full_build_box; + private JCheckBox no_clean_obj_box; + private JCheckBox no_clean_src_box; + private JCheckBox no_clean_s_source_box; + private JCheckBox debug_box; + private JComboBox build_type_box; + private int checkbox_x = 200; + private int checkbox_y = 0; + private int checkbox_width = 250; + private int checkbox_offset = 20; + + private JButton runButton; + private JButton exportButton; + + public ArrayList<String> getTrickifyCmd() + { + ArrayList<String> cmdLine = new ArrayList<String>(); + cmdLine.add("trick-ify"); + + String src_dirs_txt = src_dirs.getDirs().trim(); + if(!src_dirs_txt.equals("")) + { + cmdLine.add("-d"); + cmdLine.add(src_dirs_txt); + } + + String trick_home_dirs_txt = trick_home_dirs.getDirs().trim(); + if(!trick_home_dirs_txt.equals("")) + { + cmdLine.add("--trick_home"); + cmdLine.add(trick_home_dirs_txt); + } + + String trickify_path_dirs_txt = trickify_path_dirs.getDirs().trim(); + if(!trickify_path_dirs_txt.equals("")) + { + cmdLine.add("--trickify_make"); + cmdLine.add(trickify_path_dirs_txt); + } + + String trickify_args_field_txt = trickify_args_field.getText().trim(); + if(!trickify_args_field_txt.equals("")) + { + cmdLine.add("--trickify_args"); + cmdLine.add(trickify_args_field_txt); + } + + String source_make_dirs_txt = source_make_dirs.getDirs().trim(); + if(!source_make_dirs_txt.equals("")) + { + cmdLine.add("--source_make"); + cmdLine.add(source_make_dirs_txt); + } + + String source_make_args_field_txt = source_make_args_field.getText().trim(); + if(!source_make_args_field_txt.equals("")) + { + cmdLine.add("--source_make_args"); + cmdLine.add(source_make_args_field_txt); + } + + String lib_name = ""; + String build_path_dirs_txt = build_path_dirs.getDirs().trim(); + if(!build_path_dirs_txt.equals("")) + { + lib_name = build_path_dirs_txt; + } + + String name_field_txt = name_field.getText().trim(); + if(!name_field_txt.equals("")) + { + if(!lib_name.equals("")) + { + lib_name += System.getProperty("file.separator") + name_field_txt; + } + else + { + lib_name = name_field_txt; + } + cmdLine.add("-n"); + cmdLine.add(lib_name); + } + + if(!(full_build_box.isSelected())) + { + cmdLine.add("--no_source"); + } + + if(no_clean_obj_box.isSelected()) + { + cmdLine.add("--no_clean_obj_list"); + } + + if(no_clean_src_box.isSelected()) + { + cmdLine.add("--no_clean_src_list"); + } + + if(no_clean_s_source_box.isSelected()) + { + cmdLine.add("--no_clean_src_list"); + } + + if(debug_box.isSelected()) + { + cmdLine.add("-v"); + } + + if(build_type_box.getSelectedItem().equals("Object")) + { + cmdLine.add("-b"); + cmdLine.add("o"); + } + else if(build_type_box.getSelectedItem().equals("Shared")) + { + cmdLine.add("-b"); + cmdLine.add("so"); + } + else if(build_type_box.getSelectedItem().equals("Static")) + { + cmdLine.add("-b"); + cmdLine.add("a"); + } + + return cmdLine; + } + + private void update_checkbox_pos() + { + if(checkbox_x >= mainFrameWidth/2) + { + checkbox_y += checkbox_offset; + } + checkbox_x = mainFrameWidth - checkbox_width - checkbox_x; + } + + void trickify() + { + ArrayList<String> cmd = getTrickifyCmd(); + String[] cmdLine = new String[cmd.size()]; + cmdLine = cmd.toArray(cmdLine); + System.out.println("Executing: " + String.join(" ", cmd)); + try + { + Process process = Runtime.getRuntime().exec(cmdLine); + StringBuilder output = new StringBuilder(); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) + { + output.append(line + "\n"); + } + + String log_dirs_path = log_dirs.getDirs().trim(); + PrintWriter logfile = new PrintWriter(log_dirs_path + System.getProperty("file.separator") + "trickify.log", "UTF-8"); + logfile.println(output); + logfile.close(); + + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + TrickifyFrame() + { + String s = System.getProperty("file.separator"); + + mainFrame = new JFrame(); + + mainPanel = new JPanel(); + mainFrame.setTitle("Trickify"); + mainPanel.setBounds(0, 0, mainFrameWidth, mainFrameHeight); + mainPanel.setPreferredSize(new Dimension(mainFrameWidth, mainFrameHeight)); + mainPanel.setBackground(Color.lightGray); + mainPanel.setLayout(null); + + int fields_relative_offset = fields_y; + + src_dirs = new DirSelect(); + src_dirs.setLabel("Source Directories"); + src_dirs.setButtonText("Choose"); + src_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + src_dirs.allowMultiple(true); + src_dirs.setToolTipText("Directories to build trickified library from."); + src_dirs.addToPanel(mainPanel); + + trick_home_dirs = new DirSelect(); + trick_home_dirs.setLabel("Trick Home Directory"); + trick_home_dirs.setDirs(System.getenv("TRICK_HOME")); + trick_home_dirs.setButtonText("Choose"); + trick_home_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + trick_home_dirs.allowMultiple(false); + trick_home_dirs.setToolTipText("Trick directory to use."); + trick_home_dirs.addToPanel(mainPanel); + + trickify_path_dirs = new DirSelect(); + trickify_path_dirs.setLabel("Trickify Makefile"); + trickify_path_dirs.setDirs(System.getenv("TRICK_HOME") + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk"); + trickify_path_dirs.setButtonText("Choose"); + trickify_path_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + trickify_path_dirs.allowMultiple(false); + trickify_path_dirs.selectFile(true); + trickify_path_dirs.setToolTipText("trickify.mk to use. Defaults to your $TRICK_HOME/share/trick/makefiles/trickify.mk"); + trickify_path_dirs.addToPanel(mainPanel); + + trickify_args_field = new LabeledTextField(); + trickify_args_field.setLabel("Trickify Args"); + trickify_args_field.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + trickify_args_field.setToolTipText("Arguments to provide to trickify.mk make call"); + trickify_args_field.addToPanel(mainPanel); + + source_make_dirs = new DirSelect(); + source_make_dirs.setLabel("Source Make"); + source_make_dirs.setButtonText("Choose"); + source_make_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + source_make_dirs.allowMultiple(false); + source_make_dirs.selectFile(true); + source_make_dirs.setToolTipText("Make file to use for building source files. If none provdided just uses generic g++/gcc calls."); + source_make_dirs.addToPanel(mainPanel); + + source_make_args_field = new LabeledTextField(); + source_make_args_field.setLabel("Source Args"); + source_make_args_field.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + source_make_args_field.setToolTipText("Arguments to provide to the above make file."); + source_make_args_field.addToPanel(mainPanel); + + build_path_dirs = new DirSelect(); + build_path_dirs.setLabel("Build Path"); + build_path_dirs.setDirs(System.getProperty("user.dir")); + build_path_dirs.setButtonText("Choose"); + build_path_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + build_path_dirs.allowMultiple(false); + build_path_dirs.setToolTipText("Where to drop the library."); + build_path_dirs.addToPanel(mainPanel); + + name_field = new LabeledTextField(); + name_field.setLabel("Library Name"); + name_field.setText("TrickifiedLibrary"); + name_field.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + name_field.setToolTipText("Library name (doesn't need extension)."); + name_field.addToPanel(mainPanel); + + log_dirs = new DirSelect(); + log_dirs.setLabel("Trickify Log"); + log_dirs.setDirs(System.getProperty("user.dir")); + log_dirs.setButtonText("Choose"); + log_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + log_dirs.allowMultiple(false); + trickify_path_dirs.selectFile(false); + log_dirs.setToolTipText("Where to drop the log file."); + log_dirs.addToPanel(mainPanel); + + int checkbox_relative_offset = 0; + checkbox_y = fields_relative_offset; + + full_build_box = new JCheckBox(" Full library build"); + full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + full_build_box.setBackground(mainPanel.getBackground()); + full_build_box.setToolTipText("Full build includes swig files, icg files, and source files. Disabling excludes source files."); + full_build_box.setSelected(true); + update_checkbox_pos(); + mainPanel.add(full_build_box); + + no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh"); + no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + no_clean_s_source_box.setBackground(mainPanel.getBackground()); + no_clean_s_source_box.setToolTipText("Trickify automatically generates an S_source.hh for the build process. Can disable rebuilding if you wish to use a manually created file."); + update_checkbox_pos(); + mainPanel.add(no_clean_s_source_box); + + debug_box = new JCheckBox(" Debug info"); + debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + debug_box.setBackground(mainPanel.getBackground()); + update_checkbox_pos(); + mainPanel.add(debug_box); + + no_clean_src_box = new JCheckBox(" Don't rebuild source file list"); + no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + no_clean_src_box.setBackground(mainPanel.getBackground()); + no_clean_src_box.setToolTipText("Source file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file."); + update_checkbox_pos(); + mainPanel.add(no_clean_src_box); + + String options[] = { "Object", "Shared", "Static" }; + build_type_box = new JComboBox(options); + build_type_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, 200, 20); + update_checkbox_pos(); + mainPanel.add(build_type_box); + + no_clean_obj_box = new JCheckBox(" Don't rebuild object file list"); + no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); + no_clean_obj_box.setBackground(mainPanel.getBackground()); + no_clean_obj_box.setToolTipText("Object file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file."); + update_checkbox_pos(); + mainPanel.add(no_clean_obj_box); + + runButton = new JButton(); + runButton.setBounds(250, mainFrameHeight-30, 150, 20); + runButton.setText("Trickify"); + runButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + if(System.getProperty("user.name").charAt(0) == 'j') + { + String pw = "Java is inferior to Perl"; + String err = "Error! Try Again"; + + JFrame pwFrame = new JFrame(); + pwFrame.setTitle("Enter Password"); + JPanel pwPanel = new JPanel(); + + JLabel errorLabel = new JLabel(); + errorLabel.setForeground(Color.RED); + errorLabel.setText(err); + errorLabel.setVisible(false); + pwPanel.add(errorLabel); + + JTextField pwField = new JTextField(); + pwField.setPreferredSize(new Dimension(300, 20)); + pwField.setMaximumSize(pwField.getPreferredSize()); + pwPanel.add(pwField); + + JButton pwButton = new JButton(); + pwButton.setText("Enter"); + pwField.setMaximumSize(pwField.getPreferredSize()); + pwButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + String txt = pwField.getText().trim(); + if(txt.equals(pw)) + { + pwFrame.dispose(); + trickify(); + } + else + { + errorLabel.setText(errorLabel.getText() + "!"); + errorLabel.setVisible(true); + } + } + } ); + pwPanel.add(pwButton); + + pwFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + pwFrame.setResizable(false); + pwPanel.setLayout(new GridLayout(3, 1)); + pwFrame.add(pwPanel); + pwFrame.pack(); + pwFrame.setVisible(true); + } + else + { + trickify(); + } + } + } ); + mainPanel.add(runButton); + + exportButton = new JButton(); + exportButton.setBounds(600, mainFrameHeight-30, 150, 20); + exportButton.setText("Export"); + exportButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + System.out.println(String.join(" ", getTrickifyCmd())); + } + } ); + mainPanel.add(exportButton); + + mainFrame.add(mainPanel); + mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + mainFrame.pack(); + mainFrame.setResizable(false); + mainFrame.setVisible(true); + } +} From 7f4c78decd05ddd5f48c0d0a8fe32a5e76523dfc Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 3 Feb 2025 14:10:22 -0600 Subject: [PATCH 28/40] Test fix --- .../trickified_project/trickified/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index 9cb1723e2..4838b1b5c 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v --source_args -fPIC + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v --source_make_args -fPIC clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) From 9b44b2dfb5906d81f5f70b8889a4bc54ce06110a Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Mon, 3 Feb 2025 15:55:09 -0600 Subject: [PATCH 29/40] CI --- share/trick/makefiles/trickify.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 056fa8568..86aa146f8 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -136,6 +136,7 @@ all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) .ONESHELL: $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) + echo TRICKIFICATION STEP A @while read -r line ; do \ export FILES="$$FILES $$line" ; \ done < $(PY_LINK_LIST) @@ -154,6 +155,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ] ; then \ ar rcs $@ $ $$FILES ; \ fi + echo TRICKIFICATION STEP B $(dir $(TRICKIFY_OBJECT_NAME)) $(BUILD_DIR) $(dir $(TRICKIFY_PYTHON_DIR)) .trick: @mkdir -p $@ From c2f32a2ad6d65cf93b570cb830b4e85f1e806ac9 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 4 Feb 2025 09:32:01 -0600 Subject: [PATCH 30/40] CI --- share/trick/makefiles/trickify.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 86aa146f8..92a3498c4 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -140,14 +140,17 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT @while read -r line ; do \ export FILES="$$FILES $$line" ; \ done < $(PY_LINK_LIST) + echo TRICKIFICATION STEP B @while read -r line ; do \ export FILES="$$FILES $$line" ; \ done < $(IO_LINK_LIST) + echo TRICKIFICATION STEP C @if [ "$(FULL_TRICKIFY_BUILD)" = "1" ] ; then \ while read -r line ; do \ export FILES="$$FILES $$line" ; \ done < $(OBJ_LINK_LIST) fi + echo TRICKIFICATION STEP D @if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ] ; then \ $(LD) $(LD_PARTIAL) -o $@ $$FILES ; \ elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ] ; then \ @@ -155,7 +158,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ] ; then \ ar rcs $@ $ $$FILES ; \ fi - echo TRICKIFICATION STEP B + echo TRICKIFICATION STEP E $(dir $(TRICKIFY_OBJECT_NAME)) $(BUILD_DIR) $(dir $(TRICKIFY_PYTHON_DIR)) .trick: @mkdir -p $@ From 011c4e7060311f1ee25f7dc032c0f1c5525f11ea Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Tue, 4 Feb 2025 10:33:23 -0600 Subject: [PATCH 31/40] CI --- share/trick/makefiles/trickify.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 92a3498c4..6be2dd4ba 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -148,7 +148,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT @if [ "$(FULL_TRICKIFY_BUILD)" = "1" ] ; then \ while read -r line ; do \ export FILES="$$FILES $$line" ; \ - done < $(OBJ_LINK_LIST) + done < $(OBJ_LINK_LIST) ; \ fi echo TRICKIFICATION STEP D @if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ] ; then \ From 22c3ddd313bc5120077cd6aaf1660c01ab65fbb6 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Thu, 13 Feb 2025 10:47:34 -0600 Subject: [PATCH 32/40] S_overrides fix --- bin/trick-ify | 13 +++-- share/trick/makefiles/trickify.mk | 6 ++- share/trick/pymods/trick/build_trickify.py | 12 +++-- .../trick/build_trickify_S_source_hh.py | 6 +-- .../pymods/trick/build_trickify_obj_list.py | 6 +-- .../pymods/trick/build_trickify_src_list.py | 6 +-- .../java/trick/trickify/TrickifyFrame.java | 49 ++++++++++++++----- 7 files changed, 62 insertions(+), 36 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index 514ce6ef9..83b7e98ac 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -21,6 +21,7 @@ $no_source_build = 0 ; # Arg $no_clean_obj = 0 ; # Don't rebuild trickify_obj_list $no_clean_src = 0 ; # Don't rebuild trickify_src_list $no_clean_s_source = 0 ; # Don't rebuild S_source.hh +$s_overrides = "" ; # Directory containing S_override make files GetOptions ( @@ -38,7 +39,8 @@ GetOptions "n=s" => \$name, # Set the library name "b=s" => \$build_type, # Set library build type "v" => \$debug, # Verbose, print debug info - "trick_home=s" => \$trick_home # Set trick home directory + "trick_home=s" => \$trick_home, # Set trick home directory + "s_overrides=s" => \$s_overrides # Directory containing S_override make files ) ; $full_build = !$no_source_build ; @@ -83,6 +85,7 @@ $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" ; +$ENV{'TRICKIFY_S_OVERRIDES'} = "$s_overrides" ; if ( $build_type eq o ) { $ENV{'TRICKIFY_BUILD_TYPE'} = PLO ; @@ -134,15 +137,15 @@ if ($full_build) foreach $src (@src_files) { $file = $src ; - if($file =~ /\S*(\Q.c\E)$/) + if($file =~ /\S\w*(\Q.c\E)$/) { $file =~ s/\Q.c\E$// ; - $cmd = "gcc $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ; + $cmd = "gcc $source_make_args -I $trick_home -I $trick_home" . "/include -I $header_dir -c $src -o $file.o" ; } else { - $file =~ s/\Q.cpp\E$// ; - $cmd = "g++ $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ; + $file =~ s/\Q.\E\w*$// ; + $cmd = "g++ $source_make_args -I $trick_home -I $trick_home" . "/include -I $header_dir -c $src -o $file.o" ; } if($debug) { diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 6be2dd4ba..839f8a2de 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -88,6 +88,10 @@ # For more information, see: # https://nasa.github.io/trick/documentation/building_a_simulation/Trickified-Project-Libraries +MY_HOME := $(dir $(lastword $(MAKEFILE_LIST))) + +include $(TRICKIFY_S_OVERRIDES) + ifndef TRICKIFY_CXX_FLAGS $(error TRICKIFY_CXX_FLAGS must be set) endif @@ -100,7 +104,7 @@ TRICKIFY_OBJECT_NAME ?= trickified.o TRICKIFY_PYTHON_DIR ?= python TRICKIFY_PYTHON_DIR := $(abspath $(TRICKIFY_PYTHON_DIR)) -include $(dir $(lastword $(MAKEFILE_LIST)))Makefile.common +include $(MY_HOME)Makefile.common BUILD_DIR := $(dir $(MAKE_OUT)) PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list diff --git a/share/trick/pymods/trick/build_trickify.py b/share/trick/pymods/trick/build_trickify.py index 897b5932c..7d809864e 100644 --- a/share/trick/pymods/trick/build_trickify.py +++ b/share/trick/pymods/trick/build_trickify.py @@ -1,13 +1,17 @@ from pathlib import Path import os -def_header_ext = ["h", "hh", "hpp", "H", "hxx", "h++"] +def_header_ext = [".h", "hh", "hpp", "H", "hxx", "h++"] def_src_ext = ["cpp", "c"] def find_files_by_extension(loc, ext): - path = Path(loc) - files = list(path.rglob(f'*.{ext}')) - return files + file_list = [] + for root, dirs, files in os.walk(loc): + for f in files: + if f.endswith(ext): + file_list.append(os.path.join(root, f)) + print(file_list) + return file_list def build_S_source(): loc = "" diff --git a/share/trick/pymods/trick/build_trickify_S_source_hh.py b/share/trick/pymods/trick/build_trickify_S_source_hh.py index fb9316b61..a92b59768 100644 --- a/share/trick/pymods/trick/build_trickify_S_source_hh.py +++ b/share/trick/pymods/trick/build_trickify_S_source_hh.py @@ -1,10 +1,6 @@ import os -path = "" -if "TRICK_HOME" in os.environ: - path = os.getenv("TRICK_HOME") -path += "/share/trick/pymods/trick/build_trickify.py" - +path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py" exec(open(path).read()) build_S_source() diff --git a/share/trick/pymods/trick/build_trickify_obj_list.py b/share/trick/pymods/trick/build_trickify_obj_list.py index 6a878671b..4066cf2e2 100644 --- a/share/trick/pymods/trick/build_trickify_obj_list.py +++ b/share/trick/pymods/trick/build_trickify_obj_list.py @@ -1,10 +1,6 @@ import os -path = "" -if "TRICK_HOME" in os.environ: - path = os.getenv("TRICK_HOME") -path += "/share/trick/pymods/trick/build_trickify.py" - +path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py" exec(open(path).read()) build_obj_list() diff --git a/share/trick/pymods/trick/build_trickify_src_list.py b/share/trick/pymods/trick/build_trickify_src_list.py index f79903be1..d3a9466ae 100644 --- a/share/trick/pymods/trick/build_trickify_src_list.py +++ b/share/trick/pymods/trick/build_trickify_src_list.py @@ -1,10 +1,6 @@ import os -path = "" -if "TRICK_HOME" in os.environ: - path = os.getenv("TRICK_HOME") -path += "/share/trick/pymods/trick/build_trickify.py" - +path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py" exec(open(path).read()) build_src_list() diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java b/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java index 049550c75..63c002cb1 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java @@ -9,7 +9,7 @@ public class TrickifyFrame { - private String defaultDirectory; + private String trick_home; private JFrame mainFrame; private int mainFrameWidth = 1000; @@ -22,6 +22,7 @@ public class TrickifyFrame private DirSelect trickify_path_dirs; private DirSelect source_make_dirs; private DirSelect log_dirs; + private DirSelect s_overrides_dirs; private LabeledTextField name_field; private LabeledTextField trickify_args_field; private LabeledTextField source_make_args_field; @@ -43,16 +44,23 @@ public class TrickifyFrame private JButton runButton; private JButton exportButton; - public ArrayList<String> getTrickifyCmd() + public ArrayList<String> getTrickifyCmd(boolean useQuotes) { ArrayList<String> cmdLine = new ArrayList<String>(); - cmdLine.add("trick-ify"); + cmdLine.add(trick_home + "/bin/trick-ify"); String src_dirs_txt = src_dirs.getDirs().trim(); if(!src_dirs_txt.equals("")) { cmdLine.add("-d"); - cmdLine.add(src_dirs_txt); + if(useQuotes) + { + cmdLine.add("\"" + src_dirs_txt + "\""); + } + else + { + cmdLine.add(src_dirs_txt); + } } String trick_home_dirs_txt = trick_home_dirs.getDirs().trim(); @@ -96,6 +104,13 @@ public ArrayList<String> getTrickifyCmd() { lib_name = build_path_dirs_txt; } + + String s_overrides_dirs_txt = s_overrides_dirs.getDirs().trim(); + if(!s_overrides_dirs_txt.equals("")) + { + cmdLine.add("--s_overrides"); + cmdLine.add(s_overrides_dirs_txt); + } String name_field_txt = name_field.getText().trim(); if(!name_field_txt.equals("")) @@ -167,7 +182,7 @@ private void update_checkbox_pos() void trickify() { - ArrayList<String> cmd = getTrickifyCmd(); + ArrayList<String> cmd = getTrickifyCmd(false); String[] cmdLine = new String[cmd.size()]; cmdLine = cmd.toArray(cmdLine); System.out.println("Executing: " + String.join(" ", cmd)); @@ -186,7 +201,8 @@ void trickify() PrintWriter logfile = new PrintWriter(log_dirs_path + System.getProperty("file.separator") + "trickify.log", "UTF-8"); logfile.println(output); logfile.close(); - + + System.out.println("Your technological distinctiveness has been trickified."); } catch (IOException e) { @@ -197,6 +213,7 @@ void trickify() TrickifyFrame() { String s = System.getProperty("file.separator"); + trick_home = new File(TrickifyFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath(); mainFrame = new JFrame(); @@ -220,7 +237,7 @@ void trickify() trick_home_dirs = new DirSelect(); trick_home_dirs.setLabel("Trick Home Directory"); - trick_home_dirs.setDirs(System.getenv("TRICK_HOME")); + trick_home_dirs.setDirs(trick_home); trick_home_dirs.setButtonText("Choose"); trick_home_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; @@ -230,7 +247,7 @@ void trickify() trickify_path_dirs = new DirSelect(); trickify_path_dirs.setLabel("Trickify Makefile"); - trickify_path_dirs.setDirs(System.getenv("TRICK_HOME") + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk"); + trickify_path_dirs.setDirs(trick_home + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk"); trickify_path_dirs.setButtonText("Choose"); trickify_path_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; @@ -263,6 +280,16 @@ void trickify() source_make_args_field.setToolTipText("Arguments to provide to the above make file."); source_make_args_field.addToPanel(mainPanel); + s_overrides_dirs = new DirSelect(); + s_overrides_dirs.setLabel("S_overrides"); + s_overrides_dirs.setButtonText("Choose"); + s_overrides_dirs.setPosition(fields_x, fields_relative_offset); + fields_relative_offset += fields_offset; + s_overrides_dirs.allowMultiple(false); + s_overrides_dirs.selectFile(true); + s_overrides_dirs.setToolTipText("S_overrides to incorporate"); + s_overrides_dirs.addToPanel(mainPanel); + build_path_dirs = new DirSelect(); build_path_dirs.setLabel("Build Path"); build_path_dirs.setDirs(System.getProperty("user.dir")); @@ -288,7 +315,7 @@ void trickify() log_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; log_dirs.allowMultiple(false); - trickify_path_dirs.selectFile(false); + log_dirs.selectFile(false); log_dirs.setToolTipText("Where to drop the log file."); log_dirs.addToPanel(mainPanel); @@ -402,12 +429,12 @@ public void actionPerformed(ActionEvent e) exportButton = new JButton(); exportButton.setBounds(600, mainFrameHeight-30, 150, 20); - exportButton.setText("Export"); + exportButton.setText("Print"); exportButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - System.out.println(String.join(" ", getTrickifyCmd())); + System.out.println(String.join(" ", getTrickifyCmd(true))); } } ); mainPanel.add(exportButton); From 15a61e160a73d492d3f23126b7906b03092c45de Mon Sep 17 00:00:00 2001 From: Hong Chen <hchen99@users.noreply.github.com> Date: Wed, 19 Feb 2025 14:40:53 -0600 Subject: [PATCH 33/40] Updated to support the dylib build type for Mac and implement a compatible approach for ONESHELL that works with both make 3.81 and 4.2.1. Updated to support the dylib build type for Mac and implement a compatible approach for ONESHELL that works with both make 3.81 and 4.2.1. --- bin/trick-ify | 4 +- share/trick/makefiles/trickify.mk | 49 +++++++++---------- .../trickified_project/trickified/Makefile | 2 +- .../trickified/myproject_vars.mk | 11 ++++- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index 83b7e98ac..e778e5cb6 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -46,7 +46,7 @@ GetOptions $full_build = !$no_source_build ; $val = $ARGV[$argnum + 1] ; -if( !(($build_type eq "o") or ($build_type eq "a") or ($build_type eq "so")) ) +if( !(($build_type eq "o") or ($build_type eq "a") or ($build_type eq "so") or ($build_type eq "dylib")) ) { print "Invalid build type {$build_type}, valid build types are {o, a, so}\n" ; exit 1 ; @@ -94,7 +94,7 @@ elsif ( $build_type eq a ) { $ENV{'TRICKIFY_BUILD_TYPE'} = STATIC ; } -elsif ( $build_type eq so ) +elsif ( $build_type eq so || $build_type eq dylib ) { $ENV{'TRICKIFY_BUILD_TYPE'} = SHARED ; } diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 839f8a2de..f5432dd0a 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -130,7 +130,8 @@ UNAME := $(shell uname) ifeq ($(UNAME), Linux) SHARED_OPTIONS := -fPIC else ifeq ($(UNAME), Darwin) - SHARED_OPTIONS := -fPIC -lgcov + SHARED_OPTIONS := -fPIC + LD_OPTIONS := -Wl,-install_name,$(abspath $(TRICKIFY_OBJECT_NAME)) else SHARED_OPTIONS := endif @@ -138,31 +139,29 @@ endif .PHONY: all all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) -.ONESHELL: $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) - echo TRICKIFICATION STEP A - @while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(PY_LINK_LIST) - echo TRICKIFICATION STEP B - @while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(IO_LINK_LIST) - echo TRICKIFICATION STEP C - @if [ "$(FULL_TRICKIFY_BUILD)" = "1" ] ; then \ - while read -r line ; do \ - export FILES="$$FILES $$line" ; \ - done < $(OBJ_LINK_LIST) ; \ - fi - echo TRICKIFICATION STEP D - @if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ] ; then \ - $(LD) $(LD_PARTIAL) -o $@ $$FILES ; \ - elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ] ; then \ - $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) -o $@ $$FILES ; \ - elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ] ; then \ - ar rcs $@ $ $$FILES ; \ - fi - echo TRICKIFICATION STEP E + @echo TRICKIFICATION + @sh -c '\ + FILES=""; \ + while IFS= read -r line; do \ + FILES="$$FILES $$line"; \ + done < $(PY_LINK_LIST); \ + while IFS= read -r line; do \ + FILES="$$FILES $$line"; \ + done < $(IO_LINK_LIST); \ + if [ "$(FULL_TRICKIFY_BUILD)" = "1" ]; then \ + while IFS= read -r line; do \ + FILES="$$FILES $$line"; \ + done < $(OBJ_LINK_LIST); \ + fi; \ + if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ]; then \ + $(LD) $(LD_PARTIAL) -o $@ $$FILES; \ + elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ]; then \ + $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) $(LD_OPTIONS) -o $@ $$FILES; \ + elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ]; then \ + ar rcs $@ $$FILES; \ + fi; \ + ' $(dir $(TRICKIFY_OBJECT_NAME)) $(BUILD_DIR) $(dir $(TRICKIFY_PYTHON_DIR)) .trick: @mkdir -p $@ diff --git a/test/SIM_trickified_shared/trickified_project/trickified/Makefile b/test/SIM_trickified_shared/trickified_project/trickified/Makefile index 4838b1b5c..ce6a7d4c6 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/Makefile +++ b/test/SIM_trickified_shared/trickified_project/trickified/Makefile @@ -4,7 +4,7 @@ include $(LOCAL_DIR)/myproject_vars.mk all: @echo MAKE LOCAL_DIR $(LOCAL_DIR) - @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b so -n trickified_myproject -v --source_make_args -fPIC + @$(TRICK_HOME)/bin/trick-ify -d "$(LOCAL_DIR)/../include_bar $(LOCAL_DIR)/../include_foo" -b $(BUILD_TYPE) -n trickified_myproject -v --source_make_args -fPIC clean: @rm -rf build python trick $(TRICKIFY_OBJECT_NAME) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk index 8f3a556b0..52c8f6d16 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -11,7 +11,14 @@ MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include_bar -I$(MYPROJECT_HOME)/include TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) -export TRICKIFY_OBJECT_NAME := trickified_myproject.so +BUILD_TYPE := so +UNAME := $(shell uname) +ifeq ($(UNAME),Darwin) + BUILD_TYPE := dylib +endif + +export TRICKIFY_OBJECT_NAME := trickified_myproject.$(BUILD_TYPE) + MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME) # Tell Trick the headers and source at this location are part of a @@ -25,4 +32,4 @@ TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified # Link in the Trickified object -TRICK_LDFLAGS += $(MYPROJECT_TRICK) +TRICK_LDFLAGS += $(MYPROJECT_TRICK) -Wl,-rpath,$(MYPROJECT_HOME)/trickified From 94b5f2f594345f97bc05a48f9bf9540c2d8a4a5a Mon Sep 17 00:00:00 2001 From: Hong Chen <hchen99@users.noreply.github.com> Date: Thu, 20 Feb 2025 08:51:30 -0600 Subject: [PATCH 34/40] Removed unnecessary -rpath as -install_name has the correct path during compilation. Removed unnecessary -rpath as -install_name has the correct path during compilation. --- .../trickified_project/trickified/myproject_vars.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk index 52c8f6d16..ea715a9a1 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -32,4 +32,4 @@ TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified # Link in the Trickified object -TRICK_LDFLAGS += $(MYPROJECT_TRICK) -Wl,-rpath,$(MYPROJECT_HOME)/trickified +TRICK_LDFLAGS += $(MYPROJECT_TRICK) From 6c8f19844b87933935ca3a5d17814d5507c89137 Mon Sep 17 00:00:00 2001 From: Hong Chen <hchen99@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:54:25 -0600 Subject: [PATCH 35/40] Added USER_ADDITIONAL_OPTIONS for user to provide additional options to build trickified lib. Added USER_ADDITIONAL_OPTIONS for user to provide additional options to build trickified lib. Updated SIM_trickified_shared to use this option to pass in code coverage options to satisfy trick code coverage ci. --- share/trick/makefiles/trickify.mk | 2 +- .../trickified_project/trickified/myproject_vars.mk | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index f5432dd0a..806dbf821 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -157,7 +157,7 @@ $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT if [ "$(TRICKIFY_BUILD_TYPE)" = "PLO" ]; then \ $(LD) $(LD_PARTIAL) -o $@ $$FILES; \ elif [ "$(TRICKIFY_BUILD_TYPE)" = "SHARED" ]; then \ - $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) $(LD_OPTIONS) -o $@ $$FILES; \ + $(TRICK_CXX) $(SHARED_LIB_OPT) $(SHARED_OPTIONS) $(LD_OPTIONS) $(USER_ADDITIONAL_OPTIONS) -o $@ $$FILES; \ elif [ "$(TRICKIFY_BUILD_TYPE)" = "STATIC" ]; then \ ar rcs $@ $$FILES; \ fi; \ diff --git a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk index ea715a9a1..dab1a92dc 100644 --- a/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified_shared/trickified_project/trickified/myproject_vars.mk @@ -33,3 +33,6 @@ TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified # Link in the Trickified object TRICK_LDFLAGS += $(MYPROJECT_TRICK) + +# Link in code coverage libraries for Trick code coverage CI +export USER_ADDITIONAL_OPTIONS := -fprofile-arcs -ftest-coverage -O0 \ No newline at end of file From 389a3e09e7864a9ffa37cdd2f40aacae7a99a516 Mon Sep 17 00:00:00 2001 From: Pherring04 <pherring04@gmail.com> Date: Wed, 26 Feb 2025 12:14:47 -0600 Subject: [PATCH 36/40] Checkpoint --- share/trick/pymods/trick/build_trickify.py | 1 - .../main/java/trick/trickify/DirSelect.java | 55 +-- .../java/trick/trickify/LabeledTextField.java | 32 +- .../trick/trickify/TrickifyApplication.java | 51 ++- ...{TrickifyFrame.java => TrickifyPanel.java} | 363 ++++++++++++++---- .../resources/TrickifyApplication.properties | 21 + 6 files changed, 365 insertions(+), 158 deletions(-) rename trick_source/java/src/main/java/trick/trickify/{TrickifyFrame.java => TrickifyPanel.java} (59%) create mode 100644 trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties diff --git a/share/trick/pymods/trick/build_trickify.py b/share/trick/pymods/trick/build_trickify.py index 7d809864e..cfc8dd0d5 100644 --- a/share/trick/pymods/trick/build_trickify.py +++ b/share/trick/pymods/trick/build_trickify.py @@ -10,7 +10,6 @@ def find_files_by_extension(loc, ext): for f in files: if f.endswith(ext): file_list.append(os.path.join(root, f)) - print(file_list) return file_list def build_S_source(): diff --git a/trick_source/java/src/main/java/trick/trickify/DirSelect.java b/trick_source/java/src/main/java/trick/trickify/DirSelect.java index fe8ba9790..c503c50a5 100644 --- a/trick_source/java/src/main/java/trick/trickify/DirSelect.java +++ b/trick_source/java/src/main/java/trick/trickify/DirSelect.java @@ -4,7 +4,7 @@ import java.io.*; import javax.swing.*; -public class DirSelect +public class DirSelect extends JPanel { private int pos_x = 0; private int pos_y = 0; @@ -31,34 +31,6 @@ public class DirSelect private boolean multiDir = false; - private void updatePosition() - { - label_pos_x = pos_x; - label_pos_y = pos_y; - - textfield_pos_x = pos_x; - textfield_pos_y = pos_y + label_height; - - button_pos_x = textfield_pos_x + textfield_width; - button_pos_y = textfield_pos_y; - } - - private void redraw() - { - label.setBounds(label_pos_x, label_pos_y, label_width, label_height); - textfield.setBounds(textfield_pos_x, textfield_pos_y, textfield_width, textfield_height); - button.setBounds(button_pos_x, button_pos_y, button_width, button_height); - } - - public void setPosition(int x, int y) - { - pos_x = x; - pos_y = y; - - updatePosition(); - redraw(); - } - public void setLabel(String text) { label.setText(text); @@ -74,20 +46,6 @@ public void setButtonText(String text) button.setText(text); } - public void addToPanel(JPanel panel) - { - panel.add(label); - panel.add(textfield); - panel.add(button); - } - - public void addToFrame(JFrame frame) - { - frame.add(label); - frame.add(textfield); - frame.add(button); - } - public void allowMultiple(boolean b) { browser.setMultiSelectionEnabled(b); @@ -106,12 +64,12 @@ public void selectFile(boolean b) } } - public String getDirs() + public String getText() { return textfield.getText(); } - void setDirs(String txt) + void setText(String txt) { textfield.setText(txt); } @@ -134,8 +92,6 @@ public DirSelect() browser.setCurrentDirectory(new File(System.getProperty("user.dir"))); browser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - setPosition(pos_x, pos_y); - button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -163,6 +119,11 @@ public void actionPerformed(ActionEvent e) } } } ); + + + add(label); + add(textfield); + add(button); } } diff --git a/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java b/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java index ea77503f0..7610d515e 100644 --- a/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java +++ b/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java @@ -4,7 +4,7 @@ import java.io.*; import javax.swing.*; -public class LabeledTextField +public class LabeledTextField extends JPanel { private int pos_x = 0; private int pos_y = 0; @@ -21,30 +21,6 @@ public class LabeledTextField private int textfield_width = 800; private int textfield_height = 20; - private void updatePosition() - { - label_pos_x = pos_x; - label_pos_y = pos_y; - - textfield_pos_x = pos_x; - textfield_pos_y = pos_y + label_height; - } - - private void redraw() - { - label.setBounds(label_pos_x, label_pos_y, label_width, label_height); - textfield.setBounds(textfield_pos_x, textfield_pos_y, textfield_width, textfield_height); - } - - public void setPosition(int x, int y) - { - pos_x = x; - pos_y = y; - - updatePosition(); - redraw(); - } - public void setLabel(String text) { label.setText(text); @@ -55,11 +31,8 @@ public void setToolTipText(String tip) textfield.setToolTipText(tip); } - public void addToPanel(JPanel panel) { - panel.add(label); - panel.add(textfield); } public void addToFrame(JFrame frame) @@ -88,7 +61,8 @@ public LabeledTextField() textfield_width = 800; textfield_height = 20; - setPosition(pos_x, pos_y); + add(label); + add(textfield); } } diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java index 7304e54c5..313d9ceda 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java @@ -1,10 +1,57 @@ package trick.trickify; -public class TrickifyApplication +import javax.swing.*; +import org.jdesktop.application.View; +import trick.common.TrickApplication; + +public class TrickifyApplication extends TrickApplication { + private TrickifyPanel panel; + public static void main(String[] args) { - TrickifyFrame trickifyFrame = new TrickifyFrame(); + launch(TrickifyApplication.class, args); + } + + @Override + protected JComponent createMainPanel() + { + if(panel == null) + { + panel = new TrickifyPanel(); + } + return panel; } + @Override + protected void initialize(String[] args) + { + super.initialize(args); + trickProperties.setProperty("Application.title", "Trickify"); + } + + @Override + protected void startup() + { + super.startup(); + createMainPanel(); + + panel.load_properties(trickProperties); + + // Build the GUI. + View view = getMainView(); + view.setComponent(panel); + view.setMenuBar(panel.getMenuBar()); + + // Display the GUI. + show(view); + } + + @Override + protected void shutdown() + { + panel.save_properties(trickProperties); + + super.shutdown(); + } } diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java b/trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java similarity index 59% rename from trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java rename to trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java index 63c002cb1..f838ecd04 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java @@ -6,12 +6,28 @@ import javax.swing.*; import javax.swing.border.*; import java.util.ArrayList; +import java.io.FileWriter; +import java.io.FileReader; +import java.util.Properties; -public class TrickifyFrame +import org.jdesktop.application.Action; + +public class TrickifyPanel extends JPanel { + private JPanel fieldPanel; + private JPanel boxPanel; + private JPanel buttonPanel; + + private JMenuBar menu = new JMenuBar(); + private JMenu fileMenu = new JMenu(); + private JMenuItem saveMenuItem = new JMenuItem(); + private JMenuItem loadMenuItem = new JMenuItem(); + + private JMenu viewMenu = new JMenu(); + private JMenuItem defaultViewMenuItem = new JMenuItem(); + private String trick_home; - private JFrame mainFrame; private int mainFrameWidth = 1000; private int mainFrameHeight = 600; @@ -26,6 +42,16 @@ public class TrickifyFrame private LabeledTextField name_field; private LabeledTextField trickify_args_field; private LabeledTextField source_make_args_field; + private String src_dirs_config = "SOURCE_DIRS"; + private String trick_home_config = "TRICK_HOME"; + private String build_path_config = "BUILD_PATH"; + private String trickify_path_config = "TRICKIFY_PATH"; + private String source_make_config = "SOURCE_MAKE"; + private String log_config = "LOG"; + private String s_overrides_config = "S_OVERRIDES"; + private String name_config = "NAME"; + private String trickify_args_config = "TRICKIFY_ARGS"; + private String source_make_args_config = "SOURCE_MAKE_ARGS"; private int fields_x = 50; private int fields_y = 0; private int fields_offset = 50; @@ -36,6 +62,12 @@ public class TrickifyFrame private JCheckBox no_clean_s_source_box; private JCheckBox debug_box; private JComboBox build_type_box; + private String full_build_config = "FULL_BUILD"; + private String no_clean_obj_config = "NO_CLEAN_OBJ"; + private String no_clean_src_config = "NO_CLEAN_SRC"; + private String no_clean_s_source_config = "NO_CLEAN_S_SOURCE"; + private String debug_config = "DEBUG"; + private String build_type_config = "BUILD_TYPE"; private int checkbox_x = 200; private int checkbox_y = 0; private int checkbox_width = 250; @@ -44,12 +76,17 @@ public class TrickifyFrame private JButton runButton; private JButton exportButton; + public JMenuBar getMenuBar() + { + return menu; + } + public ArrayList<String> getTrickifyCmd(boolean useQuotes) { ArrayList<String> cmdLine = new ArrayList<String>(); cmdLine.add(trick_home + "/bin/trick-ify"); - String src_dirs_txt = src_dirs.getDirs().trim(); + String src_dirs_txt = src_dirs.getText().trim(); if(!src_dirs_txt.equals("")) { cmdLine.add("-d"); @@ -63,14 +100,14 @@ public ArrayList<String> getTrickifyCmd(boolean useQuotes) } } - String trick_home_dirs_txt = trick_home_dirs.getDirs().trim(); + String trick_home_dirs_txt = trick_home_dirs.getText().trim(); if(!trick_home_dirs_txt.equals("")) { cmdLine.add("--trick_home"); cmdLine.add(trick_home_dirs_txt); } - String trickify_path_dirs_txt = trickify_path_dirs.getDirs().trim(); + String trickify_path_dirs_txt = trickify_path_dirs.getText().trim(); if(!trickify_path_dirs_txt.equals("")) { cmdLine.add("--trickify_make"); @@ -84,7 +121,7 @@ public ArrayList<String> getTrickifyCmd(boolean useQuotes) cmdLine.add(trickify_args_field_txt); } - String source_make_dirs_txt = source_make_dirs.getDirs().trim(); + String source_make_dirs_txt = source_make_dirs.getText().trim(); if(!source_make_dirs_txt.equals("")) { cmdLine.add("--source_make"); @@ -99,13 +136,13 @@ public ArrayList<String> getTrickifyCmd(boolean useQuotes) } String lib_name = ""; - String build_path_dirs_txt = build_path_dirs.getDirs().trim(); + String build_path_dirs_txt = build_path_dirs.getText().trim(); if(!build_path_dirs_txt.equals("")) { lib_name = build_path_dirs_txt; } - String s_overrides_dirs_txt = s_overrides_dirs.getDirs().trim(); + String s_overrides_dirs_txt = s_overrides_dirs.getText().trim(); if(!s_overrides_dirs_txt.equals("")) { cmdLine.add("--s_overrides"); @@ -144,7 +181,7 @@ public ArrayList<String> getTrickifyCmd(boolean useQuotes) if(no_clean_s_source_box.isSelected()) { - cmdLine.add("--no_clean_src_list"); + cmdLine.add("--no_clean_s_srouce"); } if(debug_box.isSelected()) @@ -171,16 +208,7 @@ else if(build_type_box.getSelectedItem().equals("Static")) return cmdLine; } - private void update_checkbox_pos() - { - if(checkbox_x >= mainFrameWidth/2) - { - checkbox_y += checkbox_offset; - } - checkbox_x = mainFrameWidth - checkbox_width - checkbox_x; - } - - void trickify() + private void trickify() { ArrayList<String> cmd = getTrickifyCmd(false); String[] cmdLine = new String[cmd.size()]; @@ -197,7 +225,7 @@ void trickify() output.append(line + "\n"); } - String log_dirs_path = log_dirs.getDirs().trim(); + String log_dirs_path = log_dirs.getText().trim(); PrintWriter logfile = new PrintWriter(log_dirs_path + System.getProperty("file.separator") + "trickify.log", "UTF-8"); logfile.println(output); logfile.close(); @@ -210,158 +238,339 @@ void trickify() } } - TrickifyFrame() + public void save_properties(Properties p) + { + p.setProperty(src_dirs_config, src_dirs.getText().trim()); + p.setProperty(trick_home_config, trick_home_dirs.getText().trim()); + p.setProperty(trickify_path_config, trickify_path_dirs.getText().trim()); + p.setProperty(trickify_args_config, trickify_args_field.getText().trim()); + p.setProperty(source_make_config, source_make_dirs.getText().trim()); + p.setProperty(source_make_args_config, source_make_args_field.getText().trim()); + p.setProperty(build_path_config, build_path_dirs.getText().trim()); + p.setProperty(s_overrides_config, s_overrides_dirs.getText().trim()); + p.setProperty(name_config, name_field.getText().trim()); + p.setProperty(full_build_config, Boolean.toString(full_build_box.isSelected())); + p.setProperty(no_clean_obj_config, Boolean.toString(no_clean_obj_box.isSelected())); + p.setProperty(no_clean_src_config, Boolean.toString(no_clean_src_box.isSelected())); + p.setProperty(no_clean_s_source_config, Boolean.toString(no_clean_s_source_box.isSelected())); + p.setProperty(debug_config, Boolean.toString(debug_box.isSelected())); + p.setProperty(build_type_config, build_type_box.getSelectedItem().toString()); + } + + public void load_properties(Properties p) + { + String prop = null; + + if((prop = p.getProperty(src_dirs_config)) != null) + { + src_dirs.setText(prop); + } + prop = null; + + if((prop = p.getProperty(trick_home_config)) != null) + { + trick_home_dirs.setText(prop); + } + prop = null; + + if((prop = p.getProperty(trickify_path_config)) != null) + { + trickify_path_dirs.setText(prop); + } + prop = null; + + if((prop = p.getProperty(trickify_args_config)) != null) + { + trickify_args_field.setText(prop); + } + prop = null; + + if((prop = p.getProperty(source_make_config)) != null) + { + source_make_dirs.setText(prop); + } + prop = null; + + if((prop = p.getProperty(source_make_args_config)) != null) + { + source_make_args_field.setText(prop); + } + prop = null; + + if((prop = p.getProperty(build_path_config)) != null) + { + build_path_dirs.setText(prop); + } + prop = null; + + if((prop = p.getProperty(s_overrides_config)) != null) + { + s_overrides_dirs.setText(prop); + } + prop = null; + + if((prop = p.getProperty(name_config)) != null) + { + name_field.setText(prop); + } + prop = null; + + if((prop = p.getProperty(full_build_config)) != null) + { + if(prop.equals("true")) + { + full_build_box.setSelected(true); + } + else + { + full_build_box.setSelected(false); + } + } + prop = null; + + if((prop = p.getProperty(no_clean_obj_config)) != null) + { + if(prop.equals("true")) + { + no_clean_obj_box.setSelected(true); + } + else + { + no_clean_obj_box.setSelected(false); + } + } + prop = null; + + if((prop = p.getProperty(no_clean_src_config)) != null) + { + if(prop.equals("true")) + { + no_clean_src_box.setSelected(true); + } + else + { + no_clean_src_box.setSelected(false); + } + } + prop = null; + + if((prop = p.getProperty(no_clean_s_source_config)) != null) + { + if(prop.equals("true")) + { + no_clean_s_source_box.setSelected(true); + } + else + { + no_clean_s_source_box.setSelected(false); + } + } + prop = null; + + if((prop = p.getProperty(debug_config)) != null) + { + if(prop.equals("true")) + { + debug_box.setSelected(true); + } + else + { + debug_box.setSelected(false); + } + } + prop = null; + + if((prop = p.getProperty(build_type_config)) != null) + { + build_type_box.setSelectedItem(prop); + } + } + + private void set_default() { String s = System.getProperty("file.separator"); - trick_home = new File(TrickifyFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath(); - mainFrame = new JFrame(); + src_dirs.setText(""); + trick_home_dirs.setText(trick_home); + trickify_path_dirs.setText(trick_home + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk"); + trickify_args_field.setText(""); + source_make_dirs.setText(""); + source_make_args_field.setText(""); + s_overrides_dirs.setText(""); + build_path_dirs.setText(System.getProperty("user.dir")); + name_field.setText("TrickifiedLibrary"); + log_dirs.setText(System.getProperty("user.dir")); + full_build_box.setSelected(false); + no_clean_obj_box.setSelected(false); + no_clean_src_box.setSelected(false); + no_clean_s_source_box.setSelected(false); + debug_box.setSelected(false); + build_type_box.setSelectedItem("PLO"); + } + + @Action + public void restoreDefaultView(ActionEvent e) + { + setSize(mainFrameWidth, mainFrameHeight); + } + + TrickifyPanel() + { - mainPanel = new JPanel(); - mainFrame.setTitle("Trickify"); - mainPanel.setBounds(0, 0, mainFrameWidth, mainFrameHeight); - mainPanel.setPreferredSize(new Dimension(mainFrameWidth, mainFrameHeight)); - mainPanel.setBackground(Color.lightGray); - mainPanel.setLayout(null); + String s = System.getProperty("file.separator"); + trick_home = new File(TrickifyPanel.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath(); + + setBounds(0, 0, mainFrameWidth, mainFrameHeight); + setPreferredSize(new Dimension(mainFrameWidth, mainFrameHeight)); + setBackground(Color.lightGray); + setLayout(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridwidth = GridBagConstraints.REMAINDER; + + fieldPanel = new JPanel(); + fieldPanel.setPreferredSize(new Dimension(mainFrameWidth, 400)); + fieldPanel.setLayout(new GridLayout(10, 1)); + add(fieldPanel, gbc); + + boxPanel = new JPanel(); + boxPanel.setLayout(new GridLayout(3, 2)); + add(boxPanel, gbc); + + buttonPanel = new JPanel(); + add(buttonPanel, gbc); + + //Build File Menu + fileMenu.setName("trickify.fileMenu"); + saveMenuItem.setName("trickify.saveMenuItem"); + fileMenu.add(saveMenuItem); + loadMenuItem.setName("trickify.loadMenuItem"); + fileMenu.add(loadMenuItem); + menu.add(fileMenu); + + //Build View Menu + viewMenu.setName("trickify.viewMenu"); + defaultViewMenuItem.setName("trickify.defaultViewMenuItem"); + viewMenu.add(defaultViewMenuItem); + menu.add(viewMenu); int fields_relative_offset = fields_y; src_dirs = new DirSelect(); src_dirs.setLabel("Source Directories"); src_dirs.setButtonText("Choose"); - src_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; src_dirs.allowMultiple(true); src_dirs.setToolTipText("Directories to build trickified library from."); - src_dirs.addToPanel(mainPanel); + fieldPanel.add(src_dirs); trick_home_dirs = new DirSelect(); trick_home_dirs.setLabel("Trick Home Directory"); - trick_home_dirs.setDirs(trick_home); trick_home_dirs.setButtonText("Choose"); - trick_home_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; trick_home_dirs.allowMultiple(false); trick_home_dirs.setToolTipText("Trick directory to use."); - trick_home_dirs.addToPanel(mainPanel); + fieldPanel.add(trick_home_dirs); trickify_path_dirs = new DirSelect(); trickify_path_dirs.setLabel("Trickify Makefile"); - trickify_path_dirs.setDirs(trick_home + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk"); trickify_path_dirs.setButtonText("Choose"); - trickify_path_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; trickify_path_dirs.allowMultiple(false); trickify_path_dirs.selectFile(true); trickify_path_dirs.setToolTipText("trickify.mk to use. Defaults to your $TRICK_HOME/share/trick/makefiles/trickify.mk"); - trickify_path_dirs.addToPanel(mainPanel); + fieldPanel.add(trickify_path_dirs); trickify_args_field = new LabeledTextField(); trickify_args_field.setLabel("Trickify Args"); - trickify_args_field.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; trickify_args_field.setToolTipText("Arguments to provide to trickify.mk make call"); - trickify_args_field.addToPanel(mainPanel); + fieldPanel.add(trickify_args_field); source_make_dirs = new DirSelect(); source_make_dirs.setLabel("Source Make"); source_make_dirs.setButtonText("Choose"); - source_make_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; source_make_dirs.allowMultiple(false); source_make_dirs.selectFile(true); source_make_dirs.setToolTipText("Make file to use for building source files. If none provdided just uses generic g++/gcc calls."); - source_make_dirs.addToPanel(mainPanel); + fieldPanel.add(source_make_dirs); source_make_args_field = new LabeledTextField(); source_make_args_field.setLabel("Source Args"); - source_make_args_field.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; source_make_args_field.setToolTipText("Arguments to provide to the above make file."); - source_make_args_field.addToPanel(mainPanel); + fieldPanel.add(source_make_args_field); s_overrides_dirs = new DirSelect(); s_overrides_dirs.setLabel("S_overrides"); s_overrides_dirs.setButtonText("Choose"); - s_overrides_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; s_overrides_dirs.allowMultiple(false); s_overrides_dirs.selectFile(true); s_overrides_dirs.setToolTipText("S_overrides to incorporate"); - s_overrides_dirs.addToPanel(mainPanel); + fieldPanel.add(s_overrides_dirs); build_path_dirs = new DirSelect(); build_path_dirs.setLabel("Build Path"); - build_path_dirs.setDirs(System.getProperty("user.dir")); build_path_dirs.setButtonText("Choose"); - build_path_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; build_path_dirs.allowMultiple(false); build_path_dirs.setToolTipText("Where to drop the library."); - build_path_dirs.addToPanel(mainPanel); + fieldPanel.add(build_path_dirs); name_field = new LabeledTextField(); name_field.setLabel("Library Name"); - name_field.setText("TrickifiedLibrary"); - name_field.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; name_field.setToolTipText("Library name (doesn't need extension)."); - name_field.addToPanel(mainPanel); + fieldPanel.add(name_field); log_dirs = new DirSelect(); log_dirs.setLabel("Trickify Log"); - log_dirs.setDirs(System.getProperty("user.dir")); log_dirs.setButtonText("Choose"); - log_dirs.setPosition(fields_x, fields_relative_offset); fields_relative_offset += fields_offset; log_dirs.allowMultiple(false); log_dirs.selectFile(false); log_dirs.setToolTipText("Where to drop the log file."); - log_dirs.addToPanel(mainPanel); + fieldPanel.add(log_dirs); int checkbox_relative_offset = 0; checkbox_y = fields_relative_offset; full_build_box = new JCheckBox(" Full library build"); full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - full_build_box.setBackground(mainPanel.getBackground()); + full_build_box.setBackground(getBackground()); full_build_box.setToolTipText("Full build includes swig files, icg files, and source files. Disabling excludes source files."); - full_build_box.setSelected(true); - update_checkbox_pos(); - mainPanel.add(full_build_box); + boxPanel.add(full_build_box); no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh"); no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - no_clean_s_source_box.setBackground(mainPanel.getBackground()); + no_clean_s_source_box.setBackground(getBackground()); no_clean_s_source_box.setToolTipText("Trickify automatically generates an S_source.hh for the build process. Can disable rebuilding if you wish to use a manually created file."); - update_checkbox_pos(); - mainPanel.add(no_clean_s_source_box); + boxPanel.add(no_clean_s_source_box); debug_box = new JCheckBox(" Debug info"); debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - debug_box.setBackground(mainPanel.getBackground()); - update_checkbox_pos(); - mainPanel.add(debug_box); + debug_box.setBackground(getBackground()); + boxPanel.add(debug_box); no_clean_src_box = new JCheckBox(" Don't rebuild source file list"); no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - no_clean_src_box.setBackground(mainPanel.getBackground()); + no_clean_src_box.setBackground(getBackground()); no_clean_src_box.setToolTipText("Source file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file."); - update_checkbox_pos(); - mainPanel.add(no_clean_src_box); + boxPanel.add(no_clean_src_box); String options[] = { "Object", "Shared", "Static" }; build_type_box = new JComboBox(options); build_type_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, 200, 20); - update_checkbox_pos(); - mainPanel.add(build_type_box); + boxPanel.add(build_type_box); no_clean_obj_box = new JCheckBox(" Don't rebuild object file list"); no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - no_clean_obj_box.setBackground(mainPanel.getBackground()); + no_clean_obj_box.setBackground(getBackground()); no_clean_obj_box.setToolTipText("Object file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file."); - update_checkbox_pos(); - mainPanel.add(no_clean_obj_box); + boxPanel.add(no_clean_obj_box); + + set_default(); runButton = new JButton(); runButton.setBounds(250, mainFrameHeight-30, 150, 20); @@ -425,7 +634,7 @@ public void actionPerformed(ActionEvent e) } } } ); - mainPanel.add(runButton); + buttonPanel.add(runButton); exportButton = new JButton(); exportButton.setBounds(600, mainFrameHeight-30, 150, 20); @@ -437,12 +646,8 @@ public void actionPerformed(ActionEvent e) System.out.println(String.join(" ", getTrickifyCmd(true))); } } ); - mainPanel.add(exportButton); + buttonPanel.add(exportButton); - mainFrame.add(mainPanel); - mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - mainFrame.pack(); - mainFrame.setResizable(false); - mainFrame.setVisible(true); + setVisible(true); } } diff --git a/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties b/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties new file mode 100644 index 000000000..1b2b0969f --- /dev/null +++ b/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties @@ -0,0 +1,21 @@ +# Application global resources + +Application.name = Trickify +Application.title = Trickify +Application.version = 1.0 +Application.vendor = NASA +Application.homepage = http://trick.jsc.nasa.gov +Application.description = Java application to Trickify simulation libraries +Application.vendorId = Sun +Application.id = ${Application.name} +Application.lookAndFeel = system + +trickify.fileMenu.text = File +trickify.saveMenuItem.text = Save Config +trickify.loadMenuItem.text = Load Config +trickify.viewMenu.text = View +trickify.defaultViewMenuItem.text = Restore Default + +TestItem2.text = TESTING + +default_event_directory = ./Modified_data From 28bfdf6d25a2ce97e2a405e4f693cf42ee508d90 Mon Sep 17 00:00:00 2001 From: plherrin <pherring04@gmail.com> Date: Tue, 18 Mar 2025 12:03:48 -0500 Subject: [PATCH 37/40] Lots of changes --- bin/trick-ify | 105 ++++--- libexec/trick/make_makefile_swig | 6 +- share/trick/makefiles/trickify.mk | 1 - .../Interface_Code_Gen/PrintAttributes.cpp | 6 +- .../main/java/trick/trickify/DirSelect.java | 63 +--- .../java/trick/trickify/LabeledTextField.java | 42 +-- .../trick/trickify/TrickifyApplication.java | 6 +- .../java/trick/trickify/TrickifyPanel.java | 295 +++++++++++------- .../resources/TrickifyApplication.properties | 1 + 9 files changed, 284 insertions(+), 241 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index e778e5cb6..0c1f1160a 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -1,27 +1,29 @@ #!/usr/bin/perl use Getopt::Long; +use strict ; -$my_path = $0 ; +my $my_path = $0 ; $my_path =~ s/trick-ify// ; -$dirs = "" ; # If set, use for both source and header files -$source_dir = "" ; # Base path to build source 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 -$full_build = 1 ; # Whether to build only ICG/Swig artifacts or entire source -$name = "trickified" ; # Name of the library -$build_type = "o" ; # Type of library to be built (o, a , so) -$debug = 0 ; # Debug info flag -$trick_home = $my_path . ".." ; # Trick directory to use for building -$no_source_build = 0 ; # Arg to disable building source files -$no_clean_obj = 0 ; # Don't rebuild trickify_obj_list -$no_clean_src = 0 ; # Don't rebuild trickify_src_list -$no_clean_s_source = 0 ; # Don't rebuild S_source.hh -$s_overrides = "" ; # Directory containing S_override make files +my $dirs = "" ; # If set, use for both source and header files +my $source_dir = "" ; # Base path to build source from +my $header_dir = "" ; # Base path to find header files +my $source_make_call = "" ; # Make call to build object files +my $source_make_args = "" ; # Args to pass into default object make +my $trickify_make_args = "" ; # Arguments to pass into the trickify make +my $trickify_make_path = "$my_path../share/trick/makefiles/trickify.mk" ; # Path of the trickify make file +my $full_build = 1 ; # Whether to build only ICG/Swig artifacts or entire source +my $name = "trickified" ; # Name of the library +my $build_type = "o" ; # Type of library to be built (o, a , so) +my $debug = 0 ; # Debug info flag +my $trick_home = $my_path . ".." ; # Trick directory to use for building +my $no_source_build = 0 ; # Arg to disable building source files +my $no_clean_obj = 0 ; # Don't rebuild trickify_obj_list +my $no_clean_src = 0 ; # Don't rebuild trickify_src_list +my $no_clean_s_source = 0 ; # Don't rebuild S_source.hh +my $s_overrides = "" ; # Directory containing S_override make files +my $include = "" ; # Directories to include when building source/ICG/SWIG files GetOptions ( @@ -40,12 +42,12 @@ GetOptions "b=s" => \$build_type, # Set library build type "v" => \$debug, # Verbose, print debug info "trick_home=s" => \$trick_home, # Set trick home directory - "s_overrides=s" => \$s_overrides # Directory containing S_override make files + "s_overrides=s" => \$s_overrides, # Directory containing S_override make files + "include=s" => \$include # Directory containing S_override make files ) ; $full_build = !$no_source_build ; -$val = $ARGV[$argnum + 1] ; if( !(($build_type eq "o") or ($build_type eq "a") or ($build_type eq "so") or ($build_type eq "dylib")) ) { print "Invalid build type {$build_type}, valid build types are {o, a, so}\n" ; @@ -70,40 +72,55 @@ if($source_dir eq "" and $full_build) exit 1 ; } +#Build list of includes for compilation. Includes: +# trick_home +# trick_home/include +# Header directory +# Additional user provided directories +#$include_arg = "-I $trick_home -I $trick_home" . "/include -I $header_dir "; +my $include_arg = ""; +my @incl_dirs = split ' ', $include ; +foreach my $dir (@incl_dirs) +{ + $include_arg .= "-I" . $dir . " " ; +} + #Set Environment Variables if ($full_build) { $ENV{'FULL_TRICKIFY_BUILD'} = "1" ; } my @src_dirs = split ' ', $source_dir ; -$source_dir_arg = "" ; -foreach $dir (@src_dirs) +my $source_dir_args = "" ; +foreach my $dir (@src_dirs) { - $source_dir_arg .= "-I " . $dir . " "; + $source_dir_args .= "-I" . $dir . " " ; } -$ENV{'TRICKIFY_CXX_FLAGS'} = "$source_dir_args -I $trick_home" . "/include" ; +$ENV{'TRICKIFY_CXX_FLAGS'} = "$source_dir_args -I$trick_home -I$trick_home" . "/include $include_arg" ; $ENV{'TRICKIFY_OBJECT_NAME'} = "$name.$build_type" ; $ENV{'TRICKIFY_SOURCE'} = "$source_dir" ; $ENV{'TRICKIFY_HEADER'} = "$header_dir" ; $ENV{'TRICKIFY_S_OVERRIDES'} = "$s_overrides" ; -if ( $build_type eq o ) +$ENV{'TRICKIFY_INCLUDES'} = "$include_arg" ; +#$ENV{'TRICKIFY_INCLUDES'} = "$include" ; +if ( $build_type eq "o" ) { - $ENV{'TRICKIFY_BUILD_TYPE'} = PLO ; + $ENV{'TRICKIFY_BUILD_TYPE'} = "PLO" ; } -elsif ( $build_type eq a ) +elsif ( $build_type eq "a" ) { - $ENV{'TRICKIFY_BUILD_TYPE'} = STATIC ; + $ENV{'TRICKIFY_BUILD_TYPE'} = "STATIC" ; } -elsif ( $build_type eq so || $build_type eq dylib ) +elsif ( $build_type eq "so" || $build_type eq "dylib" ) { - $ENV{'TRICKIFY_BUILD_TYPE'} = SHARED ; + $ENV{'TRICKIFY_BUILD_TYPE'} = "SHARED" ; } #Build the S_source.hh if (!$no_clean_s_source) { print "Building S_source.hh\n" ; - $make_s_source = "python3 $my_path../share/trick/pymods/trick/build_trickify_S_source_hh.py" ; + my $make_s_source = "python3 $my_path../share/trick/pymods/trick/build_trickify_S_source_hh.py" ; print(`$make_s_source`) ; } @@ -111,15 +128,15 @@ if (!$no_clean_s_source) if (!$no_clean_src and $full_build) { print "Building trickify_src_list\n" ; - $make_src_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_src_list.py" ; + my $make_src_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_src_list.py" ; print(`$make_src_list`) ; } #Build array of source files +my @src_files ; if ($full_build) { - open ($fh, "trickify_src_list") or die "Could not open trickify_src_list: $!" ; - @src_files ; + open (my $fh, "trickify_src_list") or die "Could not open trickify_src_list: $!" ; while (my $line = <$fh>) { chomp $line ; @@ -134,18 +151,19 @@ if ($full_build) print "Building object files\n" ; if($source_make_call eq "") { - foreach $src (@src_files) + foreach my $src (@src_files) { - $file = $src ; + my $cmd = "" ; + my $file = $src ; if($file =~ /\S\w*(\Q.c\E)$/) { $file =~ s/\Q.c\E$// ; - $cmd = "gcc $source_make_args -I $trick_home -I $trick_home" . "/include -I $header_dir -c $src -o $file.o" ; + $cmd = "gcc $source_make_args $ENV{'TRICKIFY_CXX_FLAGS'} -c $src -o $file.o" ; } else { $file =~ s/\Q.\E\w*$// ; - $cmd = "g++ $source_make_args -I $trick_home -I $trick_home" . "/include -I $header_dir -c $src -o $file.o" ; + $cmd = "g++ $source_make_args $ENV{'TRICKIFY_CXX_FLAGS'} -c $src -o $file.o" ; } if($debug) { @@ -164,26 +182,27 @@ if ($full_build) if(!$no_clean_obj and $full_build) { print "Building trickify_obj_list\n" ; - $make_obj_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_obj_list.py" ; + my $make_obj_list = "python3 $my_path../share/trick/pymods/trick/build_trickify_obj_list.py" ; print(`$make_obj_list`) ; } #Build trickify call print "Begin Trickification...\n" ; -$trickify_make_call = "make $trickify_make_args -f $trickify_make_path" ; +my $trickify_make_call = "make $trickify_make_args -f $trickify_make_path" ; print(`$trickify_make_call`) ; if($debug) { print "TRICKIFY BUILD INFO: header_dir = $header_dir - source_dir = $source_dir_arg + source_dir = $source_dir_args source_make_call = $source_make_call trickify_make_args = $trickify_make_args trickify_make_path = $trickify_make_path - build_s_source = $build_s_source + build_s_source = $no_clean_s_source full_build = $full_build name = $name build_type = $build_type - trick_home = $trick_home\n" ; + trick_home = $trick_home + TRICKIFY_CXX_FLAGS = $ENV{'TRICKIFY_CXX_FLAGS'}\n" ; } diff --git a/libexec/trick/make_makefile_swig b/libexec/trick/make_makefile_swig index c182f2483..5d6fd4851 100755 --- a/libexec/trick/make_makefile_swig +++ b/libexec/trick/make_makefile_swig @@ -31,7 +31,7 @@ sub read_files_to_process() { (my $cc = gte("TRICK_CC")) =~ s/\n// ; # Prepend -I to each include path before we pass them to the compiler - my @include_paths = map("-I$_", (get_include_paths(), "$ENV{TRICK_HOME}/include", "$ENV{TRICK_HOME}/include/trick/compat", "$ENV{TRICK_HOME}/trick_source", "../include")) ; + my @include_paths = map("-I$_", (get_include_paths(), "$ENV{TRICK_HOME}", "$ENV{TRICK_HOME}/include", "$ENV{TRICK_HOME}/include/trick/compat", "$ENV{TRICK_HOME}/trick_source", "../include")) ; my @defines = (get_defines(), "-DTRICK_VER=$year", "-DSWIG", "-std=c++11") ; # get the list of header files from the compiler @@ -181,7 +181,9 @@ SWIG_I =" ; (my $swig_file = $file) =~ s/(\.[^.]*)?$/_py/ ; print MAKEFILE " \\\n build$swig_file.i" ; print PY_LINK_LIST "build$swig_file.o\n" ; - print TRICKIFY_PY_LINK_LIST "build$swig_file.o\n" ; + if ( !($swig_file =~ /(.*)S_source_py$/) ) { + print TRICKIFY_PY_LINK_LIST "build$swig_file.o\n" ; + } } print MAKEFILE " diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 806dbf821..3d262f572 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -140,7 +140,6 @@ endif all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) - @echo TRICKIFICATION @sh -c '\ FILES=""; \ while IFS= read -r line; do \ diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 5d443163a..9aa72ab0c 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -495,7 +495,11 @@ void PrintAttributes::printIOMakefile() { size_t found ; found = (*mit).second.find_last_of(".") ; io_link_list << (*mit).second.substr(0,found) << ".o" << std::endl ; - trickify_io_link_list << (*mit).second.substr(0,found) << ".o" << std::endl ; + std::string ssrc = (*mit).second.substr(0,found) ; + if(ssrc.substr( ssrc.length()-11, ssrc.length()) != "io_S_source" ) + { + trickify_io_link_list << (*mit).second.substr(0,found) << ".o" << std::endl ; + } ICG_processed << (*mit).first << std::endl ; } makefile_ICG.close() ; diff --git a/trick_source/java/src/main/java/trick/trickify/DirSelect.java b/trick_source/java/src/main/java/trick/trickify/DirSelect.java index c503c50a5..2b37ab318 100644 --- a/trick_source/java/src/main/java/trick/trickify/DirSelect.java +++ b/trick_source/java/src/main/java/trick/trickify/DirSelect.java @@ -1,46 +1,20 @@ package trick.trickify; +import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; -public class DirSelect extends JPanel +public class DirSelect extends LabeledTextField { - private int pos_x = 0; - private int pos_y = 0; - - private JLabel label; - private int label_pos_x = pos_x; - private int label_pos_y = pos_y; - private int label_width = 200; - private int label_height = 20; - - private JTextField textfield; - private int textfield_pos_x = pos_x; - private int textfield_pos_y = pos_y + label_height; - private int textfield_width = 800; - private int textfield_height = 20; - private JButton button; - private int button_pos_x = textfield_pos_x + textfield_width; - private int button_pos_y = textfield_pos_y; - private int button_width = 100; - private int button_height = 20; + public final static int button_width = 100; + public final static int button_height = 20; private JFileChooser browser; private boolean multiDir = false; - public void setLabel(String text) - { - label.setText(text); - } - - public void setToolTipText(String tip) - { - textfield.setToolTipText(tip); - } - public void setButtonText(String text) { button.setText(text); @@ -64,29 +38,11 @@ public void selectFile(boolean b) } } - public String getText() - { - return textfield.getText(); - } - - void setText(String txt) - { - textfield.setText(txt); - } - public DirSelect() { - label = new JLabel(); - label_width = 200; - label_height = 20; - - textfield = new JTextField(); - textfield_width = 800; - textfield_height = 20; - + super(); + button = new JButton(); - button_width = 100; - button_height = 20; browser = new JFileChooser(); browser.setCurrentDirectory(new File(System.getProperty("user.dir"))); @@ -109,7 +65,7 @@ public void actionPerformed(ActionEvent e) { filename += files[i].getAbsolutePath() + " "; } - textfield.setText(textfield.getText() + filename); + textfield.setText(textfield.getText().trim() + " " + filename.trim()); } else { @@ -120,10 +76,7 @@ public void actionPerformed(ActionEvent e) } } ); - - add(label); - add(textfield); - add(button); + add(button, BorderLayout.EAST); } } diff --git a/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java b/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java index 7610d515e..4cf7ea4be 100644 --- a/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java +++ b/trick_source/java/src/main/java/trick/trickify/LabeledTextField.java @@ -1,25 +1,19 @@ package trick.trickify; +import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; public class LabeledTextField extends JPanel { - private int pos_x = 0; - private int pos_y = 0; + protected JLabel label; + public final static int label_width = 200; + public final static int label_height = 20; - private JLabel label; - private int label_pos_x = pos_x; - private int label_pos_y = pos_y; - private int label_width = 200; - private int label_height = 20; - - private JTextField textfield; - private int textfield_pos_x = pos_x; - private int textfield_pos_y = pos_y + label_height; - private int textfield_width = 800; - private int textfield_height = 20; + protected JTextField textfield; + public final static int textfield_width = 1000; + public final static int textfield_height = 20; public void setLabel(String text) { @@ -31,16 +25,6 @@ public void setToolTipText(String tip) textfield.setToolTipText(tip); } - public void addToPanel(JPanel panel) - { - } - - public void addToFrame(JFrame frame) - { - frame.add(label); - frame.add(textfield); - } - public String getText() { return textfield.getText(); @@ -53,16 +37,16 @@ void setText(String txt) public LabeledTextField() { + setLayout(new BorderLayout()); + label = new JLabel(); - label_width = 200; - label_height = 20; + label.setPreferredSize(new Dimension(label_width, label_height)); textfield = new JTextField(); - textfield_width = 800; - textfield_height = 20; + textfield.setPreferredSize(new Dimension(textfield_width, textfield_height)); - add(label); - add(textfield); + add(label, BorderLayout.NORTH); + add(textfield, BorderLayout.CENTER); } } diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java index 313d9ceda..5cf93702c 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyApplication.java @@ -18,7 +18,7 @@ protected JComponent createMainPanel() { if(panel == null) { - panel = new TrickifyPanel(); + panel = new TrickifyPanel(this); } return panel; } @@ -36,7 +36,7 @@ protected void startup() super.startup(); createMainPanel(); - panel.load_properties(trickProperties); + panel.load_properties(); // Build the GUI. View view = getMainView(); @@ -50,7 +50,7 @@ protected void startup() @Override protected void shutdown() { - panel.save_properties(trickProperties); + panel.save_properties(); super.shutdown(); } diff --git a/trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java b/trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java index f838ecd04..3ada381d4 100644 --- a/trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java +++ b/trick_source/java/src/main/java/trick/trickify/TrickifyPanel.java @@ -10,10 +10,14 @@ import java.io.FileReader; import java.util.Properties; +import trick.common.TrickApplication; import org.jdesktop.application.Action; public class TrickifyPanel extends JPanel { + private TrickApplication myApp; + private Properties trickProp; + private JPanel fieldPanel; private JPanel boxPanel; private JPanel buttonPanel; @@ -22,20 +26,22 @@ public class TrickifyPanel extends JPanel private JMenu fileMenu = new JMenu(); private JMenuItem saveMenuItem = new JMenuItem(); private JMenuItem loadMenuItem = new JMenuItem(); + private JMenuItem loadDefaultMenuItem = new JMenuItem(); private JMenu viewMenu = new JMenu(); private JMenuItem defaultViewMenuItem = new JMenuItem(); private String trick_home; - private int mainFrameWidth = 1000; - private int mainFrameHeight = 600; + private int mainFrameWidth = DirSelect.textfield_width + DirSelect.button_width; + private int mainFrameHeight = 800; private JPanel mainPanel; private DirSelect src_dirs; private DirSelect trick_home_dirs; private DirSelect build_path_dirs; private DirSelect trickify_path_dirs; + private DirSelect trickify_include_dirs; private DirSelect source_make_dirs; private DirSelect log_dirs; private DirSelect s_overrides_dirs; @@ -46,15 +52,13 @@ public class TrickifyPanel extends JPanel private String trick_home_config = "TRICK_HOME"; private String build_path_config = "BUILD_PATH"; private String trickify_path_config = "TRICKIFY_PATH"; + private String trickify_include_config = "TRICKIFY_INCLUDE"; private String source_make_config = "SOURCE_MAKE"; private String log_config = "LOG"; private String s_overrides_config = "S_OVERRIDES"; private String name_config = "NAME"; private String trickify_args_config = "TRICKIFY_ARGS"; private String source_make_args_config = "SOURCE_MAKE_ARGS"; - private int fields_x = 50; - private int fields_y = 0; - private int fields_offset = 50; private JCheckBox full_build_box; private JCheckBox no_clean_obj_box; @@ -68,10 +72,6 @@ public class TrickifyPanel extends JPanel private String no_clean_s_source_config = "NO_CLEAN_S_SOURCE"; private String debug_config = "DEBUG"; private String build_type_config = "BUILD_TYPE"; - private int checkbox_x = 200; - private int checkbox_y = 0; - private int checkbox_width = 250; - private int checkbox_offset = 20; private JButton runButton; private JButton exportButton; @@ -114,6 +114,20 @@ public ArrayList<String> getTrickifyCmd(boolean useQuotes) cmdLine.add(trickify_path_dirs_txt); } + String trickify_include_dirs_txt = trickify_include_dirs.getText().trim(); + if(!trickify_include_dirs_txt.equals("")) + { + cmdLine.add("--include"); + if(useQuotes) + { + cmdLine.add("\"" + trickify_include_dirs_txt + "\""); + } + else + { + cmdLine.add(trickify_include_dirs_txt); + } + } + String trickify_args_field_txt = trickify_args_field.getText().trim(); if(!trickify_args_field_txt.equals("")) { @@ -238,86 +252,104 @@ private void trickify() } } - public void save_properties(Properties p) + + public void save_properties() { - p.setProperty(src_dirs_config, src_dirs.getText().trim()); - p.setProperty(trick_home_config, trick_home_dirs.getText().trim()); - p.setProperty(trickify_path_config, trickify_path_dirs.getText().trim()); - p.setProperty(trickify_args_config, trickify_args_field.getText().trim()); - p.setProperty(source_make_config, source_make_dirs.getText().trim()); - p.setProperty(source_make_args_config, source_make_args_field.getText().trim()); - p.setProperty(build_path_config, build_path_dirs.getText().trim()); - p.setProperty(s_overrides_config, s_overrides_dirs.getText().trim()); - p.setProperty(name_config, name_field.getText().trim()); - p.setProperty(full_build_config, Boolean.toString(full_build_box.isSelected())); - p.setProperty(no_clean_obj_config, Boolean.toString(no_clean_obj_box.isSelected())); - p.setProperty(no_clean_src_config, Boolean.toString(no_clean_src_box.isSelected())); - p.setProperty(no_clean_s_source_config, Boolean.toString(no_clean_s_source_box.isSelected())); - p.setProperty(debug_config, Boolean.toString(debug_box.isSelected())); - p.setProperty(build_type_config, build_type_box.getSelectedItem().toString()); + save_properties(trickProp); } - public void load_properties(Properties p) + public void save_properties(Properties prop) { - String prop = null; + prop.setProperty(src_dirs_config, src_dirs.getText().trim()); + prop.setProperty(trick_home_config, trick_home_dirs.getText().trim()); + prop.setProperty(trickify_path_config, trickify_path_dirs.getText().trim()); + prop.setProperty(trickify_include_config, trickify_include_dirs.getText().trim()); + prop.setProperty(trickify_args_config, trickify_args_field.getText().trim()); + prop.setProperty(source_make_config, source_make_dirs.getText().trim()); + prop.setProperty(source_make_args_config, source_make_args_field.getText().trim()); + prop.setProperty(build_path_config, build_path_dirs.getText().trim()); + prop.setProperty(s_overrides_config, s_overrides_dirs.getText().trim()); + prop.setProperty(name_config, name_field.getText().trim()); + prop.setProperty(full_build_config, Boolean.toString(full_build_box.isSelected())); + prop.setProperty(no_clean_obj_config, Boolean.toString(no_clean_obj_box.isSelected())); + prop.setProperty(no_clean_src_config, Boolean.toString(no_clean_src_box.isSelected())); + prop.setProperty(no_clean_s_source_config, Boolean.toString(no_clean_s_source_box.isSelected())); + prop.setProperty(debug_config, Boolean.toString(debug_box.isSelected())); + prop.setProperty(build_type_config, build_type_box.getSelectedItem().toString()); + } - if((prop = p.getProperty(src_dirs_config)) != null) + public void load_properties() + { + load_properties(trickProp); + } + + public void load_properties(Properties prop) + { + String propText = null; + + if((propText = prop.getProperty(src_dirs_config)) != null) + { + src_dirs.setText(propText); + } + propText = null; + + if((propText = prop.getProperty(trick_home_config)) != null) { - src_dirs.setText(prop); + trick_home_dirs.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(trick_home_config)) != null) + if((propText = prop.getProperty(trickify_path_config)) != null) { - trick_home_dirs.setText(prop); + trickify_path_dirs.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(trickify_path_config)) != null) + if((propText = prop.getProperty(trickify_include_config)) != null) { - trickify_path_dirs.setText(prop); + trickify_include_dirs.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(trickify_args_config)) != null) + if((propText = prop.getProperty(trickify_args_config)) != null) { - trickify_args_field.setText(prop); + trickify_args_field.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(source_make_config)) != null) + if((propText = prop.getProperty(source_make_config)) != null) { - source_make_dirs.setText(prop); + source_make_dirs.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(source_make_args_config)) != null) + if((propText = prop.getProperty(source_make_args_config)) != null) { - source_make_args_field.setText(prop); + source_make_args_field.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(build_path_config)) != null) + if((propText = prop.getProperty(build_path_config)) != null) { - build_path_dirs.setText(prop); + build_path_dirs.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(s_overrides_config)) != null) + if((propText = prop.getProperty(s_overrides_config)) != null) { - s_overrides_dirs.setText(prop); + s_overrides_dirs.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(name_config)) != null) + if((propText = prop.getProperty(name_config)) != null) { - name_field.setText(prop); + name_field.setText(propText); } - prop = null; + propText = null; - if((prop = p.getProperty(full_build_config)) != null) + if((propText = prop.getProperty(full_build_config)) != null) { - if(prop.equals("true")) + if(propText.equals("true")) { full_build_box.setSelected(true); } @@ -326,11 +358,11 @@ public void load_properties(Properties p) full_build_box.setSelected(false); } } - prop = null; + propText = null; - if((prop = p.getProperty(no_clean_obj_config)) != null) + if((propText = prop.getProperty(no_clean_obj_config)) != null) { - if(prop.equals("true")) + if(propText.equals("true")) { no_clean_obj_box.setSelected(true); } @@ -339,11 +371,11 @@ public void load_properties(Properties p) no_clean_obj_box.setSelected(false); } } - prop = null; + propText = null; - if((prop = p.getProperty(no_clean_src_config)) != null) + if((propText = prop.getProperty(no_clean_src_config)) != null) { - if(prop.equals("true")) + if(propText.equals("true")) { no_clean_src_box.setSelected(true); } @@ -352,11 +384,11 @@ public void load_properties(Properties p) no_clean_src_box.setSelected(false); } } - prop = null; + propText = null; - if((prop = p.getProperty(no_clean_s_source_config)) != null) + if((propText = prop.getProperty(no_clean_s_source_config)) != null) { - if(prop.equals("true")) + if(propText.equals("true")) { no_clean_s_source_box.setSelected(true); } @@ -365,11 +397,11 @@ public void load_properties(Properties p) no_clean_s_source_box.setSelected(false); } } - prop = null; + propText = null; - if((prop = p.getProperty(debug_config)) != null) + if((propText = prop.getProperty(debug_config)) != null) { - if(prop.equals("true")) + if(propText.equals("true")) { debug_box.setSelected(true); } @@ -378,14 +410,20 @@ public void load_properties(Properties p) debug_box.setSelected(false); } } - prop = null; + propText = null; - if((prop = p.getProperty(build_type_config)) != null) + if((propText = prop.getProperty(build_type_config)) != null) { - build_type_box.setSelectedItem(prop); + build_type_box.setSelectedItem(propText); } } + @Action + public void loadDefaultPropertiesAction(ActionEvent e) + { + set_default(); + } + private void set_default() { String s = System.getProperty("file.separator"); @@ -393,6 +431,7 @@ private void set_default() src_dirs.setText(""); trick_home_dirs.setText(trick_home); trickify_path_dirs.setText(trick_home + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk"); + trickify_include_dirs.setText(""); trickify_args_field.setText(""); source_make_dirs.setText(""); source_make_args_field.setText(""); @@ -400,7 +439,7 @@ private void set_default() build_path_dirs.setText(System.getProperty("user.dir")); name_field.setText("TrickifiedLibrary"); log_dirs.setText(System.getProperty("user.dir")); - full_build_box.setSelected(false); + full_build_box.setSelected(true); no_clean_obj_box.setSelected(false); no_clean_src_box.setSelected(false); no_clean_s_source_box.setSelected(false); @@ -411,25 +450,77 @@ private void set_default() @Action public void restoreDefaultView(ActionEvent e) { - setSize(mainFrameWidth, mainFrameHeight); + myApp.getMainFrame().setSize(mainFrameWidth, mainFrameHeight); } - TrickifyPanel() + @Action + public void savePropertiesAction(ActionEvent e) + { + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); + int result = fc.showOpenDialog(null); + if(result == JFileChooser.CANCEL_OPTION) + { + return; + } + String filename = ""; + File file = fc.getSelectedFile(); + filename = file.getAbsolutePath(); + + Properties p = new Properties(); + save_properties(p); + try + { + p.store(new FileWriter(filename), "Trickify Properties"); + } + catch (IOException exp) + { + exp.printStackTrace(); + } + } + + @Action + public void loadPropertiesAction(ActionEvent e) + { + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File(System.getProperty("user.dir"))); + int result = fc.showOpenDialog(null); + if(result == JFileChooser.CANCEL_OPTION) + { + return; + } + String filename = ""; + File file = fc.getSelectedFile(); + filename = file.getAbsolutePath(); + + Properties p = new Properties(); + try + { + p.load(new FileReader(filename)); + } + catch (IOException exp) + { + exp.printStackTrace(); + } + load_properties(p); + } + + TrickifyPanel(TrickApplication app) { + myApp = app; + trickProp = myApp.trickProperties; String s = System.getProperty("file.separator"); trick_home = new File(TrickifyPanel.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath(); - setBounds(0, 0, mainFrameWidth, mainFrameHeight); - setPreferredSize(new Dimension(mainFrameWidth, mainFrameHeight)); - setBackground(Color.lightGray); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1; fieldPanel = new JPanel(); - fieldPanel.setPreferredSize(new Dimension(mainFrameWidth, 400)); - fieldPanel.setLayout(new GridLayout(10, 1)); + fieldPanel.setLayout(new GridLayout(11, 1)); add(fieldPanel, gbc); boxPanel = new JPanel(); @@ -439,26 +530,31 @@ public void restoreDefaultView(ActionEvent e) buttonPanel = new JPanel(); add(buttonPanel, gbc); + javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(TrickifyPanel.class, this); + //Build File Menu fileMenu.setName("trickify.fileMenu"); saveMenuItem.setName("trickify.saveMenuItem"); + saveMenuItem.setAction(actionMap.get("savePropertiesAction")); fileMenu.add(saveMenuItem); loadMenuItem.setName("trickify.loadMenuItem"); + loadMenuItem.setAction(actionMap.get("loadPropertiesAction")); fileMenu.add(loadMenuItem); + loadDefaultMenuItem.setName("trickify.loadDefaultMenuItem"); + loadDefaultMenuItem.setAction(actionMap.get("loadDefaultPropertiesAction")); + fileMenu.add(loadDefaultMenuItem); menu.add(fileMenu); //Build View Menu viewMenu.setName("trickify.viewMenu"); defaultViewMenuItem.setName("trickify.defaultViewMenuItem"); + defaultViewMenuItem.setAction(actionMap.get("restoreDefaultView")); viewMenu.add(defaultViewMenuItem); menu.add(viewMenu); - int fields_relative_offset = fields_y; - src_dirs = new DirSelect(); src_dirs.setLabel("Source Directories"); src_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; src_dirs.allowMultiple(true); src_dirs.setToolTipText("Directories to build trickified library from."); fieldPanel.add(src_dirs); @@ -466,7 +562,6 @@ public void restoreDefaultView(ActionEvent e) trick_home_dirs = new DirSelect(); trick_home_dirs.setLabel("Trick Home Directory"); trick_home_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; trick_home_dirs.allowMultiple(false); trick_home_dirs.setToolTipText("Trick directory to use."); fieldPanel.add(trick_home_dirs); @@ -474,22 +569,27 @@ public void restoreDefaultView(ActionEvent e) trickify_path_dirs = new DirSelect(); trickify_path_dirs.setLabel("Trickify Makefile"); trickify_path_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; trickify_path_dirs.allowMultiple(false); trickify_path_dirs.selectFile(true); trickify_path_dirs.setToolTipText("trickify.mk to use. Defaults to your $TRICK_HOME/share/trick/makefiles/trickify.mk"); fieldPanel.add(trickify_path_dirs); + trickify_include_dirs = new DirSelect(); + trickify_include_dirs.setLabel("Includes"); + trickify_include_dirs.setButtonText("Choose"); + trickify_include_dirs.allowMultiple(true); + trickify_include_dirs.selectFile(false); + trickify_include_dirs.setToolTipText("Paths to include during compilation."); + fieldPanel.add(trickify_include_dirs); + trickify_args_field = new LabeledTextField(); trickify_args_field.setLabel("Trickify Args"); - fields_relative_offset += fields_offset; trickify_args_field.setToolTipText("Arguments to provide to trickify.mk make call"); fieldPanel.add(trickify_args_field); source_make_dirs = new DirSelect(); source_make_dirs.setLabel("Source Make"); source_make_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; source_make_dirs.allowMultiple(false); source_make_dirs.selectFile(true); source_make_dirs.setToolTipText("Make file to use for building source files. If none provdided just uses generic g++/gcc calls."); @@ -497,14 +597,12 @@ public void restoreDefaultView(ActionEvent e) source_make_args_field = new LabeledTextField(); source_make_args_field.setLabel("Source Args"); - fields_relative_offset += fields_offset; source_make_args_field.setToolTipText("Arguments to provide to the above make file."); fieldPanel.add(source_make_args_field); s_overrides_dirs = new DirSelect(); s_overrides_dirs.setLabel("S_overrides"); s_overrides_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; s_overrides_dirs.allowMultiple(false); s_overrides_dirs.selectFile(true); s_overrides_dirs.setToolTipText("S_overrides to incorporate"); @@ -513,67 +611,50 @@ public void restoreDefaultView(ActionEvent e) build_path_dirs = new DirSelect(); build_path_dirs.setLabel("Build Path"); build_path_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; build_path_dirs.allowMultiple(false); build_path_dirs.setToolTipText("Where to drop the library."); fieldPanel.add(build_path_dirs); name_field = new LabeledTextField(); name_field.setLabel("Library Name"); - fields_relative_offset += fields_offset; name_field.setToolTipText("Library name (doesn't need extension)."); fieldPanel.add(name_field); log_dirs = new DirSelect(); log_dirs.setLabel("Trickify Log"); log_dirs.setButtonText("Choose"); - fields_relative_offset += fields_offset; log_dirs.allowMultiple(false); log_dirs.selectFile(false); log_dirs.setToolTipText("Where to drop the log file."); fieldPanel.add(log_dirs); - int checkbox_relative_offset = 0; - checkbox_y = fields_relative_offset; - full_build_box = new JCheckBox(" Full library build"); - full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - full_build_box.setBackground(getBackground()); full_build_box.setToolTipText("Full build includes swig files, icg files, and source files. Disabling excludes source files."); boxPanel.add(full_build_box); no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh"); - no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - no_clean_s_source_box.setBackground(getBackground()); no_clean_s_source_box.setToolTipText("Trickify automatically generates an S_source.hh for the build process. Can disable rebuilding if you wish to use a manually created file."); boxPanel.add(no_clean_s_source_box); debug_box = new JCheckBox(" Debug info"); - debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - debug_box.setBackground(getBackground()); boxPanel.add(debug_box); no_clean_src_box = new JCheckBox(" Don't rebuild source file list"); - no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - no_clean_src_box.setBackground(getBackground()); no_clean_src_box.setToolTipText("Source file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file."); boxPanel.add(no_clean_src_box); String options[] = { "Object", "Shared", "Static" }; build_type_box = new JComboBox(options); - build_type_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, 200, 20); boxPanel.add(build_type_box); no_clean_obj_box = new JCheckBox(" Don't rebuild object file list"); - no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset); - no_clean_obj_box.setBackground(getBackground()); no_clean_obj_box.setToolTipText("Object file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file."); boxPanel.add(no_clean_obj_box); set_default(); runButton = new JButton(); - runButton.setBounds(250, mainFrameHeight-30, 150, 20); + runButton.setPreferredSize(new Dimension(150, 20)); runButton.setText("Trickify"); runButton.addActionListener(new ActionListener() { @@ -637,7 +718,7 @@ public void actionPerformed(ActionEvent e) buttonPanel.add(runButton); exportButton = new JButton(); - exportButton.setBounds(600, mainFrameHeight-30, 150, 20); + exportButton.setPreferredSize(new Dimension(150, 20)); exportButton.setText("Print"); exportButton.addActionListener(new ActionListener() { diff --git a/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties b/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties index 1b2b0969f..854d59801 100644 --- a/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties +++ b/trick_source/java/src/main/resources/trick/trickify/resources/TrickifyApplication.properties @@ -13,6 +13,7 @@ Application.lookAndFeel = system trickify.fileMenu.text = File trickify.saveMenuItem.text = Save Config trickify.loadMenuItem.text = Load Config +trickify.loadDefaultMenuItem.text = Load Default trickify.viewMenu.text = View trickify.defaultViewMenuItem.text = Restore Default From b6449db51ceb64704408f5c40ff36b692a57ef17 Mon Sep 17 00:00:00 2001 From: plherrin <pherring04@gmail.com> Date: Wed, 19 Mar 2025 09:36:31 -0500 Subject: [PATCH 38/40] Defaulted fPIC for shared libraries on linux --- bin/trick-ify | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index 0c1f1160a..b92a85bdb 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -77,7 +77,6 @@ if($source_dir eq "" and $full_build) # trick_home/include # Header directory # Additional user provided directories -#$include_arg = "-I $trick_home -I $trick_home" . "/include -I $header_dir "; my $include_arg = ""; my @incl_dirs = split ' ', $include ; foreach my $dir (@incl_dirs) @@ -102,7 +101,6 @@ $ENV{'TRICKIFY_SOURCE'} = "$source_dir" ; $ENV{'TRICKIFY_HEADER'} = "$header_dir" ; $ENV{'TRICKIFY_S_OVERRIDES'} = "$s_overrides" ; $ENV{'TRICKIFY_INCLUDES'} = "$include_arg" ; -#$ENV{'TRICKIFY_INCLUDES'} = "$include" ; if ( $build_type eq "o" ) { $ENV{'TRICKIFY_BUILD_TYPE'} = "PLO" ; @@ -114,6 +112,10 @@ elsif ( $build_type eq "a" ) elsif ( $build_type eq "so" || $build_type eq "dylib" ) { $ENV{'TRICKIFY_BUILD_TYPE'} = "SHARED" ; + if ($^O == "linux") + { + $source_make_args .= " -fPIC" ; + } } #Build the S_source.hh From 56b3be8f016ee99d17881085bcf172a69b3d28ce Mon Sep 17 00:00:00 2001 From: plherrin <pherring04@gmail.com> Date: Wed, 19 Mar 2025 15:52:19 -0500 Subject: [PATCH 39/40] S_overrides --- bin/trick-ify | 12 +++++++++++- .../trick/pymods/trick/build_S_overrides_trickify.py | 7 +++++++ share/trick/pymods/trick/build_trickify.py | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 share/trick/pymods/trick/build_S_overrides_trickify.py diff --git a/bin/trick-ify b/bin/trick-ify index b92a85bdb..5f80ea6df 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -1,6 +1,7 @@ #!/usr/bin/perl -use Getopt::Long; +use Getopt::Long ; +use Cwd ; use strict ; my $my_path = $0 ; @@ -118,6 +119,15 @@ elsif ( $build_type eq "so" || $build_type eq "dylib" ) } } +#Build the S_overrides_trickify.mk +if (!$no_clean_s_source) +{ + print "Building S_overrides_trickify.mk\n" ; + my $my_cwd = getcwd ; + my $make_s_overrides = "python3 $my_path../share/trick/pymods/trick/build_S_overrides_trickify.py $ENV{'TRICKIFY_OBJECT_NAME'} $ENV{'TRICKIFY_HEADER'} $my_cwd/python" ; + print(`$make_s_overrides`) ; +} + #Build the S_source.hh if (!$no_clean_s_source) { diff --git a/share/trick/pymods/trick/build_S_overrides_trickify.py b/share/trick/pymods/trick/build_S_overrides_trickify.py new file mode 100644 index 000000000..373bb0b44 --- /dev/null +++ b/share/trick/pymods/trick/build_S_overrides_trickify.py @@ -0,0 +1,7 @@ +import os +import sys + +path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py" +exec(open(path).read()) + +build_S_overrides_trickify(sys.argv[1], sys.argv[2], sys.argv[3]) diff --git a/share/trick/pymods/trick/build_trickify.py b/share/trick/pymods/trick/build_trickify.py index cfc8dd0d5..d6cfd122f 100644 --- a/share/trick/pymods/trick/build_trickify.py +++ b/share/trick/pymods/trick/build_trickify.py @@ -52,3 +52,10 @@ def build_src_list(): files = find_files_by_extension(path, ext) for i in range(len(files)): src_list.write(str(files[i]) + '\n') + +def build_S_overrides_trickify(ldflags, ext_lib_dirs, python_path): + s_overrides = open("S_overrides_trickify.mk", 'w') + + s_overrides.write("TRICK_LDFLAGS += " + ldflags + '\n') + s_overrides.write("TRICK_EXT_LIB_DIRS += " + ext_lib_dirs + '\n') + s_overrides.write("TRICK_PYTHON_PATH += " + python_path + '\n') From 9f8f0575c905c07c344754d3750f1a9c57d157f9 Mon Sep 17 00:00:00 2001 From: plherrin <pherring04@gmail.com> Date: Tue, 1 Apr 2025 13:47:34 -0500 Subject: [PATCH 40/40] Addressed issues with trickify s overrides --- bin/trick-ify | 28 +++++++++++++++---- .../trick/build_S_overrides_trickify.py | 2 +- share/trick/pymods/trick/build_trickify.py | 3 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/bin/trick-ify b/bin/trick-ify index 5f80ea6df..b3125f0d6 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -120,13 +120,29 @@ elsif ( $build_type eq "so" || $build_type eq "dylib" ) } #Build the S_overrides_trickify.mk -if (!$no_clean_s_source) -{ - print "Building S_overrides_trickify.mk\n" ; - my $my_cwd = getcwd ; - my $make_s_overrides = "python3 $my_path../share/trick/pymods/trick/build_S_overrides_trickify.py $ENV{'TRICKIFY_OBJECT_NAME'} $ENV{'TRICKIFY_HEADER'} $my_cwd/python" ; - print(`$make_s_overrides`) ; +print "Building S_overrides_trickify.mk\n" ; +my $abs_headers_str = "" ; +my @abs_headers = split ' ', $ENV{'TRICKIFY_HEADER'} ; +my $tmp_count = 0 ; +foreach my $hdr (@abs_headers) +{ + my $tmpstr = Cwd::abs_path($hdr) ; + if($tmp_count == 0) + { + $abs_headers_str = "$tmpstr" ; + $tmp_count = 1 ; + } + else + { + $abs_headers_str = "$abs_headers_str:$tmpstr" ; + } } +$abs_headers_str = "\"$abs_headers_str\"" ; + +my $my_cwd = getcwd ; +#TODO: Might want to add an option to make this a relative path. +my $make_s_overrides = "python3 $my_path../share/trick/pymods/trick/build_S_overrides_trickify.py " . Cwd::abs_path($ENV{'TRICKIFY_OBJECT_NAME'}) . " " . $abs_headers_str . " $my_cwd/python " . "$my_cwd" ; +print(`$make_s_overrides`) ; #Build the S_source.hh if (!$no_clean_s_source) diff --git a/share/trick/pymods/trick/build_S_overrides_trickify.py b/share/trick/pymods/trick/build_S_overrides_trickify.py index 373bb0b44..5b99f4f20 100644 --- a/share/trick/pymods/trick/build_S_overrides_trickify.py +++ b/share/trick/pymods/trick/build_S_overrides_trickify.py @@ -4,4 +4,4 @@ path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py" exec(open(path).read()) -build_S_overrides_trickify(sys.argv[1], sys.argv[2], sys.argv[3]) +build_S_overrides_trickify(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) diff --git a/share/trick/pymods/trick/build_trickify.py b/share/trick/pymods/trick/build_trickify.py index d6cfd122f..6b61677eb 100644 --- a/share/trick/pymods/trick/build_trickify.py +++ b/share/trick/pymods/trick/build_trickify.py @@ -53,9 +53,10 @@ def build_src_list(): for i in range(len(files)): src_list.write(str(files[i]) + '\n') -def build_S_overrides_trickify(ldflags, ext_lib_dirs, python_path): +def build_S_overrides_trickify(ldflags, ext_lib_dirs, python_path, swig_flags): s_overrides = open("S_overrides_trickify.mk", 'w') s_overrides.write("TRICK_LDFLAGS += " + ldflags + '\n') s_overrides.write("TRICK_EXT_LIB_DIRS += " + ext_lib_dirs + '\n') s_overrides.write("TRICK_PYTHON_PATH += " + python_path + '\n') + s_overrides.write("TRICK_SWIG_FLAGS += -I" + swig_flags + '\n')