Don't trace TRICK_EXT_LIB_DIRS lib deps in CP

Refs #871
This commit is contained in:
Derek Bankieris 2019-10-04 13:49:36 -05:00
parent 5e11a40a69
commit 1f33406c95
44 changed files with 397 additions and 36 deletions

View File

@ -16,9 +16,13 @@ use gte ;
use s_source ; use s_source ;
use trick_print ; use trick_print ;
use trick_version ; use trick_version ;
use get_paths ;
use verbose_build ;
my %sim ; my %sim ;
my $cwd = cwd(); my $cwd = cwd();
my $verbose_build = verbose_build() ;
my @ext_lib_paths = get_paths( "TRICK_EXT_LIB_DIRS" ) ;
# override the print format for help message # override the print format for help message
*Pod::Text::seq_i = sub { return "" . $_[1] . "" } ; *Pod::Text::seq_i = sub { return "" . $_[1] . "" } ;
@ -91,6 +95,10 @@ open LIBDEP, ">build/S_define.lib_deps" ;
foreach my $file ( @{$sim{mis_entry_files}} ) { foreach my $file ( @{$sim{mis_entry_files}} ) {
if ( $file ne "" ) { if ( $file ne "" ) {
$file = abs_path(dirname($file)) . "/" . basename($file) ; $file = abs_path(dirname($file)) . "/" . basename($file) ;
if ( my $path = get_containing_path( $file, @ext_lib_paths ) ) {
print "Dep Skip TRICK_EXT_LIB_DIRS: $path" . substr($file, length $path) . "\n" if $verbose_build ;
next ;
}
print LIBDEP "$file\n" ; print LIBDEP "$file\n" ;
} }
} }

View File

@ -14,6 +14,7 @@ use verbose_build ;
my %processed_files ; my %processed_files ;
my %non_lib_processed_files ; my %non_lib_processed_files ;
my $any_deps_changed = 0 ; my $any_deps_changed = 0 ;
my $verbose_build = verbose_build() ;
sub exist_lib_deps(@) { sub exist_lib_deps(@) {
my (@files_to_process) = @_ ; my (@files_to_process) = @_ ;
@ -24,8 +25,8 @@ sub exist_lib_deps(@) {
my ( $file, $dir, $suffix) = fileparse($l, qr/\.[^.]*/) ; my ( $file, $dir, $suffix) = fileparse($l, qr/\.[^.]*/) ;
my ($lib_dep_file_name) = "build$dir${file}${suffix}.lib_deps" ; my ($lib_dep_file_name) = "build$dir${file}${suffix}.lib_deps" ;
if ( ! -e $lib_dep_file_name ) { if ( ! -e $lib_dep_file_name ) {
$any_deps_changed =1 ; $any_deps_changed = 1 ;
print "NewDep $l\n" ; print "New Dep $l\n" ;
return 1 ; return 1 ;
} }
} }
@ -58,7 +59,7 @@ sub read_lib_deps($@) {
read_lib_deps($indent + 1 , @resolved_files) ; read_lib_deps($indent + 1 , @resolved_files) ;
} }
} }
} elsif ( verbose_build() ) { } elsif ( $verbose_build ) {
print "Skipping Previously processed file \"$l\"\n" ; print "Skipping Previously processed file \"$l\"\n" ;
} }
} }
@ -125,21 +126,6 @@ my @all_read_only_libs ;
my @all_compile_libs ; my @all_compile_libs ;
my %files_by_dir ; my %files_by_dir ;
my @exclude_dirs ;
@exclude_dirs = split /:/ , "$ENV{TRICK_EXCLUDE}:$ENV{TRICK_EXT_LIB_DIRS}";
# See if there are any elements in the exclude_dirs array
if (scalar @exclude_dirs) {
@exclude_dirs = sort(@exclude_dirs );
# Error check - delete any element that is null
# (note: sort forced all blank names to front of array
@exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @exclude_dirs ;
while ( scalar @exclude_dirs and not length @exclude_dirs[0] ) {
# Delete an element from the left side of an array (element zero)
shift @exclude_dirs ;
}
@exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @exclude_dirs ;
}
@all_cfly_files = keys %processed_files ; @all_cfly_files = keys %processed_files ;
@all_read_only_libs = sort (grep /^-/ , @all_cfly_files) ; @all_read_only_libs = sort (grep /^-/ , @all_cfly_files) ;
@all_compile_libs = grep /\.a$/ , @all_cfly_files ; @all_compile_libs = grep /\.a$/ , @all_cfly_files ;
@ -183,17 +169,6 @@ foreach my $directory ( keys %files_by_dir ) {
} }
} }
foreach $k ( sort keys %files_by_dir ) {
foreach my $ie ( @exclude_dirs ) {
# if file location begins with $ie (an exclude dir)
if ( $k =~ /^\Q$ie/ ) {
delete $files_by_dir{$k} ;
print "excluding $k from build\n" ;
last ; # break out of loop
}
}
}
my $wd = abs_path(cwd()) ; my $wd = abs_path(cwd()) ;
my $dt = localtime(); my $dt = localtime();
my ($trick_ver) = get_trick_version() ; my ($trick_ver) = get_trick_version() ;

View File

@ -6,11 +6,15 @@ use File::Path qw(make_path) ;
use Exporter (); use Exporter ();
use gte ; use gte ;
use get_paths ; use get_paths ;
use verbose_build ;
@ISA = qw(Exporter); @ISA = qw(Exporter);
@EXPORT = qw(get_lib_deps write_lib_deps); @EXPORT = qw(get_lib_deps write_lib_deps);
use strict ; use strict ;
my $verbose_build = verbose_build() ;
my @ext_lib_paths = get_paths( "TRICK_EXT_LIB_DIRS" ) ;
sub get_lib_deps ($$) { sub get_lib_deps ($$) {
my ($contents, $source_file_name) = @_ ; my ($contents, $source_file_name) = @_ ;
my ($lib_deps) ; my ($lib_deps) ;
@ -153,7 +157,16 @@ sub get_lib_deps ($$) {
} }
} }
} }
return (grep { !is_path_in($_, "TRICK_EXT_LIB_DIRS") } @ordered_resolved_files) ;
my @included_ordered_resolved_files;
foreach (@ordered_resolved_files) {
if ( my $exclude_path = get_containing_path( $_, @ext_lib_paths ) ) {
print "Dep Skip TRICK_EXT_LIB_DIRS: $exclude_path" . substr($_, length $exclude_path) . "\n" if $verbose_build ;
next ;
}
push @included_ordered_resolved_files, $_ ;
}
return @included_ordered_resolved_files ;
} }
sub write_lib_deps($) { sub write_lib_deps($) {

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 get_include_paths get_defines is_path_in); @EXPORT = qw(get_paths get_include_paths get_defines get_containing_path);
use strict ; use strict ;
@ -20,10 +20,11 @@ sub get_defines {
return "$ENV{TRICK_CFLAGS} $ENV{TRICK_CXXFLAGS}" =~ /-D\S+/g return "$ENV{TRICK_CFLAGS} $ENV{TRICK_CXXFLAGS}" =~ /-D\S+/g
} }
sub is_path_in { sub get_containing_path {
foreach my $path (get_paths($_[1])) { my $path = shift;
if ( $_[0] =~ /^\Q$path\E(.*)/ or abs_path($_[0]) =~ /^\Q$path\E(.*)/ ) { foreach my $exclude_path (@_) {
return 1 ; if ( $path =~ /^\Q$exclude_path\E(.*)/ or abs_path($path) =~ /^\Q$exclude_path\E(.*)/ ) {
return $exclude_path ;
} }
} }
return 0 ; return 0 ;

View File

@ -0,0 +1,26 @@
// @trick_link_dependency{ExtLibDir.cpp}
// @trick_link_dependency{ext_lib_dir/ExtLibDir.cpp}
#include "sim_objects/default_trick_sys.sm"
##include "Foo.hh"
##include "Exclude.hh"
##include "exclude/Exclude.hh"
##include "symlinks/exclude_link_path/links/exclude/Exclude.hh"
##include "symlinks/exclude_real_path/links/exclude/Exclude.hh"
##include "IcgExclude.hh"
##include "icg_exclude/IcgExclude.hh"
##include "symlinks/exclude_link_path/links/icg_exclude/IcgExclude.hh"
##include "symlinks/exclude_real_path/links/icg_exclude/IcgExclude.hh"
##include "SwigExclude.hh"
##include "swig_exclude/SwigExclude.hh"
##include "symlinks/exclude_link_path/links/swig_exclude/SwigExclude.hh"
##include "symlinks/exclude_real_path/links/swig_exclude/SwigExclude.hh"
##include "ExtLibDir.hh"
##include "ext_lib_dir/ExtLibDir.hh"
##include "symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.hh"
##include "symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.hh"

View File

@ -0,0 +1,32 @@
MODELS := $(CURDIR)/models
TRICK_CXXFLAGS += -I$(MODELS)
TRICK_EXCLUDE += :$(MODELS)/Exclude.hh
TRICK_EXCLUDE += :$(MODELS)/exclude
TRICK_EXCLUDE += :$(MODELS)/symlinks/exclude_link_path/links/exclude
TRICK_EXCLUDE += :$(MODELS)/symlinks/exclude_real_path/real/exclude
TRICK_ICG_EXCLUDE += :$(MODELS)/IcgExclude.hh
TRICK_ICG_EXCLUDE += :$(MODELS)/icg_exclude
TRICK_ICG_EXCLUDE += :$(MODELS)/symlinks/exclude_link_path/links/icg_exclude
TRICK_ICG_EXCLUDE += :$(MODELS)/symlinks/exclude_real_path/real/icg_exclude
TRICK_SWIG_EXCLUDE += :$(MODELS)/SwigExclude.hh
TRICK_SWIG_EXCLUDE += :$(MODELS)/swig_exclude
TRICK_SWIG_EXCLUDE += :$(MODELS)/symlinks/exclude_link_path/links/swig_exclude
TRICK_SWIG_EXCLUDE += :$(MODELS)/symlinks/exclude_real_path/real/swig_exclude
TRICK_EXT_LIB_DIRS += :$(MODELS)/ExtLibDir.hh
TRICK_EXT_LIB_DIRS += :$(MODELS)/ExtLibDir.cpp
TRICK_EXT_LIB_DIRS += :$(MODELS)/ext_lib_dir
TRICK_EXT_LIB_DIRS += :$(MODELS)/symlinks/exclude_link_path/links/ext_lib_dir
TRICK_EXT_LIB_DIRS += :$(MODELS)/symlinks/exclude_real_path/real/ext_lib_dir
TRICKIFIED := $(MODELS)/trickified/trickified.o
TRICK_PYTHON_PATH += :$(MODELS)/trickified/python
TRICK_SWIG_FLAGS += -I$(MODELS)/trickified
TRICK_LDFLAGS += $(TRICKIFIED)
$(SWIG_SRC): $(TRICKIFIED)
$(TRICKIFIED):
@$(MAKE) -s -C $(MODELS)/trickified

View File

@ -0,0 +1,22 @@
#ifndef EXCLUDE1
#define EXCLUDE1
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class Exclude1A {
private:
void operator=(const Exclude1A&);
};
class Exclude1B {
const std::vector<Exclude1A> foos;
};
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif
#endif

View File

@ -0,0 +1 @@
This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it.

View File

@ -0,0 +1,19 @@
// @trick_parse{everything}
// @trick_link_dependency{ExtLibDir.cpp}
#ifndef EXT_LIB_DIR1
#define EXT_LIB_DIR1
/**
* This file is part of a Trickified library and is meant to be excluded from
* ICG via TRICK_EXT_LIB_DIRS. If the exclusion logic failts, the generated I/O
* code will result in multiple-definition errors at link time as the symbols
* will also exist in the Trickified partially-linked object.
*/
class ExtLibDir1 {
private:
void operator=(const ExtLibDir1&);
};
#endif

View File

@ -0,0 +1,2 @@
// @trick_link_dependency{ExtLibDir.cpp}
// @trick_link_dependency{ext_lib_dir/ExtLibDir.cpp}

View File

@ -0,0 +1,22 @@
// @trick_parse{everything}
// @trick_link_dependency{Foo.cpp}
#include "Exclude.hh"
#include "exclude/Exclude.hh"
#include "symlinks/exclude_link_path/links/exclude/Exclude.hh"
#include "symlinks/exclude_real_path/links/exclude/Exclude.hh"
#include "IcgExclude.hh"
#include "icg_exclude/IcgExclude.hh"
#include "symlinks/exclude_link_path/links/icg_exclude/IcgExclude.hh"
#include "symlinks/exclude_real_path/links/icg_exclude/IcgExclude.hh"
#include "SwigExclude.hh"
#include "swig_exclude/SwigExclude.hh"
#include "symlinks/exclude_link_path/links/swig_exclude/SwigExclude.hh"
#include "symlinks/exclude_real_path/links/swig_exclude/SwigExclude.hh"
#include "ExtLibDir.hh"
#include "ext_lib_dir/ExtLibDir.hh"
#include "symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.hh"
#include "symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.hh"

View File

@ -0,0 +1,18 @@
#ifndef ICG_EXCLUDE1
#define ICG_EXCLUDE1
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class IcgExclude1A {
private:
void operator=(const IcgExclude1A&);
};
class IcgExclude1B {
const std::vector<IcgExclude1A> foos;
};
#endif

View File

@ -0,0 +1,3 @@
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif

View File

@ -0,0 +1,22 @@
#ifndef EXCLUDE2
#define EXCLUDE2
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class Exclude2A {
private:
void operator=(const Exclude2A&);
};
class Exclude2B {
const std::vector<Exclude2A> foos;
};
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif
#endif

View File

@ -0,0 +1 @@
This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it.

View File

@ -0,0 +1,19 @@
// @trick_parse{everything}
// @trick_link_dependency{ExtLibDir.cpp}
#ifndef EXT_LIB_DIR2
#define EXT_LIB_DIR2
/**
* This file is part of a Trickified library and is meant to be excluded from
* ICG via TRICK_EXT_LIB_DIRS. If the exclusion logic failts, the generated I/O
* code will result in multiple-definition errors at link time as the symbols
* will also exist in the Trickified partially-linked object.
*/
class ExtLibDir2 {
private:
void operator=(const ExtLibDir2&);
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef ICG_EXCLUDE2
#define ICG_EXCLUDE2
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class IcgExclude2A {
private:
void operator=(const IcgExclude2A&);
};
class IcgExclude2B {
const std::vector<IcgExclude2A> foos;
};
#endif

View File

@ -0,0 +1,3 @@
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif

View File

@ -0,0 +1 @@
../../real/exclude/Exclude.hh

View File

@ -0,0 +1 @@
../../real/ext_lib_dir/ExtLibDir.cpp

View File

@ -0,0 +1 @@
../../real/ext_lib_dir/ExtLibDir.hh

View File

@ -0,0 +1 @@
../../real/icg_exclude/IcgExclude.hh

View File

@ -0,0 +1 @@
../../real/swig_exclude/SwigExclude.hh

View File

@ -0,0 +1,22 @@
#ifndef EXCLUDE5
#define EXCLUDE5
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class Exclude5A {
private:
void operator=(const Exclude5A&);
};
class Exclude5B {
const std::vector<Exclude5A> foos;
};
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif
#endif

View File

@ -0,0 +1 @@
This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it.

View File

@ -0,0 +1,19 @@
// @trick_parse{everything}
// @trick_link_dependency{ExtLibDir.cpp}
#ifndef EXT_LIB_DIR3
#define EXT_LIB_DIR3
/**
* This file is part of a Trickified library and is meant to be excluded from
* ICG via TRICK_EXT_LIB_DIRS. If the exclusion logic failts, the generated I/O
* code will result in multiple-definition errors at link time as the symbols
* will also exist in the Trickified partially-linked object.
*/
class ExtLibDir3 {
private:
void operator=(const ExtLibDir3&);
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef ICG_EXCLUDE3
#define ICG_EXCLUDE3
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class IcgExclude3A {
private:
void operator=(const IcgExclude3A&);
};
class IcgExclude3B {
const std::vector<IcgExclude3A> foos;
};
#endif

View File

@ -0,0 +1,3 @@
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif

View File

@ -0,0 +1 @@
../../real/exclude/Exclude.hh

View File

@ -0,0 +1 @@
../../real/ext_lib_dir/ExtLibDir.cpp

View File

@ -0,0 +1 @@
../../real/ext_lib_dir/ExtLibDir.hh

View File

@ -0,0 +1 @@
../../real/icg_exclude/IcgExclude.hh

View File

@ -0,0 +1 @@
../../real/swig_exclude/SwigExclude.hh

View File

@ -0,0 +1,22 @@
#ifndef EXCLUDE6
#define EXCLUDE6
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class Exclude6A {
private:
void operator=(const Exclude6A&);
};
class Exclude6B {
const std::vector<Exclude6A> foos;
};
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif
#endif

View File

@ -0,0 +1 @@
This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it.

View File

@ -0,0 +1,19 @@
// @trick_parse{everything}
// @trick_link_dependency{ExtLibDir.cpp}
#ifndef EXT_LIB_DIR4
#define EXT_LIB_DIR4
/**
* This file is part of a Trickified library and is meant to be excluded from
* ICG via TRICK_EXT_LIB_DIRS. If the exclusion logic failts, the generated I/O
* code will result in multiple-definition errors at link time as the symbols
* will also exist in the Trickified partially-linked object.
*/
class ExtLibDir4 {
private:
void operator=(const ExtLibDir4&);
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef ICG_EXCLUDE4
#define ICG_EXCLUDE4
/**
* This file is meant to be excluded from ICG. It will produce ICG-generated
* code that does not compile (as long as
* https://github.com/nasa/trick/issues/422 isn't fixed).
*/
class IcgExclude4A {
private:
void operator=(const IcgExclude4A&);
};
class IcgExclude4B {
const std::vector<IcgExclude4A> foos;
};
#endif

View File

@ -0,0 +1,3 @@
#ifdef SWIG
This file is meant to be excluded from SWIG. It will cause an error if SWIG tries to process it.
#endif

View File

@ -0,0 +1,2 @@
python
trickified.o

View File

@ -0,0 +1,9 @@
SIM_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../..)
TRICK_HOME := $(abspath $(SIM_HOME)/../..)
export TRICKIFY_CXX_FLAGS := -I$(SIM_HOME)/models
all:
@$(MAKE) -s -f $(TRICK_HOME)/share/trick/makefiles/trickify.mk
clean:
@rm -rf build python trick trickified.o

View File

@ -0,0 +1,8 @@
#include "ExtLibDir.hh"
#include "ext_lib_dir/ExtLibDir.hh"
#include "symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.hh"
#include "symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.hh"
// https://github.com/nasa/trick/issues/881
//#include "symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.hh"
//#include "symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.hh"

View File

@ -19,6 +19,7 @@ COMPILE_DIRS = \
SIMS_NEEDING_TEST = \ SIMS_NEEDING_TEST = \
SIM_alloc_test \ SIM_alloc_test \
SIM_demo_inputfile \ SIM_demo_inputfile \
SIM_exclusion_mechanisms \
SIM_isystem \ SIM_isystem \
SIM_measurement_units \ SIM_measurement_units \
SIM_parse_s_define \ SIM_parse_s_define \

View File

@ -524,7 +524,7 @@ bool PrintAttributes::isHeaderExcluded(const std::string& header, bool exclude_e
return true; return true;
} }
temp = almostRealPath(header.c_str()); temp = realpath(header.c_str(), NULL);
if ( temp ) { if ( temp ) {
const std::string real_path = std::string(temp); const std::string real_path = std::string(temp);
free(temp) ; free(temp) ;