Skip to content
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
be8a772
Implmented trick-ify
Pherring04 Nov 25, 2024
ba693dc
Cleaning up code
Pherring04 Nov 25, 2024
1e7f5db
CI Fix
Pherring04 Nov 25, 2024
377e8c8
Shared library test fix
Pherring04 Nov 26, 2024
d290eeb
CI Fix
Pherring04 Nov 26, 2024
8afa83a
CI Fix
Pherring04 Nov 26, 2024
973a473
Added old trickify test
Pherring04 Nov 26, 2024
f285e2a
Added S_source.hh
Pherring04 Dec 2, 2024
df19738
Changed old trickified test to generate an archive
Pherring04 Dec 2, 2024
5960500
Added support for archive trickify builds on mac
Pherring04 Dec 2, 2024
ffb2e34
Trickify MAC fixes
Pherring04 Dec 3, 2024
573211e
Trickify shared on mac fix
Pherring04 Dec 3, 2024
d0316b5
Moved the py files to their appropriate directory
Pherring04 Dec 9, 2024
c5e044a
CI fix
Pherring04 Jan 2, 2025
2b4054f
Improved trick-ify arguments
Pherring04 Jan 3, 2025
fc96481
CI
Pherring04 Jan 6, 2025
1e9a2e1
CI
Pherring04 Jan 6, 2025
f420dca
CI
Pherring04 Jan 7, 2025
e25aaa3
CI
Pherring04 Jan 7, 2025
c3cd94e
CI
Pherring04 Jan 9, 2025
a2d4455
CI
Pherring04 Jan 13, 2025
04c0fea
CI
Pherring04 Jan 13, 2025
74c7512
Added C support
Pherring04 Jan 14, 2025
4af3fc3
Removed trickified shared test from MAC CI
Pherring04 Jan 15, 2025
ae86640
Start of trickify GUI
Pherring04 Jan 22, 2025
2e46a84
Checkpoint
Pherring04 Jan 22, 2025
e30ebf8
Trickify GUI
Pherring04 Feb 3, 2025
9578258
Merge branch 'master' into Trick-ify
Pherring04 Feb 3, 2025
7f4c78d
Test fix
Pherring04 Feb 3, 2025
9b44b2d
CI
Pherring04 Feb 3, 2025
c2f32a2
CI
Pherring04 Feb 4, 2025
011c4e7
CI
Pherring04 Feb 4, 2025
22c3ddd
S_overrides fix
Pherring04 Feb 13, 2025
15a61e1
Updated to support the dylib build type for Mac and implement a compa…
hchen99 Feb 19, 2025
94b5f2f
Removed unnecessary -rpath as -install_name has the correct path duri…
hchen99 Feb 20, 2025
6c8f198
Added USER_ADDITIONAL_OPTIONS for user to provide additional options …
hchen99 Feb 20, 2025
389a3e0
Checkpoint
Pherring04 Feb 26, 2025
28bfdf6
Lots of changes
Pherring04 Mar 18, 2025
b6449db
Defaulted fPIC for shared libraries on linux
Pherring04 Mar 19, 2025
56b3be8
S_overrides
Pherring04 Mar 19, 2025
9f8f057
Addressed issues with trickify s overrides
Pherring04 Apr 1, 2025
7d9c125
Updated tests to use trickify s overrides
Pherring04 Apr 2, 2025
83dfb5f
Fxied some dir paths
Pherring04 Apr 2, 2025
287f9f3
CI
Pherring04 Apr 2, 2025
82d9231
CI
Pherring04 Apr 2, 2025
4d8deb1
Merge branch 'master' into Trick-ify
Pherring04 Apr 2, 2025
aa10fec
Merge branch 'master' into Trick-ify
hchen99 Apr 8, 2025
27d728d
Fixed S_overrides.mk for SIM_trickified_shared to set proper shared l…
hchen99 Apr 9, 2025
d9d6744
S_overrides fix
Pherring04 Apr 14, 2025
4ab9f01
Camel Caseified
Pherring04 May 15, 2025
578e9ce
Text fix
Pherring04 May 15, 2025
5469511
Added gui insets
Pherring04 May 15, 2025
b46cffc
Added exclusions and other cleanup
Pherring04 Jun 30, 2025
2d34d5d
Some fixes
Pherring04 Jul 10, 2025
59503df
GUI changes. Will be broken until script changes pushed
Pherring04 Aug 6, 2025
4429444
Checkpoint
Pherring04 Aug 11, 2025
1005683
Permission change
Pherring04 Aug 12, 2025
db88e6e
Another checkpoint
Pherring04 Aug 13, 2025
0192533
Checkpoint
Pherring04 Sep 5, 2025
0afb69a
Merge branch 'master' into Trick-ify
Pherring04 Sep 8, 2025
d5fe217
Tidying
Pherring04 Sep 11, 2025
ef652fa
Fixes for jeod
Pherring04 Sep 16, 2025
eed34b4
Checkpoint
Pherring04 Oct 21, 2025
4c41b86
Missed some comments
Pherring04 Oct 21, 2025
2fe687b
Merge branch 'master' into Trick-ify
Pherring04 Oct 22, 2025
3501fdd
Auto rebuilding implemented for multiple libs + minor fixes
Pherring04 Oct 30, 2025
305d429
Fixed test
Pherring04 Oct 31, 2025
d74a4d6
Bug fix
Pherring04 Nov 10, 2025
5760e1f
C bug fix
Pherring04 Nov 10, 2025
e28c5c3
Some makefile changes
Pherring04 Nov 12, 2025
32b3147
Wrapped trickify make into sim make
Pherring04 Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 220 additions & 0 deletions bin/trick-ify
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
#!/usr/bin/perl

use Getopt::Long ;
use Cwd ;
use strict ;

my $my_path = $0 ;
$my_path =~ s/trick-ify// ;

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
(
"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_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
"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
"include=s" => \$include # Directory containing S_override make files
) ;

$full_build = !$no_source_build ;

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 ;
}

if($dirs ne "")
{
$header_dir = $dirs ;
$source_dir = $dirs ;
}

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 ;
}

#Build list of includes for compilation. Includes:
# trick_home
# trick_home/include
# Header directory
# Additional user provided directories
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 ;
my $source_dir_args = "" ;
foreach my $dir (@src_dirs)
{
$source_dir_args .= "-I" . $dir . " " ;
}
$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" ;
$ENV{'TRICKIFY_INCLUDES'} = "$include_arg" ;
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" || $build_type eq "dylib" )
{
$ENV{'TRICKIFY_BUILD_TYPE'} = "SHARED" ;
if ($^O == "linux")
{
$source_make_args .= " -fPIC" ;
}
}

#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)
{
print "Building S_source.hh\n" ;
my $make_s_source = "python3 $my_path../share/trick/pymods/trick/build_trickify_S_source_hh.py" ;
print(`$make_s_source`) ;
}

#Build source file list, only if trickifying the entire library
if (!$no_clean_src and $full_build)
{
print "Building trickify_src_list\n" ;
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 (my $fh, "trickify_src_list") or die "Could not open trickify_src_list: $!" ;
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 my $src (@src_files)
{
my $cmd = "" ;
my $file = $src ;
if($file =~ /\S\w*(\Q.c\E)$/)
{
$file =~ s/\Q.c\E$// ;
$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 $ENV{'TRICKIFY_CXX_FLAGS'} -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(!$no_clean_obj and $full_build)
{
print "Building trickify_obj_list\n" ;
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" ;
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_args
source_make_call = $source_make_call
trickify_make_args = $trickify_make_args
trickify_make_path = $trickify_make_path
build_s_source = $no_clean_s_source
full_build = $full_build
name = $name
build_type = $build_type
trick_home = $trick_home
TRICKIFY_CXX_FLAGS = $ENV{'TRICKIFY_CXX_FLAGS'}\n" ;
}
8 changes: 8 additions & 0 deletions bin/trick-trickify
Original file line number Diff line number Diff line change
@@ -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") ;

6 changes: 4 additions & 2 deletions libexec/trick/make_makefile_swig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "
Expand Down
56 changes: 44 additions & 12 deletions share/trick/makefiles/trickify.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,15 +104,20 @@ 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
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
FULL_TRICKIFY_BUILD = "1"
else
FULL_TRICKIFY_BUILD = "0"
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)
Expand All @@ -117,18 +126,41 @@ 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)
SHARED_OPTIONS := -fPIC
LD_OPTIONS := -Wl,-install_name,$(abspath $(TRICKIFY_OBJECT_NAME))
else
SHARED_OPTIONS :=
endif

.PHONY: all
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 -o $@ $(LINK_LISTS))
else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC)
$(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS))
endif
@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) $(USER_ADDITIONAL_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 $@
Expand Down
7 changes: 7 additions & 0 deletions share/trick/pymods/trick/build_S_overrides_trickify.py
Original file line number Diff line number Diff line change
@@ -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])
Loading
Loading