Windows native build fixes.

The testing of building on Windows is done using MSYS2.
This commit is contained in:
Chris Johns 2015-02-07 17:58:17 +11:00
parent 81ccf41bc0
commit d4eb08f55a
8 changed files with 37 additions and 16 deletions

View File

@ -190,10 +190,11 @@ BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
%{__rmfile} $SB_BUILD_ROOT%{_mandir}/man3/*ffi*
# Clean the symlinks away incase the source is a repo
%{__rmfile} ${source_dir_gcc}/newlib
%{__rmfile} ${source_dir_gcc}/mpfr
%{__rmfile} ${source_dir_gcc}/mpc
%{__rmfile} ${source_dir_gcc}/gmp
# Note, delete as a directory because of MSYS2 support on Windows.
%{__rmdir} ${source_dir_gcc}/newlib
%{__rmdir} ${source_dir_gcc}/mpfr
%{__rmdir} ${source_dir_gcc}/mpc
%{__rmdir} ${source_dir_gcc}/gmp
%testing
# Add testing here.

View File

@ -227,7 +227,6 @@ class build:
raise error.general('setup source tag not found: %d' % (source_tag))
else:
name = opt_name
name = self._name_(name)
self.script.append(self.config.expand('cd %{_builddir}'))
if not deleted_dir and delete_before_unpack:
self.script.append(self.config.expand('%{__rm} -rf ' + name))

View File

@ -104,7 +104,7 @@ def path_check(opts, silent = False):
if not silent:
log.notice('error: environment PATH contains an empty path')
return False
elif p.strip() == '.' or p.strip() == '..':
elif not options.host_windows and (p.strip() == '.' or p.strip() == '..'):
if not silent:
log.notice('error: environment PATH invalid path: %s' % (p))
return False

View File

@ -69,7 +69,7 @@ def _hash_check(file_, absfile, macros, remove = True):
_in = None
try:
hasher = hashlib.new(hash[0])
_in = open(absfile, 'rb')
_in = open(path.host(absfile), 'rb')
hasher.update(_in.read())
except IOError, err:
log.notice('hash: %s: read error: %s' % (file_, str(err)))
@ -90,7 +90,12 @@ def _hash_check(file_, absfile, macros, remove = True):
if failed and remove:
log.warning('removing: %s' % (file_))
if path.exists(absfile):
os.remove(path.host(absfile))
try:
os.remove(path.host(absfile))
except IOError, err:
raise error.general('hash: %s: remove: %s' % (absfile, str(err)))
except:
raise error.general('hash: %s: remove error' % (file_))
if hasher is not None:
del hasher
else:

View File

@ -36,7 +36,10 @@ def generate(name, opts, header = None, footer = None):
opts.defaults.get_value('%{_sbgit_id}'))]
else:
r += [' RSB: not a valid repo']
r += [' %s' % (' '.join(os.uname()))]
if os.name == 'nt':
r += [' Windows']
else:
r += [' %s' % (' '.join(os.uname()))]
r += []
r += ['Tail of the build log:']
r += log.tail()

View File

@ -74,6 +74,7 @@ def notice(text = os.linesep, log = None):
if not quiet and default is not None and not default.has_stdout():
for l in text.replace(chr(13), '').splitlines():
print l
sys.stdout.flush()
_output(text, log)
def trace(text = os.linesep, log = None):

View File

@ -127,7 +127,14 @@ def mkdir(path):
def removeall(path):
def _onerror(function, path, excinfo):
print 'removeall error: (%s) %s' % (excinfo, path)
import stat
if not os.access(path, os.W_OK):
# Is the error an access error ?
os.chmod(path, stat.S_IWUSR)
function(path)
else:
print 'removeall error: %s' % (path)
raise
path = host(path)
shutil.rmtree(path, onerror = _onerror)

View File

@ -30,13 +30,18 @@ import execute
def load():
# Default to the native Windows Python.
uname = 'win32'
system = 'mingw32'
if os.environ.has_key('HOSTTYPE'):
hosttype = os.environ['HOSTTYPE']
if os.environ.has_key('PROCESSOR_ARCHITECTURE'):
if os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64':
hosttype = 'x86_64'
machsize = '64'
else:
hosttype = 'i686'
machsize = '32'
else:
hosttype = 'i686'
host_triple = hosttype + '-pc-' + system
build_triple = hosttype + '-pc-' + system
hosttype = 'x86_64'
machsize = '32'
host_triple = '%s-w%s-mingw32' % (hosttype, machsize)
build_triple = '%s-w%s-mingw32' % (hosttype, machsize)
# See if this is actually Cygwin Python
if os.name == 'posix':