Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @system_wrapper.module_eval to defineinator, flaginator, so enviroment variables, #{ENV['VARIABLE']}, are parsed now. #880

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions lib/ceedling/defineinator.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@

class Defineinator

constructor :configurator, :streaminator, :config_matchinator
constructor :configurator, :streaminator, :config_matchinator, :system_wrapper

def setup
@topkey = :defines
@@ -38,9 +38,16 @@ def defines_defined?(context:)
# (But, we can also lookup defines symbol lists within framework configurations--:unity, :cmock, :cexception)
def defines(topkey:@topkey, subkey:, filepath:nil)
defines = @config_matchinator.get_config(primary:topkey, secondary:subkey)

if defines == nil then return []
elsif defines.is_a?(Array) then return defines.flatten # Flatten to handle list-nested YAML aliases
ret_defines = []

if defines == nil
ret_defines = []
elsif defines.is_a?(Array)
defines_parsed = defines.flatten # Flatten to handle list-nested YAML aliases
defines_parsed.each do |element|
element = element.replace( @system_wrapper.module_eval( element ) ) if (element =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
ret_defines = defines_parsed
elsif defines.is_a?(Hash)
@config_matchinator.validate_matchers(hash:defines, section:@topkey, context:subkey)

@@ -51,11 +58,28 @@ def defines(topkey:@topkey, subkey:, filepath:nil)
context: subkey
}

return @config_matchinator.matches?(**arg_hash)
defines_parsed = @config_matchinator.matches?(**arg_hash)
defines_parsed.each do |key, value|
key = key.replace( @system_wrapper.module_eval( key ) ) if (key =~ RUBY_STRING_REPLACEMENT_PATTERN)
if value.is_a?(Array)
value.each do |v|
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
elsif value.is_a?(Hash)
value.each do |k,v|
k = k.replace( @system_wrapper.module_eval( k ) ) if (k =~ RUBY_STRING_REPLACEMENT_PATTERN)
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
else
value = value.replace( @system_wrapper.module_eval( value ) ) if (value =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
end

ret_defines = defines_parsed
end

# Handle unexpected config element type
return []
return ret_defines
end

# Optionally create a command line compilation symbol that is a test file's sanitized/converted name
34 changes: 29 additions & 5 deletions lib/ceedling/flaginator.rb
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@

class Flaginator

constructor :configurator, :streaminator, :config_matchinator
constructor :configurator, :streaminator, :config_matchinator, :system_wrapper

def setup
@section = :flags
@@ -42,9 +42,16 @@ def flags_defined?(context:, operation:nil)

def flag_down(context:, operation:, filepath:nil)
flags = @config_matchinator.get_config(primary:@section, secondary:context, tertiary:operation)
ret_flags = []

if flags == nil then return []
elsif flags.is_a?(Array) then return flags.flatten # Flatten to handle list-nested YAML aliases
if flags == nil
ret_flags = []
elsif flags.is_a?(Array)
flags_parsed = flags.flatten # Flatten to handle list-nested YAML aliases
flags_parsed.each do |element|
element = element.replace( @system_wrapper.module_eval( element ) ) if (element =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
ret_flags = flags_parsed
elsif flags.is_a?(Hash)
@config_matchinator.validate_matchers(hash:flags, section:@section, context:context, operation:operation)

@@ -56,11 +63,28 @@ def flag_down(context:, operation:, filepath:nil)
operation: operation
}

return @config_matchinator.matches?(**arg_hash)
flags_parsed = @config_matchinator.matches?(**arg_hash)
flags_parsed.each do |key, value|
key = key.replace( @system_wrapper.module_eval( key ) ) if (key =~ RUBY_STRING_REPLACEMENT_PATTERN)
if value.is_a?(Array)
value.each do |v|
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
elsif value.is_a?(Hash)
value.each do |k,v|
k = k.replace( @system_wrapper.module_eval( k ) ) if (k =~ RUBY_STRING_REPLACEMENT_PATTERN)
v = v.replace( @system_wrapper.module_eval( v ) ) if (v =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
else
value = value.replace( @system_wrapper.module_eval( value ) ) if (value =~ RUBY_STRING_REPLACEMENT_PATTERN)
end
end

ret_flags = flags_parsed
end

# Handle unexpected config element type
return []
return ret_flags
end

end
2 changes: 2 additions & 0 deletions lib/ceedling/objects.yml
Original file line number Diff line number Diff line change
@@ -205,12 +205,14 @@ flaginator:
- configurator
- streaminator
- config_matchinator
- system_wrapper

defineinator:
compose:
- configurator
- streaminator
- config_matchinator
- system_wrapper

generator:
compose: