mirror of
https://github.com/nasa/trick.git
synced 2025-04-08 03:44:21 +00:00
Backport capability to exclude individual files to 15 branch #527
Copied the code from Trick 17 that excludes individual files as well as directories
This commit is contained in:
parent
3a0c168c18
commit
0a01186ce3
@ -132,6 +132,18 @@ if ( $help ) {
|
||||
if ( scalar @swig_exclude_dirs == 0 ) {
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"} ;
|
||||
}
|
||||
if (scalar @swig_exclude_dirs) {
|
||||
@swig_exclude_dirs = sort(@swig_exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@swig_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @swig_exclude_dirs ;
|
||||
while ( not length @swig_exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @swig_exclude_dirs ;
|
||||
}
|
||||
@swig_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @swig_exclude_dirs ;
|
||||
}
|
||||
|
||||
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
|
||||
@ -391,6 +403,10 @@ sub process_file($$) {
|
||||
$exclude = 1 ;
|
||||
last ;
|
||||
}
|
||||
if ( abs_path($file_name) =~ /^\"\Q$i/ ) {
|
||||
$exclude = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $exclude == 0 ) {
|
||||
|
@ -166,11 +166,20 @@ sub make_makefile($$$) {
|
||||
my $dum = $_ ;
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $dum =~ s/^\Q$ie// ) {
|
||||
if ( $dum =~ /^\// ) {
|
||||
if ( $dum eq "" or $dum =~ /^\// ) {
|
||||
trick_print($$sim_ref{fh}, "CP skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
} else {
|
||||
$dum = abs_path($dum) ;
|
||||
if ( $dum =~ s/^\Q$ie// ) {
|
||||
if ( $dum eq "" or $dum =~ /^\// ) {
|
||||
trick_print($$sim_ref{fh}, "CP skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
|
@ -169,6 +169,12 @@ sub make_swig_makefile($$$) {
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
# if an exlude path is a file, then we need to check absolute path vs. absolute path of exclude directory.
|
||||
if ( abs_path($f) =~ /^\Q$ie/ ) {
|
||||
trick_print($$sim_ref{fh}, "CP(swig) skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
my $temp_str ;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@ -132,9 +133,17 @@ void HeaderSearchDirs::AddICGExcludeDirs () {
|
||||
//icg_exclude_dirs.push_back(item);
|
||||
item = trim(item) ;
|
||||
if ( ! item.empty() ) {
|
||||
char * resolved_path = realpath(item.c_str(), NULL) ;
|
||||
//char * resolved_path = realpath(item.c_str(), NULL) ;
|
||||
char * resolved_path = almostRealPath(item.c_str() ) ;
|
||||
if ( resolved_path ) {
|
||||
icg_exclude_dirs.push_back(std::string(resolved_path) + std::string("/"));
|
||||
std::ifstream file_or_dir(resolved_path) ;
|
||||
file_or_dir.seekg(0, std::ios::end) ;
|
||||
if ( !file_or_dir.good()) {
|
||||
icg_exclude_dirs.push_back(std::string(resolved_path) + "/");
|
||||
} else {
|
||||
icg_exclude_dirs.push_back(std::string(resolved_path));
|
||||
}
|
||||
free(resolved_path) ;
|
||||
} else {
|
||||
std::cout << "Cannot find TRICK_ICG_EXCLUDE directory " << item << std::endl ;
|
||||
}
|
||||
@ -156,7 +165,13 @@ void HeaderSearchDirs::AddICGNoCommentDirs () {
|
||||
if ( ! item.empty() ) {
|
||||
char * resolved_path = realpath(item.c_str(), NULL) ;
|
||||
if ( resolved_path ) {
|
||||
icg_nocomment_dirs.push_back(std::string(resolved_path) + std::string("/"));
|
||||
std::ifstream file_or_dir(resolved_path) ;
|
||||
file_or_dir.seekg(0, std::ios::end) ;
|
||||
if ( !file_or_dir.good()) {
|
||||
icg_nocomment_dirs.push_back(std::string(resolved_path) + "/");
|
||||
} else {
|
||||
icg_nocomment_dirs.push_back(std::string(resolved_path));
|
||||
}
|
||||
} else {
|
||||
std::cout << "Cannot find TRICK_ICG_NOCOMMENT directory " << item << std::endl ;
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ extern "C" {
|
||||
|
||||
const char* trickTypeCharString( TRICK_TYPE type, const char* name);
|
||||
|
||||
/* here for backwards compatibility */
|
||||
#define TRICK_USER_DEFINED_TYPE TRICK_OPAQUE_TYPE
|
||||
|
||||
/* Define int_64t and uint_64t depending on compiler options */
|
||||
#if __linux
|
||||
# include <stdint.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user