diff --git a/libexec/trick/configuration_processor b/libexec/trick/configuration_processor index 3fada80e..b92f3664 100755 --- a/libexec/trick/configuration_processor +++ b/libexec/trick/configuration_processor @@ -16,9 +16,13 @@ use gte ; use s_source ; use trick_print ; use trick_version ; +use get_paths ; +use verbose_build ; my %sim ; 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 *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}} ) { if ( $file ne "" ) { $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" ; } } diff --git a/libexec/trick/make_makefile_src b/libexec/trick/make_makefile_src index 5f16a0a2..3db90eec 100755 --- a/libexec/trick/make_makefile_src +++ b/libexec/trick/make_makefile_src @@ -14,6 +14,7 @@ use verbose_build ; my %processed_files ; my %non_lib_processed_files ; my $any_deps_changed = 0 ; +my $verbose_build = verbose_build() ; sub exist_lib_deps(@) { my (@files_to_process) = @_ ; @@ -24,8 +25,8 @@ sub exist_lib_deps(@) { my ( $file, $dir, $suffix) = fileparse($l, qr/\.[^.]*/) ; my ($lib_dep_file_name) = "build$dir${file}${suffix}.lib_deps" ; if ( ! -e $lib_dep_file_name ) { - $any_deps_changed =1 ; - print "NewDep $l\n" ; + $any_deps_changed = 1 ; + print "New Dep $l\n" ; return 1 ; } } @@ -58,7 +59,7 @@ sub read_lib_deps($@) { read_lib_deps($indent + 1 , @resolved_files) ; } } - } elsif ( verbose_build() ) { + } elsif ( $verbose_build ) { print "Skipping Previously processed file \"$l\"\n" ; } } @@ -125,21 +126,6 @@ my @all_read_only_libs ; my @all_compile_libs ; 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_read_only_libs = sort (grep /^-/ , @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 $dt = localtime(); my ($trick_ver) = get_trick_version() ; diff --git a/libexec/trick/pm/get_lib_deps.pm b/libexec/trick/pm/get_lib_deps.pm index 614bf326..90937e15 100644 --- a/libexec/trick/pm/get_lib_deps.pm +++ b/libexec/trick/pm/get_lib_deps.pm @@ -6,11 +6,15 @@ use File::Path qw(make_path) ; use Exporter (); use gte ; use get_paths ; +use verbose_build ; @ISA = qw(Exporter); @EXPORT = qw(get_lib_deps write_lib_deps); use strict ; +my $verbose_build = verbose_build() ; +my @ext_lib_paths = get_paths( "TRICK_EXT_LIB_DIRS" ) ; + sub get_lib_deps ($$) { my ($contents, $source_file_name) = @_ ; 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($) { diff --git a/libexec/trick/pm/get_paths.pm b/libexec/trick/pm/get_paths.pm index c44d25f1..675cb608 100644 --- a/libexec/trick/pm/get_paths.pm +++ b/libexec/trick/pm/get_paths.pm @@ -3,7 +3,7 @@ package get_paths ; use Exporter (); use Cwd 'abs_path' ; @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 ; @@ -20,10 +20,11 @@ sub get_defines { return "$ENV{TRICK_CFLAGS} $ENV{TRICK_CXXFLAGS}" =~ /-D\S+/g } -sub is_path_in { - foreach my $path (get_paths($_[1])) { - if ( $_[0] =~ /^\Q$path\E(.*)/ or abs_path($_[0]) =~ /^\Q$path\E(.*)/ ) { - return 1 ; +sub get_containing_path { + my $path = shift; + foreach my $exclude_path (@_) { + if ( $path =~ /^\Q$exclude_path\E(.*)/ or abs_path($path) =~ /^\Q$exclude_path\E(.*)/ ) { + return $exclude_path ; } } return 0 ; diff --git a/test/SIM_exclusion_mechanisms/RUN_test/input.py b/test/SIM_exclusion_mechanisms/RUN_test/input.py new file mode 100644 index 00000000..e69de29b diff --git a/test/SIM_exclusion_mechanisms/S_define b/test/SIM_exclusion_mechanisms/S_define new file mode 100644 index 00000000..a03b3fc0 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/S_define @@ -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" diff --git a/test/SIM_exclusion_mechanisms/S_overrides.mk b/test/SIM_exclusion_mechanisms/S_overrides.mk new file mode 100644 index 00000000..a5c60c6d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/S_overrides.mk @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/Exclude.hh b/test/SIM_exclusion_mechanisms/models/Exclude.hh new file mode 100644 index 00000000..b748403b --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/Exclude.hh @@ -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 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 diff --git a/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp new file mode 100644 index 00000000..02086a78 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp @@ -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. diff --git a/test/SIM_exclusion_mechanisms/models/ExtLibDir.hh b/test/SIM_exclusion_mechanisms/models/ExtLibDir.hh new file mode 100644 index 00000000..9972b8e0 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/ExtLibDir.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/Foo.cpp b/test/SIM_exclusion_mechanisms/models/Foo.cpp new file mode 100644 index 00000000..222ffaa3 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/Foo.cpp @@ -0,0 +1,2 @@ +// @trick_link_dependency{ExtLibDir.cpp} +// @trick_link_dependency{ext_lib_dir/ExtLibDir.cpp} diff --git a/test/SIM_exclusion_mechanisms/models/Foo.hh b/test/SIM_exclusion_mechanisms/models/Foo.hh new file mode 100644 index 00000000..fa57158a --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/Foo.hh @@ -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" diff --git a/test/SIM_exclusion_mechanisms/models/IcgExclude.hh b/test/SIM_exclusion_mechanisms/models/IcgExclude.hh new file mode 100644 index 00000000..e2e42e1d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/IcgExclude.hh @@ -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 foos; +}; + +#endif diff --git a/test/SIM_exclusion_mechanisms/models/SwigExclude.hh b/test/SIM_exclusion_mechanisms/models/SwigExclude.hh new file mode 100644 index 00000000..1c9c3a1d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/SwigExclude.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/exclude/Exclude.hh b/test/SIM_exclusion_mechanisms/models/exclude/Exclude.hh new file mode 100644 index 00000000..18fabf1a --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/exclude/Exclude.hh @@ -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 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 diff --git a/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp new file mode 100644 index 00000000..02086a78 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp @@ -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. diff --git a/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.hh b/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.hh new file mode 100644 index 00000000..dd9b4161 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/icg_exclude/IcgExclude.hh b/test/SIM_exclusion_mechanisms/models/icg_exclude/IcgExclude.hh new file mode 100644 index 00000000..a8dce493 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/icg_exclude/IcgExclude.hh @@ -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 foos; +}; + +#endif diff --git a/test/SIM_exclusion_mechanisms/models/swig_exclude/SwigExclude.hh b/test/SIM_exclusion_mechanisms/models/swig_exclude/SwigExclude.hh new file mode 100644 index 00000000..1c9c3a1d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/swig_exclude/SwigExclude.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/exclude/Exclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/exclude/Exclude.hh new file mode 120000 index 00000000..c7cd3b30 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/exclude/Exclude.hh @@ -0,0 +1 @@ +../../real/exclude/Exclude.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.cpp new file mode 120000 index 00000000..041627f3 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.cpp @@ -0,0 +1 @@ +../../real/ext_lib_dir/ExtLibDir.cpp \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.hh new file mode 120000 index 00000000..ab9c06eb --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/ext_lib_dir/ExtLibDir.hh @@ -0,0 +1 @@ +../../real/ext_lib_dir/ExtLibDir.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/icg_exclude/IcgExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/icg_exclude/IcgExclude.hh new file mode 120000 index 00000000..24f91a3b --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/icg_exclude/IcgExclude.hh @@ -0,0 +1 @@ +../../real/icg_exclude/IcgExclude.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/swig_exclude/SwigExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/swig_exclude/SwigExclude.hh new file mode 120000 index 00000000..846ffdd0 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/links/swig_exclude/SwigExclude.hh @@ -0,0 +1 @@ +../../real/swig_exclude/SwigExclude.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/exclude/Exclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/exclude/Exclude.hh new file mode 100644 index 00000000..0082eeac --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/exclude/Exclude.hh @@ -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 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 diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp new file mode 100644 index 00000000..02086a78 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp @@ -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. diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.hh new file mode 100644 index 00000000..88943646 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/icg_exclude/IcgExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/icg_exclude/IcgExclude.hh new file mode 100644 index 00000000..82ae2979 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/icg_exclude/IcgExclude.hh @@ -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 foos; +}; + +#endif diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/swig_exclude/SwigExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/swig_exclude/SwigExclude.hh new file mode 100644 index 00000000..1c9c3a1d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/swig_exclude/SwigExclude.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/exclude/Exclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/exclude/Exclude.hh new file mode 120000 index 00000000..c7cd3b30 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/exclude/Exclude.hh @@ -0,0 +1 @@ +../../real/exclude/Exclude.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.cpp new file mode 120000 index 00000000..041627f3 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.cpp @@ -0,0 +1 @@ +../../real/ext_lib_dir/ExtLibDir.cpp \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.hh new file mode 120000 index 00000000..ab9c06eb --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/ext_lib_dir/ExtLibDir.hh @@ -0,0 +1 @@ +../../real/ext_lib_dir/ExtLibDir.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/icg_exclude/IcgExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/icg_exclude/IcgExclude.hh new file mode 120000 index 00000000..24f91a3b --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/icg_exclude/IcgExclude.hh @@ -0,0 +1 @@ +../../real/icg_exclude/IcgExclude.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/swig_exclude/SwigExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/swig_exclude/SwigExclude.hh new file mode 120000 index 00000000..846ffdd0 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/links/swig_exclude/SwigExclude.hh @@ -0,0 +1 @@ +../../real/swig_exclude/SwigExclude.hh \ No newline at end of file diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/exclude/Exclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/exclude/Exclude.hh new file mode 100644 index 00000000..30ab794e --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/exclude/Exclude.hh @@ -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 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 diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp new file mode 100644 index 00000000..02086a78 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp @@ -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. diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.hh new file mode 100644 index 00000000..4cdeb4af --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/icg_exclude/IcgExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/icg_exclude/IcgExclude.hh new file mode 100644 index 00000000..bda112c8 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/icg_exclude/IcgExclude.hh @@ -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 foos; +}; + +#endif diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/swig_exclude/SwigExclude.hh b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/swig_exclude/SwigExclude.hh new file mode 100644 index 00000000..1c9c3a1d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/swig_exclude/SwigExclude.hh @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/trickified/.gitignore b/test/SIM_exclusion_mechanisms/models/trickified/.gitignore new file mode 100644 index 00000000..11033b5d --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/trickified/.gitignore @@ -0,0 +1,2 @@ +python +trickified.o diff --git a/test/SIM_exclusion_mechanisms/models/trickified/Makefile b/test/SIM_exclusion_mechanisms/models/trickified/Makefile new file mode 100644 index 00000000..772c6ddb --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/trickified/Makefile @@ -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 diff --git a/test/SIM_exclusion_mechanisms/models/trickified/S_source.hh b/test/SIM_exclusion_mechanisms/models/trickified/S_source.hh new file mode 100644 index 00000000..0e71e080 --- /dev/null +++ b/test/SIM_exclusion_mechanisms/models/trickified/S_source.hh @@ -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" diff --git a/test/makefile b/test/makefile index 79f46a36..c2e8b138 100644 --- a/test/makefile +++ b/test/makefile @@ -19,6 +19,7 @@ COMPILE_DIRS = \ SIMS_NEEDING_TEST = \ SIM_alloc_test \ SIM_demo_inputfile \ + SIM_exclusion_mechanisms \ SIM_isystem \ SIM_measurement_units \ SIM_parse_s_define \ diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 3474d3de..bf9495fe 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -524,7 +524,7 @@ bool PrintAttributes::isHeaderExcluded(const std::string& header, bool exclude_e return true; } - temp = almostRealPath(header.c_str()); + temp = realpath(header.c_str(), NULL); if ( temp ) { const std::string real_path = std::string(temp); free(temp) ;