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.

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