Alien-SVN
view release on metacpan or search on metacpan
src/subversion/build/generator/gen_win.py view on Meta::CPAN
# library name to link SWIG bindings with
self._find_ruby()
# Find the right Perl library name to link SWIG bindings with
self._find_perl()
# Find the right Python include and libraries dirs for SWIG bindings
self._find_python()
# Find the installed SWIG version to adjust swig options
self._find_swig()
# Find the installed Java Development Kit
self._find_jdk()
# Find APR and APR-util version
self._find_apr()
self._find_apr_util()
# Find Sqlite
self._find_sqlite()
# Look for ZLib and ML
if self.zlib_path:
self._find_zlib()
self._find_ml()
# Find serf and its dependencies
if self.serf_path:
self._find_serf()
#Make some files for the installer so that we don't need to
#require sed or some other command to do it
### GJS: don't do this right now
if 0:
buf = open(os.path.join("packages","win32-innosetup","svn.iss.in"), 'rb').read()
buf = buf.replace("@VERSION@", "0.16.1+").replace("@RELEASE@", "4365")
buf = buf.replace("@DBBINDLL@", self.dbbindll)
svnissrel = os.path.join("packages","win32-innosetup","svn.iss.release")
svnissdeb = os.path.join("packages","win32-innosetup","svn.iss.debug")
if self.write_file_if_changed(svnissrel, buf.replace("@CONFIG@", "Release")):
print('Wrote %s' % svnissrel)
if self.write_file_if_changed(svnissdeb, buf.replace("@CONFIG@", "Debug")):
print('Wrote %s' % svnissdeb)
#Make the project files directory if it doesn't exist
#TODO win32 might not be the best path as win64 stuff will go here too
self.projfilesdir=os.path.join("build","win32",subdir)
self.rootpath = self.find_rootpath()
if not os.path.exists(self.projfilesdir):
os.makedirs(self.projfilesdir)
# Generate the build_zlib.bat file
if self.zlib_path:
data = {'zlib_path': os.path.relpath(self.zlib_path, self.projfilesdir),
'zlib_version': self.zlib_version,
'use_ml': self.have_ml and 1 or None}
bat = os.path.join(self.projfilesdir, 'build_zlib.bat')
self.write_with_template(bat, 'templates/build_zlib.ezt', data)
# Generate the build_locale.bat file
pofiles = []
if self.enable_nls:
for po in os.listdir(os.path.join('subversion', 'po')):
if fnmatch.fnmatch(po, '*.po'):
pofiles.append(POFile(po[:-3]))
data = {'pofiles': pofiles}
self.write_with_template(os.path.join(self.projfilesdir,
'build_locale.bat'),
'templates/build_locale.ezt', data)
#Here we can add additional platforms to compile for
self.platforms = ['Win32']
# VC 2002 and VC 2003 only allow a single platform per project file
if subdir == 'vcnet-vcproj':
if self.vcproj_version != '7.00' and self.vcproj_version != '7.10':
self.platforms = ['Win32','x64']
#Here we can add additional modes to compile for
self.configs = ['Debug','Release']
if self.swig_libdir:
# Generate SWIG header wrappers and external runtime
for swig in (generator.swig.header_wrappers,
generator.swig.checkout_swig_header,
generator.swig.external_runtime):
swig.Generator(self.conf, self.swig_exe).write()
else:
print("%s not found; skipping SWIG file generation..." % self.swig_exe)
def find_rootpath(self):
"Gets the root path as understand by the project system"
return os.path.relpath('.', self.projfilesdir) + "\\"
def makeguid(self, data):
"Generate a windows style GUID"
### blah. this function can generate invalid GUIDs. leave it for now,
### but we need to fix it. we can wrap the apr UUID functions, or
### implement this from scratch using the algorithms described in
### http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt
myhash = hashlib_md5(data).hexdigest()
guid = ("{%s-%s-%s-%s-%s}" % (myhash[0:8], myhash[8:12],
myhash[12:16], myhash[16:20],
myhash[20:32])).upper()
return guid
def path(self, *paths):
"""Convert build path to msvc path and prepend root"""
return self.rootpath + msvc_path_join(*list(map(msvc_path, paths)))
def apath(self, path, *paths):
"""Convert build path to msvc path and prepend root if not absolute"""
### On Unix, os.path.isabs won't do the right thing if "item"
### contains backslashes or drive letters
if os.path.isabs(path):
return msvc_path_join(msvc_path(path), *list(map(msvc_path, paths)))
else:
return self.rootpath + msvc_path_join(msvc_path(path),
*list(map(msvc_path, paths)))
def get_install_targets(self):
"Generate the list of targets"
# Get list of targets to generate project files for
install_targets = self.graph.get_all_sources(gen_base.DT_INSTALL) \
+ self.projects
src/subversion/build/generator/gen_win.py view on Meta::CPAN
def get_intermediate_dir(self, target):
if isinstance(target, gen_base.TargetSWIG):
return msvc_path_join(msvc_path(target.path), target.name)
else:
return self.get_output_dir(target)
def get_def_file(self, target):
if isinstance(target, gen_base.TargetLib) and target.msvc_export \
and not self.disable_shared:
return target.name + ".def"
return None
def gen_proj_names(self, install_targets):
"Generate project file names for the targets"
# Generate project file names for the targets: replace dashes with
# underscores and replace *-test with test_* (so that the test
# programs are visually separare from the rest of the projects)
for target in install_targets:
if target.msvc_name:
target.proj_name = target.msvc_name
continue
name = target.name
pos = name.find('-test')
if pos >= 0:
proj_name = 'test_' + name[:pos].replace('-', '_')
elif isinstance(target, gen_base.TargetSWIG):
proj_name = 'swig_' + name.replace('-', '_')
else:
proj_name = name.replace('-', '_')
target.proj_name = proj_name
def get_external_project(self, target, proj_ext):
if not ((isinstance(target, gen_base.TargetLinked)
or isinstance(target, gen_base.TargetI18N))
and target.external_project):
return None
if target.external_project[:5] == 'serf/' and self.serf_lib:
path = self.serf_path + target.external_project[4:]
elif target.external_project.find('/') != -1:
path = target.external_project
else:
path = os.path.join(self.projfilesdir, target.external_project)
return "%s.%s" % (gen_base.native_path(path), proj_ext)
def adjust_win_depends(self, target, name):
"Handle special dependencies if needed"
if name == '__CONFIG__':
depends = []
else:
depends = self.sections['__CONFIG__'].get_dep_targets(target)
depends.extend(self.get_win_depends(target, FILTER_PROJECTS))
# Make the default target generate the .mo files, too
if self.enable_nls and name == '__ALL__':
depends.extend(self.sections['locale'].get_targets())
# Build ZLib as a dependency of Serf if we have it
if self.zlib_path and name == 'serf':
depends.extend(self.sections['zlib'].get_targets())
# To set the correct build order of the JavaHL targets, the javahl-javah
# and libsvnjavahl targets are defined with extra dependencies in build.conf
# like this:
# add-deps = $(javahl_javah_DEPS) $(javahl_java_DEPS)
#
# This section parses those dependencies and adds them to the dependency list
# for this target.
if name.startswith('javahl') or name == 'libsvnjavahl':
for dep in re.findall('\$\(([^\)]*)_DEPS\)', target.add_deps):
dep = dep.replace('_', '-')
depends.extend(self.sections[dep].get_targets())
return depends
def get_win_depends(self, target, mode):
"""Return the list of dependencies for target"""
dep_dict = {}
if isinstance(target, gen_base.TargetLib) and target.msvc_static:
self.get_static_win_depends(target, dep_dict)
else:
self.get_linked_win_depends(target, dep_dict)
deps = []
if mode == FILTER_PROJECTS:
for dep, (is_proj, is_lib, is_static) in dep_dict.items():
if is_proj:
deps.append(dep)
elif mode == FILTER_LIBS:
for dep, (is_proj, is_lib, is_static) in dep_dict.items():
if is_static or (is_lib and not is_proj):
deps.append(dep)
else:
raise NotImplementedError
deps.sort(key = lambda d: d.name)
return deps
def get_direct_depends(self, target):
"""Read target dependencies from graph
return value is list of (dependency, (is_project, is_lib, is_static)) tuples
"""
deps = []
for dep in self.graph.get_sources(gen_base.DT_LINK, target.name):
if not isinstance(dep, gen_base.Target):
continue
is_project = hasattr(dep, 'proj_name')
is_lib = isinstance(dep, gen_base.TargetLib)
is_static = is_lib and dep.msvc_static
deps.append((dep, (is_project, is_lib, is_static)))
src/subversion/build/generator/gen_win.py view on Meta::CPAN
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'
% (msg, self.perl_lib))
finally:
fp.close()
fp = os.popen('perl -MConfig -e ' + escape_shell_arg(
'print $Config{archlib}'), 'r')
try:
line = fp.readline()
if line:
self.perl_libdir = os.path.join(line, 'CORE')
self.perl_includes = [os.path.join(line, 'CORE')]
finally:
fp.close()
def _find_ruby(self):
"Find the right Ruby library name to link swig bindings with"
self.ruby_includes = []
self.ruby_libdir = None
self.ruby_version = None
self.ruby_major_version = None
self.ruby_minor_version = None
# Pass -W0 to stifle the "-e:1: Use RbConfig instead of obsolete
# and deprecated Config." warning if we are using Ruby 1.9.
proc = os.popen('ruby -rrbconfig -W0 -e ' + escape_shell_arg(
"puts Config::CONFIG['ruby_version'];"
"puts Config::CONFIG['LIBRUBY'];"
"puts Config::CONFIG['archdir'];"
( run in 1.282 second using v1.01-cache-2.11-cpan-ceb78f64989 )