Skip to content

Commit 22c3ddd

Browse files
committed
S_overrides fix
1 parent 011c4e7 commit 22c3ddd

File tree

7 files changed

+62
-36
lines changed

7 files changed

+62
-36
lines changed

bin/trick-ify

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ $no_source_build = 0 ; # Arg
2121
$no_clean_obj = 0 ; # Don't rebuild trickify_obj_list
2222
$no_clean_src = 0 ; # Don't rebuild trickify_src_list
2323
$no_clean_s_source = 0 ; # Don't rebuild S_source.hh
24+
$s_overrides = "" ; # Directory containing S_override make files
2425

2526
GetOptions
2627
(
@@ -38,7 +39,8 @@ GetOptions
3839
"n=s" => \$name, # Set the library name
3940
"b=s" => \$build_type, # Set library build type
4041
"v" => \$debug, # Verbose, print debug info
41-
"trick_home=s" => \$trick_home # Set trick home directory
42+
"trick_home=s" => \$trick_home, # Set trick home directory
43+
"s_overrides=s" => \$s_overrides # Directory containing S_override make files
4244
) ;
4345

4446
$full_build = !$no_source_build ;
@@ -83,6 +85,7 @@ $ENV{'TRICKIFY_CXX_FLAGS'} = "$source_dir_args -I $trick_home" . "/include" ;
8385
$ENV{'TRICKIFY_OBJECT_NAME'} = "$name.$build_type" ;
8486
$ENV{'TRICKIFY_SOURCE'} = "$source_dir" ;
8587
$ENV{'TRICKIFY_HEADER'} = "$header_dir" ;
88+
$ENV{'TRICKIFY_S_OVERRIDES'} = "$s_overrides" ;
8689
if ( $build_type eq o )
8790
{
8891
$ENV{'TRICKIFY_BUILD_TYPE'} = PLO ;
@@ -134,15 +137,15 @@ if ($full_build)
134137
foreach $src (@src_files)
135138
{
136139
$file = $src ;
137-
if($file =~ /\S*(\Q.c\E)$/)
140+
if($file =~ /\S\w*(\Q.c\E)$/)
138141
{
139142
$file =~ s/\Q.c\E$// ;
140-
$cmd = "gcc $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ;
143+
$cmd = "gcc $source_make_args -I $trick_home -I $trick_home" . "/include -I $header_dir -c $src -o $file.o" ;
141144
}
142145
else
143146
{
144-
$file =~ s/\Q.cpp\E$// ;
145-
$cmd = "g++ $source_make_args -I $trick_home" . "/include -c $src -o $file.o" ;
147+
$file =~ s/\Q.\E\w*$// ;
148+
$cmd = "g++ $source_make_args -I $trick_home -I $trick_home" . "/include -I $header_dir -c $src -o $file.o" ;
146149
}
147150
if($debug)
148151
{

share/trick/makefiles/trickify.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
# For more information, see:
8989
# https://nasa.github.io/trick/documentation/building_a_simulation/Trickified-Project-Libraries
9090

91+
MY_HOME := $(dir $(lastword $(MAKEFILE_LIST)))
92+
93+
include $(TRICKIFY_S_OVERRIDES)
94+
9195
ifndef TRICKIFY_CXX_FLAGS
9296
$(error TRICKIFY_CXX_FLAGS must be set)
9397
endif
@@ -100,7 +104,7 @@ TRICKIFY_OBJECT_NAME ?= trickified.o
100104
TRICKIFY_PYTHON_DIR ?= python
101105
TRICKIFY_PYTHON_DIR := $(abspath $(TRICKIFY_PYTHON_DIR))
102106

103-
include $(dir $(lastword $(MAKEFILE_LIST)))Makefile.common
107+
include $(MY_HOME)Makefile.common
104108

105109
BUILD_DIR := $(dir $(MAKE_OUT))
106110
PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list

share/trick/pymods/trick/build_trickify.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from pathlib import Path
22
import os
33

4-
def_header_ext = ["h", "hh", "hpp", "H", "hxx", "h++"]
4+
def_header_ext = [".h", "hh", "hpp", "H", "hxx", "h++"]
55
def_src_ext = ["cpp", "c"]
66

77
def find_files_by_extension(loc, ext):
8-
path = Path(loc)
9-
files = list(path.rglob(f'*.{ext}'))
10-
return files
8+
file_list = []
9+
for root, dirs, files in os.walk(loc):
10+
for f in files:
11+
if f.endswith(ext):
12+
file_list.append(os.path.join(root, f))
13+
print(file_list)
14+
return file_list
1115

1216
def build_S_source():
1317
loc = ""
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import os
22

3-
path = ""
4-
if "TRICK_HOME" in os.environ:
5-
path = os.getenv("TRICK_HOME")
6-
path += "/share/trick/pymods/trick/build_trickify.py"
7-
3+
path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py"
84
exec(open(path).read())
95

106
build_S_source()
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import os
22

3-
path = ""
4-
if "TRICK_HOME" in os.environ:
5-
path = os.getenv("TRICK_HOME")
6-
path += "/share/trick/pymods/trick/build_trickify.py"
7-
3+
path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py"
84
exec(open(path).read())
95

106
build_obj_list()
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import os
22

3-
path = ""
4-
if "TRICK_HOME" in os.environ:
5-
path = os.getenv("TRICK_HOME")
6-
path += "/share/trick/pymods/trick/build_trickify.py"
7-
3+
path = os.path.dirname(os.path.abspath(__file__)) + "/build_trickify.py"
84
exec(open(path).read())
95

106
build_src_list()

trick_source/java/src/main/java/trick/trickify/TrickifyFrame.java

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class TrickifyFrame
1111
{
12-
private String defaultDirectory;
12+
private String trick_home;
1313

1414
private JFrame mainFrame;
1515
private int mainFrameWidth = 1000;
@@ -22,6 +22,7 @@ public class TrickifyFrame
2222
private DirSelect trickify_path_dirs;
2323
private DirSelect source_make_dirs;
2424
private DirSelect log_dirs;
25+
private DirSelect s_overrides_dirs;
2526
private LabeledTextField name_field;
2627
private LabeledTextField trickify_args_field;
2728
private LabeledTextField source_make_args_field;
@@ -43,16 +44,23 @@ public class TrickifyFrame
4344
private JButton runButton;
4445
private JButton exportButton;
4546

46-
public ArrayList<String> getTrickifyCmd()
47+
public ArrayList<String> getTrickifyCmd(boolean useQuotes)
4748
{
4849
ArrayList<String> cmdLine = new ArrayList<String>();
49-
cmdLine.add("trick-ify");
50+
cmdLine.add(trick_home + "/bin/trick-ify");
5051

5152
String src_dirs_txt = src_dirs.getDirs().trim();
5253
if(!src_dirs_txt.equals(""))
5354
{
5455
cmdLine.add("-d");
55-
cmdLine.add(src_dirs_txt);
56+
if(useQuotes)
57+
{
58+
cmdLine.add("\"" + src_dirs_txt + "\"");
59+
}
60+
else
61+
{
62+
cmdLine.add(src_dirs_txt);
63+
}
5664
}
5765

5866
String trick_home_dirs_txt = trick_home_dirs.getDirs().trim();
@@ -96,6 +104,13 @@ public ArrayList<String> getTrickifyCmd()
96104
{
97105
lib_name = build_path_dirs_txt;
98106
}
107+
108+
String s_overrides_dirs_txt = s_overrides_dirs.getDirs().trim();
109+
if(!s_overrides_dirs_txt.equals(""))
110+
{
111+
cmdLine.add("--s_overrides");
112+
cmdLine.add(s_overrides_dirs_txt);
113+
}
99114

100115
String name_field_txt = name_field.getText().trim();
101116
if(!name_field_txt.equals(""))
@@ -167,7 +182,7 @@ private void update_checkbox_pos()
167182

168183
void trickify()
169184
{
170-
ArrayList<String> cmd = getTrickifyCmd();
185+
ArrayList<String> cmd = getTrickifyCmd(false);
171186
String[] cmdLine = new String[cmd.size()];
172187
cmdLine = cmd.toArray(cmdLine);
173188
System.out.println("Executing: " + String.join(" ", cmd));
@@ -186,7 +201,8 @@ void trickify()
186201
PrintWriter logfile = new PrintWriter(log_dirs_path + System.getProperty("file.separator") + "trickify.log", "UTF-8");
187202
logfile.println(output);
188203
logfile.close();
189-
204+
205+
System.out.println("Your technological distinctiveness has been trickified.");
190206
}
191207
catch (IOException e)
192208
{
@@ -197,6 +213,7 @@ void trickify()
197213
TrickifyFrame()
198214
{
199215
String s = System.getProperty("file.separator");
216+
trick_home = new File(TrickifyFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath();
200217

201218
mainFrame = new JFrame();
202219

@@ -220,7 +237,7 @@ void trickify()
220237

221238
trick_home_dirs = new DirSelect();
222239
trick_home_dirs.setLabel("Trick Home Directory");
223-
trick_home_dirs.setDirs(System.getenv("TRICK_HOME"));
240+
trick_home_dirs.setDirs(trick_home);
224241
trick_home_dirs.setButtonText("Choose");
225242
trick_home_dirs.setPosition(fields_x, fields_relative_offset);
226243
fields_relative_offset += fields_offset;
@@ -230,7 +247,7 @@ void trickify()
230247

231248
trickify_path_dirs = new DirSelect();
232249
trickify_path_dirs.setLabel("Trickify Makefile");
233-
trickify_path_dirs.setDirs(System.getenv("TRICK_HOME") + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk");
250+
trickify_path_dirs.setDirs(trick_home + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk");
234251
trickify_path_dirs.setButtonText("Choose");
235252
trickify_path_dirs.setPosition(fields_x, fields_relative_offset);
236253
fields_relative_offset += fields_offset;
@@ -263,6 +280,16 @@ void trickify()
263280
source_make_args_field.setToolTipText("Arguments to provide to the above make file.");
264281
source_make_args_field.addToPanel(mainPanel);
265282

283+
s_overrides_dirs = new DirSelect();
284+
s_overrides_dirs.setLabel("S_overrides");
285+
s_overrides_dirs.setButtonText("Choose");
286+
s_overrides_dirs.setPosition(fields_x, fields_relative_offset);
287+
fields_relative_offset += fields_offset;
288+
s_overrides_dirs.allowMultiple(false);
289+
s_overrides_dirs.selectFile(true);
290+
s_overrides_dirs.setToolTipText("S_overrides to incorporate");
291+
s_overrides_dirs.addToPanel(mainPanel);
292+
266293
build_path_dirs = new DirSelect();
267294
build_path_dirs.setLabel("Build Path");
268295
build_path_dirs.setDirs(System.getProperty("user.dir"));
@@ -288,7 +315,7 @@ void trickify()
288315
log_dirs.setPosition(fields_x, fields_relative_offset);
289316
fields_relative_offset += fields_offset;
290317
log_dirs.allowMultiple(false);
291-
trickify_path_dirs.selectFile(false);
318+
log_dirs.selectFile(false);
292319
log_dirs.setToolTipText("Where to drop the log file.");
293320
log_dirs.addToPanel(mainPanel);
294321

@@ -402,12 +429,12 @@ public void actionPerformed(ActionEvent e)
402429

403430
exportButton = new JButton();
404431
exportButton.setBounds(600, mainFrameHeight-30, 150, 20);
405-
exportButton.setText("Export");
432+
exportButton.setText("Print");
406433
exportButton.addActionListener(new ActionListener()
407434
{
408435
public void actionPerformed(ActionEvent e)
409436
{
410-
System.out.println(String.join(" ", getTrickifyCmd()));
437+
System.out.println(String.join(" ", getTrickifyCmd(true)));
411438
}
412439
} );
413440
mainPanel.add(exportButton);

0 commit comments

Comments
 (0)