From 5da3dfdf08120c655c5d5cfb894a681aba7b021e Mon Sep 17 00:00:00 2001 From: ski Date: Thu, 22 Dec 2016 20:54:00 +0300 Subject: [PATCH] 0026866: Configuration, genproj - ensure consistency between FILES and actual content of inc and src folders Added check of consistency between FILES and actual content of inc and src folders in genproj procedure. --- adm/genproj.tcl | 60 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/adm/genproj.tcl b/adm/genproj.tcl index 57848aa3bc..3a97b319ee 100644 --- a/adm/genproj.tcl +++ b/adm/genproj.tcl @@ -816,6 +816,7 @@ proc osutils:collectinc {theModules theIncPath} { } } + set allHeaderFiles {} if { $aCopyType == "shortcut" } { # template preparation if { ![file exists $::THE_CASROOT/adm/templates/header.in] } { @@ -829,9 +830,12 @@ proc osutils:collectinc {theModules theIncPath} { # create and copy short-cut header files foreach anUnit $anUnits { - set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"] - foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] { - set aHeaderFileName [file tail $aHeaderFile] + osutils:checksrcfiles ${anUnit} + + set aHFiles [_get_used_files ${anUnit} true false] + foreach aHeaderFile ${aHFiles} { + set aHeaderFileName [lindex ${aHeaderFile} 1] + lappend allHeaderFiles "${aHeaderFileName}" regsub -all -- {@OCCT_HEADER_FILE_CONTENT@} $aHeaderTmpl "#include \"$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName\"" aShortCutHeaderFileContent @@ -863,9 +867,12 @@ proc osutils:collectinc {theModules theIncPath} { } else { set nbcopied 0 foreach anUnit $anUnits { - set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"] - foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] { - set aHeaderFileName [file tail $aHeaderFile] + osutils:checksrcfiles ${anUnit} + + set aHFiles [_get_used_files ${anUnit} true false] + foreach aHeaderFile ${aHFiles} { + set aHeaderFileName [lindex ${aHeaderFile} 1] + lappend allHeaderFiles "${aHeaderFileName}" # copy file only if target does not exist or is older than original set torig [file mtime $aHeaderFile] @@ -890,6 +897,15 @@ proc osutils:collectinc {theModules theIncPath} { } puts "Info: $nbcopied files updated" } + + # remove header files not listed in FILES + set anIncFiles [glob -tails -nocomplain -dir ${anIncPath} "*"] + foreach anIncFile ${anIncFiles} { + if { [lsearch -exact ${allHeaderFiles} ${anIncFile}] == -1 } { + puts "Warning: file ${anIncPath}/${anIncFile} is not presented in the sources and will be removed from ${theIncPath}!" + file delete -force "${theIncPath}/${anIncFile}" + } + } } # Generate header for VS solution file @@ -3323,3 +3339,35 @@ proc osutils:uwp:proj { theVcVer theProjTmpl } { return ${theProjTmpl} } + +# Report all files found in package directory but not listed in FILES +proc osutils:checksrcfiles { theUnit } { + global path + set aCasRoot [file normalize ${path}] + + if {![file isdirectory ${aCasRoot}]} { + puts "OCCT directory is not defined correctly: ${aCasRoot}" + return + } + + set anUnitAbsPath [file normalize "${aCasRoot}/src/${theUnit}"] + + if {[file exists "${anUnitAbsPath}/FILES"]} { + set aFilesFile [open "${anUnitAbsPath}/FILES" rb] + set aFilesFileList [split [read ${aFilesFile}] "\n"] + close ${aFilesFile} + + set aFilesFileList [lsearch -inline -all -not -exact ${aFilesFileList} ""] + + # report all files not listed in FILES + set anAllFiles [glob -tails -nocomplain -dir ${anUnitAbsPath} "*"] + foreach aFile ${anAllFiles} { + if { "${aFile}" == "FILES" } { + continue + } + if { [lsearch -exact ${aFilesFileList} ${aFile}] == -1 } { + puts "Warning: file ${anUnitAbsPath}/${aFile} is not listed in ${anUnitAbsPath}/FILES!" + } + } + } +}