mirror of
https://github.com/nasa/trick.git
synced 2025-04-08 11:54:23 +00:00
Improved trick-ify arguments
This commit is contained in:
parent
c5e044a0a8
commit
2b4054f73c
141
bin/trick-ify
141
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
|
||||
|
||||
$skip_arg = 0 ;
|
||||
foreach $argnum (0 .. $#ARGV)
|
||||
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 ;
|
||||
|
||||
$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" ;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user