Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/build/v2/util/os.jam @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 3.1 KB
Line 
1#  (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
2#  distribute this software is granted provided this copyright notice appears in
3#  all copies. This software is provided "as is" without express or implied
4#  warranty, and with no claim as to its suitability for any purpose.
5
6import modules ;
7
8# Return the value(s) of the given environment variable(s) at the time
9# bjam was invoked.
10rule environ ( variable-names + )
11{
12    return [ modules.peek .ENVIRON : $(variable-names) ] ;
13}
14
15.name = [ modules.peek : OS ] ;
16.platform = [ modules.peek : OSPLAT ] ;
17.version = [ modules.peek : OSVER ] ;
18
19local rule constant ( c )
20{
21    # First look for platform-specific name, then general value
22    local variables = .$(c)-$(.name) .$(c) ;
23    local result = $($(variables)) ;
24    return $(result[1]) ;
25}
26
27rule get-constant  ( )
28{
29    # Find the name of the constant being accessed, which is
30    # equal to the name used to invoke us.
31    local bt = [ BACKTRACE 1 ] ;
32    local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ;
33    return [ constant $(rulename) ] ;
34}
35
36
37# export all the common constants
38.constants = name platform version shared-library-path-variable path-separator ;
39for local constant in $(.constants)
40{
41    IMPORT $(__name__) : get-constant : $(__name__) : $(constant) ;
42}
43EXPORT $(__name__) : $(.constants) ;
44
45.shared-library-path-variable-NT = PATH ;
46.path-separator-NT = ";" ;
47.expand-variable-prefix-NT = % ;
48.expand-variable-suffix-NT = % ;
49
50.shared-library-path-variable-CYGWIN = PATH ;
51.path-separator-CYGWIN = ":" ;
52.expand-variable-prefix-CYGWIN = $ ;
53.expand-variable-suffix-CYGWIN = "" ;
54
55.shared-library-path-variable-MACOSX = DYLD_LIBRARY_PATH ;
56
57
58.shared-library-path-variable = LD_LIBRARY_PATH ;
59.path-separator = ":" ;
60.expand-variable-prefix = $ ;
61.expand-variable-suffix = "" ;
62
63if $(.name) = NT
64{
65    local home = [ environ HOMEDRIVE HOMEPATH ] ;
66    .home-directories = $(home[1])$(home[2]) [ environ HOME ] ;
67}
68else
69{
70    .home-directories = [ environ HOME ] ;
71}
72
73# Can't use 'constant' mechanism because it only returns 1-element
74# values.
75rule home-directories ( )
76{
77    return $(.home-directories) ;
78}
79# Return the string needed to represent the expansion of the named
80# shell variable.
81rule expand-variable ( variable )
82{
83    local prefix = [ constant expand-variable-prefix ] ;
84    local suffix = [ constant expand-variable-suffix ] ;
85    return $(prefix)$(variable)$(suffix) ;
86}
87
88# Returns true if running on windows, whether in cygwin or not.
89rule on-windows
90{
91    local result ;
92    if [ modules.peek : NT ]
93    {
94        result = true ;
95    }
96    else if [ modules.peek : UNIX ]
97    {
98        switch [ modules.peek : JAMUNAME ]
99        {
100            case CYGWIN* :
101            {
102                result = true ;
103            }
104        }
105    }
106    return $(result) ;
107}
108
109if ! [ on-windows ]
110{
111    .on-unix = 1 ;
112}
113
114rule on-unix
115{
116    return $(.on-unix) ;
117}
118     
119
120import regex ;
121
122rule __test__
123{
124    import assert ;
125    rule identity ( args * ) { return $(args) ; }
126
127    if ! ( --quiet in [ modules.peek : ARGV ] )
128    {
129        ECHO os: name= [ name ] ;
130        ECHO os: version= [ version ] ;
131    }
132    assert.true name ;
133}
Note: See TracBrowser for help on using the repository browser.