Merge pull request #6623 from DavidGriffith/gmake-conditional-assignment

Deal with GMake Makefile conditional assignment operators.
This commit is contained in:
Mike McQuaid 2019-10-21 10:07:55 +01:00 committed by GitHub
commit 962ca6a86a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ module StringInreplaceExtension
# Looks for Makefile style variable definitions and replaces the
# value with "new_value", or removes the definition entirely.
def change_make_var!(flag, new_value)
return if gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
return if gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
end
@ -50,12 +50,14 @@ module StringInreplaceExtension
def remove_make_var!(flags)
Array(flags).each do |flag|
# Also remove trailing \n, if present.
errors << "expected to remove #{flag.inspect}" unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=.*$\n?/, "", false)
if gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=.*$\n?/, "", false)
errors << "expected to remove #{flag.inspect}"
end
end
end
# Finds the specified variable
def get_make_var(flag)
self[/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, 1]
self[/^#{Regexp.escape(flag)}[ \t]*[\\?\+\:\!]?=[ \t]*(.*)$/, 1]
end
end