Sha256: 9d80fabd8da85221adc674a15559fd500a5fdd76ce433274d372abe8c67f272b

Contents?: true

Size: 1.53 KB

Versions: 9

Compression:

Stored size: 1.53 KB

Contents

require 'rubygems'
require 'rake' # for ext()
require 'fileutils'
require 'ceedling/constants'


# :flags:
#   :release:
#     :compile:
#       :*:          # add '-foo' to compilation of all files not main.c
#         - -foo
#       :main:       # add '-Wall' to compilation of main.c
#         - -Wall
#   :test:
#     :link:
#       :test_main:  # add '--bar --baz' to linking of test_main.exe
#         - --bar
#         - --baz


class Flaginator

  constructor :configurator

  def flag_down( operation, context, file )
    # create configurator accessor method
    accessor = ('flags_' + context.to_s).to_sym

    # create simple filename key from whatever filename provided
    file_key = File.basename( file ).ext('').to_sym

    # if no entry in configuration for flags for this context, bail out
    return [] if not @configurator.respond_to?( accessor )

    # get flags sub hash associated with this context
    flags = @configurator.send( accessor )

    # if operation not represented in flags hash, bail out
    return [] if not flags.include?( operation )

    # redefine flags to sub hash associated with the operation
    flags = flags[operation]

    # if our file is in the flags hash, extract the array of flags
    if (flags.include?( file_key )) then return flags[file_key]
    # if our file isn't in the flags hash, but there is default for all other files, extract array of flags
    elsif (flags.include?( :* )) then return flags[:*]
    end

    # fall through: flags were specified but none applying to present file
    return []
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ceedling-0.28.1 lib/ceedling/flaginator.rb
ceedling-0.27.0 lib/ceedling/flaginator.rb
ceedling-0.25.0 lib/ceedling/flaginator.rb
ceedling-0.24.0 lib/ceedling/flaginator.rb
ceedling-0.22.0 lib/ceedling/flaginator.rb
ceedling-0.21.0 lib/ceedling/flaginator.rb
ceedling-0.20.3 lib/ceedling/flaginator.rb
ceedling-0.20.2 lib/ceedling/flaginator.rb
ceedling-0.19.0 lib/ceedling/flaginator.rb