Checkpoint

This commit is contained in:
Pherring04 2024-11-07 16:37:19 -06:00
parent 3c54861118
commit 1ad530270c
4 changed files with 82 additions and 31 deletions

View File

@ -11,6 +11,8 @@ $build_s_source = 0 ; # Whet
$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
$work_dir = "./trickify/" ; # Directory to dump work artifacts
$skip_arg = 0 ;
foreach $argnum (0 .. $#ARGV)
@ -74,6 +76,15 @@ foreach $argnum (0 .. $#ARGV)
}
$skip_arg = 1 ;
}
elsif($arg eq "-v") # Verbose, print debug info
{
$debug = 1 ;
}
elsif($arg eq "-w") # Set working directory
{
$work_dir = $ARGV[$argnum + 1] . "/trickify/" ;
$skip_arg = 1 ;
}
else
{
print "Unrecognized argument: $arg\n" ;
@ -86,6 +97,8 @@ $ENV{'TRICKIFY_CXX_FLAGS'} = "-I $source_dir" ; #TODO: Test with multiple dirs p
$ENV{'TRICKIFY_OBJECT_NAME'} = "$name.$build_type" ;
$ENV{'TRICKIFY_SOURCE'} = "$source_dir" ;
$ENV{'TRICKIFY_HEADER'} = "$header_dir" ;
$ENV{'TRICKIFY_WORK_DIR'} = "$work_dir" ;
mkdir $work_dir ;
if ( $build_type eq o )
{
$ENV{'TRICKIFY_BUILD_TYPE'} = PLO ;
@ -104,41 +117,71 @@ $make_s_source = "python3 $my_path../share/trick/makefiles/build_trickify_S_sour
print(`$make_s_source`) ;
#Build source file list, only if trickifying the entire library
#TODO: Move build artifacts into build? Maybe?
if($full_build)
{
#$make_obj_list = "python3 $my_path../share/trick/makefiles/build_trickify_obj_list.py" ;
#print(`$make_obj_list`) ;
$make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ;
print(`$make_src_list`) ;
}
else
{
#open (fh, ">", "trickify_obj_list") ;
#close (fh) ;
open (fh, ">", "trickify_src_list") ;
open (fh, ">", "$work_dir"."trickify_src_list") ;
close (fh) ;
}
open (fh, "<", "trickify_src_list") ;
#Build array of source files
open ($fh, "$work_dir"."trickify_src_list") or die "Could not open trickify_src_list: $!" ;
@src_files ;
while ($line = <$fh>)
while (my $line = <$fh>)
{
chomp $line ;
print $line AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
push @src_files, $line ;
}
close (fh) ;
#Build object files from source file list
print "Building object files\n" ;
foreach $src (@src_files)
{
$file = $src ;
$file =~ s/$\Q.cpp\E// ;
$file =~ s/$\Q.c\E// ;
$cmd = "g++ -c $src -o $file.o" ;
if($debug)
{
print "Building obj file: $cmd\n" ;
}
print(`$cmd`) ;
}
#Build object file list, only if trickifying the entire library
if($full_build)
{
$make_obj_list = "python3 $my_path../share/trick/makefiles/build_trickify_obj_list.py" ;
print(`$make_obj_list`) ;
}
else
{
open (fh, ">", "$work_dir"."trickify_obj_list") ;
close (fh) ;
}
#Build trickify call
$trickify_make_call = "make $trickify_make_args -f $trickify_make_path" ;
print(`$trickify_make_call`) ;
print "TRICKIFY BUILD INFO:
header_dir = $header_dir
source_dir = $source_dir
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\n" ;
if($debug) {
print
"TRICKIFY BUILD INFO:
header_dir = $header_dir
source_dir = $source_dir
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
work_dir = $work_dir\n" ;
}
#TODO: Can't run trickify neutrally, must set source dir/output dir or conflicts will occur. Should fix or just document?

View File

@ -13,8 +13,11 @@ def build_S_source():
loc = ""
if "TRICKIFY_HEADER" in os.environ:
loc = os.getenv("TRICKIFY_HEADER")
work_dir = ""
if "TRICKIFY_WORK_DIR" in os.environ:
work_dir = os.getenv("TRICKIFY_WORK_DIR")
s_source = open("S_source.hh", 'w')
s_source = open(work_dir + "S_source.hh", 'w')
for ext in def_header_ext:
files = find_files_by_extension(loc, ext)
for i in range(len(files)):
@ -24,9 +27,12 @@ def build_obj_list():
loc = ""
if "TRICKIFY_SOURCE" in os.environ:
loc = os.getenv("TRICKIFY_SOURCE")
work_dir = ""
if "TRICKIFY_WORK_DIR" in os.environ:
work_dir = os.getenv("TRICKIFY_WORK_DIR")
files = find_files_by_extension(loc, "o")
s_source = open("trickify_obj_list", 'w')
s_source = open(work_dir + "trickify_obj_list", 'w')
for i in range(len(files)):
s_source.write(str(files[i]) + '\n')
@ -34,9 +40,12 @@ def build_src_list():
loc = ""
if "TRICKIFY_SOURCE" in os.environ:
loc = os.getenv("TRICKIFY_SOURCE")
work_dir = ""
if "TRICKIFY_WORK_DIR" in os.environ:
work_dir = os.getenv("TRICKIFY_WORK_DIR")
for ext in def_src_ext:
files = find_files_by_extension(loc, ext)
s_source = open("trickify_src_list", 'w')
s_source = open(work_dir + "trickify_src_list", 'w')
for i in range(len(files)):
s_source.write(str(files[i]) + '\n')

View File

@ -105,10 +105,12 @@ TRICKIFY_PYTHON_DIR := $(abspath $(TRICKIFY_PYTHON_DIR))
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
SRC_LINK_LIST := trickify_obj_list
LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(SRC_LINK_LIST)
#PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list
#IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list
PY_LINK_LIST := $(MAKE_OUT)___trickify_py_link_list
IO_LINK_LIST := $(BUILD_DIR)___trickify_io_link_list
OBJ_LINK_LIST := trickify_obj_list
LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST)
ifneq ($(wildcard $(BUILD_DIR)),)
SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST))
IO_OBJECTS := $(shell cat $(IO_LINK_LIST))

View File

@ -1,17 +1,14 @@
LOCAL_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
PROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
TRICK_HOME := $(abspath $(PROJECT_HOME)/../../..)
include $(LOCAL_DIR)/myproject_vars.mk
export TRICKIFY_SOURCE := $(PROJECT_HOME)/include
export TRICKIFY_CXX_FLAGS := -I $(PROJECT_HOME)/include -I $(TRICK_HOME)/include
all:
#@$(MAKE) -s -f $(TRICK_HOME)/share/trick/makefiles/trickify.mk
#@trick-ify -h "/users/plherrin/trick/test/SIM_trickified/trickified_project/include" -b a -n trickified_myproject
#@trick-ify -d "/users/plherrin/trick/test/SIM_trickified/trickified_project/include" -b a -n trickified_myproject
@trick-ify -d "/users/plherrin/trick/test/SIM_trickified/trickified_project/testing" -b a -n trickified_myproject
clean:
@rm -rf build python trick $(TRICKIFY_OBJECT_NAME)
@rm -rf $(MYPROJECT_TRICK)
@rm -rf trickify_obj_list
@rm -rf trickify_src_list
@rm -rf /users/plherrin/trick/test/SIM_trickified/trickified_project/testing/*.o