Alien-SVN
view release on metacpan or search on metacpan
src/subversion/build/generator/gen_win.py view on Meta::CPAN
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#
# gen_win.py -- base class for generating windows projects
#
import os
try:
# Python >=2.5
from hashlib import md5 as hashlib_md5
except ImportError:
# Python <2.5
from md5 import md5 as hashlib_md5
import sys
import fnmatch
import re
import subprocess
import glob
import string
import generator.swig.header_wrappers
import generator.swig.checkout_swig_header
import generator.swig.external_runtime
if sys.version_info[0] >= 3:
# Python >=3.0
from io import StringIO
else:
# Python <3.0
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
import gen_base
import ezt
class GeneratorBase(gen_base.GeneratorBase):
"""This intermediate base class exists to be instantiated by win-tests.py,
in order to obtain information from build.conf and library paths without
actually doing any generation."""
_extension_map = {
('exe', 'target'): '.exe',
('exe', 'object'): '.obj',
('lib', 'target'): '.dll',
('lib', 'object'): '.obj',
('pyd', 'target'): '.pyd',
('pyd', 'object'): '.obj',
}
def parse_options(self, options):
self.apr_path = 'apr'
self.apr_util_path = 'apr-util'
self.apr_iconv_path = 'apr-iconv'
self.serf_path = None
self.serf_lib = None
self.bdb_path = 'db4-win32'
self.httpd_path = None
self.libintl_path = None
self.zlib_path = 'zlib'
self.openssl_path = None
self.jdk_path = None
self.junit_path = None
self.swig_path = None
self.vs_version = '2002'
self.sln_version = '7.00'
self.vcproj_version = '7.00'
self.vcproj_extension = '.vcproj'
self.sqlite_path = 'sqlite-amalgamation'
self.skip_sections = { 'mod_dav_svn': None,
'mod_authz_svn': None,
'mod_dontdothat' : None,
'libsvn_auth_kwallet': None,
'libsvn_auth_gnome_keyring': None }
# Instrumentation options
self.disable_shared = None
self.static_apr = None
src/subversion/build/generator/gen_win.py view on Meta::CPAN
nondeplibs.append(self.aprutil_lib)
if dep.external_lib == '$(SVN_XML_LIBS)':
nondeplibs.append('xml.lib')
return gen_base.unique(nondeplibs)
def get_win_sources(self, target, reldir_prefix=''):
"Return the list of source files that need to be compliled for target"
sources = { }
for obj in self.graph.get_sources(gen_base.DT_LINK, target.name):
if isinstance(obj, gen_base.Target):
continue
for src in self.graph.get_sources(gen_base.DT_OBJECT, obj):
if isinstance(src, gen_base.SourceFile):
if reldir_prefix:
if src.reldir:
reldir = reldir_prefix + '\\' + src.reldir
else:
reldir = reldir_prefix
else:
reldir = src.reldir
else:
reldir = ''
sources[src] = src, obj, reldir
return list(sources.values())
def write_file_if_changed(self, fname, new_contents):
"""Rewrite the file if new_contents are different than its current content.
If you have your windows projects open and generate the projects
it's not a small thing for windows to re-read all projects so
only update those that have changed.
"""
try:
old_contents = open(fname, 'rb').read()
except IOError:
old_contents = None
if old_contents != new_contents:
open(fname, 'wb').write(new_contents)
print("Wrote: %s" % fname)
def write_with_template(self, fname, tname, data):
fout = StringIO()
template = ezt.Template(compress_whitespace = 0)
template.parse_file(os.path.join('build', 'generator', tname))
template.generate(fout, data)
self.write_file_if_changed(fname, fout.getvalue())
def write_zlib_project_file(self, name):
if not self.zlib_path:
return
zlib_path = os.path.abspath(self.zlib_path)
zlib_sources = map(lambda x : os.path.relpath(x, self.projfilesdir),
glob.glob(os.path.join(zlib_path, '*.c')) +
glob.glob(os.path.join(zlib_path,
'contrib/masmx86/*.c')) +
glob.glob(os.path.join(zlib_path,
'contrib/masmx86/*.asm')))
zlib_headers = map(lambda x : os.path.relpath(x, self.projfilesdir),
glob.glob(os.path.join(zlib_path, '*.h')))
self.move_proj_file(self.projfilesdir, name,
(('zlib_path', os.path.relpath(zlib_path,
self.projfilesdir)),
('zlib_sources', zlib_sources),
('zlib_headers', zlib_headers),
('zlib_version', self.zlib_version),
('project_guid', self.makeguid('zlib')),
('use_ml', self.have_ml and 1 or None),
))
def write_serf_project_file(self, name):
if not self.serf_lib:
return
serf_path = os.path.abspath(self.serf_path)
serf_sources = map(lambda x : os.path.relpath(x, self.serf_path),
glob.glob(os.path.join(serf_path, '*.c'))
+ glob.glob(os.path.join(serf_path, 'auth', '*.c'))
+ glob.glob(os.path.join(serf_path, 'buckets',
'*.c')))
serf_headers = map(lambda x : os.path.relpath(x, self.serf_path),
glob.glob(os.path.join(serf_path, '*.h'))
+ glob.glob(os.path.join(serf_path, 'auth', '*.h'))
+ glob.glob(os.path.join(serf_path, 'buckets', '*.h')))
if self.serf_ver_maj != 0:
serflib = 'serf-%d.lib' % self.serf_ver_maj
else:
serflib = 'serf.lib'
apr_static = self.static_apr and 'APR_STATIC=1' or ''
openssl_static = self.static_openssl and 'OPENSSL_STATIC=1' or ''
self.move_proj_file(self.serf_path, name,
(('serf_sources', serf_sources),
('serf_headers', serf_headers),
('zlib_path', os.path.relpath(self.zlib_path,
self.serf_path)),
('openssl_path', os.path.relpath(self.openssl_path,
self.serf_path)),
('apr_path', os.path.relpath(self.apr_path,
self.serf_path)),
('apr_util_path', os.path.relpath(self.apr_util_path,
self.serf_path)),
('project_guid', self.makeguid('serf')),
('apr_static', apr_static),
('openssl_static', openssl_static),
('serf_lib', serflib),
))
def move_proj_file(self, path, name, params=()):
### Move our slightly templatized pre-built project files into place --
### these projects include zlib, serf, locale, config, etc.
dest_file = os.path.join(path, name)
source_template = os.path.join('templates', name + '.ezt')
data = {
'version' : self.vcproj_version,
'configs' : self.configs,
'platforms' : self.platforms,
'toolset_version' : 'v' + self.vcproj_version.replace('.',''),
}
for key, val in params:
data[key] = val
self.write_with_template(dest_file, source_template, data)
def write(self):
"Override me when creating a new project type"
raise NotImplementedError
def _find_perl(self):
"Find the right perl library name to link swig bindings with"
self.perl_includes = []
self.perl_libdir = None
fp = os.popen('perl -MConfig -e ' + escape_shell_arg(
'print "$Config{PERL_REVISION}$Config{PERL_VERSION}"'), 'r')
try:
line = fp.readline()
if line:
msg = 'Found installed perl version number.'
self.perl_lib = 'perl' + line.rstrip() + '.lib'
else:
msg = 'Could not detect perl version.'
self.perl_lib = 'perl56.lib'
print('%s\n Perl bindings will be linked with %s\n'
( run in 0.450 second using v1.01-cache-2.11-cpan-97f6503c9c8 )