]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright 2012 Steven Watanabe |
2 | # Distributed under the Boost Software License, Version 1.0. | |
3 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) | |
4 | ||
5 | import modules ; | |
6 | import errors ; | |
7 | import regex ; | |
8 | import path ; | |
9 | import project ; | |
10 | import os ; | |
11 | ||
12 | rule get ( name ) | |
13 | { | |
14 | return $(.vars.$(name)) ; | |
15 | } | |
16 | ||
17 | rule set ( name : value * ) | |
18 | { | |
19 | .all-vars += $(name) ; | |
20 | .vars.$(name) = $(value) ; | |
21 | } | |
22 | ||
23 | rule save ( ) | |
24 | { | |
25 | if $(.cache-file) | |
26 | { | |
27 | local cache-file-native = [ path.native $(.cache-file) ] ; | |
28 | local target = <new-cache-file>$(cache-file-native) ; | |
29 | local contents = "# Automatically generated by Boost.Build.\n# Do not edit.\n\nmodule config-cache {\n" ; | |
30 | for local var in $(.all-vars) | |
31 | { | |
32 | local transformed ; | |
33 | for local value in $(.vars.$(var)) | |
34 | { | |
35 | transformed += [ regex.escape $(value) : \"\\ : \\ ] ; | |
36 | } | |
37 | local quoted = \"$(transformed)\" ; | |
38 | contents += " set \"$(var)\" : $(quoted:J= ) ;\n" ; | |
39 | } | |
40 | contents += "}\n" ; | |
41 | FILE_CONTENTS on $(target) = $(contents) ; | |
42 | ALWAYS $(target) ; | |
43 | config-cache.write $(target) ; | |
44 | UPDATE_NOW $(target) : [ modules.peek configure : .log-fd ] : ignore-minus-n ; | |
11fdf7f2 TL |
45 | import common ; |
46 | common.Clean clean-all : $(target) ; | |
7c673cae FG |
47 | } |
48 | } | |
49 | ||
50 | actions write | |
51 | { | |
52 | @($(STDOUT):E=$(FILE_CONTENTS:J=)) > "$(<)" | |
53 | } | |
54 | ||
55 | if [ os.name ] = VMS | |
56 | { | |
57 | actions write | |
58 | { | |
59 | @($(STDOUT):E=$(FILE_CONTENTS:J=)) | TYPE SYS$INPUT /OUT=$(<:W) | |
60 | } | |
61 | } | |
62 | ||
63 | rule load ( cache-file ) | |
64 | { | |
65 | if $(.cache-file) | |
66 | { | |
67 | errors.error duplicate load of cache file ; | |
68 | } | |
69 | cache-file = [ path.native $(cache-file) ] ; | |
70 | if [ path.exists $(cache-file) ] && ! ( --reconfigure in [ modules.peek : ARGV ] ) | |
71 | { | |
11fdf7f2 TL |
72 | FILE_CONTENTS on <old-cache-file>$(cache-file) = "" ; |
73 | config-cache.write <old-cache-file>$(cache-file) ; | |
74 | UPDATE_NOW <old-cache-file>$(cache-file) : [ modules.peek configure : .log-fd ] ; | |
7c673cae FG |
75 | include <old-cache-file>$(cache-file) ; |
76 | } | |
77 | .cache-file = $(cache-file) ; | |
78 | } |