You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3022 lines
110 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. ####################################################################################
  2. #
  3. # write_project_tcl.tcl (write a Vivado project tcl script for re-creating project)
  4. #
  5. # Script created on 02/08/2013 by Raj Klair (Xilinx, Inc.)
  6. #
  7. # 2014.2 - v2.0 (rev 4)
  8. # * do not return value from main proc
  9. # * fixed bug with relative file path calculation (break from loop while comparing
  10. # directory elements of file paths for file to make relative to o/p script dir)
  11. # 2014.1 - v2.0 (rev 3)
  12. # * make source file paths relative to script output directory
  13. #
  14. # 2013.4 -
  15. # 2013.3 -
  16. # 2013.2 - v1.0 (rev 2)
  17. # * no change
  18. #
  19. # 2013.1 - v1.0 (rev 1)
  20. # * initial version
  21. #
  22. ####################################################################################
  23. #
  24. # Modified version to better support revision control.
  25. # Can be called as write_project_tcl_git from the tcl console in Vivado.
  26. #
  27. # Differences:
  28. #
  29. # 1. The project directory is now relative to the scripts location.
  30. # Project directory was relative to the tcl console current directory.
  31. #
  32. # 2. When recreating a project, the generated files will be put in a "vivado_project" directory
  33. # under the top directory. If "vivado_project" exists already, it will be rewritten.
  34. #
  35. # 3. After recreating a project, the tcl console will change directory to the project directory.
  36. #
  37. # 4. No mention to the creation time of the project script, so that it is not different
  38. # every time it is generated.
  39. #
  40. # 5. Remove warning when local sources are detected.
  41. #
  42. ####################################################################################
  43. package require Vivado 1.2014.1
  44. namespace eval ::custom_projutils {
  45. namespace export write_project_tcl_git
  46. }
  47. namespace eval ::custom_projutils {
  48. proc write_project_tcl_git {args} {
  49. # Summary:
  50. # Export Tcl script for re-creating the current project
  51. # Argument Usage:
  52. # [-paths_relative_to <arg> = Script output directory path]: Override the reference directory variable for source file relative paths
  53. # [-origin_dir_override <arg>]: Set 'origin_dir' directory variable to the specified value (Default is value specified with the -paths_relative_to switch)
  54. # [-target_proj_dir <arg> = Current project directory path]: Directory where the project needs to be restored
  55. # [-force]: Overwrite existing tcl script file
  56. # [-all_properties]: Write all properties (default & non-default) for the project object(s)
  57. # [-no_copy_sources]: Do not import sources even if they were local in the original project
  58. # [-absolute_path]: Make all file paths absolute wrt the original project directory
  59. # [-dump_project_info]: Write object values
  60. # [-use_bd_files ]: Use BD sources directly instead of writing out procs to create them
  61. # [-internal]: Print basic header information in the generated tcl script
  62. # file: Name of the tcl script file to generate
  63. # Return Value:
  64. # true (0) if success, false (1) otherwise
  65. # Categories: xilinxtclstore, projutils
  66. # reset global variables
  67. variable a_global_vars
  68. reset_global_vars
  69. # process options
  70. for {set i 0} {$i < [llength $args]} {incr i} {
  71. set option [string trim [lindex $args $i]]
  72. switch -regexp -- $option {
  73. "-paths_relative_to" {
  74. incr i;
  75. if { [regexp {^-} [lindex $args $i]] } {
  76. send_msg_id Vivado-projutils-021 ERROR "Missing value for the $option option.\
  77. Please provide a valid path/directory name immediately following '$option'"
  78. return
  79. }
  80. set a_global_vars(s_relative_to) [file normalize [lindex $args $i]]
  81. }
  82. "-target_proj_dir" {
  83. incr i;
  84. if { [regexp {^-} [lindex $args $i]] } {
  85. send_msg_id Vivado-projutils-021 ERROR "Missing value for the $option option.\
  86. Please provide a valid path/directory name immediately following '$option'"
  87. return
  88. }
  89. set a_global_vars(s_target_proj_dir) [lindex $args $i]
  90. }
  91. "-origin_dir_override" { incr i;set a_global_vars(s_origin_dir_override) [lindex $args $i] }
  92. "-force" { set a_global_vars(b_arg_force) 1 }
  93. "-all_properties" { set a_global_vars(b_arg_all_props) 1 }
  94. "-no_copy_sources" { set a_global_vars(b_arg_no_copy_srcs) 1 }
  95. "-absolute_path" { set a_global_vars(b_absolute_path) 1 }
  96. "-dump_project_info" { set a_global_vars(b_arg_dump_proj_info) 1 }
  97. "-use_bd_files" { set a_global_vars(b_arg_use_bd_files) 1 }
  98. "-internal" { set a_global_vars(b_internal) 1 }
  99. default {
  100. # is incorrect switch specified?
  101. if { [regexp {^-} $option] } {
  102. send_msg_id Vivado-projutils-001 ERROR "Unknown option '$option', please type 'write_project_tcl -help' for usage info.\n"
  103. return
  104. }
  105. set a_global_vars(script_file) $option
  106. }
  107. }
  108. }
  109. # script file is a must
  110. if { [string equal $a_global_vars(script_file) ""] } {
  111. send_msg_id Vivado-projutils-002 ERROR "Missing value for option 'file', please type 'write_project_tcl -help' for usage info.\n"
  112. return
  113. }
  114. # should not be a directory
  115. if { [file isdirectory $a_global_vars(script_file)] } {
  116. send_msg_id Vivado-projutils-003 ERROR "The specified filename is a directory ($a_global_vars(script_file)), please type 'write_project_tcl -help' for usage info.\n"
  117. return
  118. }
  119. # check extension
  120. if { [file extension $a_global_vars(script_file)] != ".tcl" } {
  121. set a_global_vars(script_file) $a_global_vars(script_file).tcl
  122. }
  123. set a_global_vars(script_file) [file normalize $a_global_vars(script_file)]
  124. # error if file directory path does not exist
  125. set file_path [file dirname $a_global_vars(script_file)]
  126. if { ! [file exists $file_path] } {
  127. set script_filename [file tail $a_global_vars(script_file)]
  128. send_msg_id Vivado-projutils-013 ERROR "Directory in which file ${script_filename} is to be written does not exist \[$a_global_vars(script_file)\]\n"
  129. return
  130. }
  131. # recommend -force if file exists
  132. if { [file exists $a_global_vars(script_file)] && !$a_global_vars(b_arg_force) } {
  133. send_msg_id Vivado-projutils-004 ERROR "Tcl Script '$a_global_vars(script_file)' already exist. Use -force option to overwrite.\n"
  134. return
  135. }
  136. if { [get_files -quiet *.bd] eq "" } { set a_global_vars(b_arg_use_bd_files) 1 }
  137. # -no_copy_sources cannot be used without -use_bd_files
  138. if { $a_global_vars(b_arg_no_copy_srcs) && !$a_global_vars(b_arg_use_bd_files) } {
  139. send_msg_id Vivado-projutils-019 ERROR "This design contains BD sources. The option -no_copy_sources cannot be used without -use_bd_files.\
  140. Please remove -no_copy_sources if you wish to write out BD's as procs in the project tcl, otherwise add the option -use_bd_files to directly\
  141. include the *.bd files to the new project \n"
  142. return
  143. }
  144. # set script file directory path
  145. set a_global_vars(s_path_to_script_dir) [file normalize $file_path]
  146. # now write
  147. if {[write_project_tcl_script]} {
  148. return
  149. }
  150. }
  151. }
  152. namespace eval ::custom_projutils {
  153. #
  154. # write_project_tcl tcl script argument & file handle vars
  155. #
  156. variable a_global_vars
  157. variable l_script_data [list]
  158. variable l_local_files [list]
  159. variable l_remote_files [list]
  160. variable b_project_board_set 0
  161. # set file types to filter
  162. variable l_filetype_filter [list]
  163. # Setup filter for non-user-settable filetypes
  164. set l_filetype_filter [list "ip" "ipx" "embedded design sources" "elf" "coefficient files" "configuration files" \
  165. "block diagrams" "block designs" "dsp design sources" "text" \
  166. "design checkpoint" "waveform configuration file"]
  167. # ip file extension types
  168. variable l_valid_ip_extns [list]
  169. set l_valid_ip_extns [list ".xci" ".bd" ".slx"]
  170. # set fileset types
  171. variable a_fileset_types
  172. set a_fileset_types {
  173. {{DesignSrcs} {srcset}}
  174. {{BlockSrcs} {blockset}}
  175. {{Constrs} {constrset}}
  176. {{SimulationSrcs} {simset}}
  177. {{Utils} {utilset}}
  178. }
  179. proc reset_global_vars {} {
  180. # Summary: initializes global namespace vars
  181. # This helper command is used to reset the variables used in the script.
  182. # Argument Usage:
  183. # none
  184. # Return Value:
  185. # None
  186. variable a_global_vars
  187. set a_global_vars(s_relative_to) {.}
  188. set a_global_vars(s_path_to_script_dir) ""
  189. set a_global_vars(s_origin_dir_override) ""
  190. set a_global_vars(s_target_proj_dir) ""
  191. set a_global_vars(b_arg_force) 0
  192. set a_global_vars(b_arg_no_copy_srcs) 0
  193. set a_global_vars(b_absolute_path) 0
  194. set a_global_vars(b_internal) 0
  195. set a_global_vars(b_arg_all_props) 0
  196. set a_global_vars(b_arg_dump_proj_info) 0
  197. set a_global_vars(b_local_sources) 0
  198. set a_global_vars(curr_time) [clock format [clock seconds]]
  199. set a_global_vars(fh) 0
  200. set a_global_vars(dp_fh) 0
  201. set a_global_vars(def_val_fh) 0
  202. set a_global_vars(script_file) ""
  203. if { [get_param project.enableMergedProjTcl] } {
  204. set a_global_vars(b_arg_use_bd_files) 0
  205. } else {
  206. set a_global_vars(b_arg_use_bd_files) 1
  207. }
  208. set l_script_data [list]
  209. set l_local_files [list]
  210. set l_remote_files [list]
  211. }
  212. proc write_project_tcl_script {} {
  213. # Summary: write project script
  214. # This helper command is used to script help.
  215. # Argument Usage:
  216. # none
  217. # Return Value:
  218. # true (0) if success, false (1) otherwise
  219. variable a_global_vars
  220. variable l_script_data
  221. variable l_remote_files
  222. variable l_local_files
  223. variable temp_dir
  224. variable temp_offset 1
  225. variable clean_temp
  226. variable l_open_bds [list]
  227. variable l_added_bds
  228. variable a_os
  229. set l_script_data [list]
  230. set l_local_files [list]
  231. set l_remote_files [list]
  232. set l_open_bds [list]
  233. set l_added_bds [list]
  234. # Create temp directory (if required) for BD procs
  235. set temp_dir [ file join [file dirname $a_global_vars(script_file)] .Xiltemp ]
  236. set clean_temp 1
  237. if { [file isdirectory $temp_dir] || $a_global_vars(b_arg_use_bd_files) } {
  238. set clean_temp 0
  239. } else {
  240. file mkdir $temp_dir
  241. }
  242. # Get OS
  243. if { [is_win_os] } {
  244. set a_os "win"
  245. } else {
  246. set a_os ""
  247. }
  248. # get the project name
  249. set tcl_obj [current_project]
  250. set proj_name [file tail [get_property name $tcl_obj]]
  251. set proj_dir [get_property directory $tcl_obj]
  252. set part_name [get_property part $tcl_obj]
  253. # output file script handle
  254. set file $a_global_vars(script_file)
  255. if {[catch {open $file w} a_global_vars(fh)]} {
  256. send_msg_id Vivado-projutils-005 ERROR "failed to open file for write ($file)\n"
  257. return 1
  258. }
  259. # dump project in canonical form
  260. if { $a_global_vars(b_arg_dump_proj_info) } {
  261. set dump_file [file normalize [file join $a_global_vars(s_path_to_script_dir) ${proj_name}_dump.txt]]
  262. if {[catch {open $dump_file w} a_global_vars(dp_fh)]} {
  263. send_msg_id Vivado-projutils-006 ERROR "failed to open file for write ($dump_file)\n"
  264. return 1
  265. }
  266. # default value output file script handle
  267. set def_val_file [file normalize [file join $a_global_vars(s_path_to_script_dir) ${proj_name}_def_val.txt]]
  268. if {[catch {open $def_val_file w} a_global_vars(def_val_fh)]} {
  269. send_msg_id Vivado-projutils-007 ERROR "failed to open file for write ($file)\n"
  270. return 1
  271. }
  272. }
  273. # explicitly update the compile order for current source/simset, if following conditions are met
  274. if { {All} == [get_property source_mgmt_mode [current_project]] &&
  275. {0} == [get_property is_readonly [current_project]] &&
  276. {RTL} == [get_property design_mode [current_fileset]] } {
  277. # re-parse source fileset compile order for the current top
  278. if {[llength [get_files -quiet -compile_order sources -used_in synthesis]] > 1} {
  279. update_compile_order -fileset [current_fileset] -quiet
  280. }
  281. # re-parse simlulation fileset compile order for the current top
  282. if {[llength [get_files -quiet -compile_order sources -used_in simulation]] > 1} {
  283. update_compile_order -fileset [current_fileset -simset] -quiet
  284. }
  285. }
  286. # writer helpers
  287. wr_create_project $proj_dir $proj_name $part_name
  288. wr_project_properties $proj_dir $proj_name
  289. wr_filesets $proj_dir $proj_name
  290. wr_prflow $proj_dir $proj_name
  291. if { !$a_global_vars(b_arg_use_bd_files) } {
  292. wr_bd
  293. }
  294. wr_runs $proj_dir $proj_name
  295. wr_proj_info $proj_name
  296. #write dashboards
  297. wr_dashboards $proj_dir $proj_name
  298. # write header
  299. write_header $proj_dir $proj_name $file
  300. # write script data
  301. foreach line $l_script_data {
  302. puts $a_global_vars(fh) $line
  303. }
  304. close $a_global_vars(fh)
  305. if { $a_global_vars(b_arg_dump_proj_info) } {
  306. close $a_global_vars(def_val_fh)
  307. close $a_global_vars(dp_fh)
  308. }
  309. set script_filename [file tail $file]
  310. set out_dir [file dirname [file normalize $file]]
  311. send_msg_id Vivado-projutils-008 INFO "Tcl script '$script_filename' generated in output directory '$out_dir'\n\n"
  312. if { $a_global_vars(b_absolute_path) } {
  313. send_msg_id Vivado-projutils-016 INFO "Please note that the -absolute_path switch was specified, hence the project source files will be referenced using\n\
  314. absolute path only, in the generated script. As such, the generated script will only work in the same filesystem where those absolute paths are accessible."
  315. } else {
  316. if { "." != $a_global_vars(s_relative_to) } {
  317. if { {} == $a_global_vars(s_origin_dir_override) } {
  318. send_msg_id Vivado-projutils-017 INFO "Please note that the -paths_relative_to switch was specified, hence the project source files will be referenced\n\
  319. wrt the path that was specified with this switch. The 'origin_dir' variable is set to this path in the generated script."
  320. } else {
  321. send_msg_id Vivado-projutils-017 INFO "Please note that the -paths_relative_to switch was specified, hence the project source files will be referenced wrt the\n\
  322. path that was specified with this switch. The 'origin_dir' variable is set to '$a_global_vars(s_origin_dir_override)' in the generated script."
  323. }
  324. } else {
  325. send_msg_id Vivado-projutils-015 INFO "The file paths for the project source files were set relative to the location of the generated script.\n"
  326. }
  327. }
  328. reset_global_vars
  329. return 0
  330. }
  331. proc wr_create_project { proj_dir name part_name } {
  332. # Summary: write create project command
  333. # This helper command is used to script help.
  334. # Argument Usage:
  335. # proj_dir: project directory path
  336. # name: project name
  337. # Return Value:
  338. # none
  339. variable a_global_vars
  340. variable l_script_data
  341. lappend l_script_data "# Set the reference directory for source file relative paths (by default the value is script directory path)"
  342. lappend l_script_data "set origin_dir \[file dirname \[info script\]\]"
  343. lappend l_script_data ""
  344. set var_name "origin_dir_loc"
  345. lappend l_script_data "# Use origin directory path location variable, if specified in the tcl shell"
  346. lappend l_script_data "if \{ \[info exists ::$var_name\] \} \{"
  347. lappend l_script_data " set origin_dir \$::$var_name"
  348. lappend l_script_data "\}"
  349. lappend l_script_data ""
  350. set var_name "user_project_name"
  351. lappend l_script_data "# Set the project name\nset _xil_proj_name_ \"$name\"\n"
  352. lappend l_script_data "# Use project name variable, if specified in the tcl shell"
  353. lappend l_script_data "if \{ \[info exists ::$var_name\] \} \{"
  354. lappend l_script_data " set _xil_proj_name_ \$::$var_name"
  355. lappend l_script_data "\}\n"
  356. lappend l_script_data "variable script_file"
  357. lappend l_script_data "set script_file \"[file tail $a_global_vars(script_file)]\"\n"
  358. lappend l_script_data "# Help information for this script"
  359. lappend l_script_data "proc help \{\} \{"
  360. lappend l_script_data " variable script_file"
  361. lappend l_script_data " puts \"\\nDescription:\""
  362. lappend l_script_data " puts \"Recreate a Vivado project from this script. The created project will be\""
  363. lappend l_script_data " puts \"functionally equivalent to the original project for which this script was\""
  364. lappend l_script_data " puts \"generated. The script contains commands for creating a project, filesets,\""
  365. lappend l_script_data " puts \"runs, adding/importing sources and setting properties on various objects.\\n\""
  366. lappend l_script_data " puts \"Syntax:\""
  367. lappend l_script_data " puts \"\$script_file\""
  368. lappend l_script_data " puts \"\$script_file -tclargs \\\[--origin_dir <path>\\\]\""
  369. lappend l_script_data " puts \"\$script_file -tclargs \\\[--project_name <name>\\\]\""
  370. lappend l_script_data " puts \"\$script_file -tclargs \\\[--help\\\]\\n\""
  371. lappend l_script_data " puts \"Usage:\""
  372. lappend l_script_data " puts \"Name Description\""
  373. lappend l_script_data " puts \"-------------------------------------------------------------------------\""
  374. if { {} == $a_global_vars(s_origin_dir_override) } {
  375. lappend l_script_data " puts \"\\\[--origin_dir <path>\\\] Determine source file paths wrt this path. Default\""
  376. lappend l_script_data " puts \" origin_dir path value is \\\".\\\", otherwise, the value\""
  377. lappend l_script_data " puts \" that was set with the \\\"-paths_relative_to\\\" switch\""
  378. lappend l_script_data " puts \" when this script was generated.\\n\""
  379. } else {
  380. lappend l_script_data " puts \"\\\[--origin_dir <path>\\\] Determine source file paths wrt this path. Default\""
  381. lappend l_script_data " puts \" origin_dir path value is \\\".\\\", otherwise, the value\""
  382. lappend l_script_data " puts \" that was set with the \\\"-origin_dir_override\\\" switch\""
  383. lappend l_script_data " puts \" when this script was generated.\\n\""
  384. }
  385. lappend l_script_data " puts \"\\\[--project_name <name>\\\] Create project with the specified name. Default\""
  386. lappend l_script_data " puts \" name is the name of the project from where this\""
  387. lappend l_script_data " puts \" script was generated.\\n\""
  388. lappend l_script_data " puts \"\\\[--help\\\] Print help information for this script\""
  389. lappend l_script_data " puts \"-------------------------------------------------------------------------\\n\""
  390. lappend l_script_data " exit 0"
  391. lappend l_script_data "\}\n"
  392. lappend l_script_data "if \{ \$::argc > 0 \} \{"
  393. lappend l_script_data " for \{set i 0\} \{\$i < \$::argc\} \{incr i\} \{"
  394. lappend l_script_data " set option \[string trim \[lindex \$::argv \$i\]\]"
  395. lappend l_script_data " switch -regexp -- \$option \{"
  396. lappend l_script_data " \"--origin_dir\" \{ incr i; set origin_dir \[lindex \$::argv \$i\] \}"
  397. lappend l_script_data " \"--project_name\" \{ incr i; set _xil_proj_name_ \[lindex \$::argv \$i\] \}"
  398. lappend l_script_data " \"--help\" \{ help \}"
  399. lappend l_script_data " default \{"
  400. lappend l_script_data " if \{ \[regexp \{^-\} \$option\] \} \{"
  401. lappend l_script_data " puts \"ERROR: Unknown option '\$option' specified, please type '\$script_file -tclargs --help' for usage info.\\n\""
  402. lappend l_script_data " return 1"
  403. lappend l_script_data " \}"
  404. lappend l_script_data " \}"
  405. lappend l_script_data " \}"
  406. lappend l_script_data " \}"
  407. lappend l_script_data "\}\n"
  408. lappend l_script_data "# Set the directory path for the original project from where this script was exported"
  409. if { $a_global_vars(b_absolute_path) || [need_abs_path $proj_dir] } {
  410. lappend l_script_data "set orig_proj_dir \"$proj_dir\""
  411. } else {
  412. set rel_file_path "[get_relative_file_path_for_source $proj_dir [get_script_execution_dir]]"
  413. set path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  414. lappend l_script_data "set orig_proj_dir \"$path\""
  415. }
  416. lappend l_script_data ""
  417. # create project
  418. lappend l_script_data "# Create project"
  419. set tcl_cmd ""
  420. # set target project directory path if specified. If not, create project dir in current dir.
  421. set target_dir $a_global_vars(s_target_proj_dir)
  422. if { {} == $target_dir } {
  423. set tcl_cmd "create_project \$\{_xil_proj_name_\} \$origin_dir/vivado_project -part $part_name -quiet -force"
  424. } else {
  425. # is specified target proj dir == current dir?
  426. set cwd [file normalize [string map {\\ /} [pwd]]]
  427. set dir [file normalize [string map {\\ /} $target_dir]]
  428. if { [string equal $cwd $dir] } {
  429. set tcl_cmd "create_project \$\{_xil_proj_name_\} -part $part_name"
  430. } else {
  431. set tcl_cmd "create_project \$\{_xil_proj_name_\} \"$target_dir\" -part $part_name"
  432. }
  433. }
  434. if { [get_property managed_ip [current_project]] } {
  435. set tcl_cmd "$tcl_cmd -ip"
  436. }
  437. lappend l_script_data $tcl_cmd
  438. if { $a_global_vars(b_arg_dump_proj_info) } {
  439. puts $a_global_vars(dp_fh) "project_name=\$\{_xil_proj_name_\}"
  440. }
  441. lappend l_script_data ""
  442. lappend l_script_data "# Set the directory path for the new project"
  443. lappend l_script_data "set proj_dir \[get_property directory \[current_project\]\]"
  444. lappend l_script_data ""
  445. lappend l_script_data "# Reconstruct message rules"
  446. set msg_control_rules [ debug::get_msg_control_rules -as_tcl ]
  447. if { [string length $msg_control_rules] > 0 } {
  448. lappend l_script_data "${msg_control_rules}"
  449. } else {
  450. lappend l_script_data "# None"
  451. }
  452. lappend l_script_data ""
  453. }
  454. proc wr_project_properties { proj_dir proj_name } {
  455. # Summary: write project properties
  456. # This helper command is used to script help.
  457. # Argument Usage:
  458. # proj_name: project name
  459. # Return Value:
  460. # None
  461. variable l_script_data
  462. variable b_project_board_set
  463. # write project properties
  464. set tcl_obj [current_project]
  465. set get_what "get_projects"
  466. lappend l_script_data "# Set project properties"
  467. lappend l_script_data "set obj \[current_project\]"
  468. # is project "board_part" set already?
  469. if { [string length [get_property "board_part" $tcl_obj]] > 0 } {
  470. set b_project_board_set 1
  471. }
  472. write_props $proj_dir $proj_name $get_what $tcl_obj "project"
  473. }
  474. proc write_bd_as_proc { bd_file } {
  475. # Summary: writes out BD creation steps as a proc
  476. # Argument: BD file
  477. # Return Value: None
  478. variable l_added_bds
  479. variable l_bd_proc_calls
  480. variable l_script_data
  481. variable temp_offset
  482. variable l_open_bds
  483. variable temp_dir
  484. variable bd_prop_steps
  485. set bd_file [list "$bd_file"]
  486. if { [lsearch $l_added_bds $bd_file] != -1 } { return }
  487. set to_close 1
  488. # Add sources referenced in the BD
  489. add_references $bd_file
  490. # Open BD in stealth mode, if not already open
  491. set bd_filename [file tail $bd_file]
  492. if { [lsearch $l_open_bds $bd_filename] != -1 } {
  493. set to_close 0
  494. } else {
  495. open_bd_design -stealth [ get_files $bd_file ]
  496. }
  497. current_bd_design [get_bd_designs [file rootname $bd_filename]]
  498. # write the BD as a proc to a temp file
  499. while { [file exists [file join $temp_dir "temp_$temp_offset.tcl"]] } {
  500. incr temp_offset
  501. }
  502. set temp_bd_file [file join $temp_dir "temp_$temp_offset.tcl"]
  503. write_bd_tcl -no_project_wrapper -make_local $temp_bd_file
  504. # Set non default properties for the BD
  505. wr_bd_properties $bd_file
  506. # Close BD if opened in stealth mode
  507. if {$to_close == 1 } {
  508. close_bd_design [get_bd_designs [file rootname $bd_filename]]
  509. }
  510. # Get proc call
  511. if {[catch {open $temp_bd_file r} fp]} {
  512. send_msg_id Vivado-projutils-020 ERROR "failed to write out proc for $bd_file \n"
  513. return 1
  514. }
  515. # TODO no need to read whole file, just second line will do
  516. set file_data [read $fp ]
  517. set split_proc [split $file_data]
  518. set proc_index 7
  519. set str [lindex $split_proc $proc_index]
  520. close $fp
  521. # Add the BD proc, call to the proc and BD property steps
  522. if { [string equal [lindex $split_proc [expr {$proc_index-1}] ] "proc"]
  523. && [regexp {^cr_bd_.*} $str]
  524. } then {
  525. append str " \"\""
  526. lappend l_script_data "\n"
  527. lappend l_script_data $file_data
  528. lappend l_added_bds $bd_file
  529. lappend l_script_data $str
  530. lappend l_script_data $bd_prop_steps
  531. }
  532. # delete temp file
  533. file delete $temp_bd_file
  534. incr temp_offset
  535. }
  536. proc wr_bd_properties { file } {
  537. # Summary: writes non default BD properties
  538. # Argument: the .BD file
  539. # Return Value: none
  540. variable bd_prop_steps
  541. variable a_global_vars
  542. set bd_prop_steps ""
  543. set bd_name [get_property FILE_NAME [current_bd_design]]
  544. set bd_props [list_property [ get_files $file ] ]
  545. set read_only_props [rdi::get_attr_specs -object [get_files $file] -filter {is_readonly}]
  546. foreach prop $bd_props {
  547. if { [lsearch $read_only_props $prop] != -1
  548. || [string equal -nocase $prop "file_type" ]
  549. } then { continue }
  550. set def_val [list_property_value -default $prop [ get_files $file ] ]
  551. set cur_val [get_property $prop [get_files $file ] ]
  552. set def_val \"$def_val\"
  553. set cur_val \"$cur_val\"
  554. if { $a_global_vars(b_arg_all_props) } {
  555. append bd_prop_steps "set_property $prop $cur_val \[get_files $bd_name \] \n"
  556. } else {
  557. if { $def_val ne $cur_val } {
  558. append bd_prop_steps "set_property $prop $cur_val \[get_files $bd_name \] \n"
  559. }
  560. }
  561. }
  562. }
  563. proc add_references { sub_design } {
  564. # Summary: Looks for sources referenced in the block design and adds them
  565. # Argument: sub_design file
  566. # Return Value: None
  567. variable l_script_data
  568. variable l_added_bds
  569. # Getting references, if any
  570. set refs [ get_files -quiet -references -of_objects [ get_files $sub_design ] ]
  571. foreach file $refs {
  572. if { [file extension $file ] ==".bd" } {
  573. if { [lsearch $l_added_bds $file] != -1 } { continue }
  574. # Write out referred bd as a proc
  575. write_bd_as_proc $file
  576. } else {
  577. # Skip adding file if it's already part of the project
  578. lappend l_script_data "if { \[get_files [file tail $file]\] == \"\" } {"
  579. lappend l_script_data " import_files -quiet -fileset [current_fileset -srcset] $file\n}"
  580. }
  581. }
  582. }
  583. proc wr_bd {} {
  584. # Summary: write procs to create BD's
  585. # Return Value: None
  586. variable a_global_vars
  587. variable l_script_data
  588. variable l_added_bds
  589. variable l_bd_proc_calls
  590. variable l_open_bds [list]
  591. variable temp_dir
  592. variable clean_temp
  593. # String that will hold commands to set BD properties
  594. variable bd_prop_steps "\n# Setting BD properties \n"
  595. # Get already opened BD designs
  596. set open_bd_names [get_bd_designs]
  597. foreach bd_name $open_bd_names {
  598. lappend l_open_bds [get_property FILE_NAME [get_bd_designs $bd_name]]
  599. }
  600. # Get all BD files in the design
  601. set bd_files [get_files -norecurse *.bd]
  602. lappend l_script_data "\n# Adding sources referenced in BDs, if not already added"
  603. foreach bd_file $bd_files {
  604. # Making sure BD is not locked
  605. set is_locked [get_property IS_LOCKED [get_files [list "$bd_file"] ] ]
  606. if { $is_locked == 1 } {
  607. file delete $a_global_vars(script_file)
  608. send_msg_id Vivado-projutils-018 ERROR "Project tcl cannot be written as the design contains one or more \
  609. locked/out-of-date design(s). Please run report_ip_status and update the design.\n"
  610. return 1
  611. }
  612. # Write out bd as a proc
  613. write_bd_as_proc $bd_file
  614. }
  615. # Delete temp directory
  616. if { $clean_temp == 1} {
  617. file delete -force $temp_dir
  618. }
  619. }
  620. proc wr_filesets { proj_dir proj_name } {
  621. # Summary: write fileset object properties
  622. # This helper command is used to script help.
  623. # Argument Usage:
  624. # proj_name: project name
  625. # Return Value:
  626. # None
  627. variable a_fileset_types
  628. # write fileset data
  629. foreach {fs_data} $a_fileset_types {
  630. set filesets [get_filesets -filter FILESET_TYPE==[lindex $fs_data 0]]
  631. write_specified_fileset $proj_dir $proj_name $filesets
  632. }
  633. }
  634. proc write_specified_fileset { proj_dir proj_name filesets } {
  635. # Summary: write fileset properties and sources
  636. # This helper command is used to script help.
  637. # Argument Usage:
  638. # proj_name: project name
  639. # filesets: list of filesets
  640. # Return Value:
  641. # None
  642. variable a_global_vars
  643. variable l_script_data
  644. variable a_fileset_types
  645. # write filesets
  646. set type "file"
  647. foreach tcl_obj $filesets {
  648. # Is this a IP block fileset for a proxy IP that is owned by another composite file?
  649. # If so, we don't want to write it out as an independent file. The parent will take care of it.
  650. if { [is_proxy_ip_fileset $tcl_obj] } {
  651. continue
  652. }
  653. set fs_type [get_property fileset_type [get_filesets $tcl_obj]]
  654. # is this a IP block fileset? if yes, do not create block fileset, but create for a pure HDL based fileset (no IP's)
  655. if { [is_ip_fileset $tcl_obj] } {
  656. # do not create block fileset
  657. } elseif { [string equal $tcl_obj "utils_1"] } {
  658. # do not create utils fileset
  659. } else {
  660. lappend l_script_data "# Create '$tcl_obj' fileset (if not found)"
  661. lappend l_script_data "if \{\[string equal \[get_filesets -quiet $tcl_obj\] \"\"\]\} \{"
  662. set fs_sw_type [get_fileset_type_switch $fs_type]
  663. lappend l_script_data " create_fileset $fs_sw_type $tcl_obj"
  664. lappend l_script_data "\}\n"
  665. }
  666. set get_what_fs "get_filesets"
  667. # set IP REPO PATHS (if any) for filesets of type "DesignSrcs" or "BlockSrcs"
  668. if { (({DesignSrcs} == $fs_type) || ({BlockSrcs} == $fs_type)) } {
  669. # If BlockSet contains only one IP, then this indicates the case of OOC1
  670. # This means that we should not write these properties, they are read-only
  671. set blockset_is_ooc1 false
  672. if { {BlockSrcs} == $fs_type } {
  673. set current_fs_files [get_files -quiet -of_objects [get_filesets $tcl_obj] -norecurse]
  674. if { [llength $current_fs_files] == 1 } {
  675. set only_file_in_fs [lindex $current_fs_files 0]
  676. set file_type [get_property FILE_TYPE $only_file_in_fs]
  677. set blockset_is_ooc1 [expr {$file_type == {IP}} ? true : false]
  678. }
  679. }
  680. if { $blockset_is_ooc1} {
  681. # We do not write properties for OOC1
  682. } elseif { ({RTL} == [get_property design_mode [get_filesets $tcl_obj]]) } {
  683. set repo_paths [get_ip_repo_paths $tcl_obj]
  684. if { [llength $repo_paths] > 0 } {
  685. lappend l_script_data "# Set IP repository paths"
  686. lappend l_script_data "set obj \[get_filesets $tcl_obj\]"
  687. set path_list [list]
  688. foreach path $repo_paths {
  689. if { $a_global_vars(b_absolute_path) || [need_abs_path $path] } {
  690. lappend path_list $path
  691. } else {
  692. set rel_file_path "[get_relative_file_path_for_source $path [get_script_execution_dir]]"
  693. set path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  694. lappend path_list $path
  695. }
  696. }
  697. set repo_path_str [join $path_list " "]
  698. lappend l_script_data "set_property \"ip_repo_paths\" \"${repo_path_str}\" \$obj"
  699. lappend l_script_data ""
  700. lappend l_script_data "# Rebuild user ip_repo's index before adding any source files"
  701. lappend l_script_data "update_ip_catalog -rebuild"
  702. lappend l_script_data ""
  703. }
  704. }
  705. }
  706. # is this a IP block fileset? if yes, then set the current srcset object (IP's will be added to current source fileset)
  707. if { [is_ip_fileset $tcl_obj] } {
  708. set srcset [current_fileset -srcset]
  709. lappend l_script_data "# Set '$srcset' fileset object"
  710. lappend l_script_data "set obj \[$get_what_fs $srcset\]"
  711. } else {
  712. lappend l_script_data "# Set '$tcl_obj' fileset object"
  713. lappend l_script_data "set obj \[$get_what_fs $tcl_obj\]"
  714. }
  715. if { {Constrs} == $fs_type } {
  716. lappend l_script_data ""
  717. write_constrs $proj_dir $proj_name $tcl_obj $type
  718. } else {
  719. write_files $proj_dir $proj_name $tcl_obj $type
  720. }
  721. # is this a IP block fileset? if yes, do not write block fileset properties (block fileset doesnot exist in new project)
  722. if { [is_ip_fileset $tcl_obj] } {
  723. # do not write ip fileset properties
  724. } else {
  725. lappend l_script_data "# Set '$tcl_obj' fileset properties"
  726. lappend l_script_data "set obj \[$get_what_fs $tcl_obj\]"
  727. write_props $proj_dir $proj_name $get_what_fs $tcl_obj "fileset"
  728. }
  729. }
  730. }
  731. proc wr_runs { proj_dir proj_name } {
  732. # Summary: write runs and properties
  733. # This helper command is used to script help.
  734. # Argument Usage:
  735. # proj_name: project name
  736. # Return Value:
  737. # None
  738. variable l_script_data
  739. # write runs (synthesis, Implementation)
  740. set runs [get_runs -filter {IS_SYNTHESIS == 1}]
  741. write_specified_run $proj_dir $proj_name $runs
  742. if { {RTL} == [get_property design_mode [current_fileset]] } {
  743. lappend l_script_data "# set the current synth run"
  744. lappend l_script_data "current_run -synthesis \[get_runs [current_run -synthesis]\]\n"
  745. }
  746. set runs [get_runs -filter {IS_IMPLEMENTATION == 1}]
  747. write_specified_run $proj_dir $proj_name $runs
  748. lappend l_script_data "# set the current impl run"
  749. lappend l_script_data "current_run -implementation \[get_runs [current_run -implementation]\]"
  750. lappend l_script_data ""
  751. lappend l_script_data "# Change current directory to project folder"
  752. lappend l_script_data "cd \[file dirname \[info script\]\]"
  753. }
  754. proc wr_proj_info { proj_name } {
  755. # Summary: write generated project status message
  756. # This helper command is used to script help.
  757. # Argument Usage:
  758. # proj_name: project name
  759. # Return Value:
  760. # None
  761. variable l_script_data
  762. lappend l_script_data "\nputs \"INFO: Project created:\${_xil_proj_name_}\""
  763. }
  764. proc write_header { proj_dir proj_name file } {
  765. # Summary: write script header
  766. # This helper command is used to script help.
  767. # Argument Usage:
  768. # Return Value:
  769. # None
  770. variable a_global_vars
  771. variable l_local_files
  772. variable l_remote_files
  773. set version_txt [split [version] "\n"]
  774. set version [lindex $version_txt 0]
  775. set copyright [lindex $version_txt 2]
  776. set product [lindex [split $version " "] 0]
  777. set version_id [join [lrange $version 1 end] " "]
  778. set tcl_file [file tail $file]
  779. puts $a_global_vars(fh) "#*****************************************************************************************"
  780. puts $a_global_vars(fh) "# $product (TM) $version_id"
  781. puts $a_global_vars(fh) "#\n# $tcl_file: Tcl script for re-creating project '$proj_name'\n#"
  782. puts $a_global_vars(fh) "# $copyright"
  783. puts $a_global_vars(fh) "#\n# This file contains the $product Tcl commands for re-creating the project to the state*"
  784. puts $a_global_vars(fh) "# when this script was generated. In order to re-create the project, please source this"
  785. puts $a_global_vars(fh) "# file in the $product Tcl Shell."
  786. puts $a_global_vars(fh) "#"
  787. puts $a_global_vars(fh) "# * Note that the runs in the created project will be configured the same way as the"
  788. puts $a_global_vars(fh) "# original project, however they will not be launched automatically. To regenerate the"
  789. puts $a_global_vars(fh) "# run results please launch the synthesis/implementation runs as needed.\n#"
  790. puts $a_global_vars(fh) "#*****************************************************************************************"
  791. }
  792. proc print_local_file_msg { msg_type } {
  793. # Summary: print warning on finding local sources
  794. # This helper command is used to script help.
  795. # Argument Usage:
  796. # Return Value:
  797. # None
  798. puts ""
  799. if { [string equal $msg_type "warning"] } {
  800. send_msg_id Vivado-projutils-010 WARNING "Found source(s) that were local or imported into the project. If this project is being source controlled, then\n\
  801. please ensure that the project source(s) are also part of this source controlled data. The list of these local source(s) can be found in the generated script\n\
  802. under the header section."
  803. } else {
  804. send_msg_id Vivado-projutils-011 INFO "If this project is being source controlled, then please ensure that the project source(s) are also part of this source\n\
  805. controlled data. The list of these local source(s) can be found in the generated script under the header section."
  806. }
  807. puts ""
  808. }
  809. proc get_ip_repo_paths { tcl_obj } {
  810. # Summary:
  811. # Iterate over the fileset properties and get the ip_repo_paths (if set)
  812. # Argument Usage:
  813. # tcl_obj : fileset
  814. # Return Value:
  815. # List of repo paths
  816. set repo_path_list [list]
  817. foreach path [get_property ip_repo_paths [get_filesets $tcl_obj]] {
  818. lappend repo_path_list $path
  819. }
  820. return $repo_path_list
  821. }
  822. proc filter { prop val { file {} } } {
  823. # Summary: filter special properties
  824. # This helper command is used to script help.
  825. # Argument Usage:
  826. # Return Value:
  827. # true (1) if found, false (1) otherwise
  828. variable l_filetype_filter
  829. variable l_valid_ip_extns
  830. set prop [string toupper $prop]
  831. if { [expr { $prop == "BOARD" } || \
  832. { $prop == "IS_HD" } || \
  833. { $prop == "IS_PARTIAL_RECONFIG" } || \
  834. { $prop == "ADD_STEP" }]} {
  835. return 1
  836. }
  837. if { [string equal type "project"] } {
  838. if { [expr { $prop == "DIRECTORY" }] } {
  839. return 1
  840. }
  841. }
  842. # error reported if file_type is set
  843. # e.g ERROR: [Vivado 12-563] The file type 'IP' is not user settable.
  844. set val [string tolower $val]
  845. if { [string equal $prop "FILE_TYPE"] } {
  846. if { [lsearch $l_filetype_filter $val] != -1 } {
  847. return 1
  848. }
  849. }
  850. # filter readonly is_managed property for ip
  851. if { [string equal $prop "IS_MANAGED"] } {
  852. if { [lsearch -exact $l_valid_ip_extns [string tolower [file extension $file]]] >= 0 } {
  853. return 1
  854. }
  855. }
  856. # filter ip_repo_paths (ip_repo_paths is set before adding sources)
  857. if { [string equal -nocase $prop {ip_repo_paths}] } {
  858. return 1
  859. }
  860. # filter sim_types
  861. if { [string equal -nocase $prop {sim_types}] } {
  862. return 1
  863. }
  864. return 0
  865. }
  866. proc is_local_to_project { file } {
  867. # Summary: check if file is local to the project directory structure
  868. # This helper command is used to script help.
  869. # Argument Usage:
  870. # Return Value:
  871. # true (1), if file is local to the project (inside project directory structure)
  872. # false (0), if file is outside the project directory structure
  873. # Remove quotes for proper normalize output
  874. set file [string trim $file "\""]
  875. set dir [get_property directory [current_project]]
  876. set proj_comps [split [string trim [file normalize [string map {\\ /} $dir]]] "/"]
  877. set file_comps [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  878. set is_local 1
  879. for {set i 1} {$i < [llength $proj_comps]} {incr i} {
  880. if { [lindex $proj_comps $i] != [lindex $file_comps $i] } {
  881. set is_local 0;break
  882. }
  883. }
  884. return $is_local
  885. }
  886. proc is_ip_readonly_prop { name } {
  887. # Summary: Return true if dealing with following IP properties that are not settable for an IP in read-only state
  888. # Argument Usage:
  889. # name: property name
  890. # Return Value:
  891. # true if success, false otherwise
  892. if { [regexp -nocase {synth_checkpoint_mode} $name] ||
  893. [regexp -nocase {is_locked} $name] ||
  894. [regexp -nocase {generate_synth_checkpoint} $name] } {
  895. return true
  896. }
  897. return false
  898. }
  899. proc write_properties { prop_info_list get_what tcl_obj {delim "#"} } {
  900. # Summary: write object properties
  901. # This helper command is used to script help.
  902. # Argument Usage:
  903. # Return Value:
  904. # None
  905. variable a_global_vars
  906. variable l_script_data
  907. if {[llength $prop_info_list] > 0} {
  908. set b_add_closing_brace 0
  909. foreach x $prop_info_list {
  910. set elem [split $x $delim]
  911. set name [lindex $elem 0]
  912. set value [lindex $elem 1]
  913. if { ([is_ip_readonly_prop $name]) && ([string equal $get_what "get_files"]) } {
  914. set cmd_str "if \{ !\[get_property \"is_locked\" \$file_obj\] \} \{"
  915. lappend l_script_data "$cmd_str"
  916. set cmd_str " set_property -name \"$name\" -value \"$value\" -objects"
  917. set b_add_closing_brace 1
  918. } else {
  919. set cmd_str "set_property -name \"$name\" -value \"$value\" -objects"
  920. }
  921. if { [string equal $get_what "get_files"] } {
  922. lappend l_script_data "$cmd_str \$file_obj"
  923. if { $b_add_closing_brace } {
  924. lappend l_script_data "\}"
  925. set b_add_closing_brace 0
  926. }
  927. } else {
  928. # comment "is_readonly" project property
  929. if { [string equal $get_what "get_projects"] && [string equal "$name" "is_readonly"] } {
  930. if { ! $a_global_vars(b_arg_all_props) } {
  931. send_msg_id Vivado-projutils-012 INFO "The current project is in 'read_only' state. The generated script will create a writable project."
  932. }
  933. continue
  934. }
  935. lappend l_script_data "$cmd_str \$obj"
  936. }
  937. }
  938. }
  939. lappend l_script_data ""
  940. }
  941. proc align_project_properties { prop proj_name proj_file_path } {
  942. # Summary:
  943. # Argument Usage:
  944. # Return Value:
  945. variable a_global_vars
  946. set dir_suffix {}
  947. if { {} == $prop } {
  948. return $proj_file_path
  949. }
  950. # align project properties to have project name variable
  951. if {[string equal -nocase $prop "ip_output_repo"] ||
  952. [string equal -nocase $prop "sim.ipstatic.compiled_library_dir"] } {
  953. set dir_suffix "cache"
  954. } else {
  955. if {[string equal -nocase $prop "sim.central_dir"] ||
  956. [string equal -nocase $prop "ip.user_files_dir"] ||
  957. [string equal -nocase $prop "sim.ipstatic.source_dir"] } {
  958. set dir_suffix "ip_user_files"
  959. }}
  960. # skip other properties
  961. if { {} == $dir_suffix } {
  962. return $proj_file_path
  963. }
  964. set match_str "${proj_name}/${proj_name}.${dir_suffix}"
  965. set proj_file_path [string map {\\ /} $proj_file_path]
  966. if { [regexp $match_str $proj_file_path] } {
  967. set proj_file_path [regsub -all "${proj_name}" $proj_file_path "\$\{_xil_proj_name_\}"]
  968. } else {
  969. set match_str "${proj_name}.${dir_suffix}"
  970. set proj_file_path [regsub "${proj_name}\.${dir_suffix}" $proj_file_path "\$\{_xil_proj_name_\}\.${dir_suffix}"]
  971. }
  972. return $proj_file_path
  973. }
  974. proc write_props { proj_dir proj_name get_what tcl_obj type {delim "#"}} {
  975. # Summary: write first class object properties
  976. # This helper command is used to script help.
  977. # Argument Usage:
  978. # Return Value:
  979. # none
  980. variable a_global_vars
  981. variable l_script_data
  982. variable b_project_board_set
  983. if {[string equal $type "project"]} {
  984. # escape empty spaces in project name
  985. set tcl_obj [ list "$tcl_obj"]
  986. }
  987. if { [string first " " $get_what 0] != -1 } {
  988. # For cases where get_what is multiple workds like "get_gadgets -of_object..."
  989. set current_obj [ eval $get_what $tcl_obj]
  990. } else {
  991. set current_obj [$get_what $tcl_obj]
  992. }
  993. if { $current_obj == "" } { return }
  994. set obj_name [get_property name $current_obj]
  995. set read_only_props [rdi::get_attr_specs -class [get_property class $current_obj] -filter {is_readonly}]
  996. set prop_info_list [list]
  997. set properties [list_property $current_obj]
  998. foreach prop $properties {
  999. if { [is_deprecated_property $prop] } { continue }
  1000. # skip read-only properties
  1001. if { [lsearch $read_only_props $prop] != -1 } { continue }
  1002. if { ([string equal $type "gadget"]) && ([string equal -nocase $prop "type"]) } {
  1003. continue
  1004. }
  1005. # To handle the work-around solution of CR-988588 set board_part to base_board_part value then set board_connections
  1006. if { ([ string equal $type "project" ]) && ([ string equal [ string tolower $prop ] "board_connections" ]) } {
  1007. continue
  1008. }
  1009. if { ([ string equal $type "project" ]) && $b_project_board_set && ([ string equal [ string tolower $prop ] "board_part" ]) } {
  1010. set board_part_val [get_property $prop $current_obj]
  1011. set base_board_part_val [get_property base_board_part $current_obj]
  1012. set board_connections_val [get_property board_connections $current_obj]
  1013. if { $base_board_part_val != "" && $base_board_part_val != $board_part_val } {
  1014. set prop_entry "[string tolower $prop]$delim$base_board_part_val"
  1015. lappend prop_info_list $prop_entry
  1016. set prop_entry "board_connections$delim$board_connections_val"
  1017. lappend prop_info_list $prop_entry
  1018. continue
  1019. }
  1020. }
  1021. # skip writing PR-Configuration, attached right after creation of impl run
  1022. if { ([get_property pr_flow [current_project]] == 1) && [string equal $type "run"] } {
  1023. set isImplRun [get_property is_implementation $current_obj]
  1024. if { ($isImplRun == 1) && [string equal -nocase $prop "pr_configuration"] } {
  1025. continue
  1026. }
  1027. }
  1028. set prop_type "unknown"
  1029. if { [string equal $type "run"] } {
  1030. # skip steps.<step_name>.reports dynamic read only property (to be populated by creation of reports)
  1031. if { [regexp -nocase "STEPS\..*\.REPORTS" $prop] || [string equal -nocase "REPORT_STRATEGY" $prop] } {
  1032. continue;
  1033. }
  1034. if { [regexp "STEPS" $prop] } {
  1035. # skip step properties
  1036. } else {
  1037. set attr_names [rdi::get_attr_specs -class [get_property class [get_runs $tcl_obj] ]]
  1038. if { [lsearch $attr_names $prop] != -1 } {
  1039. set prop_type [get_property type [lindex $attr_names [lsearch $attr_names $prop]]]
  1040. }
  1041. }
  1042. } else {
  1043. set attr_spec [rdi::get_attr_specs -quiet $prop -object $current_obj]
  1044. if { {} == $attr_spec } {
  1045. set prop_lower [string tolower $prop]
  1046. set attr_spec [rdi::get_attr_specs -quiet $prop_lower -object $current_obj]
  1047. }
  1048. set prop_type [get_property type $attr_spec]
  1049. }
  1050. set def_val [list_property_value -default $prop $current_obj]
  1051. set dump_prop_name [string tolower ${obj_name}_${type}_$prop]
  1052. set cur_val [get_property $prop $current_obj]
  1053. # filter special properties
  1054. if { [filter $prop $cur_val] } { continue }
  1055. # do not set "runs" or "project" part, if "board_part" is set
  1056. if { ([string equal $type "project"] || [string equal $type "run"]) &&
  1057. [string equal -nocase $prop "part"] &&
  1058. $b_project_board_set } {
  1059. continue
  1060. }
  1061. # do not set "fileset" target_part, if "board_part" is set
  1062. if { [string equal $type "fileset"] &&
  1063. [string equal -nocase $prop "target_part"] &&
  1064. $b_project_board_set } {
  1065. continue
  1066. }
  1067. # do not set default_rm for partitionDef initially as RM is not created at time of creation of pdef
  1068. if { [string equal $type "partitionDef"] &&
  1069. [string equal -nocase $prop "default_rm"] } {
  1070. continue
  1071. }
  1072. # re-align values
  1073. set cur_val [get_target_bool_val $def_val $cur_val]
  1074. set abs_proj_file_path [get_property $prop $current_obj]
  1075. set path_match [string match $proj_dir* $abs_proj_file_path]
  1076. if { ($path_match == 1) && ($a_global_vars(b_absolute_path) != 1) && ![need_abs_path $abs_proj_file_path] } {
  1077. # changing the absolute path to relative
  1078. set abs_path_length [string length $proj_dir]
  1079. set proj_file_path [string replace $abs_proj_file_path 0 $abs_path_length "\$proj_dir/"]
  1080. set proj_file_path [align_project_properties $prop $proj_name $proj_file_path]
  1081. set prop_entry "[string tolower $prop]$delim$proj_file_path"
  1082. } else {
  1083. set abs_proj_file_path [align_project_properties $prop $proj_name $abs_proj_file_path]
  1084. set prop_entry "[string tolower $prop]$delim$abs_proj_file_path"
  1085. }
  1086. # re-align include dir path wrt origin dir
  1087. if { [string equal -nocase $prop "include_dirs"] } {
  1088. if { [llength $abs_proj_file_path] > 0 } {
  1089. if { !$a_global_vars(b_absolute_path) } {
  1090. set incl_paths $abs_proj_file_path
  1091. set rel_paths [list]
  1092. foreach path $incl_paths {
  1093. if { ![need_abs_path $path] } {
  1094. lappend rel_paths "\[file normalize \"\$origin_dir/[get_relative_file_path_for_source $path [get_script_execution_dir]]\"\]"
  1095. }
  1096. }
  1097. set prop_entry "[string tolower $prop]$delim[join $rel_paths " "]"
  1098. }
  1099. }
  1100. }
  1101. # fix paths wrt the original project dir
  1102. if {([string equal -nocase $prop "top_file"]) && ($cur_val != "") } {
  1103. set file $cur_val
  1104. set srcs_dir "${proj_name}.srcs"
  1105. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1106. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1107. if { [is_local_to_project $file] || [need_abs_path $file]} {
  1108. set proj_file_path "\$proj_dir/$src_file"
  1109. } else {
  1110. set proj_file_path "[get_relative_file_path_for_source $src_file [get_script_execution_dir]]"
  1111. }
  1112. set prop_entry "[string tolower $prop]$delim$proj_file_path"
  1113. } elseif {([string equal -nocase $prop "target_constrs_file"] ||
  1114. [string equal -nocase $prop "target_ucf"]) &&
  1115. ($cur_val != "") } {
  1116. set file $cur_val
  1117. set fs_name $tcl_obj
  1118. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1119. set src_file [join [lrange $path_dirs [lsearch -exact $path_dirs "$fs_name"] end] "/"]
  1120. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1121. set file_props [list_property $file_object]
  1122. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1123. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1124. set proj_file_path "\$orig_proj_dir/${proj_name}.srcs/$src_file"
  1125. } else {
  1126. set proj_file_path "\$proj_dir/\$\{_xil_proj_name_\}.srcs/$src_file"
  1127. }
  1128. } else {
  1129. # is file new inside project?
  1130. if { [is_local_to_project $file] } {
  1131. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1132. set local_constrs_file [join [lrange $path_dirs end-1 end] "/"]
  1133. set local_constrs_file [string trimleft $local_constrs_file "/"]
  1134. set local_constrs_file [string trimleft $local_constrs_file "\\"]
  1135. set file $local_constrs_file
  1136. set proj_file_path "\[get_files *$local_constrs_file\]"
  1137. } else {
  1138. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1139. set proj_file_path "$file"
  1140. } else {
  1141. set file_no_quotes [string trim $file "\""]
  1142. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1143. set proj_file_path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  1144. }
  1145. }
  1146. }
  1147. set prop_entry "[string tolower $prop]$delim$proj_file_path"
  1148. }
  1149. # re-align compiled_library_dir
  1150. if { [string equal -nocase $prop "compxlib.compiled_library_dir"] ||
  1151. [string equal -nocase $prop "compxlib.modelsim_compiled_library_dir"] ||
  1152. [string equal -nocase $prop "compxlib.questa_compiled_library_dir"] ||
  1153. [string equal -nocase $prop "compxlib.ies_compiled_library_dir"] ||
  1154. [string equal -nocase $prop "compxlib.vcs_compiled_library_dir"] ||
  1155. [string equal -nocase $prop "compxlib.riviera_compiled_library_dir"] ||
  1156. [string equal -nocase $prop "compxlib.activehdl_compiled_library_dir"] } {
  1157. set compile_lib_dir_path $cur_val
  1158. set cache_dir "${proj_name}.cache"
  1159. set path_dirs [split [string trim [file normalize [string map {\\ /} $cur_val]]] "/"]
  1160. if {[lsearch -exact $path_dirs "$cache_dir"] > 0} {
  1161. set dir_path [join [lrange $path_dirs [lsearch -exact $path_dirs "$cache_dir"] end] "/"]
  1162. set compile_lib_dir_path "\$proj_dir/$dir_path"
  1163. set compile_lib_dir_path [regsub $cache_dir $compile_lib_dir_path "\$\{_xil_proj_name_\}\.cache"]
  1164. }
  1165. set prop_entry "[string tolower $prop]$delim$compile_lib_dir_path"
  1166. }
  1167. # process run step tcl pre/post properties
  1168. if { [string equal $type "run"] } {
  1169. if { [regexp "STEPS" $prop] } {
  1170. if { [regexp "TCL.PRE" $prop] || [regexp "TCL.POST" $prop] } {
  1171. if { ($cur_val != "") } {
  1172. set file $cur_val
  1173. set srcs_dir "${proj_name}.srcs"
  1174. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1175. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1176. set tcl_file_path {}
  1177. if { [is_local_to_project $file] } {
  1178. set tcl_file_path "\$proj_dir/$src_file"
  1179. } else {
  1180. if { $a_global_vars(b_absolute_path)|| [need_abs_path $file] } {
  1181. set tcl_file_path "$file"
  1182. } else {
  1183. set rel_file_path "[get_relative_file_path_for_source $src_file [get_script_execution_dir]]"
  1184. set tcl_file_path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  1185. }
  1186. }
  1187. set prop_entry "[string tolower $prop]$delim$tcl_file_path"
  1188. }
  1189. }
  1190. }
  1191. }
  1192. if { $a_global_vars(b_arg_all_props) } {
  1193. lappend prop_info_list $prop_entry
  1194. } else {
  1195. if { $def_val != $cur_val } {
  1196. lappend prop_info_list $prop_entry
  1197. }
  1198. }
  1199. if { $a_global_vars(b_arg_dump_proj_info) } {
  1200. if { ([string equal -nocase $prop "top_file"] ||
  1201. [string equal -nocase $prop "target_constrs_file"] ||
  1202. [string equal -nocase $prop "target_ucf"] ) && [string equal $type "fileset"] } {
  1203. # fix path
  1204. set file $cur_val
  1205. set srcs_dir "${proj_name}.srcs"
  1206. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1207. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1208. set cur_val "\$PSRCDIR/$src_file"
  1209. }
  1210. puts $a_global_vars(def_val_fh) "$prop:($prop_type) DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1211. puts $a_global_vars(dp_fh) "${dump_prop_name}=$cur_val"
  1212. }
  1213. }
  1214. if { {fileset} == $type } {
  1215. set fs_type [get_property fileset_type [get_filesets $tcl_obj]]
  1216. if { {SimulationSrcs} == $fs_type } {
  1217. if { ![get_property is_readonly [current_project]] } {
  1218. add_simulator_props $get_what $tcl_obj prop_info_list
  1219. }
  1220. }
  1221. }
  1222. # write properties now
  1223. write_properties $prop_info_list $get_what $tcl_obj $delim
  1224. }
  1225. proc add_simulator_props { get_what tcl_obj prop_info_list_arg } {
  1226. # Summary: write file and file properties
  1227. # This helper command is used to script help.
  1228. # Argument Usage:
  1229. # Return Value:
  1230. # none
  1231. upvar $prop_info_list_arg prop_info_list
  1232. set target_simulator [get_property target_simulator [current_project]]
  1233. set simulators [get_simulators]
  1234. foreach simulator [get_simulators] {
  1235. if { $target_simulator == $simulator } { continue }
  1236. set_property target_simulator $simulator [current_project]
  1237. set prefix [string tolower [lindex [split $simulator {.}] 0]]
  1238. write_simulator_props $prefix $get_what $tcl_obj prop_info_list
  1239. }
  1240. set_property target_simulator $target_simulator [current_project]
  1241. }
  1242. proc write_simulator_props { prefix get_what tcl_obj prop_info_list_arg } {
  1243. # Summary: write non-default simulator properties
  1244. # Argument Usage:
  1245. # Return Value:
  1246. # none
  1247. upvar $prop_info_list_arg prop_info_list
  1248. variable a_global_vars
  1249. variable l_script_data
  1250. set read_only_props [rdi::get_attr_specs -class [get_property class $tcl_obj] -filter {is_readonly}]
  1251. foreach prop [list_property [$get_what $tcl_obj]] {
  1252. if { [lsearch $read_only_props $prop] != -1 } { continue }
  1253. if { [is_deprecated_property $prop] } { continue }
  1254. set sim_prefix [string tolower [lindex [split $prop {.}] 0]]
  1255. if { $prefix != $sim_prefix } { continue }
  1256. set attr_spec [rdi::get_attr_specs -quiet $prop -object [$get_what $tcl_obj]]
  1257. if { {} == $attr_spec } {
  1258. set prop_lower [string tolower $prop]
  1259. set attr_spec [rdi::get_attr_specs -quiet $prop_lower -object [$get_what $tcl_obj]]
  1260. }
  1261. set prop_type [get_property type $attr_spec]
  1262. set def_val [list_property_value -default $prop $tcl_obj]
  1263. set cur_val [get_property $prop $tcl_obj]
  1264. set cur_val [get_target_bool_val $def_val $cur_val]
  1265. set prop_entry "[string tolower $prop]#[get_property $prop [$get_what $tcl_obj]]"
  1266. if { $def_val != $cur_val } {
  1267. lappend prop_info_list $prop_entry
  1268. }
  1269. }
  1270. }
  1271. proc is_deprecated_property { property } {
  1272. # Summary: filter old properties
  1273. # Argument Usage:
  1274. # Return Value:
  1275. set property [string tolower $property]
  1276. if { [string equal $property "board"] ||
  1277. [string equal $property "verilog_dir"] ||
  1278. [string equal $property "compxlib.compiled_library_dir"] ||
  1279. [string equal $property "dsa.build_flow"] ||
  1280. [string equal $property "runtime"] ||
  1281. [string equal $property "unit_under_test"] ||
  1282. [string equal $property "xelab.snapshot"] ||
  1283. [string equal $property "xelab.debug_level"] ||
  1284. [string equal $property "xelab.relax"] ||
  1285. [string equal $property "xelab.mt_level"] ||
  1286. [string equal $property "xelab.load_glbl"] ||
  1287. [string equal $property "xelab.rangecheck"] ||
  1288. [string equal $property "xelab.sdf_delay"] ||
  1289. [string equal $property "xelab.unifast"] ||
  1290. [string equal $property "xelab.nosort"] ||
  1291. [string equal $property "xelab.more_options"] ||
  1292. [string equal $property "xsim.view"] ||
  1293. [string equal $property "xsim.wdb"] ||
  1294. [string equal $property "xsim.saif"] ||
  1295. [string equal $property "xsim.tclbatch"] ||
  1296. [string equal $property "xsim.more_options"] ||
  1297. [string equal $property "modelsim.custom_do"] ||
  1298. [string equal $property "modelsim.custom_udo"] ||
  1299. [string equal $property "modelsim.vhdl_syntax"] ||
  1300. [string equal $property "modelsim.use_explicit_decl"] ||
  1301. [string equal $property "modelsim.log_all_signals"] ||
  1302. [string equal $property "modelsim.sdf_delay"] ||
  1303. [string equal $property "modelsim.saif"] ||
  1304. [string equal $property "modelsim.incremental"] ||
  1305. [string equal $property "modelsim.unifast"] ||
  1306. [string equal $property "modelsim.64bit"] ||
  1307. [string equal $property "modelsim.vsim_more_options"] ||
  1308. [string equal $property "modelsim.vlog_more_options"] ||
  1309. [string equal $property "modelsim.vcom_more_options"] ||
  1310. [string equal $property "xsim.simulate.uut"] ||
  1311. [string equal $property "modelsim.simulate.uut"] ||
  1312. [string equal $property "questa.simulate.uut"] ||
  1313. [string equal $property "ies.simulate.uut"] ||
  1314. [string equal $property "vcs.simulate.uut"] } {
  1315. return true
  1316. }
  1317. return false
  1318. }
  1319. proc write_files { proj_dir proj_name tcl_obj type } {
  1320. # Summary: write file and file properties
  1321. # This helper command is used to script help.
  1322. # Argument Usage:
  1323. # Return Value:
  1324. # none
  1325. variable a_global_vars
  1326. variable l_script_data
  1327. set l_local_file_list [list]
  1328. set l_remote_file_list [list]
  1329. # return if empty fileset
  1330. if {[llength [get_files -quiet -of_objects [get_filesets $tcl_obj]]] == 0 } {
  1331. lappend l_script_data "# Empty (no sources present)\n"
  1332. return
  1333. }
  1334. set fs_name [get_filesets $tcl_obj]
  1335. set import_coln [list]
  1336. set add_file_coln [list]
  1337. foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
  1338. if { [file extension $file] == ".xcix" } { continue }
  1339. # Skip direct import/add of BD files if -use_bd_files is not provided
  1340. if { [file extension $file] == ".bd" && !$a_global_vars(b_arg_use_bd_files) } { continue }
  1341. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1342. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  1343. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  1344. # fetch first object
  1345. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1346. set file_props [list_property $file_object]
  1347. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1348. # import files
  1349. set imported_path [get_property "imported_from" $file]
  1350. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  1351. set proj_file_path "\$\{origin_dir\}/$rel_file_path"
  1352. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  1353. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1354. # add to the local collection
  1355. lappend l_remote_file_list $file
  1356. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1357. lappend add_file_coln "$file"
  1358. } else {
  1359. lappend add_file_coln "\[file normalize \"$proj_file_path\"\]"
  1360. }
  1361. } else {
  1362. # add to the import collection
  1363. lappend l_local_file_list $file
  1364. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1365. lappend import_coln "$file"
  1366. } else {
  1367. lappend import_coln "\[file normalize \"$proj_file_path\"\]"
  1368. }
  1369. }
  1370. } else {
  1371. set file "\"$file\""
  1372. # is local? add to local project, add to collection and then import this collection by default unless -no_copy_sources is specified
  1373. if { [is_local_to_project $file] } {
  1374. if { $a_global_vars(b_arg_dump_proj_info) } {
  1375. set src_file "\$PSRCDIR/$src_file"
  1376. }
  1377. # add to the import collection
  1378. if { $a_global_vars(b_absolute_path)|| [need_abs_path $file] } {
  1379. lappend import_coln $file
  1380. } else {
  1381. set file_no_quotes [string trim $file "\""]
  1382. set org_file_path "\$\{origin_dir\}/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1383. lappend import_coln "\[file normalize \"$org_file_path\" \]"
  1384. }
  1385. lappend l_local_file_list $file
  1386. } else {
  1387. if {$a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1388. lappend add_file_coln [string trim $file "\""]
  1389. } else {
  1390. set file_no_quotes [string trim $file "\""]
  1391. set org_file_path "\$\{origin_dir\}/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1392. lappend add_file_coln "\[file normalize \"$org_file_path\"\]"
  1393. }
  1394. lappend l_remote_file_list $file
  1395. }
  1396. }
  1397. }
  1398. # set flag that local sources were found and print warning at the end
  1399. if { (!$a_global_vars(b_local_sources)) && ([llength l_local_file_list] > 0) } {
  1400. set a_global_vars(b_local_sources) 1
  1401. }
  1402. if {[llength $add_file_coln]>0} {
  1403. lappend l_script_data "set files \[list \\"
  1404. foreach file $add_file_coln {
  1405. lappend l_script_data " $file \\"
  1406. }
  1407. lappend l_script_data "\]"
  1408. lappend l_script_data "add_files -norecurse -fileset \$obj \$files"
  1409. lappend l_script_data ""
  1410. }
  1411. # now import local files if -no_copy_sources is not specified
  1412. if { [llength $import_coln] > 0 } {
  1413. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  1414. lappend l_script_data "# Import local files from the original project"
  1415. lappend l_script_data "set files \[list \\"
  1416. foreach ifile $import_coln {
  1417. lappend l_script_data " $ifile\\"
  1418. }
  1419. lappend l_script_data "\]"
  1420. # is this a IP block fileset? if yes, import files into current source fileset
  1421. if { [is_ip_fileset $tcl_obj] } {
  1422. lappend l_script_data "set imported_files \[import_files -fileset [current_fileset -srcset] \$files\]"
  1423. } else {
  1424. lappend l_script_data "set imported_files \[import_files -fileset $tcl_obj \$files\]"
  1425. }
  1426. } else {
  1427. lappend l_script_data "# Add local files from the original project (-no_copy_sources specified)"
  1428. lappend l_script_data "set files \[list \\"
  1429. foreach ifile $import_coln {
  1430. lappend l_script_data " $ifile\\"
  1431. }
  1432. lappend l_script_data "\]"
  1433. # is this a IP block fileset? if yes, add files into current source fileset
  1434. if { [is_ip_fileset $tcl_obj] } {
  1435. lappend l_script_data "set added_files \[add_files -fileset [current_fileset -srcset] \$files\]"
  1436. } else {
  1437. lappend l_script_data "set added_files \[add_files -fileset $tcl_obj \$files\]"
  1438. }
  1439. }
  1440. lappend l_script_data ""
  1441. }
  1442. # write fileset file properties for remote files (added sources)
  1443. write_fileset_file_properties $tcl_obj $fs_name $proj_dir $l_remote_file_list "remote"
  1444. # write fileset file properties for local files (imported sources)
  1445. write_fileset_file_properties $tcl_obj $fs_name $proj_dir $l_local_file_list "local"
  1446. }
  1447. proc write_constrs { proj_dir proj_name tcl_obj type } {
  1448. # Summary: write constrs fileset files and properties
  1449. # Argument Usage:
  1450. # Return Value:
  1451. # none
  1452. variable a_global_vars
  1453. variable l_script_data
  1454. set fs_name [get_filesets $tcl_obj]
  1455. # return if empty fileset
  1456. if {[llength [get_files -quiet -of_objects [get_filesets $tcl_obj]]] == 0 } {
  1457. lappend l_script_data "# Empty (no sources present)\n"
  1458. return
  1459. }
  1460. foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
  1461. lappend l_script_data "# Add/Import constrs file and set constrs file properties"
  1462. set constrs_file {}
  1463. set file_category {}
  1464. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1465. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  1466. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  1467. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1468. set file_props [list_property $file_object]
  1469. # constrs sources imported?
  1470. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1471. set imported_path [get_property "imported_from" $file]
  1472. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  1473. set proj_file_path \$\{origin_dir\}/$rel_file_path
  1474. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  1475. # donot copy imported constrs in new project? set it as remote file in new project.
  1476. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1477. set constrs_file $file
  1478. set file_category "remote"
  1479. if { $a_global_vars(b_absolute_path) || [need_abs_path $imported_path] } {
  1480. add_constrs_file "$file"
  1481. } else {
  1482. set str "\"\[file normalize $proj_file_path\]\""
  1483. add_constrs_file $str
  1484. }
  1485. } else {
  1486. # copy imported constrs in new project. Set it as local file in new project.
  1487. set constrs_file $file
  1488. set file_category "local"
  1489. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1490. import_constrs_file $tcl_obj "$file"
  1491. } else {
  1492. set str "\"\[file normalize $proj_file_path\]\""
  1493. import_constrs_file $tcl_obj $str
  1494. }
  1495. }
  1496. } else {
  1497. # constrs sources were added, so check if these are local or added from remote location
  1498. set file "\"$file\""
  1499. set constrs_file $file
  1500. # is added constrs local to the project? import it in the new project and set it as local in the new project
  1501. if { [is_local_to_project $file] } {
  1502. # file is added from within project, so set it as local in the new project
  1503. set file_category "local"
  1504. if { $a_global_vars(b_arg_dump_proj_info) } {
  1505. set src_file "\$PSRCDIR/$src_file"
  1506. }
  1507. set file_no_quotes [string trim $file "\""]
  1508. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1509. set str "\"\[file normalize \"$org_file_path\"\]\""
  1510. if { $a_global_vars(b_arg_no_copy_srcs)} {
  1511. add_constrs_file "$str"
  1512. } else {
  1513. import_constrs_file $tcl_obj $str
  1514. }
  1515. } else {
  1516. # file is added from remote location, so set it as remote in the new project
  1517. set file_category "remote"
  1518. # find relative file path of the added constrs if no_copy in the new project
  1519. if { $a_global_vars(b_arg_no_copy_srcs) && (!$a_global_vars(b_absolute_path))&& ![need_abs_path $file] } {
  1520. set file_no_quotes [string trim $file "\""]
  1521. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1522. set file_1 "\"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  1523. add_constrs_file "$file_1"
  1524. } else {
  1525. add_constrs_file "$file"
  1526. }
  1527. }
  1528. # set flag that local sources were found and print warning at the end
  1529. if { !$a_global_vars(b_local_sources) } {
  1530. set a_global_vars(b_local_sources) 1
  1531. }
  1532. }
  1533. write_constrs_fileset_file_properties $tcl_obj $fs_name $proj_dir $constrs_file $file_category
  1534. }
  1535. }
  1536. proc add_constrs_file { file_str } {
  1537. # Summary: add constrs file
  1538. # This helper command is used to script help.
  1539. # Argument Usage:
  1540. # Return Value:
  1541. # none
  1542. variable a_global_vars
  1543. variable l_script_data
  1544. if { $a_global_vars(b_absolute_path) || [need_abs_path $file_str]} {
  1545. lappend l_script_data "set file $file_str"
  1546. } else {
  1547. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1548. lappend l_script_data "set file $file_str"
  1549. } else {
  1550. set file_no_quotes [string trim $file_str "\""]
  1551. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1552. lappend l_script_data "set file \"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  1553. }
  1554. }
  1555. lappend l_script_data "set file_added \[add_files -norecurse -fileset \$obj \[list \$file\]\]"
  1556. }
  1557. proc import_constrs_file { tcl_obj file_str } {
  1558. # Summary: import constrs file
  1559. # This helper command is used to script help.
  1560. # Argument Usage:
  1561. # Return Value:
  1562. # none
  1563. variable a_global_vars
  1564. variable l_script_data
  1565. # now import local files if -no_copy_sources is not specified
  1566. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  1567. lappend l_script_data "set file $file_str"
  1568. lappend l_script_data "set file_imported \[import_files -fileset $tcl_obj \[list \$file\]\]"
  1569. }
  1570. }
  1571. proc write_constrs_fileset_file_properties { tcl_obj fs_name proj_dir file file_category } {
  1572. # Summary: write constrs fileset file properties
  1573. # This helper command is used to script help.
  1574. # Argument Usage:
  1575. # Return Value:
  1576. # none
  1577. variable a_global_vars
  1578. variable l_script_data
  1579. variable l_local_files
  1580. variable l_remote_files
  1581. set file_prop_count 0
  1582. # collect local/remote files for the header section
  1583. if { [string equal $file_category "local"] } {
  1584. lappend l_local_files $file
  1585. } elseif { [string equal $file_category "remote"] } {
  1586. lappend l_remote_files $file
  1587. }
  1588. set file [string trim $file "\""]
  1589. # fix file path for local files
  1590. if { [string equal $file_category "local"] } {
  1591. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1592. set src_file [join [lrange $path_dirs end-1 end] "/"]
  1593. set src_file [string trimleft $src_file "/"]
  1594. set src_file [string trimleft $src_file "\\"]
  1595. set file $src_file
  1596. }
  1597. set file_object ""
  1598. if { [string equal $file_category "local"] } {
  1599. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list "*$file"]] 0]
  1600. } elseif { [string equal $file_category "remote"] } {
  1601. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1602. }
  1603. # get the constrs file properties
  1604. set file_props [list_property $file_object]
  1605. set prop_info_list [list]
  1606. set prop_count 0
  1607. foreach file_prop $file_props {
  1608. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  1609. if { [string equal $is_readonly "1"] } {
  1610. continue
  1611. }
  1612. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  1613. set def_val [list_property_value -default $file_prop $file_object]
  1614. set cur_val [get_property $file_prop $file_object]
  1615. # filter special properties
  1616. if { [filter $file_prop $cur_val $file] } { continue }
  1617. # re-align values
  1618. set cur_val [get_target_bool_val $def_val $cur_val]
  1619. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  1620. set prop_entry ""
  1621. if { [string equal $file_category "local"] } {
  1622. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  1623. } elseif { [string equal $file_category "remote"] } {
  1624. set prop_value_entry [get_property $file_prop $file_object]
  1625. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  1626. }
  1627. # include all properties?
  1628. if { $a_global_vars(b_arg_all_props) } {
  1629. lappend prop_info_list $prop_entry
  1630. incr prop_count
  1631. } else {
  1632. # include only non-default (default behavior)
  1633. if { $def_val != $cur_val } {
  1634. lappend prop_info_list $prop_entry
  1635. incr prop_count
  1636. }
  1637. }
  1638. if { $a_global_vars(b_arg_dump_proj_info) } {
  1639. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1640. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  1641. }
  1642. }
  1643. # write properties now
  1644. if { $prop_count>0 } {
  1645. if { {remote} == $file_category } {
  1646. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  1647. lappend l_script_data "set file \"$file\""
  1648. } else {
  1649. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  1650. lappend l_script_data "set file \[file normalize \$file\]"
  1651. }
  1652. } else {
  1653. lappend l_script_data "set file \"$file\""
  1654. }
  1655. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets $tcl_obj\] \[list \"*\$file\"\]\]"
  1656. set get_what "get_files"
  1657. write_properties $prop_info_list $get_what $tcl_obj
  1658. incr file_prop_count
  1659. }
  1660. if { $file_prop_count == 0 } {
  1661. lappend l_script_data "# None"
  1662. }
  1663. }
  1664. proc write_specified_run { proj_dir proj_name runs } {
  1665. # Summary: write the specified run information
  1666. # This helper command is used to script help.
  1667. # Argument Usage:
  1668. # Return Value:
  1669. # none
  1670. variable a_global_vars
  1671. variable l_script_data
  1672. set get_what "get_runs"
  1673. foreach tcl_obj $runs {
  1674. # is block fileset based run that contains IP? donot create OOC run
  1675. if { [is_ip_run $tcl_obj] } {
  1676. continue
  1677. }
  1678. # fetch run attributes
  1679. set part [get_property part [$get_what $tcl_obj]]
  1680. set parent_run [get_property parent [$get_what $tcl_obj]]
  1681. set src_set [get_property srcset [$get_what $tcl_obj]]
  1682. set constrs_set [get_property constrset [$get_what $tcl_obj]]
  1683. set strategy [get_property strategy [$get_what $tcl_obj]]
  1684. set parent_run_str ""
  1685. if { $parent_run != "" } {
  1686. set parent_run_str " -parent_run $parent_run"
  1687. }
  1688. set fileset_type [get_property fileset_type [get_property srcset [$get_what $tcl_obj]]]
  1689. set isImplRun [get_property is_implementation [$get_what $tcl_obj]]
  1690. set isPRProject [get_property pr_flow [current_project]]
  1691. set def_flow_type_val [list_property_value -default flow [$get_what $tcl_obj]]
  1692. set cur_flow_type_val [get_property flow [$get_what $tcl_obj]]
  1693. set def_strat_type_val [list_property_value -default strategy [$get_what $tcl_obj]]
  1694. set cur_strat_type_val [get_property strategy [$get_what $tcl_obj]]
  1695. set isChildImplRun 0
  1696. if { $isPRProject == 1 && $isImplRun == 1 && $parent_run != "" } {
  1697. set isChildImplRun [get_property is_implementation [$get_what $parent_run]]
  1698. if { $isChildImplRun == 1 } {
  1699. set prConfig [get_property pr_configuration [get_runs $tcl_obj]]
  1700. if { [get_pr_configurations $prConfig] == "" } {
  1701. # review this change. Either skip this run creation or flag error while sourcing script...???
  1702. continue
  1703. }
  1704. }
  1705. }
  1706. set cmd_str " create_run -name $tcl_obj -part $part -flow {$cur_flow_type_val} -strategy \"$cur_strat_type_val\""
  1707. set retVal [get_param project.enableReportConfiguration]
  1708. set report_strategy ""
  1709. if { $retVal == 1 } {
  1710. set cmd_str " $cmd_str -report_strategy {No Reports}"
  1711. set report_strategy [get_property report_strategy $tcl_obj]
  1712. }
  1713. if { $isChildImplRun == 1 } {
  1714. set cmd_str " $cmd_str -pr_config $prConfig"
  1715. }
  1716. lappend l_script_data "# Create '$tcl_obj' run (if not found)"
  1717. lappend l_script_data "if \{\[string equal \[get_runs -quiet $tcl_obj\] \"\"\]\} \{"
  1718. lappend l_script_data "$cmd_str -constrset $constrs_set$parent_run_str"
  1719. lappend l_script_data "\} else \{"
  1720. lappend l_script_data " set_property strategy \"$cur_strat_type_val\" \[get_runs $tcl_obj\]"
  1721. lappend l_script_data " set_property flow \"$cur_flow_type_val\" \[get_runs $tcl_obj\]"
  1722. lappend l_script_data "\}"
  1723. if { ($isImplRun == 1) && ($isPRProject == 1 && $isChildImplRun == 0) && ({DesignSrcs} == $fileset_type) } {
  1724. set prConfig [get_property pr_configuration [get_runs $tcl_obj]]
  1725. if { [get_pr_configurations $prConfig] != "" } {
  1726. lappend l_script_data "set_property pr_configuration $prConfig \[get_runs $tcl_obj\]"
  1727. }
  1728. }
  1729. write_report_strategy $tcl_obj $report_strategy
  1730. lappend l_script_data "set obj \[$get_what $tcl_obj\]"
  1731. write_props $proj_dir $proj_name $get_what $tcl_obj "run"
  1732. }
  1733. }
  1734. proc get_fileset_type_switch { fileset_type } {
  1735. # Summary: Return the fileset type switch for a given fileset
  1736. # Argument Usage:
  1737. # Return Value:
  1738. # Fileset type switch name
  1739. variable a_fileset_types
  1740. set fs_switch ""
  1741. foreach {fs_data} $a_fileset_types {
  1742. set fs_type [lindex $fs_data 0]
  1743. if { [string equal -nocase $fileset_type $fs_type] } {
  1744. set fs_switch [lindex $fs_data 1]
  1745. set fs_switch "-$fs_switch"
  1746. break
  1747. }
  1748. }
  1749. return $fs_switch
  1750. }
  1751. proc get_target_bool_val { def_val cur_val } {
  1752. # Summary: Resolve current boolean property value wrt its default value
  1753. # Argument Usage:
  1754. # Return Value:
  1755. # Resolved boolean value
  1756. set target_val $cur_val
  1757. if { [string equal $def_val "false"] && [string equal $cur_val "0"] } { set target_val "false" } \
  1758. elseif { [string equal $def_val "true"] && [string equal $cur_val "1"] } { set target_val "true" } \
  1759. elseif { [string equal $def_val "false"] && [string equal $cur_val "1"] } { set target_val "true" } \
  1760. elseif { [string equal $def_val "true"] && [string equal $cur_val "0"] } { set target_val "false" } \
  1761. elseif { [string equal $def_val "{}"] && [string equal $cur_val ""] } { set target_val "{}" }
  1762. return $target_val
  1763. }
  1764. proc write_fileset_file_properties { tcl_obj fs_name proj_dir l_file_list file_category } {
  1765. # Summary:
  1766. # Write fileset file properties for local and remote files
  1767. # Argument Usage:
  1768. # tcl_obj: object to inspect
  1769. # fs_name: fileset name
  1770. # l_file_list: list of files (local or remote)
  1771. # file_category: file catwgory (local or remote)
  1772. # Return Value:
  1773. # none
  1774. variable a_global_vars
  1775. variable l_script_data
  1776. variable l_local_files
  1777. variable l_remote_files
  1778. # is this a IP block fileset? if yes, set current source fileset
  1779. if { [is_ip_fileset $tcl_obj] } {
  1780. lappend l_script_data "# Set '[current_fileset -srcset]' fileset file properties for $file_category files"
  1781. } else {
  1782. lappend l_script_data "# Set '$tcl_obj' fileset file properties for $file_category files"
  1783. }
  1784. set file_prop_count 0
  1785. # collect local/remote files
  1786. foreach file $l_file_list {
  1787. if { [string equal $file_category "local"] } {
  1788. lappend l_local_files $file
  1789. } elseif { [string equal $file_category "remote"] } {
  1790. lappend l_remote_files $file
  1791. } else {}
  1792. }
  1793. foreach file $l_file_list {
  1794. set file [string trim $file "\""]
  1795. # fix file path for local files
  1796. if { [string equal $file_category "local"] } {
  1797. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1798. set src_file [join [lrange $path_dirs end-1 end] "/"]
  1799. set src_file [string trimleft $src_file "/"]
  1800. set src_file [string trimleft $src_file "\\"]
  1801. set file $src_file
  1802. }
  1803. set file_object ""
  1804. if { [string equal $file_category "local"] } {
  1805. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list "*$file"]] 0]
  1806. } elseif { [string equal $file_category "remote"] } {
  1807. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1808. }
  1809. set file_props [list_property $file_object]
  1810. set prop_info_list [list]
  1811. set prop_count 0
  1812. foreach file_prop $file_props {
  1813. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  1814. if { [string equal $is_readonly "1"] } {
  1815. continue
  1816. }
  1817. # Fix for CR-939211
  1818. if { ([file extension $file] == ".bd") && ([string equal -nocase $file_prop "generate_synth_checkpoint"] || [string equal -nocase $file_prop "synth_checkpoint_mode"]) } {
  1819. continue
  1820. }
  1821. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  1822. set def_val [list_property_value -default $file_prop $file_object]
  1823. set cur_val [get_property $file_prop $file_object]
  1824. # filter special properties
  1825. if { [filter $file_prop $cur_val $file] } { continue }
  1826. # re-align values
  1827. set cur_val [get_target_bool_val $def_val $cur_val]
  1828. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  1829. set prop_entry ""
  1830. if { [string equal $file_category "local"] } {
  1831. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  1832. } elseif { [string equal $file_category "remote"] } {
  1833. set prop_value_entry [get_property $file_prop $file_object]
  1834. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  1835. } else {}
  1836. if { $a_global_vars(b_arg_all_props) } {
  1837. lappend prop_info_list $prop_entry
  1838. incr prop_count
  1839. } else {
  1840. if { $def_val != $cur_val } {
  1841. lappend prop_info_list $prop_entry
  1842. incr prop_count
  1843. }
  1844. }
  1845. if { $a_global_vars(b_arg_dump_proj_info) } {
  1846. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1847. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  1848. }
  1849. }
  1850. # write properties now
  1851. if { $prop_count>0 } {
  1852. if { {remote} == $file_category } {
  1853. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  1854. lappend l_script_data "set file \"$file\""
  1855. } else {
  1856. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  1857. lappend l_script_data "set file \[file normalize \$file\]"
  1858. }
  1859. } else {
  1860. lappend l_script_data "set file \"$file\""
  1861. }
  1862. # is this a IP block fileset? if yes, get files from current source fileset
  1863. if { [is_ip_fileset $tcl_obj] } {
  1864. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets [current_fileset -srcset]\] \[list \"*\$file\"\]\]"
  1865. } else {
  1866. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets $tcl_obj\] \[list \"*\$file\"\]\]"
  1867. }
  1868. set get_what "get_files"
  1869. write_properties $prop_info_list $get_what $tcl_obj
  1870. incr file_prop_count
  1871. }
  1872. }
  1873. if { $file_prop_count == 0 } {
  1874. lappend l_script_data "# None"
  1875. }
  1876. lappend l_script_data ""
  1877. }
  1878. proc get_script_execution_dir { } {
  1879. # Summary: Return script directory path from where the script will be executed
  1880. # Argument Usage:
  1881. # none
  1882. # Return Value:
  1883. # Path to the script direc
  1884. variable a_global_vars
  1885. # default: return script directory path
  1886. set scr_exe_dir $a_global_vars(s_path_to_script_dir)
  1887. # is -path_to_relative specified and the path exists? return this dir
  1888. set rel_to_dir $a_global_vars(s_relative_to)
  1889. if { ("." != $rel_to_dir) } {
  1890. set rel_to_dir [file normalize $rel_to_dir]
  1891. if { [file exists $rel_to_dir] } {
  1892. set scr_exe_dir $rel_to_dir
  1893. }
  1894. }
  1895. return $scr_exe_dir
  1896. }
  1897. # TODO: This is the same as xcs_get_relative_file_path for simulators, see common/utils.tcl
  1898. # Remember to add the 'source .../common/utils.tcl' in the write_project_tcl proc to load the common file
  1899. proc get_relative_file_path_for_source { file_path_to_convert relative_to } {
  1900. # Summary: Get the relative path wrt to path specified
  1901. # Argument Usage:
  1902. # file_path_to_convert: input file to make relative to specfied path
  1903. # Return Value:
  1904. # Relative path wrt the path specified
  1905. variable a_xport_sim_vars
  1906. # make sure we are dealing with a valid relative_to directory. If regular file or is not a directory, get directory
  1907. if { [file isfile $relative_to] || ![file isdirectory $relative_to] } {
  1908. set relative_to [file dirname $relative_to]
  1909. }
  1910. set cwd [file normalize [pwd]]
  1911. if { [file pathtype $file_path_to_convert] eq "relative" } {
  1912. # is relative_to path same as cwd?, just return this path, no further processing required
  1913. if { [string equal $relative_to $cwd] } {
  1914. return $file_path_to_convert
  1915. }
  1916. # the specified path is "relative" but something else, so make it absolute wrt current working dir
  1917. set file_path_to_convert [file join $cwd $file_path_to_convert]
  1918. }
  1919. # is relative_to "relative"? convert to absolute as well wrt cwd
  1920. if { [file pathtype $relative_to] eq "relative" } {
  1921. set relative_to [file join $cwd $relative_to]
  1922. }
  1923. # normalize
  1924. set file_path_to_convert [file normalize $file_path_to_convert]
  1925. set relative_to [file normalize $relative_to]
  1926. set file_path $file_path_to_convert
  1927. set file_comps [file split $file_path]
  1928. set relative_to_comps [file split $relative_to]
  1929. set found_match false
  1930. set index 0
  1931. set fc_comps_len [llength $file_comps]
  1932. set rt_comps_len [llength $relative_to_comps]
  1933. # compare each dir element of file_to_convert and relative_to, set the flag and
  1934. # get the final index till these sub-dirs matched. Break if limit reaches.
  1935. while { [lindex $file_comps $index] == [lindex $relative_to_comps $index] } {
  1936. if { !$found_match } { set found_match true }
  1937. incr index
  1938. if { ($index == $fc_comps_len) || ($index == $rt_comps_len) } {
  1939. break;
  1940. }
  1941. }
  1942. # any common dirs found? convert path to relative
  1943. if { $found_match } {
  1944. set parent_dir_path ""
  1945. set rel_index $index
  1946. # keep traversing the relative_to dirs and build "../" levels
  1947. while { [lindex $relative_to_comps $rel_index] != "" } {
  1948. set parent_dir_path "../$parent_dir_path"
  1949. incr rel_index
  1950. }
  1951. #
  1952. # at this point we have parent_dir_path setup with exact number of sub-dirs to go up
  1953. #
  1954. # now build up part of path which is relative to matched part
  1955. set rel_path ""
  1956. set rel_index $index
  1957. while { [lindex $file_comps $rel_index] != "" } {
  1958. set comps [lindex $file_comps $rel_index]
  1959. if { $rel_path == "" } {
  1960. # first dir
  1961. set rel_path $comps
  1962. } else {
  1963. # append remaining dirs
  1964. set rel_path "${rel_path}/$comps"
  1965. }
  1966. incr rel_index
  1967. }
  1968. # prepend parent dirs, this is the complete resolved path now
  1969. set resolved_path "${parent_dir_path}${rel_path}"
  1970. return $resolved_path
  1971. }
  1972. # no common dirs found, just return the normalized path
  1973. return $file_path
  1974. }
  1975. proc is_ip_fileset { fileset } {
  1976. # Summary: Find IP's if any from the specified fileset and return true if 'generate_synth_checkpoint' is set to 1
  1977. # Argument Usage:
  1978. # fileset: fileset name
  1979. # Return Value:
  1980. # true (1) if success, false (0) otherwise
  1981. # make sure fileset is block fileset type
  1982. set isPRFlow [get_property pr_flow [current_project]]
  1983. set isRMFileset 0
  1984. if { $isPRFlow == 1 } {
  1985. set allReconfigModules [get_reconfig_modules]
  1986. foreach reconfigmodule $allReconfigModules {
  1987. set rmFileset [get_filesets -of_objects [get_reconfig_modules $reconfigmodule]]
  1988. if { [string equal $rmFileset $fileset] } {
  1989. set isRMFileset 1
  1990. break
  1991. }
  1992. }
  1993. }
  1994. if { $isRMFileset == 1 } {
  1995. return false
  1996. }
  1997. if { {BlockSrcs} != [get_property fileset_type [get_filesets $fileset]] } {
  1998. return false
  1999. }
  2000. set ip_filter "FILE_TYPE == \"IP\" || FILE_TYPE==\"Block Designs\""
  2001. set ips [get_files -all -quiet -of_objects [get_filesets $fileset] -filter $ip_filter]
  2002. set b_found false
  2003. foreach ip $ips {
  2004. if { [get_property generate_synth_checkpoint [lindex [get_files -quiet -all [list "$ip"]] 0]] } {
  2005. set b_found true
  2006. break
  2007. }
  2008. }
  2009. if { $b_found } {
  2010. return true
  2011. }
  2012. return false
  2013. }
  2014. proc is_proxy_ip_fileset { fileset } {
  2015. # Summary: Determine if the fileset is an OOC run for a proxy IP that has a parent composite
  2016. # Argument Usage:
  2017. # fileset: fileset name
  2018. # Return Value:
  2019. # true (1) if the fileset contains an IP at its root with a parent composite, false (0) otherwise
  2020. # make sure fileset is block fileset type
  2021. if { {BlockSrcs} != [get_property fileset_type [get_filesets $fileset]] } {
  2022. return false
  2023. }
  2024. set ip_with_parent_filter "FILE_TYPE == IP && PARENT_COMPOSITE_FILE != \"\""
  2025. if {[llength [get_files -norecurse -quiet -of_objects [get_filesets $fileset] -filter $ip_with_parent_filter]] == 1} {
  2026. return true
  2027. }
  2028. return false
  2029. }
  2030. proc is_ip_run { run } {
  2031. # Summary: Find IP's if any from the fileset linked with the block fileset run
  2032. # Argument Usage:
  2033. # run: run name
  2034. # Return Value:
  2035. # true (1) if success, false (0) otherwise
  2036. set fileset [get_property srcset [get_runs $run]]
  2037. return [is_ip_fileset $fileset]
  2038. }
  2039. proc is_win_os {} {
  2040. # Summary: Determine if OS is Windows
  2041. # Return Value:
  2042. # true (1) if windows, false (0) otherwise
  2043. set os [lindex $::tcl_platform(os) 0]
  2044. set plat [lindex $::tcl_platform(platform) 0]
  2045. if { [string compare -nocase -length 3 $os "win"] == 0 ||
  2046. [string compare -nocase -length 3 $plat "win"] == 0 } {
  2047. return true
  2048. } else { return false }
  2049. }
  2050. proc need_abs_path { src } {
  2051. # Summary: Determine if src provided is in a different network mount than execution directory
  2052. # Argument Usage:
  2053. # src: source file to check
  2054. # Return Value:
  2055. # true (1) if src is in a different drive than script execution directory, false (0) otherwise
  2056. variable a_os
  2057. if { $a_os eq "win" } {
  2058. set src_path [file normalize [string trim $src "\""]]
  2059. set ref_path [file normalize [get_script_execution_dir]]
  2060. if { [string compare -nocase -length 2 $src_path $ref_path] != 0 } {
  2061. return true;
  2062. }
  2063. }
  2064. return false
  2065. }
  2066. proc wr_dashboards { proj_dir proj_name } {
  2067. # Summary: write dashboards and properties
  2068. # This helper command is used to script help.
  2069. # Argument Usage:
  2070. # proj_name: project name
  2071. # Return Value:
  2072. # None
  2073. # get current dash board
  2074. # get all dash boards
  2075. # For each dash boards
  2076. # create dash board
  2077. variable l_script_data
  2078. set dashboardsExist 0
  2079. set dashboards [get_dashboards]
  2080. foreach db $dashboards {
  2081. write_specified_dashboard $proj_dir $proj_name $db
  2082. set dashboardsExist 1
  2083. }
  2084. if { $dashboardsExist == 0} {
  2085. return
  2086. }
  2087. set currentDashboard [current_dashboard]
  2088. lappend l_script_data "# Set current dashboard to '$currentDashboard' "
  2089. lappend l_script_data "current_dashboard $currentDashboard "
  2090. }
  2091. proc write_specified_gadget { proj_dir proj_name gadget dashboard} {
  2092. # Summary: write the specified gadget
  2093. # This helper command is used to script help.
  2094. # Argument Usage:
  2095. # Return Value:
  2096. # none
  2097. variable l_script_data
  2098. set db_name [get_property name [get_dashboards $dashboard]]
  2099. set gadgetName [get_property name [get_gadgets -of_objects [get_dashboards $db_name] $gadget]]
  2100. set gadgetType [get_property type [get_gadgets -of_objects [get_dashboards $db_name] $gadget]]
  2101. set cmd_str "create_gadget -name {$gadgetName} -type $gadgetType -dashboard $dashboard"
  2102. lappend l_script_data "# Create '$gadgetName' gadget (if not found)"
  2103. lappend l_script_data "if \{\[string equal \[get_gadgets -of_objects \[get_dashboards $db_name\] $gadget \] \"\"\]\} \{"
  2104. lappend l_script_data "$cmd_str"
  2105. lappend l_script_data "\}"
  2106. lappend l_script_data "set obj \[get_gadgets -of_objects \[get_dashboards $db_name\] $gadget \]"
  2107. set tcl_obj [get_gadgets -of_objects [get_dashboards $db_name] $gadget ]
  2108. set get_what "get_gadgets -of_objects \[get_dashboards $db_name\]"
  2109. write_props $proj_dir $proj_name $get_what $tcl_obj "gadget" "$"
  2110. }
  2111. proc write_specified_dashboard { proj_dir proj_name dashboard } {
  2112. # Summary: write the specified dashboard
  2113. # This helper command is used to script help.
  2114. # Argument Usage:
  2115. # Return Value:
  2116. # none
  2117. variable l_script_data
  2118. set get_what "get_dashboards"
  2119. set dashboardName [get_property name [$get_what $dashboard]]
  2120. lappend l_script_data "set obj \[$get_what $dashboard\]"
  2121. write_props $proj_dir $proj_name $get_what $dashboard "dashboard"
  2122. ##get gadgets of this dashboard
  2123. set gadgets [get_gadgets -of_objects [$get_what $dashboard]]
  2124. foreach gd $gadgets {
  2125. write_specified_gadget $proj_dir $proj_name $gd $dashboard
  2126. }
  2127. #if current dashboard is "default_dashboard"
  2128. #check if the above "gadgets" variable has all the default_gadgets, if any default gadget is not there in "gadgets" variable, it means user has deleted those gadgets but as part of create_project, all the default gadgets are created. So we have to delete the gadgets which user has deleted.
  2129. set def_db "default_dashboard"
  2130. if { [string equal $def_db $dashboard] } {
  2131. set default_gadgets {"drc_1" "methodology_1" "power_1" "timing_1" "utilization_1" "utilization_2"}
  2132. foreach dgd $default_gadgets {
  2133. #if dgd is not in gadgets, then delete dgd
  2134. if {$dgd ni $gadgets } {
  2135. set cmd_str "delete_gadgets -gadgets $dgd"
  2136. lappend l_script_data "# Delete the gadget '$dgd' "
  2137. lappend l_script_data "$cmd_str"
  2138. }
  2139. }
  2140. }
  2141. }
  2142. proc wr_prflow { proj_dir proj_name } {
  2143. # Summary: write partial reconfiguration and properties
  2144. # This helper command is used to script help.
  2145. # Argument Usage:
  2146. # proj_name: project name
  2147. # Return Value:
  2148. # None
  2149. if { [get_property pr_flow [current_project]] == 0 } {
  2150. return
  2151. }
  2152. # write below properties only if it's a pr project
  2153. wr_pdefs $proj_dir $proj_name
  2154. wr_reconfigModules $proj_dir $proj_name
  2155. wr_prConf $proj_dir $proj_name
  2156. }
  2157. proc wr_pdefs { proj_dir proj_name } {
  2158. # Summary: write partial reconfiguration and properties
  2159. # This helper command is used to script help.
  2160. # Argument Usage:
  2161. # proj_name: project name
  2162. # Return Value:
  2163. # None
  2164. # write pDef i.e. create partition def
  2165. set partitionDefs [get_partition_def]
  2166. foreach partitionDef $partitionDefs {
  2167. write_specified_partition_definition $proj_dir $proj_name $partitionDef
  2168. }
  2169. }
  2170. proc write_specified_partition_definition { proj_dir proj_name pDef } {
  2171. # Summary: write the specified partition definition
  2172. # This helper command is used to script help.
  2173. # Argument Usage:
  2174. # Return Value:
  2175. # none
  2176. variable l_script_data
  2177. set get_what "get_partition_defs"
  2178. set pdefName [get_property name [$get_what $pDef]]
  2179. set moduleName [get_property module_name [$get_what $pDef]]
  2180. set pdef_library [get_property library [$get_what $pDef]]
  2181. set default_library [get_property default_lib [current_project]]
  2182. set cmd_str "create_partition_def -name $pdefName -module $moduleName"
  2183. if { ($pdef_library != "") && (![string equal $pdef_library $default_library]) } {
  2184. set cmd_str "$cmd_str -library $pdef_library"
  2185. }
  2186. lappend l_script_data "# Create '$pdefName' partition definition"
  2187. lappend l_script_data "$cmd_str"
  2188. lappend l_script_data "set obj \[$get_what $pDef\]"
  2189. write_props $proj_dir $proj_name $get_what $pDef "partitionDef"
  2190. }
  2191. proc wr_reconfigModules { proj_dir proj_name } {
  2192. # Summary: write reconfiguration modules for RPs
  2193. # This helper command is used to script help.
  2194. # Argument Usage:
  2195. # proj_name: project name
  2196. # Return Value:
  2197. # None
  2198. # write reconfigurations modules
  2199. set reconfigModules [get_reconfig_modules]
  2200. variable a_global_vars
  2201. foreach rm $reconfigModules {
  2202. if { !$a_global_vars(b_arg_use_bd_files) } {
  2203. set rm_bds [get_files -norecurse -quiet -of_objects [get_reconfig_modules $rm] *.bd]
  2204. foreach rm_bd $rm_bds {
  2205. write_bd_as_proc $rm_bd
  2206. }
  2207. }
  2208. write_specified_reconfig_module $proj_dir $proj_name $rm
  2209. }
  2210. }
  2211. proc write_specified_reconfig_module { proj_dir proj_name reconfModule } {
  2212. # Summary: write the specified partial reconfiguration module information
  2213. # This helper command is used to script help.
  2214. # Argument Usage:
  2215. # Return Value:
  2216. # none
  2217. variable l_script_data
  2218. set get_what "get_reconfig_modules"
  2219. # fetch all the run attritubes and properties of passed reconfig modules
  2220. set name [get_property name [$get_what $reconfModule]]
  2221. set partitionDefName [get_property partition_def [$get_what $reconfModule]]
  2222. set isGateLevelSet [get_property is_gate_level [$get_what $reconfModule]]
  2223. lappend l_script_data "# Create '$reconfModule' reconfigurable module"
  2224. lappend l_script_data "set partitionDef \[get_partition_defs $partitionDefName\]"
  2225. if { $isGateLevelSet } {
  2226. set moduleName [get_property module_name [$get_what $reconfModule]]
  2227. if { $moduleName == "" } {
  2228. return
  2229. }
  2230. lappend l_script_data "create_reconfig_module -name $name -top $moduleName -partition_def \$partitionDef -gate_level"
  2231. } else {
  2232. lappend l_script_data "create_reconfig_module -name $name -partition_def \$partitionDef"
  2233. }
  2234. # write default_rm property for pDef if RM and its corresponding property for pDef->defaultRM is same
  2235. set defaultRM_for_pDef [get_property default_rm [get_partition_def $partitionDefName]]
  2236. if { [string equal $reconfModule $defaultRM_for_pDef] } {
  2237. lappend l_script_data "set_property default_rm $reconfModule \$partitionDef"
  2238. }
  2239. lappend l_script_data "set obj \[$get_what $reconfModule\]"
  2240. write_props $proj_dir $proj_name $get_what $reconfModule "reconfigModule"
  2241. write_reconfigmodule_files $proj_dir $proj_name $reconfModule
  2242. }
  2243. proc wr_prConf {proj_dir proj_name} {
  2244. # Summary: write reconfiguration modules for RPs
  2245. # This helper command is used to script help.
  2246. # Argument Usage:
  2247. # proj_name: project name
  2248. # Return Value:
  2249. # None
  2250. # write pr configurations
  2251. set prConfigurations [get_pr_configurations]
  2252. foreach prConfig $prConfigurations {
  2253. write_specified_prConfiguration $proj_dir $proj_name $prConfig
  2254. }
  2255. }
  2256. proc write_specified_prConfiguration { proj_dir proj_name prConfig } {
  2257. # Summary: write the specified pr reconfiguration
  2258. # This helper command is used to script help.
  2259. # Argument Usage:
  2260. # Return Value:
  2261. # none
  2262. variable l_script_data
  2263. set get_what "get_pr_configurations"
  2264. # fetch pr config properties
  2265. set name [get_property name [$get_what $prConfig]]
  2266. lappend l_script_data "# Create '$prConfig' pr configurations"
  2267. lappend l_script_data "create_pr_configuration -name $name"
  2268. lappend l_script_data "set obj \[$get_what $prConfig\]"
  2269. write_props $proj_dir $proj_name $get_what $prConfig "prConfiguration"
  2270. }
  2271. proc write_reconfigmodule_files { proj_dir proj_name reconfigModule } {
  2272. # Summary: write file and file properties
  2273. # This helper command is used to script help.
  2274. # Argument Usage:
  2275. # Return Value:
  2276. # none
  2277. variable a_global_vars
  2278. variable l_script_data
  2279. set l_local_file_list [list]
  2280. set l_remote_file_list [list]
  2281. # return if empty fileset
  2282. if {[llength [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule]]] == 0 } {
  2283. lappend l_script_data "# Empty (no sources present)\n"
  2284. return
  2285. }
  2286. set fileset [get_filesets -of_objects $reconfigModule]
  2287. set fs_name [get_property name $fileset]
  2288. set import_coln [list]
  2289. set add_file_coln [list]
  2290. set bd_list [list]
  2291. foreach file [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule]] {
  2292. if { [file extension $file ] ==".bd" && !$a_global_vars(b_arg_use_bd_files)} {
  2293. lappend bd_list $file
  2294. continue
  2295. }
  2296. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  2297. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  2298. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  2299. # fetch first object
  2300. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list $file]] 0]
  2301. set file_props [list_property $file_object]
  2302. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  2303. # import files
  2304. set imported_path [get_property "imported_from" $file]
  2305. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  2306. set proj_file_path "\$origin_dir/$rel_file_path"
  2307. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  2308. if { $a_global_vars(b_arg_no_copy_srcs) } {
  2309. # add to the local collection
  2310. lappend l_remote_file_list $file
  2311. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2312. lappend add_file_coln "$file"
  2313. } else {
  2314. lappend add_file_coln "\"\[file normalize \"$proj_file_path\"\]\""
  2315. }
  2316. } else {
  2317. # add to the import collection
  2318. lappend l_local_file_list $file
  2319. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2320. lappend import_coln "$file"
  2321. } else {
  2322. lappend import_coln "\"\[file normalize \"$proj_file_path\"\]\""
  2323. }
  2324. }
  2325. } else {
  2326. set file "\"$file\""
  2327. # is local? add to local project, add to collection and then import this collection by default unless -no_copy_sources is specified
  2328. if { [is_local_to_project $file] } {
  2329. if { $a_global_vars(b_arg_dump_proj_info) } {
  2330. set src_file "\$PSRCDIR/$src_file"
  2331. }
  2332. # add to the import collection
  2333. set file_no_quotes [string trim $file "\""]
  2334. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  2335. lappend import_coln "\"\[file normalize \"$org_file_path\"\]\""
  2336. lappend l_local_file_list $file
  2337. } else {
  2338. lappend l_remote_file_list $file
  2339. }
  2340. # add file to collection
  2341. if { $a_global_vars(b_arg_no_copy_srcs) && (!$a_global_vars(b_absolute_path)) && ![need_abs_path $file]} {
  2342. set file_no_quotes [string trim $file "\""]
  2343. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  2344. set file1 "\"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  2345. lappend add_file_coln "$file1"
  2346. } else {
  2347. lappend add_file_coln "$file"
  2348. }
  2349. }
  2350. }
  2351. if {[llength $bd_list] > 0 } {
  2352. foreach bd_file $bd_list {
  2353. set filename [file tail $bd_file]
  2354. lappend l_script_data " move_files \[ get_files $filename \] -of_objects \[get_reconfig_modules $reconfigModule\]"
  2355. }
  2356. }
  2357. if {[llength $add_file_coln]>0} {
  2358. lappend l_script_data "set files \[list \\"
  2359. foreach file $add_file_coln {
  2360. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2361. lappend l_script_data " $file\\"
  2362. } else {
  2363. if { $a_global_vars(b_arg_no_copy_srcs) } {
  2364. lappend l_script_data " $file\\"
  2365. } else {
  2366. set file_no_quotes [string trim $file "\""]
  2367. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  2368. lappend l_script_data " \"\[file normalize \"\$origin_dir/$rel_file_path\"\]\"\\"
  2369. }
  2370. }
  2371. }
  2372. lappend l_script_data "\]"
  2373. lappend l_script_data "add_files -norecurse -of_objects \[get_reconfig_modules $reconfigModule\] \$files"
  2374. lappend l_script_data ""
  2375. }
  2376. # now import local files if -no_copy_sources is not specified
  2377. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  2378. if { [llength $import_coln] > 0 } {
  2379. lappend l_script_data "# Import local files from the original project"
  2380. lappend l_script_data "set files \[list \\"
  2381. foreach ifile $import_coln {
  2382. lappend l_script_data " $ifile\\"
  2383. }
  2384. lappend l_script_data "\]"
  2385. lappend l_script_data "import_files -of_objects \[get_reconfig_modules $reconfigModule\] \$files"
  2386. lappend l_script_data ""
  2387. }
  2388. }
  2389. # write fileset file properties for remote files (added sources)
  2390. write_reconfigmodule_file_properties $reconfigModule $fs_name $proj_dir $l_remote_file_list "remote"
  2391. # write fileset file properties for local files (imported sources)
  2392. write_reconfigmodule_file_properties $reconfigModule $fs_name $proj_dir $l_local_file_list "local"
  2393. # move sub-design files (XCI/BD) of reconfig modules from sources fileset to reconfig-module (RM) fileset
  2394. add_reconfigmodule_subdesign_files $reconfigModule
  2395. }
  2396. proc add_reconfigmodule_subdesign_files { reconfigModule } {
  2397. # Summary:
  2398. # Argument Usage:
  2399. # Return Value:
  2400. variable l_script_data
  2401. foreach rmSubdesignFileset [get_property subdesign_filesets $reconfigModule] {
  2402. foreach fileObj [get_files -quiet -norecurse -of_objects [get_filesets $rmSubdesignFileset]] {
  2403. set path_dirs [split [string trim [file normalize [string map {\\ /} $fileObj ]]] "/"]
  2404. set path [join [lrange $path_dirs end-1 end] "/"]
  2405. set path [string trimleft $path "/"]
  2406. lappend l_script_data "move_files -of_objects \$obj \[get_files *$path\]"
  2407. lappend l_script_data ""
  2408. }
  2409. }
  2410. }
  2411. proc write_reconfigmodule_file_properties { reconfigModule fs_name proj_dir l_file_list file_category } {
  2412. # Summary:
  2413. # Write fileset file properties for local and remote files
  2414. # Argument Usage:
  2415. # reconfigModule : object to inspect
  2416. # fs_name: fileset name
  2417. # l_file_list: list of files (local or remote)
  2418. # file_category: file catwgory (local or remote)
  2419. # Return Value:
  2420. # none
  2421. variable a_global_vars
  2422. variable l_script_data
  2423. variable l_local_files
  2424. variable l_remote_files
  2425. set l_local_files [list]
  2426. set l_remote_files [list]
  2427. set tcl_obj [get_filesets -of_objects $reconfigModule]
  2428. lappend l_script_data "# Set '$reconfigModule' fileset file properties for $file_category files"
  2429. set file_prop_count 0
  2430. # collect local/remote files
  2431. foreach file $l_file_list {
  2432. if { [string equal $file_category "local"] } {
  2433. lappend l_local_files $file
  2434. } elseif { [string equal $file_category "remote"] } {
  2435. lappend l_remote_files $file
  2436. } else {}
  2437. }
  2438. foreach file $l_file_list {
  2439. set file [string trim $file "\""]
  2440. # fix file path for local files
  2441. if { [string equal $file_category "local"] } {
  2442. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  2443. set src_file [join [lrange $path_dirs end-1 end] "/"]
  2444. set src_file [string trimleft $src_file "/"]
  2445. set src_file [string trimleft $src_file "\\"]
  2446. set file $src_file
  2447. }
  2448. set file_object ""
  2449. if { [string equal $file_category "local"] } {
  2450. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list "*$file"]] 0]
  2451. } elseif { [string equal $file_category "remote"] } {
  2452. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list $file]] 0]
  2453. }
  2454. set file_props [list_property $file_object]
  2455. set prop_info_list [list]
  2456. set prop_count 0
  2457. foreach file_prop $file_props {
  2458. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  2459. if { [string equal $is_readonly "1"] } {
  2460. continue
  2461. }
  2462. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  2463. set def_val [list_property_value -default $file_prop $file_object]
  2464. set cur_val [get_property $file_prop $file_object]
  2465. # filter special properties
  2466. if { [filter $file_prop $cur_val $file] } { continue }
  2467. # re-align values
  2468. set cur_val [get_target_bool_val $def_val $cur_val]
  2469. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  2470. set prop_entry ""
  2471. if { [string equal $file_category "local"] } {
  2472. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  2473. } elseif { [string equal $file_category "remote"] } {
  2474. set prop_value_entry [get_property $file_prop $file_object]
  2475. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  2476. } else {}
  2477. if { $a_global_vars(b_arg_all_props) } {
  2478. lappend prop_info_list $prop_entry
  2479. incr prop_count
  2480. } else {
  2481. if { $def_val != $cur_val } {
  2482. lappend prop_info_list $prop_entry
  2483. incr prop_count
  2484. }
  2485. }
  2486. if { $a_global_vars(b_arg_dump_proj_info) } {
  2487. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  2488. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  2489. }
  2490. }
  2491. # write properties now
  2492. if { $prop_count>0 } {
  2493. if { {remote} == $file_category } {
  2494. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2495. lappend l_script_data "set file \"$file\""
  2496. } else {
  2497. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  2498. lappend l_script_data "set file \[file normalize \$file\]"
  2499. }
  2500. } else {
  2501. lappend l_script_data "set file \"$file\""
  2502. }
  2503. lappend l_script_data "set obj \[get_files -of_objects \[get_reconfig_modules $reconfigModule\] \[list \"*\$file\"\]\]"
  2504. set get_what "get_files -of_objects "
  2505. write_properties $prop_info_list $get_what $tcl_obj
  2506. incr file_prop_count
  2507. }
  2508. }
  2509. if { $file_prop_count == 0 } {
  2510. lappend l_script_data "# None"
  2511. }
  2512. lappend l_script_data ""
  2513. }
  2514. proc write_report_strategy { run report_strategy } {
  2515. # Summary:
  2516. # create report one by one as per its configuration.
  2517. # Argument Usage:
  2518. # run FCO:
  2519. # Return Value: none
  2520. set retVal [get_param project.enableReportConfiguration]
  2521. if { $retVal == 0 } {
  2522. return
  2523. }
  2524. set reports [get_report_configs -of_objects [get_runs $run]]
  2525. if { [llength $reports] == 0 } {
  2526. return
  2527. }
  2528. variable l_script_data
  2529. lappend l_script_data "set obj \[get_runs $run\]"
  2530. lappend l_script_data "set_property set_report_strategy_name 1 \$obj"
  2531. lappend l_script_data "set_property report_strategy {$report_strategy} \$obj"
  2532. lappend l_script_data "set_property set_report_strategy_name 0 \$obj"
  2533. foreach report $reports {
  2534. set report_name [get_property name $report]
  2535. set report_spec [get_property report_type $report]
  2536. set step [get_property run_step $report]
  2537. lappend l_script_data "# Create '$report' report (if not found)"
  2538. lappend l_script_data "if \{ \[ string equal \[get_report_configs -of_objects \[get_runs $run\] $report\] \"\" \] \} \{"
  2539. lappend l_script_data " create_report_config -report_name $report_name -report_type $report_spec -steps $step -runs $run"
  2540. lappend l_script_data "\}"
  2541. lappend l_script_data "set obj \[get_report_configs -of_objects \[get_runs $run\] $report\]"
  2542. lappend l_script_data "if { \$obj != \"\" } {"
  2543. write_report_props $report
  2544. lappend l_script_data "}"
  2545. }
  2546. }
  2547. proc write_report_props { report } {
  2548. # Summary:
  2549. # iterate over all report options and send all non default values to -->set_property <property> <curr_value> [report FCO]
  2550. # Argument Usage:
  2551. # report FCO:
  2552. # Return Value: none
  2553. variable l_script_data
  2554. variable a_global_vars
  2555. set obj_name [get_property name $report]
  2556. set read_only_props [rdi::get_attr_specs -class [get_property class $report] -filter {is_readonly}]
  2557. set prop_info_list [list]
  2558. set properties [list_property $report]
  2559. foreach prop $properties {
  2560. if { [string equal -nocase $prop "OPTIONS.pb"] || [string equal -nocase $prop "OPTIONS.rpx"] } {
  2561. #skipping read_only property
  2562. continue
  2563. }
  2564. if { [lsearch $read_only_props $prop] != -1 } { continue }
  2565. set def_val [list_property_value -default $prop $report]
  2566. set cur_val [get_property $prop $report]
  2567. # filter special properties
  2568. if { [filter $prop $cur_val] } { continue }
  2569. set cur_val [get_target_bool_val $def_val $cur_val]
  2570. set prop_entry "[string tolower $prop]#[get_property $prop $report]"
  2571. if { $a_global_vars(b_arg_all_props) } {
  2572. lappend prop_info_list $prop_entry
  2573. } elseif { $def_val != $cur_val } {
  2574. lappend prop_info_list $prop_entry
  2575. }
  2576. }
  2577. write_properties $prop_info_list "get_report_configs" $report
  2578. }
  2579. }