Use TRICK_CXXFLAGS for include paths & defines

Fixes #819
This commit is contained in:
Derek Bankieris 2019-06-18 10:52:37 -05:00
parent 03d93aee18
commit 9f3175d01b
6 changed files with 28 additions and 39 deletions

View File

@ -53,10 +53,6 @@ Examples:
my $help = ''; # option variable with default value (false) my $help = ''; # option variable with default value (false)
my $stls = 0; # option variable with default value (false) my $stls = 0; # option variable with default value (false)
my ( @include_dirs , @defines) ;
my @exclude_paths ;
my @swig_exclude_paths ;
my @ext_lib_paths ;
my %sim ; my %sim ;
my %out_of_date ; my %out_of_date ;
my ($version, $thread, $year) ; my ($version, $thread, $year) ;
@ -128,14 +124,13 @@ if ( $help ) {
($version, $thread) = get_trick_version() ; ($version, $thread) = get_trick_version() ;
($year) = $version =~ /^(\d+)/ ; ($year) = $version =~ /^(\d+)/ ;
@include_dirs = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS my @include_dirs = get_include_paths() ;
my @defines = get_defines() ;
my @exclude_paths = get_paths("TRICK_EXCLUDE") ;
my @swig_exclude_paths = get_paths("TRICK_SWIG_EXCLUDE") ;
my @ext_lib_paths = get_paths("TRICK_EXT_LIB_DIRS") ;
@exclude_paths = get_paths( "TRICK_EXCLUDE") ; if ( "$ENV{'TRICK_CFLAGS'} $ENV{'TRICK_CXXFLAGS'}" !~ /DTRICK_VER=/ ) {
@swig_exclude_paths = get_paths( "TRICK_SWIG_EXCLUDE") ;
@ext_lib_paths = get_paths( "TRICK_EXT_LIB_DIRS") ;
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
push @defines , "-DTRICK_VER=$year" ; push @defines , "-DTRICK_VER=$year" ;
} }

View File

@ -26,26 +26,13 @@ my %python_modules ;
my %python_module_dirs ; my %python_module_dirs ;
sub read_files_to_process() { sub read_files_to_process() {
my @include_paths ; my $version, my $thread = get_trick_version() ;
my $cc ; my $year = $version =~ /^(\d+)/ ;
my @defines ; (my $cc = gte("TRICK_CC")) =~ s/\n// ;
my ($version, $thread, $year) ;
($version, $thread) = get_trick_version() ; # Prepend -I to each include path before we pass them to the compiler
($year) = $version =~ /^(\d+)/ ; my @include_paths = map("-I$_", (get_include_paths(), "$ENV{TRICK_HOME}/include", "$ENV{TRICK_HOME}/include/trick/compat", "$ENV{TRICK_HOME}/trick_source", "../include")) ;
($cc = gte("TRICK_CC")) =~ s/\n// ; my @defines = (get_defines(), "-DTRICK_VER=$year", "-DSWIG", "-std=c++11") ;
# add -I paths and #defines
foreach my $value ( "TRICK_CFLAGS", "TRICK_CXXFLAGS" ) {
push @include_paths, $ENV{$value} =~ /(-I\s*\S+)/g ;
push @defines, $ENV{$value} =~ /(-D\S+)/g ;
}
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/include") ;
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/include/trick/compat") ;
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
push @defines , "-DTRICK_VER=$year" ;
push @defines , "-DSWIG" ;
push @defines , "-std=c++11" ;
# get the list of header files from the compiler # get the list of header files from the compiler
open FILE_LIST, "$cc -MM @include_paths @defines S_source.hh |" ; open FILE_LIST, "$cc -MM @include_paths @defines S_source.hh |" ;

View File

@ -9,6 +9,7 @@ use strict ;
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ; use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use gte ; use gte ;
use trick_print ; use trick_print ;
use get_paths ;
#-------------------------------------------------------------- #--------------------------------------------------------------
# Make Default Data # Make Default Data
@ -53,7 +54,7 @@ sub make_default_data($) {
// USER: $user\n\n" ; // USER: $user\n\n" ;
my @default_data_list ; my @default_data_list ;
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS @include_paths = get_include_paths() ;
foreach my $dd_comment ( @{$$sim_ref{default_data}} ) { foreach my $dd_comment ( @{$$sim_ref{default_data}} ) {
$dd_comment =~ s/\(\s*\(/\(/sg ; $dd_comment =~ s/\(\s*\(/\(/sg ;

View File

@ -5,6 +5,7 @@ use Cwd 'abs_path';
use File::Path qw(make_path) ; use File::Path qw(make_path) ;
use Exporter (); use Exporter ();
use gte ; use gte ;
use get_paths ;
@ISA = qw(Exporter); @ISA = qw(Exporter);
@EXPORT = qw(get_lib_deps write_lib_deps); @EXPORT = qw(get_lib_deps write_lib_deps);
@ -29,7 +30,7 @@ sub get_lib_deps ($$) {
# if there is preprocessor directive in the library dependencies, run the text through cpp. # if there is preprocessor directive in the library dependencies, run the text through cpp.
if ( $r =~ /#/ ) { if ( $r =~ /#/ ) {
(my $cc = gte("TRICK_CC")) =~ s/\n// ; (my $cc = gte("TRICK_CC")) =~ s/\n// ;
my @defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; my @defines = get_defines() ;
my $temp ; my $temp ;
open FILE, "echo \"$r\" | cpp -P @defines |" ; open FILE, "echo \"$r\" | cpp -P @defines |" ;
while ( <FILE> ) { while ( <FILE> ) {
@ -40,7 +41,7 @@ sub get_lib_deps ($$) {
push @lib_list , (split /\)[ \t\n\r\*]*\(/ , $r) ; push @lib_list , (split /\)[ \t\n\r\*]*\(/ , $r) ;
} }
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS @inc_paths = get_include_paths() ;
# Get only the include paths that exist # Get only the include paths that exist
my @valid_inc_paths ; my @valid_inc_paths ;
foreach (@inc_paths) { foreach (@inc_paths) {

View File

@ -3,7 +3,7 @@ package get_paths ;
use Exporter (); use Exporter ();
use Cwd 'abs_path' ; use Cwd 'abs_path' ;
@ISA = qw(Exporter); @ISA = qw(Exporter);
@EXPORT = qw(get_paths); @EXPORT = qw(get_paths get_include_paths get_defines);
use strict ; use strict ;
@ -12,4 +12,12 @@ sub get_paths {
return grep { $_ ne ''} map abs_path($_), grep { $_ ne '' } map { s/(^\s+|\s+$)//g ; $_ } split /:/, $ENV{$_[0]} ; return grep { $_ ne ''} map abs_path($_), grep { $_ ne '' } map { s/(^\s+|\s+$)//g ; $_ } split /:/, $ENV{$_[0]} ;
} }
sub get_include_paths {
return "$ENV{TRICK_CFLAGS} $ENV{TRICK_CXXFLAGS}" =~ /-I(\S+)/g
}
sub get_defines {
return "$ENV{TRICK_CFLAGS} $ENV{TRICK_CXXFLAGS}" =~ /-D\S+/g
}
1; 1;

View File

@ -11,7 +11,6 @@ use strict ;
use Cwd 'abs_path'; use Cwd 'abs_path';
use IPC::Open3 ; use IPC::Open3 ;
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use edit ; use edit ;
use find_module ; use find_module ;
use gte ; use gte ;
@ -19,6 +18,7 @@ use trick_print ;
use trick_version ; use trick_version ;
use Text::Balanced qw(extract_bracketed); use Text::Balanced qw(extract_bracketed);
use html ; use html ;
use get_paths ;
my ($integ_loop_def , $collect_def , $vcollect_def); my ($integ_loop_def , $collect_def , $vcollect_def);
my ($job_class_order_def ) ; my ($job_class_order_def ) ;
@ -172,15 +172,12 @@ sub parse_s_define ($) {
my ($CC, $contents) ; my ($CC, $contents) ;
my (@prescan_job_class_order) ; my (@prescan_job_class_order) ;
my ($version, $thread, $year) ; my ($version, $thread, $year) ;
my @defines ;
my @comments ; my @comments ;
my @preprocess_output; my @preprocess_output;
# Get Include Paths From $TRICK_CFLAGS @{$$sim_ref{inc_paths}} = (get_include_paths(), $ENV{TRICK_SYSTEM_CFLAGS} =~ /-I(\S+)/g, "$ENV{TRICK_HOME}/trick_source" , "../include") ;
@{$$sim_ref{inc_paths}} = "$ENV{TRICK_CFLAGS} $ENV{TRICK_SYSTEM_CFLAGS}" =~ /-I\s*(\S+)/g ;
push @{$$sim_ref{inc_paths}} , ("$ENV{TRICK_HOME}/trick_source" , "../include") ;
my @valid_inc_paths ; my @valid_inc_paths ;
foreach (@{$$sim_ref{inc_paths}}) { foreach (@{$$sim_ref{inc_paths}}) {