Skip to content

Commit

Permalink
S_overrides fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pherring04 committed Feb 13, 2025
1 parent 011c4e7 commit 22c3ddd
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 36 deletions.
13 changes: 8 additions & 5 deletions bin/trick-ify
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
Expand All @@ -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 ;
Expand Down Expand Up @@ -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 ;
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 5 additions & 1 deletion 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,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
Expand Down
12 changes: 8 additions & 4 deletions share/trick/pymods/trick/build_trickify.py
Original file line number Diff line number Diff line change
@@ -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 = ""
Expand Down
6 changes: 1 addition & 5 deletions share/trick/pymods/trick/build_trickify_S_source_hh.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 1 addition & 5 deletions share/trick/pymods/trick/build_trickify_obj_list.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 1 addition & 5 deletions share/trick/pymods/trick/build_trickify_src_list.py
Original file line number Diff line number Diff line change
@@ -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()
49 changes: 38 additions & 11 deletions trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class TrickifyFrame
{
private String defaultDirectory;
private String trick_home;

private JFrame mainFrame;
private int mainFrameWidth = 1000;
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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(""))
Expand Down Expand Up @@ -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));
Expand All @@ -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)
{
Expand All @@ -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();

Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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"));
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 22c3ddd

Please sign in to comment.