Hog v9.9.0
copy_xml.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 # Copy IPBus XML files listed in a Hog list file and replace the version and SHA placeholders if they are present in any of the XML files.
18 
19 if {[catch {package require cmdline} ERROR]} {
20  puts "$ERROR\n If you are running this script on tclsh, you can fix this by installing 'tcllib'"
21  return
22 }
23 
24 set parameters {
25  {generate "If set, the VHDL address files will be generated and replaced if already exisiting."}
26  {arg.ext_path "" "Path to external libraries"}
27 }
28 
29 set usage "Copy IPBus XML files listed in a XML list file of a project and replace the version and SHA placeholders if they are present in any of the XML files.\nUsage: $argv0 \[-generate\] <project> <destination directory>"
30 set tcl_path [file dirname [info script]]
31 set repo_path [file normalize $tcl_path/../../..]
32 source $tcl_path/../hog.tcl
33 
34 
35 if {[catch {array set options [cmdline::getoptions ::argv $parameters $usage]}] || [llength $argv] < 2} {
36  Msg Info [cmdline::usage $parameters $usage]
37  exit 1
38 } else {
39  set project [lindex $argv 0]
40  set dst [lindex $argv 1]
41  if { $options(generate) == 1 } {
42  set generate 1
43  } else {
44  set generate 0
45  }
46  if { $options(arg.ext_path) == "" } {
47  set ext_path ""
48  } else {
49  set ext_path $options(arg.ext_path)
50  }
51 }
52 
53 set proj_dir $repo_path/Top/$project
54 if {[llength [glob -nocomplain $proj_dir/list/*.ipb]] > 0 } {
55  if {![file exists $dst]} {
56  Msg Info "$dst directory not found, creating it..."
57  file mkdir $dst
58  }
59 } else {
60  Msg Error "No .ipb files found in $proj_dir/list/"
61  exit
62 }
63 set ret [GetRepoVersions $repo_path/Top/$project $repo_path $ext_path]
64 
65 set sha [lindex $ret 13]
66 set hex_ver [lindex $ret 14]
67 
68 set ver [HexVersionToString $hex_ver]
69 CopyIPbusXMLs $proj_dir $repo_path $dst $ver $sha $generate