⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copyrelease.tcl

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 TCL
字号:

set WaitOnFinish 1


#go to this directory
set basedir [file dirname "$argv0"]
cd $basedir



proc BackUpOld {} {

  cd ../DelphiDocRelease

  set files [concat [glob -nocomplain -types d "DelphiDoc.*"] [glob -nocomplain -types f "ConvertForKylix.*.tcl.zip"]]

  if {"$files" != ""} {
    set newdir "z_old_[clock format [clock seconds] -format {%Y_%m_%d_%H%M%S}]"
    file mkdir $newdir
    foreach f $files {
      file rename $f $newdir
    }

    puts stderr "Moved old release to: $newdir"
  }

  cd ../DelphiDoc
}










proc CopyRelease {} {
global basedir

  set release ../DelphiDocRelease

  set bin $release/DelphiDoc.bin
  set src $release/DelphiDoc.src



  file mkdir $bin 


  puts stdout "Copying base bin files..."

  foreach f {DelphiDoc.exe DelphiDocCL.exe DelphiDocGUI.chm 
             LICENSE.txt README.txt 
             PreDefinedIdents.txt SystemIdents.txt SystemTypes.txt} {
    if [file isfile $f] {
      file copy $f $bin
    } else {
      puts stderr "File for bin not found: $f"
    }
  }


  set doc ${bin}/Documentation
  file mkdir $doc

  puts stdout "Copying documentation for bin..."

  foreach f [glob -types f -directory z_html/SumUp "*{.html,.png,.css}"] {
    file copy $f $doc
  }







  file mkdir $src

  puts stdout "Copying base src files..."

  foreach f {LICENSE.txt README.txt 
             PreDefinedIdents.txt SystemIdents.txt SystemTypes.txt} {
    if [file isfile $f] {
      file copy $f $src
    } else {
      puts stderr "File for src not found: $f"
    }
  }


  puts stdout "Copying documentation for src..."

  file copy $doc ${src}


  set srcs ${src}/Source
  file mkdir $srcs


  puts stdout "Copying sources..."

  foreach f [glob -types d "*"] {

    if {[string first [string range $f 0 0] _zZ] == -1} {
      puts stdout "Copying ${f}..."

      file copy $f ${srcs}/$f

      foreach backup [glob -nocomplain -directory ${srcs}/$f -types f {*.~*}] {
        file delete $backup
      }

      foreach subdir [glob -nocomplain -directory ${srcs}/$f -types d "*"] {
        foreach backup [glob -nocomplain -directory $subdir -types f {*.~*}] {
          file delete $backup
        }
      }
    }
  }

  puts stdout "Extracting Extras..."
  file rename ${srcs}/Extras $release/DelphiDoc.Extras



  set docsrc ${src}/GUIDocSource
  file mkdir $docsrc

  puts stdout "Copying sources of documentation about GUI..."

  foreach f [glob -types f -directory z_html/generate "*"] {
    file copy $f ${docsrc}
  }




  puts stdout "Creating empty directories for DCUs..."
  file mkdir ${srcs}/z_dcus ${srcs}/z_dcusCL

  puts stdout "Removing Delphi..."
  file delete -force ${srcs}/General/Delphi
  puts stdout "Removing ZLib..."
  file delete -force ${srcs}/General/Zlib

#  puts stdout "Removing GUI Components..."
#  foreach backup [glob -nocomplain -directory ${srcs}/GUI/Components -types f {*.~*}] {
#    file delete $backup
#  }
#  foreach f [glob -types f -directory ${srcs}/GUI/Components "*"] {
##    puts "debug: $f = [string range $f end-13 end] = [string equal -nocase [string range $f end-13 end] /SetButton.pas]"
#    if {! [string equal -nocase [string range $f end-13 end] /SetButton.pas]} {
#      file delete $f
#    }
#  }





  puts stdout "Copying sources in root directory..."

  foreach f {DelphiDoc.cfg DelphiDoc.dof DelphiDoc.dpr DelphiDoc.res 
             DelphiDocCL.cfg DelphiDocCL.dof DelphiDocCL.dpr DelphiDocCL.res 
             DelphiDocGrp.bpg DelphiDocGrp.dsk 
             ToDo.txt 
             changecomments.tcl CopyRelease.tcl CheckHTMLFiles.tcl 
             dd.ddp 
             UserDocumentation.txt UserDocumentation_1.txt UserDocumentation_2.txt 
             icon.bmp icon.png icon.jpg icon.ico icon.wmf pal_rgba.png pal_ga.png} {
    if [file isfile $f] {
      file copy $f $srcs
    } else {
      puts stderr "File for src's not found: $f"
    }
  }


  puts stdout "Finished copying sources"


  file copy ConvertForKylix.tcl.zip $release

  puts stdout "Copied ConvertForKylix.tcl.zip"
}




#Conditionals=Debug;USENORMALSPINEDIT
#../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.cfg
#-DDebug;   USENORMALSPINEDIT




proc DefineCompilerSymbols {} {

  puts stdout "Adding Compiler Symbols...."


  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.dof" r]
  fconfigure $FileID -translation binary
  set content [read $FileID]
  close $FileID


  if [regsub -nocase {(\nConditionals=[^\n\r]*)(\r?\n)} $content {\1;USENORMALSPINEDIT\2} newcontent] {
    set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.dof" w]
    fconfigure $FileID -translation binary
    puts -nonewline $FileID "$newcontent"
    close $FileID
  } {
    puts stderr "Can't set Compiler Symbols in DelphiDoc.dof"
  }




  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.cfg" r]
  fconfigure $FileID -translation binary
  set content [read $FileID]
  close $FileID


  if [regsub -nocase {(\n-D[^\n\r]*)(\r?\n)} $content {\1;USENORMALSPINEDIT\2} newcontent] {
    set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.cfg" w]
    fconfigure $FileID -translation binary
    puts -nonewline $FileID "$newcontent"
    close $FileID
  } {
    puts stderr "Can't set Compiler Symbols in DelphiDoc.cfg"
  }
 
 
  puts stdout "Added Compiler Symbols"
}






proc IgnoreUnsureWarnings {} {

  puts stdout "Ignoring Unsure ... Warnings (.NET)...."



  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.dof" r]
  fconfigure $FileID -translation binary
  set content [read $FileID]
  close $FileID

  if [regsub -nocase {(^\[Compiler\])(\r?\n)} $content {\1\2UnsafeType=0\2UnsafeCode=0\2UnsafeCast=0\2} newcontent] {
    set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.dof" w]
    fconfigure $FileID -translation binary
    puts -nonewline $FileID "$newcontent"
    close $FileID
  } {
    puts stderr "Can't ignore \"Unsure ...\" warnings in DelphiDoc.dof"
  }


  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.cfg" a]
  fconfigure $FileID -translation binary
  puts -nonewline $FileID "-w-UNSAFE_TYPE\r\n-w-UNSAFE_CODE\r\n-w-UNSAFE_CAST\r\n"
  close $FileID





  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDocCL.dof" r]
  fconfigure $FileID -translation binary
  set content [read $FileID]
  close $FileID

  if [regsub -nocase {(^\[Compiler\])(\r?\n)} $content {\1\2UnsafeType=0\2UnsafeCode=0\2UnsafeCast=0\2} newcontent] {
    set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDocCL.dof" w]
    fconfigure $FileID -translation binary
    puts -nonewline $FileID "$newcontent"
    close $FileID
  } {
    puts stderr "Can't ignore \"Unsure ...\" warnings in DelphiDocCL.dof"
  }


  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDocCL.cfg" a]
  fconfigure $FileID -translation binary
  puts -nonewline $FileID "-w-UNSAFE_TYPE\r\n-w-UNSAFE_CODE\r\n-w-UNSAFE_CAST\r\n"
  close $FileID

 

  puts stdout "Ignoring warning messages"
}



proc RenameToReleaseNames {} {

  set FileID [open "../DelphiDocRelease/DelphiDoc.src/Source/DelphiDoc.dof" r]
  fconfigure $FileID -translation binary
  set content [read $FileID]
  close $FileID


  set reldir "../DelphiDocRelease/"

  if [regexp -nocase {\nFileVersion=([^\n\r]*)\r?\n} $content newcontent fileversion] {

    foreach f {DelphiDoc.bin DelphiDoc.src DelphiDoc.Extras ConvertForKylix.tcl.zip} {

      set dot [string first . $f]
      if {$dot == -1} {
        set newf $f.$fileversion
      } {
        set newf [string replace $f $dot $dot .$fileversion.]
      }

puts "renaming $f to $newf after $fileversion and $dot"

      file rename $reldir/$f $reldir/$newf
    }
  } {
    puts stderr "Can't ignore rename final names as not file version found in DelphiDoc.dof"
  }

}




exec mode con lines=50

if { [catch BackUpOld message] } {
  puts stderr "ERROR!"
  puts stderr "$message"
} {
  if { [catch CopyRelease message] } {
    puts stderr "ERROR!"
    puts stderr "$message"
  } {
    if { [catch DefineCompilerSymbols message] } {
      puts stderr "ERROR!"
      puts stderr "$message"
    } {
      if { [catch IgnoreUnsureWarnings message] } {
        puts stderr "ERROR!"
        puts stderr "$message"
      } {
        if { [catch RenameToReleaseNames message] } {
          puts stderr "ERROR!"
          puts stderr "$message"
        }
      }
    }
  }
}


if {$WaitOnFinish} {
  puts stdout "Press Enter to finish the Script..."
  gets stdin somevar
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -