Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: pylib/gyp/generator/make.py

Issue 10332236: make: Support '#' characters in defines. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/defines/defines.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Notes: 5 # Notes:
6 # 6 #
7 # This is all roughly based on the Makefile system used by the Linux 7 # This is all roughly based on the Makefile system used by the Linux
8 # kernel, but is a non-recursive make -- we put the entire dependency 8 # kernel, but is a non-recursive make -- we put the entire dependency
9 # graph in front of make and let it figure it out. 9 # graph in front of make and let it figure it out.
10 # 10 #
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 def EscapeMakeVariableExpansion(s): 576 def EscapeMakeVariableExpansion(s):
577 """Make has its own variable expansion syntax using $. We must escape it for 577 """Make has its own variable expansion syntax using $. We must escape it for
578 string to be interpreted literally.""" 578 string to be interpreted literally."""
579 return s.replace('$', '$$') 579 return s.replace('$', '$$')
580 580
581 581
582 def EscapeCppDefine(s): 582 def EscapeCppDefine(s):
583 """Escapes a CPP define so that it will reach the compiler unaltered.""" 583 """Escapes a CPP define so that it will reach the compiler unaltered."""
584 s = EscapeShellArgument(s) 584 s = EscapeShellArgument(s)
585 s = EscapeMakeVariableExpansion(s) 585 s = EscapeMakeVariableExpansion(s)
586 return s 586 # '#' characters must be escaped even embedded in a string, else Make will
587 # treat it as the start of a comment.
588 return s.replace('#', r'\#')
587 589
588 590
589 def QuoteIfNecessary(string): 591 def QuoteIfNecessary(string):
590 """TODO: Should this ideally be replaced with one or more of the above 592 """TODO: Should this ideally be replaced with one or more of the above
591 functions?""" 593 functions?"""
592 if '"' in string: 594 if '"' in string:
593 string = '"' + string.replace('"', '\\"') + '"' 595 string = '"' + string.replace('"', '\\"') + '"'
594 return string 596 return string
595 597
596 598
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 root_makefile.write(" include " + include_file + "\n") 2130 root_makefile.write(" include " + include_file + "\n")
2129 root_makefile.write("endif\n") 2131 root_makefile.write("endif\n")
2130 root_makefile.write('\n') 2132 root_makefile.write('\n')
2131 2133
2132 if generator_flags.get('auto_regeneration', True): 2134 if generator_flags.get('auto_regeneration', True):
2133 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2135 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2134 2136
2135 root_makefile.write(SHARED_FOOTER) 2137 root_makefile.write(SHARED_FOOTER)
2136 2138
2137 root_makefile.close() 2139 root_makefile.close()
OLDNEW
« no previous file with comments | « no previous file | test/defines/defines.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698