Winrc processing is almost certainly broken...

This commit is contained in:
Thomas Nagy 2016-06-05 00:01:01 +02:00
parent 062a5263a0
commit 75b1423ce8
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
4 changed files with 19 additions and 56 deletions

View File

@ -289,7 +289,7 @@ class BuildContext(Context.Context):
dbfn = os.path.join(self.variant_dir, Context.DBFILE)
try:
data = Utils.readf(dbfn, 'rb')
except (IOError, EOFError):
except (EnvironmentError, EOFError):
# handle missing file/empty file
Logs.debug('build: Could not load the build cache %s (missing)', dbfn)
else:

View File

@ -700,7 +700,7 @@ class Task(TaskBase):
except Errors.TaskNotReady:
raise
except EnvironmentError:
# when a file was renamed (IOError usually), remove the stale nodes (headers in folders without source files)
# when a file was renamed, remove the stale nodes (headers in folders without source files)
# this will break the order calculation for headers created during the build in the source directory (should be uncommon)
# the behaviour will differ when top != out
for x in bld.node_deps.get(self.uid(), []):

View File

@ -28,7 +28,6 @@ A dumb preprocessor is also available in the tool *c_dumbpreproc*
import re, string, traceback
from waflib import Logs, Utils, Errors
from waflib.Logs import debug, error
class PreprocError(Errors.WafError):
pass
@ -908,14 +907,14 @@ class c_parser(object):
raise PreprocError('recursion limit exceeded')
if Logs.verbose:
debug('preproc: reading file %r', node)
Logs.debug('preproc: reading file %r', node)
try:
lines = self.parse_lines(node)
except EnvironmentError:
raise PreprocError('could not read the file %r' % node)
except Exception:
if Logs.verbose > 0:
error("parsing %r failed" % node)
Logs.error('parsing %r failed', node)
traceback.print_exc()
else:
self.lines.extend(lines)
@ -930,7 +929,7 @@ class c_parser(object):
:param env: config set containing additional defines to take into account
:type env: :py:class:`waflib.ConfigSet.ConfigSet`
"""
debug('preproc: scanning %s (in %s)', node.name, node.parent.name)
Logs.debug('preproc: scanning %s (in %s)', node.name, node.parent.name)
self.current_file = node
self.addlines(node)
@ -950,7 +949,7 @@ class c_parser(object):
try:
ve = Logs.verbose
if ve: debug('preproc: line is %s - %s state is %s', token, line, self.state)
if ve: Logs.debug('preproc: line is %s - %s state is %s', token, line, self.state)
state = self.state
# make certain we define the state if we are about to enter in an if block
@ -978,7 +977,7 @@ class c_parser(object):
else: state[-1] = accepted
elif token == 'include' or token == 'import':
(kind, inc) = extract_include(line, self.defs)
if ve: debug('preproc: include found %s (%s) ', inc, kind)
if ve: Logs.debug('preproc: include found %s (%s) ', inc, kind)
if kind == '"' or not strict_quotes:
self.current_file = self.tryfind(inc)
if token == 'import':
@ -1007,7 +1006,7 @@ class c_parser(object):
self.ban_includes.add(self.current_file)
except Exception as e:
if Logs.verbose:
debug('preproc: line parsing failed (%s): %s %s', e, line, Utils.ex_stack())
Logs.debug('preproc: line parsing failed (%s): %s %s', e, line, Utils.ex_stack())
def define_name(self, line):
"""
@ -1042,6 +1041,6 @@ def scan(task):
tmp = c_parser(nodepaths)
tmp.start(task.inputs[0], task.env)
if Logs.verbose:
debug('deps: deps for %r: %r; unresolved %r', task.inputs, tmp.nodes, tmp.names)
Logs.debug('deps: deps for %r: %r; unresolved %r', task.inputs, tmp.nodes, tmp.names)
return (tmp.nodes, tmp.names)

View File

@ -43,36 +43,6 @@ class rc_parser(c_preproc.c_parser):
ret.append(('include', m.group(5)))
return ret
def addlines(self, node):
self.currentnode_stack.append(node.parent)
filepath = node.abspath()
self.count_files += 1
if self.count_files > c_preproc.recursion_limit:
raise c_preproc.PreprocError("recursion limit exceeded")
pc = self.parse_cache
Logs.debug('preproc: reading file %r', filepath)
try:
lns = pc[filepath]
except KeyError:
pass
else:
self.lines.extend(lns)
return
try:
lines = self.filter_comments(filepath)
lines.append((c_preproc.POPFILE, ''))
lines.reverse()
pc[filepath] = lines
self.lines.extend(lines)
except IOError:
raise c_preproc.PreprocError("could not read the file %s" % filepath)
except Exception:
if Logs.verbose > 0:
Logs.error("parsing %s failed", filepath)
traceback.print_exc()
class winrc(Task.Task):
"""
Task for compiling resource files
@ -83,32 +53,26 @@ class winrc(Task.Task):
def scan(self):
tmp = rc_parser(self.generator.includes_nodes)
tmp.start(self.inputs[0], self.env)
nodes = tmp.nodes
names = tmp.names
if Logs.verbose:
Logs.debug('deps: deps for %s: %r; unresolved %r', str(self), nodes, names)
return (nodes, names)
Logs.debug('deps: deps for %s: %r; unresolved %r', self.inputs, tmp.nodes, tmp.names)
return (tmp.nodes, tmp.names)
def configure(conf):
"""
Detect the programs RC or windres, depending on the C/C++ compiler in use
"""
v = conf.env
v['WINRC_TGT_F'] = '-o'
v['WINRC_SRC_F'] = '-i'
v.WINRC_TGT_F = '-o'
v.WINRC_SRC_F = '-i'
# find rc.exe
if not conf.env.WINRC:
if not v.WINRC:
if v.CC_NAME == 'msvc':
conf.find_program('RC', var='WINRC', path_list = v['PATH'])
v['WINRC_TGT_F'] = '/fo'
v['WINRC_SRC_F'] = ''
conf.find_program('RC', var='WINRC', path_list=v.PATH)
v.WINRC_TGT_F = '/fo'
v.WINRC_SRC_F = ''
else:
conf.find_program('windres', var='WINRC', path_list = v['PATH'])
if not conf.env.WINRC:
conf.find_program('windres', var='WINRC', path_list=v.PATH)
if not v.WINRC:
conf.fatal('winrc was not found!')
v['WINRCFLAGS'] = []