Hog Hog2024.2-4
make_doxygen.tcl
Go to the documentation of this file.
1 #!/usr/bin/env tclsh
2 # Copyright 2018-2024 The University of Birmingham
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 # @file
17 # Create the doxygen documentation
18 
19 #parsing command options
20 if {[catch {package require cmdline} ERROR]} {
21  puts "$ERROR\n If you are running this script on tclsh, you can fix this by installing 'tcllib'"
22  return
23 }
24 set parameters {
25 }
26 
27 set usage "USAGE: $::argv0"
28 
29 set tcl_path [file dirname [info script]]
30 set repo_path [file normalize $tcl_path/../../..]
31 cd $tcl_path
32 source ../hog.tcl
33 cd $repo_path
34 
35 if {[catch {array set options [cmdline::getoptions ::argv $parameters $usage]}] || $::argc != 0 } {
36  Msg Info [cmdline::usage $parameters $usage]
37  cd $repo_path
38  exit 1
39 }
40 
41 lassign [GetVer .] version commit
42 set version [HexVersionToString $version]
43 Msg Info "Creating doxygen documentation for tag $version"
44 
45 
46 # Run doxygen
47 set doxygen_conf "./doxygen/doxygen.conf"
48 if {[file exists $doxygen_conf] == 0 } {
49  # Using Default hog template
50  set doxygen_conf "./Hog/Templates/doxygen.conf"
51  Msg Info "Running doxygen with ./Hog/Templates/doxygen.conf..."
52 } else {
53  Msg Info "Running doxygen with $doxygen_conf..."
54 }
55 
56 if {[DoxygenVersion 1.8.13]} {
57  if {![DoxygenVersion 1.9.1]} {
58  Msg Warning "It seems that you are using Doxygen version [Execute doxygen --version]. We recommend Doxygen version 1.9.1 or higher"
59  }
60  set conffile [open $doxygen_conf r+]
61  #replacing PROJECT_NUMBER with current version if existing, otherwise adding it
62  set buf_tmp ""
63  set VERSION_SET False
64  set conf_read [read $conffile]
65  foreach line [split $conf_read \n] {
66  if {[string match "#*" [string trim $line]]} {
67  append buf_tmp "\n$line"
68  } elseif {[string first "PROJECT_NUMBER" $line] != -1} {
69  set VERSION_SET True
70  append buf_tmp "\nPROJECT_NUMBER = $version"
71  } else {
72  append buf_tmp "\n$line"
73  }
74  }
75  if {!$VERSION_SET} {
76  append buf_tmp "\nPROJECT_NUMBER = $version"
77  }
78  close $conffile
79  #removing first endline
80  set buf_tmp [string range $buf_tmp 1 end]
81 
82  set doxygen_conf_out ".doxygen.conf"
83  set outfile [open $doxygen_conf_out w+]
84  puts -nonewline $outfile $buf_tmp
85  close $outfile
86 
87  Execute doxygen $doxygen_conf_out
88  file delete $doxygen_conf_out
89 } else {
90  cd $repo_path
91  Msg Error "Cannot find Doxygen version 1.8.13 or higher"
92 }
93 
94 cd $repo_path