Fix support for Windows (MinGW) native builds using MSYS.

Fix paths that need to be coverted to host format.

The shell expansion needs to invoke a shell on Windows as cmd.exe
will not work.

Munch the paths into smaller sizes for Windows due to the limited
path size.
This commit is contained in:
Chris Johns 2013-05-13 14:44:49 +10:00
parent e2266055bc
commit 5237f1ccb7
7 changed files with 51 additions and 12 deletions

View File

@ -43,12 +43,16 @@ _bset: none, none, ''
name: none, none, ''
version: none, none, ''
release: none, none, ''
buildname: none, none, '%{name}'
# GNU triples needed to build packages
_host: triplet, required, ''
_build: triplet, required, '%{_host}'
_target: none, optional, ''
# The user
_uid: none, convert, '%(%{__id_u} -n)'
# Paths
_host_platform: none, none, '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}'
_arch: none, none, '%{_host_arch}'
@ -57,14 +61,14 @@ _configdir: dir, optional, '%{_topdir}/config:%{_sbdir}/config'
_tardir: dir, optional, '%{_topdir}/tar'
_sourcedir: dir, optional, '%{_topdir}/sources'
_patchdir: dir, optional, '%{_topdir}/patches:%{_sbdir}/patches'
_builddir: dir, optional, '%{_topdir}/build/%{name}-%{version}-%{release}'
_buildcxcdir: dir, optional, '%{_topdir}/build/%{name}-%{version}-%{release}-cxc'
_builddir: dir, optional, '%{_topdir}/build/%{buildname}'
_buildcxcdir: dir, optional, '%{_topdir}/build/%{buildname}-cxc'
_docdir: dir, none, '%{_defaultdocdir}'
_tmppath: dir, none, '%{_topdir}/build/tmp'
_tmproot: dir, none, '%{_tmppath}/source-build-%(%{__id_u} -n)/%{_bset}'
_tmpcxcroot: dir, none, '%{_tmppath}/source-build-%(%{__id_u} -n)-cxc/%{_bset}'
buildroot: dir, none, '%{_tmppath}/%{name}-root-%(%{__id_u} -n)'
buildcxcroot: dir, none, '%{_tmppath}/%{name}-root-%(%{__id_u} -n)-cxc'
_tmproot: dir, none, '%{_tmppath}/sb-%{_uid}/%{_bset}'
_tmpcxcroot: dir, none, '%{_tmppath}/sb-%{_uid}-cxc/%{_bset}'
buildroot: dir, none, '%{_tmppath}/%{buildname}-%{_uid}'
buildcxcroot: dir, none, '%{_tmppath}/%{buildname}-%{_uid}-cxc'
_datadir: dir, none, '%{_prefix}/share'
_defaultdocdir: dir, none, '%{_prefix}/share/doc'
_exeext: none, none, ''
@ -175,6 +179,7 @@ SB_DOC_DIR="%{_docdir}"
export SB_DOC_DIR
# Packages
SB_PACKAGE_NAME="%{name}"
SB_PACKAGE_BUILDNAME="%{buildname}"
SB_PACKAGE_VERSION="%{version}"
SB_PACKAGE_RELEASE="%{release}"
export SB_PACKAGE_NAME SB_PACKAGE_VERSION SB_PACKAGE_RELEASE

View File

@ -90,6 +90,23 @@ class script:
class build:
"""Build a package given a config file."""
def _name_(self, name):
#
# If on Windows use shorter names to keep the build paths.
#
if options.host_windows:
buildname = ''
add = True
for c in name:
if c == '-':
add = True
elif add:
buildname += c
add = False
return buildname
else:
return name
def __init__(self, name, create_tar_files, opts, macros = None):
self.opts = opts
if macros is None:
@ -100,6 +117,7 @@ class build:
log.notice('config: ' + name)
self.config = config.file(name, opts, self.macros)
self.script = script()
self.macros['buildname'] = self._name_(self.macros['name'])
def rmdir(self, rmpath):
log.output('removing: %s' % (path.host(rmpath)))
@ -214,6 +232,7 @@ class build:
name = source['name']
else:
raise error.general('setup source tag not found: %d' % (source_tag))
name = self._name_(name)
self.script.append(self.config.expand('cd %{_builddir}'))
if delete_before_unpack:
self.script.append(self.config.expand('%{__rm} -rf ' + name))

View File

@ -353,7 +353,11 @@ class file:
if len(sl):
e = execute.capture_execution()
for s in sl:
exit_code, proc, output = e.shell(s[2:-1])
if options.host_windows:
cmd = '%s -c "%s"' % (self.macros.expand('%{__sh}'), s[2:-1])
else:
cmd = s[2:-1]
exit_code, proc, output = e.shell(cmd)
if exit_code == 0:
line = line.replace(s, output)
else:

View File

@ -68,7 +68,7 @@ class repo:
raise error.general('cvs path needs to exist: %s' % (cwd))
cmd = [self.cvs, '-z', '9', '-q'] + args
log.output('cmd: (%s) %s' % (str(cwd), ' '.join(cmd)))
exit_code, proc, output = e.spawn(cmd, cwd = cwd)
exit_code, proc, output = e.spawn(cmd, cwd = path.host(cwd))
log.trace(output)
if check:
self._cvs_exit_code(cmd, exit_code, output)

View File

@ -44,7 +44,7 @@ class repo:
cwd = None
cmd = [self.git] + args
log.trace('cmd: (%s) %s' % (str(cwd), ' '.join(cmd)))
exit_code, proc, output = e.spawn(cmd, cwd = cwd)
exit_code, proc, output = e.spawn(cmd, cwd = path.host(cwd))
log.trace(output)
if check:
self._git_exit_code(exit_code)
@ -69,8 +69,8 @@ class repo:
raise error.general('invalid version number from git: %s' % (gvs[2]))
return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))
def clone(self, url, path):
ec, output = self._run(['clone', url, path], check = True)
def clone(self, url, _path):
ec, output = self._run(['clone', url, path.host(_path)], check = True)
def fetch(self):
ec, output = self._run(['fetch'], check = True)

View File

@ -145,8 +145,11 @@ class macros:
raise TypeError('bad value tuple value field: %s' % (type(value[2])))
if value[0] not in ['none', 'triplet', 'dir', 'file', 'exe']:
raise TypeError('bad value tuple (type field): %s' % (value[0]))
if value[1] not in ['none', 'optional', 'required', 'override', 'undefine']:
if value[1] not in ['none', 'optional', 'required',
'override', 'undefine', 'convert']:
raise TypeError('bad value tuple (attrib field): %s' % (value[1]))
if value[1] == 'convert':
value = self.expand(value)
self.macros[self.write_map][self.key_filter(key)] = value
def __delitem__(self, key):

View File

@ -37,6 +37,11 @@ import sys
basepath = 'sb'
#
# Save the host state.
#
host_windows = False
class command_line:
"""Process the command line in a common way for all Tool Builder commands."""
@ -460,6 +465,8 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc'):
command line.
"""
global host_windows
#
# The path to this command.
#
@ -482,6 +489,7 @@ def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc'):
try:
import windows
overrides = windows.load()
host_windows = True
except:
raise error.general('failed to load Windows host support')
elif os.name == 'posix':