@@ -12,6 +12,12 @@ if {[info exists ::create_path]} {
12
12
set dest_dir [file normalize $script_dir /../src]
13
13
}
14
14
15
+ if {[info exists ::debug_prevent_fileio]} {
16
+ set debug_prevent_fileio $::debug_prevent_fileio
17
+ } else {
18
+ set debug_prevent_fileio 0
19
+ }
20
+
15
21
puts " INFO: Targeting $dest_dir for export"
16
22
set var_overwrite_ok [dict create]
17
23
@@ -76,12 +82,24 @@ foreach pf $pf_names {
76
82
}
77
83
# For some reason it needs to be made active for report to work
78
84
platform active $pf
85
+ set pf_dest [file normalize $dest_dir /$pf /]
79
86
# Get the xsa
80
- set xsa [dict get [platform report -dict $pf ] {hw spec}]
81
- file copy -force -- " $xsa " $dest_dir /$pf /
82
- set pf_subscript $dest_dir /$pf /5_hw_pf_xsa.tcl
83
- file copy -force -- $script_dir /sub/hw_pf_xsa.tcl " $pf_subscript "
84
- set fid [open " $pf_subscript " a]
87
+ set xsa [file normalize [dict get [platform report -dict $pf ] {hw spec}]]
88
+ set pf_subscript [file normalize $pf_dest /5_hw_pf_xsa.tcl]
89
+
90
+ if {$debug_prevent_fileio == 0} {
91
+ # Check if xsa is linked from src already, copy if not
92
+ if { [file dirname $xsa ] ne $pf_dest } {
93
+ file copy -force -- " $xsa " $pf_dest
94
+ }
95
+ file copy -force -- $script_dir /sub/hw_pf_xsa.tcl " $pf_subscript "
96
+ set fid [open " $pf_subscript " a]
97
+ } else {
98
+ puts " TRACE: file copy -force -- \" $xsa \" $pf_dest "
99
+ puts " TRACE: file copy -force -- $script_dir /sub/hw_pf_xsa.tcl \" $pf_subscript \" "
100
+ set fid stdout
101
+ }
102
+
85
103
catch {
86
104
# Export platform config
87
105
puts $fid " \n "
@@ -90,7 +108,9 @@ foreach pf $pf_names {
90
108
puts $fid " platform config -extra-compiler-flags pmufw \" [ platform config -extra-compiler-flags pmufw] \" "
91
109
puts $fid " platform config -extra-linker-flags pmufw \" [ platform config -extra-linker-flags pmufw] \" "
92
110
} result options
93
- close $fid
111
+ if {$debug_prevent_fileio == 0} {
112
+ close $fid
113
+ }
94
114
return -options $options $result
95
115
96
116
# Do the domains
@@ -130,16 +150,20 @@ foreach pf $pf_names {
130
150
set d_subscript $dest_dir /$d /25_standalone_bsp.tcl
131
151
puts " INFO: Generating $d_subscript ."
132
152
133
- set dfid [open $d_subscript w]
153
+ if {$debug_prevent_fileio == 0} {
154
+ set dfid [open $d_subscript w]
155
+ } else {
156
+ set dfid stdout
157
+ }
134
158
set sfid [open $script_dir /sub/standalone_bsp.tcl r]
135
159
catch {
136
160
# Get domain properties
137
161
set proc [dict get [domain report -dict $d ] {processor}]
138
- # Write to subscript's beginning
139
- puts $dfid " set proc \" $proc \" "
140
- # Copy the rest of the subscript
162
+ set var_map [ list <processor> $proc \
163
+ ]
164
+ # Copy the subcript while replacing variables
141
165
while { [gets $sfid line] >= 0 } {
142
- puts $dfid $ line
166
+ puts $dfid [ string map $var_map $ line]
143
167
}
144
168
# Only SOME of the config params possible
145
169
set bsp_configs {\
@@ -167,18 +191,14 @@ foreach pf $pf_names {
167
191
}
168
192
169
193
} result options
170
- close $dfid
194
+ if {$debug_prevent_fileio == 0} {
195
+ close $dfid
196
+ }
171
197
close $sfid
172
198
return -options $options $result
173
199
}
174
200
}
175
201
176
- if {[info exists ::debug_prevent_fileio]} {
177
- set debug_prevent_fileio $::debug_prevent_fileio
178
- } else {
179
- set debug_prevent_fileio 0
180
- }
181
-
182
202
# Do the applications
183
203
set app_names " "
184
204
if { [catch {app list}] != 0 } {
@@ -342,4 +362,33 @@ foreach app_name $app_names {
342
362
close $outfile
343
363
}
344
364
return -options $options $result
345
- }
365
+ }
366
+
367
+ # When all sources are checked into src/, copy checkout script and README too
368
+ if {$debug_prevent_fileio == 0} {
369
+ file copy -force -- [file normalize $script_dir /checkout.tcl] $dest_dir /
370
+ file copy -force -- [file normalize $script_dir /README.md] [file normalize $dest_dir /]
371
+ # Attempt to query git HEAD hash
372
+ if { [catch { set fid [open " |git -C \" $script_dir \" rev-parse HEAD" r] } errmsg] } {
373
+ puts " WARNING: $errmsg "
374
+ puts " WARNING: git command cannot be found (not in PATH?), so could not append $dest_dir /README.md with script versioning info."
375
+ } elseif { [gets $fid hash] eq -1 } {
376
+ puts " WARNING: git error so could not append $dest_dir /README.md with script versioning info."
377
+ } else {
378
+ set dfid [open [file normalize $dest_dir /README.md] a]
379
+ catch {
380
+ puts $dfid " \n This README.md was created by the following commit hash:\n $hash "
381
+ } result options
382
+ close $dfid
383
+ close $fid
384
+ return -options $options $result
385
+ }
386
+ }
387
+
388
+ # Copy cleanup scripts to ws/, which is the default destination for checkout.tcl
389
+ if {$debug_prevent_fileio == 0} {
390
+ file copy -force -- [file normalize $script_dir /sub/cleanup._sh] [file normalize $dest_dir /../ws/cleanup.sh]
391
+ file copy -force -- [file normalize $script_dir /sub/cleanup._cmd] [file normalize $dest_dir /../ws/cleanup.cmd]
392
+ }
393
+
394
+ puts " INFO: Checked in workspace [ getws] to $dest_dir "
0 commit comments