Fossil SCM
| 762ef68… | mistachkin | 1 | # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/ |
| 762ef68… | mistachkin | 2 | # All rights reserved |
| 762ef68… | mistachkin | 3 | |
| 762ef68… | mistachkin | 4 | # @synopsis: |
| 762ef68… | mistachkin | 5 | # |
| 762ef68… | mistachkin | 6 | # The 'tmake' module makes it easy to support the tmake build system. |
| 762ef68… | mistachkin | 7 | # |
| 762ef68… | mistachkin | 8 | # The following variables are set: |
| 762ef68… | mistachkin | 9 | # |
| 762ef68… | mistachkin | 10 | ## CONFIGURED - to indicate that the project is configured |
| 762ef68… | mistachkin | 11 | |
| 762ef68… | mistachkin | 12 | use system |
| 762ef68… | mistachkin | 13 | |
| 370c263… | stephan | 14 | options {} |
| 762ef68… | mistachkin | 15 | |
| 762ef68… | mistachkin | 16 | define CONFIGURED |
| 762ef68… | mistachkin | 17 | |
| 762ef68… | mistachkin | 18 | # @make-tmake-settings outfile patterns ... |
| 762ef68… | mistachkin | 19 | # |
| 51d006f… | stephan | 20 | # Examines all defined variables which match the given patterns (defaults to '*') |
| 762ef68… | mistachkin | 21 | # and writes a tmake-compatible .conf file defining those variables. |
| 51d006f… | stephan | 22 | # For example, if 'ABC' is '"3 monkeys"' and 'ABC' matches a pattern, then the file will include: |
| 762ef68… | mistachkin | 23 | # |
| 762ef68… | mistachkin | 24 | ## define ABC {3 monkeys} |
| 762ef68… | mistachkin | 25 | # |
| 762ef68… | mistachkin | 26 | # If the file would be unchanged, it is not written. |
| 762ef68… | mistachkin | 27 | # |
| 762ef68… | mistachkin | 28 | # Typical usage is: |
| 762ef68… | mistachkin | 29 | # |
| 51d006f… | stephan | 30 | ## make-tmake-settings [get-env BUILDDIR objdir]/settings.conf {[A-Z]*} |
| 762ef68… | mistachkin | 31 | proc make-tmake-settings {file args} { |
| 762ef68… | mistachkin | 32 | file mkdir [file dirname $file] |
| 762ef68… | mistachkin | 33 | set lines {} |
| 762ef68… | mistachkin | 34 | |
| 762ef68… | mistachkin | 35 | if {[llength $args] == 0} { |
| 762ef68… | mistachkin | 36 | set args * |
| 762ef68… | mistachkin | 37 | } |
| 762ef68… | mistachkin | 38 | |
| 762ef68… | mistachkin | 39 | foreach n [lsort [dict keys [all-defines]]] { |
| 762ef68… | mistachkin | 40 | foreach p $args { |
| 762ef68… | mistachkin | 41 | if {[string match $p $n]} { |
| 762ef68… | mistachkin | 42 | set value [get-define $n] |
| 762ef68… | mistachkin | 43 | lappend lines "define $n [list $value]" |
| 762ef68… | mistachkin | 44 | break |
| 762ef68… | mistachkin | 45 | } |
| 762ef68… | mistachkin | 46 | } |
| 762ef68… | mistachkin | 47 | } |
| 762ef68… | mistachkin | 48 | set buf [join $lines \n] |
| 762ef68… | mistachkin | 49 | write-if-changed $file $buf { |
| 762ef68… | mistachkin | 50 | msg-result "Created $file" |
| 762ef68… | mistachkin | 51 | } |
| 762ef68… | mistachkin | 52 | } |