Skip to content

Commit

Permalink
Fix SCons-based webkit build on Windows (broken by the Linux
Browse files Browse the repository at this point in the history
command-line changes) by using portable SCons idioms:
* Side-step command-line differences by using a Python function as a
  build action to generate a .h file by surrounding the contents of
  the yacc-generated .hpp file with a #ifndef-#define-#endif guard.
* Use the pre-defined Delete() ActionFactory to let SCons delete the
  .hpp file directly, instead of calling "rm" to do it.
TBR: evanm

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1523 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sgk@google.com committed Aug 29, 2008
1 parent b492eae commit f9dec56
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions webkit/build/port/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,31 @@ env.Command(['$DERIVED_DIR/UserAgentStyleSheets.h',
'$DERIVED_DIR/quirks.css'],
'$PERL ${SOURCES[0].posix} ${TARGETS.posix} ${SOURCES[1:].posix}')

def create_h_wrapper(target, source, env):
"""
Create a *.h file by surrounding the contents of a
yacc-generated *.hpp with a #ifndef-#define-#endif guard.
"""
t = str(target[1])
fp = open(t, 'w')
define = os.path.splitext(os.path.split(t)[1])[0]
fp.write('#ifndef %s_h\n' % define)
fp.write('#define %s_h\n' % define)
fp.write(open(t + 'pp', 'r').read())
fp.write('#endif %s_h\n' % define)

# TODO(sgk): make this a real pseudo-Builder
def BuildYacc(env, dir, name, file):
env.Command(['$DERIVED_DIR/%s.cpp' % file,
'$DERIVED_DIR/%s.h' % file],
['$WEBKIT_PORT_DIR/%s/%s.y' % (dir, file)],
('$YACC -d -p %syy ${SOURCES[0].posix} ' % name +
'-o ${TARGET.posix} && ' +
'(echo \#ifndef %s_h;' % file +
' echo \#define %s_h;' % file +
' cat $DERIVED_DIR/%s.hpp;' % file +
' echo \#endif) >> $DERIVED_DIR/%s.h && ' % file +
'rm $DERIVED_DIR/%s.hpp' % file))

BuildYacc(env, 'xml', 'xpath', 'XPathGrammar')
BuildYacc(env, 'css', 'css', 'CSSGrammar')
['$YACC -d -p %s ${SOURCES[0].posix} ' % name +
'-o ${TARGET.posix}',
Action(create_h_wrapper),
Delete('${TARGETS[1]}pp')])

BuildYacc(env, 'xml', 'xpathyy', 'XPathGrammar')
BuildYacc(env, 'css', 'cssyy', 'CSSGrammar')

# TODO(bradnelson): need to add in error checking

Expand Down

0 comments on commit f9dec56

Please sign in to comment.