Index: Doc/buildChm.tcl ================================================================== --- Doc/buildChm.tcl +++ Doc/buildChm.tcl @@ -31,16 +31,63 @@ regsub -all -- {&} $data {\\\&} data regsub -all -- {\\(\d+)} $data {\\\\\1} data return $data } -set path [file dirname [info script]] +proc getFileHash { fileName } { + if {[catch { + exec fossil.exe sha1sum [file nativename $fileName] + } result] == 0} then { + return [string trim [lindex [split $result " "] 0]] + } + return "" +} + +# +# HACK: Copy our local [fixed] copy of the MSDN documenter assembly into the +# installed location of NDoc3, if necessary. Actually copying the file +# will require elevated administrator privileges; otherwise, it would +# fail. Any errors encountered while copying the file are reported via +# the console; however, they will not halt processing. +# +proc copyMsdnDocumenter { sourceDirectory destinationDirectory } { + set fileNameOnly NDoc3.Documenter.Msdn.dll + + set sourceFileName [file join $sourceDirectory bin $fileNameOnly] + set destinationFileName [file join $destinationDirectory bin $fileNameOnly] + + set sourceFileHash [getFileHash $sourceFileName] + # puts stdout "Hashed \"$sourceFileName\" ==> \"$sourceFileHash\"" + + set destinationFileHash [getFileHash $destinationFileName] + # puts stdout "Hashed \"$destinationFileName\" ==> \"$destinationFileHash\"" + + if {[string length $sourceFileHash] > 0 && \ + [string length $destinationFileHash] > 0 && \ + $sourceFileHash ne $destinationFileHash} then { + if {[catch { + file copy -force $destinationFileName $destinationFileName.bak + file copy -force $sourceFileName $destinationFileName + } result] == 0} then { + puts stdout \ + "finished copying \"$sourceFileName\" to \"$destinationFileName\"" + } else { + puts stdout $result + } + } else { + puts stdout \ + "skipped copying \"$sourceFileName\" to \"$destinationFileName\"" + } +} + +set path [file normalize [file dirname [info script]]] -set nDocPath [file join $env(ProgramFiles) NDoc3] +set nDocExtPath [file join [file dirname $path] Externals NDoc3] +set nDocInstPath [file join $env(ProgramFiles) NDoc3] -if {![file isdirectory $nDocPath]} then { - puts stdout "NDoc3 must be installed to: $nDocPath" +if {![file isdirectory $nDocInstPath]} then { + puts stdout "NDoc3 must be installed to: $nDocInstPath" exit 1 } set hhcPath [file join $env(ProgramFiles) "HTML Help Workshop"] @@ -95,20 +142,25 @@ # # TODO: If the NDoc version number ever changes, the next line of code will # probably need to be updated. # -set outputPath [file join Output ndoc3_msdn_temp] +set outputPath [file join Output] +set temporaryPath [file join $outputPath ndoc3_msdn_temp] + +if {[file isdirectory $nDocExtPath]} then { + copyMsdnDocumenter $nDocExtPath $nDocInstPath +} -set code [catch {exec [file join $nDocPath bin NDoc3Console.exe] \ +set code [catch {exec [file join $nDocInstPath bin NDoc3Console.exe] \ "-project=[file nativename $projectFile]"} result] puts stdout $result; if {$code != 0} then {exit $code} set fileNames [list SQLite.NET.hhp SQLite.NET.hhc] -foreach fileName [glob -nocomplain [file join $outputPath *.html]] { +foreach fileName [glob -nocomplain [file join $temporaryPath *.html]] { lappend fileNames [file tail $fileName] } set patterns(.hhc,1) {