Make a status test pass against old servers.
[svn.git] / build / generator / gen_msvc_dsp.py
blob51976267756f2df4095fd06b05170c88513a9abf
2 # gen_dsp.py -- generate Microsoft Visual C++ 6 projects
5 import os
6 import sys
7 import string
9 import gen_base
10 import gen_win
11 import ezt
14 class Generator(gen_win.WinGeneratorBase):
15 "Generate a Microsoft Visual C++ 6 project"
17 def __init__(self, fname, verfname, options):
18 gen_win.WinGeneratorBase.__init__(self, fname, verfname, options,
19 'msvc-dsp')
21 def quote(self, str):
22 return '"%s"' % str
24 def write_project(self, target, fname):
25 "Write a Project (.dsp)"
27 if isinstance(target, gen_base.TargetExe):
28 targtype = "Win32 (x86) Console Application"
29 targval = "0x0103"
30 elif isinstance(target, gen_base.TargetJava):
31 targtype = "Win32 (x86) Generic Project"
32 targval = "0x010a"
33 elif isinstance(target, gen_base.TargetLib):
34 if target.msvc_static:
35 targtype = "Win32 (x86) Static Library"
36 targval = "0x0104"
37 else:
38 targtype = "Win32 (x86) Dynamic-Link Library"
39 targval = "0x0102"
40 elif isinstance(target, gen_base.TargetProject):
41 if target.cmd:
42 targtype = "Win32 (x86) External Target"
43 targval = "0x0106"
44 else:
45 targtype = "Win32 (x86) Generic Project"
46 targval = "0x010a"
47 else:
48 raise gen_base.GenError("Cannot create project for %s" % target.name)
50 target.output_name = self.get_output_name(target)
51 target.output_dir = self.get_output_dir(target)
52 target.intermediate_dir = self.get_intermediate_dir(target)
53 target.output_pdb = self.get_output_pdb(target)
55 configs = self.get_configs(target)
57 sources = self.get_proj_sources(True, target)
59 data = {
60 'target' : target,
61 'target_type' : targtype,
62 'target_number' : targval,
63 'rootpath' : self.rootpath,
64 'platforms' : self.platforms,
65 'configs' : configs,
66 'includes' : self.get_win_includes(target),
67 'sources' : sources,
68 'default_platform' : self.platforms[0],
69 'default_config' : configs[0].name,
70 'is_exe' : ezt.boolean(isinstance(target, gen_base.TargetExe)),
71 'is_external' : ezt.boolean((isinstance(target, gen_base.TargetProject)
72 or isinstance(target, gen_base.TargetI18N))
73 and target.cmd),
74 'is_utility' : ezt.boolean(isinstance(target,
75 gen_base.TargetProject)),
76 'is_dll' : ezt.boolean(isinstance(target, gen_base.TargetLib)
77 and not target.msvc_static),
78 'instrument_apr_pools' : self.instrument_apr_pools,
79 'instrument_purify_quantify' : self.instrument_purify_quantify,
82 self.write_with_template(fname, 'msvc_dsp.ezt', data)
84 def write(self):
85 "Write a Workspace (.dsw)"
87 self.write_zlib_project_file('zlib.dsp')
88 self.write_neon_project_file('neon.dsp')
89 self.write_serf_project_file('serf.dsp')
90 install_targets = self.get_install_targets()
92 targets = [ ]
94 self.gen_proj_names(install_targets)
96 # Traverse the targets and generate the project files
97 for target in install_targets:
98 name = target.name
99 fname = self.get_external_project(target, 'dsp')
100 if fname is None:
101 fname = os.path.join(self.projfilesdir,
102 "%s_msvc.dsp" % target.proj_name)
103 self.write_project(target, fname)
105 if '-' in fname:
106 fname = '"%s"' % fname
108 depends = [ ]
109 if not isinstance(target, gen_base.TargetI18N):
110 depends = self.adjust_win_depends(target, name)
111 #print name
112 #for dep in depends:
113 # print " ",dep.name
115 dep_names = [ ]
116 for dep in depends:
117 dep_names.append(dep.proj_name)
119 targets.append(
120 gen_win.ProjectItem(name=target.proj_name,
121 dsp=string.replace(fname, os.sep, '\\'),
122 depends=dep_names))
124 targets.sort(lambda x, y: cmp(x.name, y.name))
125 data = {
126 'targets' : targets,
129 self.write_with_template('subversion_msvc.dsw', 'msvc_dsw.ezt', data)
132 # compatibility with older Pythons:
133 try:
134 True
135 except NameError:
136 True = 1
137 False = 0