Symbolic links rise again #530

Found more places where symbolic links cause havoc.  Also added back a #define
that was removed in parameter_types.h and added back the messaging routines to
the list swig processes.
This commit is contained in:
Alex Lin 2017-12-12 10:14:23 -06:00
parent 1682a0d3c5
commit 5285f1a72e
6 changed files with 76 additions and 6 deletions

View File

@ -45,6 +45,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>

View File

@ -128,7 +128,27 @@ if ( $help ) {
@include_dirs = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
@exclude_paths = map abs_path($_), split /:/ , $ENV{"TRICK_EXCLUDE"} ;
if (scalar @exclude_paths) {
@exclude_paths = sort(@exclude_paths );
# Error check - delete any element that is null
# (note: sort forced all blank names to front of array
@exclude_paths = map { s/(^\s+|\s+$)//g ; $_ } @exclude_paths ;
while ( not length @exclude_paths[0] ) {
# Delete an element from the left side of an array (element zero)
shift @exclude_paths ;
}
}
@swig_exclude_paths = map abs_path($_), split /:/ , $ENV{"TRICK_SWIG_EXCLUDE"} ;
if (scalar @swig_exclude_paths) {
@swig_exclude_paths = sort(@swig_exclude_paths );
# Error check - delete any element that is null
# (note: sort forced all blank names to front of array
@swig_exclude_paths = map { s/(^\s+|\s+$)//g ; $_ } @swig_exclude_paths ;
while ( not length @swig_exclude_paths[0] ) {
# Delete an element from the left side of an array (element zero)
shift @swig_exclude_paths ;
}
}
@ext_lib_paths = map abs_path($_), split /:/ , $ENV{"TRICK_EXT_LIB_DIRS"} ;
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
@ -211,8 +231,8 @@ sub process_file() {
# remove all comments, they can cause all kinds of trouble
# leave the line continuation character if present
$raw_contents =~ s/\/\/(?:.*?)(\\)?(\n)/$1\n/sg ;
$raw_contents =~ s/\/\*(?:.*?)\*\/(\s*\\\n)?/$1/sg ;
$raw_contents =~ s/\/\*(?:.*?)\*\/|\/\/(?:.*?)(\\)?(\n)/$1\n/sg ;
## The init_attr functions cause problems when we try and wrap them with SWIG.
## We can safely remove them from the header files.
@ -258,7 +278,7 @@ sub process_file() {
}
# Get the canonical path (resolve ., .., and symbolic links)
$file_name = abs_path($file_name) ;
$file_name = abs_path(dirname($file_name)) . "/" . basename($file_name) ;
# Skip excluded paths
foreach my $i ( @exclude_paths, @swig_exclude_paths ) {
@ -266,7 +286,6 @@ sub process_file() {
next outer ;
}
}
$file_name = "build" . $file_name ;
$file_name =~ s/\.[^\.]+?$/\_py.i/ ;
$contents .= "\%import \"$file_name\"\n" ;

View File

@ -95,6 +95,10 @@ sub read_files_to_process() {
print "SWIG Skip TRICK_EXCLUDE: $path$1\n" if $verbose_build ;
next outer ;
}
if ( abs_path($word) =~ /^\Q$path\E(.*)/ ) {
print "SWIG Skip TRICK_EXCLUDE: $path$1\n" if $verbose_build ;
next outer ;
}
}
# skip paths in TRICK_SWIG_EXCLUDE
@ -103,6 +107,10 @@ sub read_files_to_process() {
print "SWIG Skip TRICK_SWIG_EXCLUDE: $path$1\n" if $verbose_build ;
next outer ;
}
if ( abs_path($word) =~ /^\Q$path\E(.*)/ ) {
print "SWIG Skip TRICK_SWIG_EXCLUDE: $path$1\n" if $verbose_build ;
next outer ;
}
}
# we'll be needing this later
@ -161,7 +169,7 @@ sub write_makefile_swig() {
print PY_LINK_LIST "build/init_swig_modules.o\n" ;
print PY_LINK_LIST "build/top.o\n" ;
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers -Wno-unused-but-set-variable
ifeq (\$(IS_CC_CLANG), 1)
SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized -Wno-deprecated-register

View File

@ -426,7 +426,7 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
tst_string.erase(pos , 7) ;
}
// clang changes bool to _Bool. We need to change it back
if ((pos = tst_string.find("<_Bool")) != std::string::npos ) {
while ((pos = tst_string.find("<_Bool")) != std::string::npos ) {
tst_string.replace(pos , 6, "<bool") ;
}
while ((pos = tst_string.find(" _Bool")) != std::string::npos ) {

View File

@ -240,6 +240,10 @@ void PrintAttributes::printClass( ClassValues * cv ) {
outfile.close();
}
if (!isHeaderExcluded(fileName)) {
printer->printClassMap(class_map_outfile, cv);
}
/*
char* realPath = almostRealPath(fileName.c_str());
if (realPath) {
if (isFileIncluded(fileName) or hsd.isPathInExtLib(realPath)) {
@ -247,6 +251,7 @@ void PrintAttributes::printClass( ClassValues * cv ) {
}
free(realPath);
}
*/
}
void PrintAttributes::printEnum(EnumValues* ev) {
@ -270,9 +275,14 @@ void PrintAttributes::printEnum(EnumValues* ev) {
outfile.close() ;
}
if (!isHeaderExcluded(fileName)) {
printer->printEnumMap(enum_map_outfile, ev);
}
/*
if (isFileIncluded(fileName)) {
printer->printEnumMap(enum_map_outfile, ev) ;
}
*/
}
void PrintAttributes::createMapFiles() {
@ -531,6 +541,35 @@ bool PrintAttributes::isHeaderExcluded(const std::string& header, bool exclude_e
return true;
}
temp = realpath(header.c_str(),NULL);
if ( temp ) {
const std::string real_path = std::string(temp);
free(temp) ;
if ( real_path.compare(path) ) {
if (hsd.isPathInExclude(real_path)) {
if (verboseBuild) {
std::cout << skipping << "TRICK_EXCLUDE: " << underline(real_path, hsd.getPathInExclude(real_path).size()) << std::endl;
}
return true;
}
if (hsd.isPathInICGExclude(real_path)) {
if (verboseBuild) {
std::cout << skipping << "TRICK_ICG_EXCLUDE: " << underline(real_path, hsd.getPathInICGExclude(real_path).size()) << std::endl;
}
return true;
}
if (hsd.isPathInExtLib(real_path) && exclude_ext_libs) {
if (verboseBuild) {
std::cout << skipping << "TRICK_EXT_LIB_DIRS: " << underline(real_path, hsd.getPathInExtLib(real_path).size()) << std::endl;
}
ext_lib_io_files.insert(header) ;
return true;
}
}
}
return false;
}

View File

@ -120,6 +120,7 @@
#include "trick/MessagePublisher.hh"
#include "trick/MessageSubscriber.hh"
#include "trick/MessageTCDevice.hh"
#include "trick/Message_proto.hh"
#include "trick/message_proto.h"
#include "trick/MonteCarlo.hh"
#include "trick/montecarlo_c_intf.h"