~voluntatefaber/beat-box/bug952329

« back to all changes in this revision

Viewing changes to .waf-1.6.2-ad4cc42bd7d347f7e283789e711b993f/waflib/extras/compat15.py

  • Committer: Scott Ringwelski
  • Date: 2011-02-10 21:30:53 UTC
  • Revision ID: sgringwe@mtu.edu-20110210213053-d3c7mnexeref3cwj
sexy icons, sexy waf

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# encoding: utf-8
 
3
# WARNING! All changes made to this file will be lost!
 
4
 
 
5
import sys
 
6
if sys.hexversion < 0x020400f0: from sets import Set as set
 
7
import sys
 
8
from waflib import ConfigSet,Logs,Options,Scripting,Task,Build,Configure,Node,Runner,TaskGen,Utils,Errors,Context
 
9
sys.modules['Environment']=ConfigSet
 
10
ConfigSet.Environment=ConfigSet.ConfigSet
 
11
sys.modules['Logs']=Logs
 
12
sys.modules['Options']=Options
 
13
sys.modules['Scripting']=Scripting
 
14
sys.modules['Task']=Task
 
15
sys.modules['Build']=Build
 
16
sys.modules['Configure']=Configure
 
17
sys.modules['Node']=Node
 
18
sys.modules['Runner']=Runner
 
19
sys.modules['TaskGen']=TaskGen
 
20
sys.modules['Utils']=Utils
 
21
from waflib.Tools import c_preproc
 
22
sys.modules['preproc']=c_preproc
 
23
from waflib.Tools import c_config
 
24
sys.modules['config_c']=c_config
 
25
ConfigSet.ConfigSet.copy=ConfigSet.ConfigSet.derive
 
26
ConfigSet.ConfigSet.set_variant=Utils.nada
 
27
Build.BuildContext.add_subdirs=Build.BuildContext.recurse
 
28
Build.BuildContext.new_task_gen=Build.BuildContext.__call__
 
29
Build.BuildContext.is_install=0
 
30
Node.Node.relpath_gen=Node.Node.path_from
 
31
def name_to_obj(self,s,env=None):
 
32
        Logs.warn('compat: change "name_to_obj(name, env)" by "get_tgen_by_name(name)"')
 
33
        return self.get_tgen_by_name(s)
 
34
Build.BuildContext.name_to_obj=name_to_obj
 
35
def env_of_name(self,name):
 
36
        try:
 
37
                return self.all_envs[name]
 
38
        except KeyError:
 
39
                Logs.error('no such environment: '+name)
 
40
                return None
 
41
Build.BuildContext.env_of_name=env_of_name
 
42
def set_env_name(self,name,env):
 
43
        self.all_envs[name]=env
 
44
        return env
 
45
Configure.ConfigurationContext.set_env_name=set_env_name
 
46
def retrieve(self,name,fromenv=None):
 
47
        try:
 
48
                env=self.all_envs[name]
 
49
        except KeyError:
 
50
                env=ConfigSet.ConfigSet()
 
51
                self.prepare_env(env)
 
52
                self.all_envs[name]=env
 
53
        else:
 
54
                if fromenv:Logs.warn("The environment %s may have been configured already"%name)
 
55
        return env
 
56
Configure.ConfigurationContext.retrieve=retrieve
 
57
Configure.ConfigurationContext.sub_config=Configure.ConfigurationContext.recurse
 
58
Configure.ConfigurationContext.check_tool=Configure.ConfigurationContext.load
 
59
Configure.conftest=Configure.conf
 
60
Configure.ConfigurationError=Errors.ConfigurationError
 
61
Options.OptionsContext.sub_options=Options.OptionsContext.recurse
 
62
Options.OptionsContext.tool_options=Context.Context.load
 
63
Options.Handler=Options.OptionsContext
 
64
Task.simple_task_type=Task.task_type_from_func=Task.task_factory
 
65
Task.TaskBase.classes=Task.classes
 
66
def setitem(self,key,value):
 
67
        if key.startswith('CCFLAGS'):
 
68
                key=key[1:]
 
69
        self.table[key]=value
 
70
ConfigSet.ConfigSet.__setitem__=setitem
 
71
def old_importpaths(self):
 
72
        if getattr(self,'importpaths',[]):
 
73
                self.includes=self.importpaths
 
74
from waflib import Context
 
75
eld=Context.load_tool
 
76
def load_tool(*k,**kw):
 
77
        ret=eld(*k,**kw)
 
78
        if'set_options'in ret.__dict__:
 
79
                Logs.warn('compat: rename "set_options" to options')
 
80
                ret.options=ret.set_options
 
81
        if'detect'in ret.__dict__:
 
82
                Logs.warn('compat: rename "detect" to "configure"')
 
83
                ret.configure=ret.detect
 
84
        return ret
 
85
Context.load_tool=load_tool
 
86
rev=Context.load_module
 
87
def load_module(path):
 
88
        ret=rev(path)
 
89
        if'set_options'in ret.__dict__:
 
90
                Logs.warn('compat: rename "set_options" to "options" (%r)'%path)
 
91
                ret.options=ret.set_options
 
92
        if'srcdir'in ret.__dict__:
 
93
                Logs.warn('compat: rename "srcdir" to "top" (%r)'%path)
 
94
                ret.top=ret.srcdir
 
95
        if'blddir'in ret.__dict__:
 
96
                Logs.warn('compat: rename "blddir" to "out" (%r)'%path)
 
97
                ret.out=ret.blddir
 
98
        return ret
 
99
Context.load_module=load_module
 
100
old_post=TaskGen.task_gen.post
 
101
def post(self):
 
102
        self.features=self.to_list(self.features)
 
103
        if'cc'in self.features:
 
104
                Logs.warn('compat: the feature cc does not exist anymore (use "c")')
 
105
                self.features.remove('cc')
 
106
                self.features.append('c')
 
107
        if'cstaticlib'in self.features:
 
108
                Logs.warn('compat: the feature cstaticlib does not exist anymore (use "cstlib" or "cxxstlib")')
 
109
                self.features.remove('cstaticlib')
 
110
                self.features.append(('cxx'in self.features)and'cxxstlib'or'cstlib')
 
111
        if getattr(self,'ccflags',None):
 
112
                Logs.warn('compat: "ccflags" was renamed to "cflags"')
 
113
                self.cflags=self.ccflags
 
114
        return old_post(self)
 
115
TaskGen.task_gen.post=post
 
116
def waf_version(*k,**kw):
 
117
        Logs.warn('wrong version (waf_version was removed in waf 1.6)')
 
118
Utils.waf_version=waf_version
 
119
import os
 
120
def apply_uselib_local(self):
 
121
        env=self.env
 
122
        from waflib.Tools.ccroot import stlink_task
 
123
        self.uselib=self.to_list(getattr(self,'uselib',[]))
 
124
        self.includes=self.to_list(getattr(self,'includes',[]))
 
125
        names=self.to_list(getattr(self,'uselib_local',[]))
 
126
        get=self.bld.get_tgen_by_name
 
127
        seen=set([])
 
128
        tmp=Utils.deque(names)
 
129
        if tmp:
 
130
                Logs.warn('"uselib_local" is deprecated, replace by "use"')
 
131
        while tmp:
 
132
                lib_name=tmp.popleft()
 
133
                if lib_name in seen:
 
134
                        continue
 
135
                y=get(lib_name)
 
136
                y.post()
 
137
                seen.add(lib_name)
 
138
                if getattr(y,'uselib_local',None):
 
139
                        for x in self.to_list(getattr(y,'uselib_local',[])):
 
140
                                obj=get(x)
 
141
                                obj.post()
 
142
                                if getattr(obj,'link_task',None):
 
143
                                        if not isinstance(obj.link_task,stlink_task):
 
144
                                                tmp.append(x)
 
145
                if getattr(y,'link_task',None):
 
146
                        link_name=y.target[y.target.rfind(os.sep)+1:]
 
147
                        if isinstance(y.link_task,stlink_task):
 
148
                                env.append_value('STLIB',[link_name])
 
149
                        else:
 
150
                                env.append_value('LIB',[link_name])
 
151
                        self.link_task.set_run_after(y.link_task)
 
152
                        self.link_task.dep_nodes+=y.link_task.outputs
 
153
                        tmp_path=y.link_task.outputs[0].parent.bldpath()
 
154
                        if not tmp_path in env['LIBPATH']:
 
155
                                env.prepend_value('LIBPATH',[tmp_path])
 
156
                for v in self.to_list(getattr(y,'uselib',[])):
 
157
                        if not env['STLIB_'+v]:
 
158
                                if not v in self.uselib:
 
159
                                        self.uselib.insert(0,v)
 
160
                if getattr(y,'export_includes',None):
 
161
                        self.includes.extend(y.to_incnodes(y.export_includes))
 
162
def apply_objdeps(self):
 
163
        names=getattr(self,'add_objects',[])
 
164
        if not names:
 
165
                return
 
166
        names=self.to_list(names)
 
167
        get=self.bld.get_tgen_by_name
 
168
        seen=[]
 
169
        while names:
 
170
                x=names[0]
 
171
                if x in seen:
 
172
                        names=names[1:]
 
173
                        continue
 
174
                y=get(x)
 
175
                if getattr(y,'add_objects',None):
 
176
                        added=0
 
177
                        lst=y.to_list(y.add_objects)
 
178
                        lst.reverse()
 
179
                        for u in lst:
 
180
                                if u in seen:continue
 
181
                                added=1
 
182
                                names=[u]+names
 
183
                        if added:continue
 
184
                y.post()
 
185
                seen.append(x)
 
186
                for t in getattr(y,'compiled_tasks',[]):
 
187
                        self.link_task.inputs.extend(t.outputs)
 
188
def process_obj_files(self):
 
189
        if not hasattr(self,'obj_files'):
 
190
                return
 
191
        for x in self.obj_files:
 
192
                node=self.path.find_resource(x)
 
193
                self.link_task.inputs.append(node)
 
194
def add_obj_file(self,file):
 
195
        if not hasattr(self,'obj_files'):self.obj_files=[]
 
196
        if not'process_obj_files'in self.meths:self.meths.append('process_obj_files')
 
197
        self.obj_files.append(file)
 
198
old_define=Configure.ConfigurationContext.__dict__['define']
 
199
def define(self,key,val,quote=True):
 
200
        old_define(self,key,val,quote)
 
201
        if key.startswith('HAVE_'):
 
202
                self.env[key]=1
 
203
old_undefine=Configure.ConfigurationContext.__dict__['undefine']
 
204
def undefine(self,key):
 
205
        old_undefine(self,key)
 
206
        if key.startswith('HAVE_'):
 
207
                self.env[key]=0
 
208
def set_incdirs(self,val):
 
209
        Logs.warn('compat: change "export_incdirs" by "export_includes"')
 
210
        self.export_includes=val
 
211
TaskGen.task_gen.export_incdirs=property(None,set_incdirs)
 
212
 
 
213
TaskGen.feature('d')(old_importpaths)
 
214
TaskGen.before('apply_incpaths')(old_importpaths)
 
215
TaskGen.feature('c','cxx','d')(apply_uselib_local)
 
216
TaskGen.before('apply_incpaths','propagate_uselib_vars')(apply_uselib_local)
 
217
TaskGen.after('apply_link','process_source')(apply_uselib_local)
 
218
TaskGen.feature('cprogram','cxxprogram','cstlib','cxxstlib','cshlib','cxxshlib','dprogram','dstlib','dshlib')(apply_objdeps)
 
219
TaskGen.after('apply_link')(apply_objdeps)
 
220
TaskGen.after('apply_link')(process_obj_files)
 
221
TaskGen.taskgen_method(add_obj_file)
 
222
Configure.conf(define)
 
223
Configure.conf(undefine)
 
 
b'\\ No newline at end of file'