|
1
|
#!/usr/bin/tclsh |
|
2
|
# |
|
3
|
# This script is run as part of "make wasm". After emcc has |
|
4
|
# run to generate extsrc/pikchr.wasm and extsrc/pikchr.js from |
|
5
|
# extsrc/pikchr.c, we need to make changes to these filenames to |
|
6
|
# work around caching problems. |
|
7
|
# |
|
8
|
# (1) in extsrc/pikchr.js -> change "pikchr.wasm" into |
|
9
|
# "pikchr-vNNNNNNNN.wasm" where Ns are random digits. |
|
10
|
# |
|
11
|
# (2) in extsrc/pikchr-worker.js -> change "pikchr-vNNNNNNNN.js" |
|
12
|
# by altering the random digits N. |
|
13
|
# |
|
14
|
set DIR extsrc |
|
15
|
if {[llength $argv]>0} { |
|
16
|
set DIR [lindex $argv 0] |
|
17
|
} |
|
18
|
|
|
19
|
set R [expr {int(rand()*10000000000)+1000000000}] |
|
20
|
set in [open $DIR/pikchr.js rb] |
|
21
|
set f1 [read $in] |
|
22
|
close $in |
|
23
|
set f1mod [regsub {\ypikchr(-v\d+)?\.wasm\y} $f1 "pikchr-v$R.wasm"] |
|
24
|
set out [open $DIR/pikchr.js wb] |
|
25
|
puts -nonewline $out $f1mod |
|
26
|
close $out |
|
27
|
puts "modified $DIR/pikchr.js to reference \"pikchr-v$R.wasm\"" |
|
28
|
|
|
29
|
set in [open $DIR/pikchr-worker.js rb] |
|
30
|
set f1 [read $in] |
|
31
|
close $in |
|
32
|
set f1mod [regsub {\ypikchr(-v\d+)?\.js\y} $f1 "pikchr-v$R.js"] |
|
33
|
set out [open $DIR/pikchr-worker.js wb] |
|
34
|
puts -nonewline $out $f1mod |
|
35
|
close $out |
|
36
|
puts "modified $DIR/pikchr-worker.js to reference \"pikchr-v$R.js\"" |
|
37
|
|