Hog v9.9.0
check_syntax.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 # Check the code syntax in a vivado project
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 <project>"
28 
29 
30 
31 set Name LaunchCheckSyntax
32 set hog_path [file normalize "[file dirname [info script]]/.."]
33 set repo_path [pwd]
34 cd $hog_path
35 source ./hog.tcl
36 
37 if {[catch {array set options [cmdline::getoptions ::argv $parameters $usage]}] || $::argc eq 0 } {
38  Msg Info [cmdline::usage $parameters $usage]
39  cd $repo_path
40  exit 1
41 } else {
42  set project [lindex $argv 0]
43  set main_folder [file normalize "$repo_path/Projects/$project/$project.runs/"]
44 }
45 
46 Msg Info "Opening project $project..."
47 
48 open_project ../../Projects/$project/$project.xpr
49 
50 
51 Msg Info "Checkin syntax for project $project..."
52 set syntax [check_syntax -return_string]
53 
54 if {[string first "CRITICAL" $syntax ] != -1} {
55  check_syntax
56  exit 1
57 }