2
# gen_vcnet.py -- generate Microsoft Visual C++.NET projects
14
class Generator(gen_win.WinGeneratorBase):
15
"Generate a Visual C++.NET project"
17
def __init__(self, fname, verfname, options):
18
gen_win.WinGeneratorBase.__init__(self, fname, verfname, options,
22
return '"%s"' % str
24
def write_project(self, target, fname):
25
"Write a Project (.vcproj)"
27
if isinstance(target, gen_base.TargetExe):
30
elif isinstance(target, gen_base.TargetJava):
32
elif isinstance(target, gen_base.TargetLib):
33
if target.msvc_static:
37
elif isinstance(target, gen_base.TargetProject):
39
elif isinstance(target, gen_base.TargetI18N):
42
raise gen_base.GenError("Cannot create project for %s" % target.name)
44
target.output_name = self.get_output_name(target)
45
target.output_dir = self.get_output_dir(target)
46
target.intermediate_dir = self.get_intermediate_dir(target)
48
configs = self.get_configs(target)
50
sources = self.get_proj_sources(False, target)
54
'target_type' : config_type,
55
# 'target_number' : targval,
56
'rootpath' : self.rootpath,
57
'platforms' : self.platforms,
59
'includes' : self.get_win_includes(target),
61
'default_platform' : self.platforms[0],
62
'default_config' : configs[0].name,
63
'def_file' : self.get_def_file(target),
64
'is_exe' : ezt.boolean(isinstance(target, gen_base.TargetExe)),
65
'is_external' : ezt.boolean((isinstance(target, gen_base.TargetProject)
66
or isinstance(target, gen_base.TargetI18N))
68
'is_utility' : ezt.boolean(isinstance(target,
69
gen_base.TargetProject)),
70
'instrument_apr_pools' : self.instrument_apr_pools,
71
'instrument_purify_quantify' : self.instrument_purify_quantify,
72
'version' : self.vsnet_proj_ver,
75
self.write_with_template(fname, 'vcnet_vcproj.ezt', data)
77
def makeguid(self, data):
78
"Generate a windows style GUID"
79
### blah. this function can generate invalid GUIDs. leave it for now,
80
### but we need to fix it. we can wrap the apr UUID functions, or
81
### implement this from scratch using the algorithms described in
82
### http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt
86
myhash = hash.hexdigest()
87
except AttributeError:
89
myhash = string.join(map(lambda x: '%02x' % ord(x), hash.digest()), '')
91
guid = string.upper("{%s-%s-%s-%s-%s}" % (myhash[0:8], myhash[8:12],
92
myhash[12:16], myhash[16:20],
97
"Write a Solution (.sln)"
99
# apr doesn't supply vcproj files, so move our pre-defined ones
100
# over if they don't match
101
self.move_proj_file(self.apr_path, 'libapr.vcproj')
102
self.move_proj_file(self.apr_iconv_path, 'libapriconv.vcproj')
103
self.move_proj_file(os.path.join(self.apr_iconv_path,'ccs'),
104
'libapriconv_ccs_modules.vcproj')
105
self.move_proj_file(os.path.join(self.apr_iconv_path,'ces'),
106
'libapriconv_ces_modules.vcproj')
107
self.move_proj_file(self.apr_util_path, 'libaprutil.vcproj')
108
self.move_proj_file(os.path.join(self.apr_util_path,'uri'),
109
'gen_uri_delims.vcproj')
110
self.move_proj_file(os.path.join(self.apr_util_path,'xml', 'expat',
111
'lib'), 'xml.vcproj')
112
self.move_proj_file(os.path.join('build', 'win32'), 'svn_config.vcproj')
113
self.move_proj_file(os.path.join('build', 'win32'), 'svn_locale.vcproj')
114
self.write_zlib_project_file('zlib.vcproj')
115
self.write_neon_project_file('neon.vcproj')
117
install_targets = self.get_install_targets()
123
# VC.NET uses GUIDs to refer to projects. generate them up front
124
# because we need them already assigned on the dependencies for
125
# each target we work with.
126
for target in install_targets:
127
# These aren't working yet
128
if isinstance(target, gen_base.TargetProject) and target.cmd:
130
guids[target.name] = self.makeguid(target.name)
132
self.gen_proj_names(install_targets)
134
# Traverse the targets and generate the project files
135
for target in install_targets:
137
# These aren't working yet
138
if isinstance(target, gen_base.TargetProject) and target.cmd:
141
fname = self.get_external_project(target, 'vcproj')
143
fname = os.path.join(self.projfilesdir,
144
"%s_vcnet.vcproj" % target.proj_name)
145
self.write_project(target, fname)
148
fname = '"%s"' % fname
151
if not isinstance(target, gen_base.TargetI18N):
152
depends = self.adjust_win_depends(target, name)
155
for i in range(len(depends)):
156
deplist.append(gen_win.ProjectItem(guid=guids[depends[i].name],
160
gen_win.ProjectItem(name=target.name,
161
path=string.replace(fname, os.sep, '\\'),
162
guid=guids[target.name],
166
targets.sort(lambda x, y: cmp(x.name, y.name))
169
for i in range(len(self.configs)):
170
### this is different from write_project
171
configs.append(gen_win.ProjectItem(name=self.configs[i], index=i))
173
# sort the values for output stability.
174
guidvals = guids.values()
178
'version': self.vsnet_version,
181
'platforms' : self.platforms,
185
self.write_with_template('subversion_vcnet.sln', 'vcnet_sln.ezt', data)
188
# compatibility with older Pythons: