Hog v9.9.0
check_proj_ver.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 set tcl_path [file normalize "[file dirname [info script]]/.."]
17 set repo_path [file normalize "$tcl_path/../.."]
18 
19 source $tcl_path/hog.tcl
20 
21 # Import tcllib for libero
22 if {[IsLibero]} {
23  if {[info exists env(HOG_TCLLIB_PATH)]} {
24  lappend auto_path $env(HOG_TCLLIB_PATH)
25  } else {
26  puts "ERROR: To run Hog with Microsemi Libero SoC, you need to define the HOG_TCLLIB_PATH variable."
27  return
28  }
29 }
30 
31 #parsing command options
32 if {[catch {package require cmdline} ERROR] || [catch {package require struct::matrix} ERROR]} {
33  puts "$ERROR\n Tcllib not found. If you are running this script on tclsh, you can fix this by installing 'tcllib'"
34  return
35 }
36 
37 set parameters {
38  {sim "If set, checks also the version of the simulation files."}
39  {ext_path.arg "" "Sets the absolute path for the external libraries."}
40 }
41 
42 set usage "- USAGE: $::argv0 \[OPTIONS\] <project> \n. Options:"
43 
44 if { $::argc eq 0 } {
45  Msg Info [cmdline::usage $parameters $usage]
46  exit 1
47 } elseif {[IsXilinx] && [catch {array set options [cmdline::getoptions ::argv $parameters $usage]}] } {
48  #Vivado
49  Msg Info [cmdline::usage $parameters $usage]
50  exit 1
51  ##nagelfar ignore Unknown variable
52 } elseif {[IsQuartus] && [ catch {array set options [cmdline::getoptions quartus(args) $parameters $usage] } ] || $::argc eq 0 } {
53  #Quartus
54  Msg Info [cmdline::usage $parameters $usage]
55  exit 1
56 } elseif {[IsLibero] && [catch {array set options [cmdline::getoptions ::argv $parameters $usage]}]} {
57  Msg Info [cmdline::usage $parameters $usage]
58  exit 1
59 } else {
60  set project [lindex $argv 0]
61  set sim 0
62  set ext_path ""
63 }
64 set project_dir $repo_path/Top/$project
65 
66 if {$options(sim) == 1} {
67  set sim 1
68  Msg Info "Will check also the version of the simulation files..."
69 }
70 
71 if { $options(ext_path) != "" } {
72  set ext_path $options(ext_path)
73  Msg Info "External path set to $ext_path"
74 }
75 
76 set ver [ GetProjectVersion $project_dir $repo_path $ext_path $sim ]
77 if {$ver == 0} {
78  Msg Info "$project was modified, continuing with the CI..."
79 } elseif {$ver != -1} {
80  Msg Info "$project was not modified since version: $ver, disabling the CI..."
81  file mkdir $repo_path/Projects/$project
82  set fp [open "$repo_path/Projects/$project/skip.me" w+]
83  close $fp
84 }