File: mk_version.tcl

package info (click to toggle)
yaz 5.27.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,184 kB
  • sloc: xml: 123,414; ansic: 72,530; sh: 5,007; tcl: 2,169; makefile: 1,321; yacc: 382
file content (76 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/tclsh

proc usage {} {
    puts {mk_version.tcl [-v] IDMETA infile ..}
    exit 1
}

set verbose 0
set l [llength $argv]
set i 0
while {$i < $l} {
    set arg [lindex $argv $i]
    switch -glob -- $arg {
        -v {
            incr verbose
        }
        default {
	    if {![info exists conffile]} {
		set conffile $arg
	    } else {
		lappend infiles $arg
	    }
        }
    }
    incr i
}
if {![info exists infiles]} {
    puts "mk_version.tcl: missing input file(s)"
    usage
}

set f [open $conffile r]
while {1} {
    set cnt [gets $f line]
    if {$cnt < 0} {
	break
    }
    regexp {VERSION=([0-9.]+)} $line s version
}
close $f

set maps(VERSION) $version

set c [split $version .]

set versionl [expr ([lindex $c 0] * 256 + [lindex $c 1]) * 256 + [lindex $c 2]]
set maps(VERSION_HEX) [format %x $versionl]

if {[llength $c] == 3} {
    lappend c 1
}
set maps(WIN_FILEVERSION) [join $c ,]

set maps(VERSION_SHA1) {}

foreach x [array names maps] {
    puts "$x=$maps($x)"
}

foreach ifile $infiles {
    set if [open "${ifile}.in" r]
    set of [open "${ifile}" w]

    while {1} {
	set cnt [gets $if line]
	if {$cnt < 0} {
	    break
	}
	foreach x [array names maps] {
	    regsub -all "@$x@" $line $maps($x) line
	}
	puts $of $line
    }
    close $if
    close $of
}