diff --git a/assets/project_as_gem.yml b/assets/project_as_gem.yml index 9b73317c..8bd8d26b 100644 --- a/assets/project_as_gem.yml +++ b/assets/project_as_gem.yml @@ -108,38 +108,30 @@ :test: [] :source: [] -# Defines to be injected into the builds -# in order to add common defines: -# 1) remove the trailing [] from the :common: section -# 2) add entries to the :common: section (e.g. :test: has TEST defined) +# Compilation symbols to be injected into builds +# See documentation for advanced options: +# - Test name matchers for different symbols per test executable build +# - Referencing symbols in multiple lists using advanced YAML +# - Specifiying symbols used during test preprocessing :defines: - :common: &common_defines [] :test: - - *common_defines - - TEST - :test_preprocess: - - *common_defines - - TEST + - TEST # Simple list option to add symbol 'TEST' to compilation of all files in all test executables :release: [] - :release_preprocess: [] - # enable to have the name of the test defined with each test build. - # this is SLOW as it requires all files to be rebuilt for each test module + # Enable to inject name of a test as a unique compilation symbol into its respective executable build. :use_test_definition: FALSE -# flags allows you to configure the flags used when calling the different tools in -# your toolchain. It can be used to override flags for specific files. Overriding flags -# here is easier than building a new tool from scratch, but it only applies to when -# you're calling gcc +# Configure additional command line flags provided to tools used in each build step # :flags: # :release: +# :compile: # Add '-Wall' and '--02' to compilation of all files in release target +# - -Wall +# - --O2 +# :test: # :compile: -# 'main': -# - -Wall -# - --O2 -# 'test_.+': # add '-pedantic' to all test-files +# '(_|-)special': # Add '-pedantic' to compilation of all files in all test executables with '_special' or '-special' in their names # - -pedantic -# '*': # add '-foo' to compilation of all files not main.c or test files +# '*': # Add '-foo' to compilation of all files in all test executables # - -foo # Configuration Options specific to CMock. See CMock docs for details @@ -162,10 +154,6 @@ :defines: - UNITY_EXCLUDE_FLOAT -# Configuration options specify to Unity's test runner generator -:test_runner: - :cmdline_args: FALSE - # You can optionally have ceedling create environment variables for you before # performing the rest of its tasks. :environment: [] diff --git a/assets/project_with_guts.yml b/assets/project_with_guts.yml index baf7e184..58cdd76f 100644 --- a/assets/project_with_guts.yml +++ b/assets/project_with_guts.yml @@ -108,38 +108,30 @@ :test: [] :source: [] -# Defines to be injected into the builds -# in order to add common defines: -# 1) remove the trailing [] from the :common: section -# 2) add entries to the :common: section (e.g. :test: has TEST defined) +# Compilation symbols to be injected into builds +# See documentation for advanced options: +# - Test name matchers for different symbols per test executable build +# - Referencing symbols in multiple lists using advanced YAML +# - Specifiying symbols used during test preprocessing :defines: - :common: &common_defines [] :test: - - *common_defines - - TEST - :test_preprocess: - - *common_defines - - TEST + - TEST # Simple list option to add symbol 'TEST' to compilation of all files in all test executables :release: [] - :release_preprocess: [] - # enable to have the name of the test defined with each test build. - # this is SLOW as it requires all files to be rebuilt for each test module + # Enable to inject name of a test as a unique compilation symbol into its respective executable build. :use_test_definition: FALSE -# flags allows you to configure the flags used when calling the different tools in -# your toolchain. It can be used to override flags for specific files. Overriding flags -# here is easier than building a new tool from scratch, but it only applies to when -# you're calling gcc +# Configure additional command line flags provided to tools used in each build step # :flags: # :release: +# :compile: # Add '-Wall' and '--02' to compilation of all files in release target +# - -Wall +# - --O2 +# :test: # :compile: -# 'main': -# - -Wall -# - --O2 -# 'test_.+': # add '-pedantic' to all test-files +# '(_|-)special': # Add '-pedantic' to compilation of all files in all test executables with '_special' or '-special' in their names # - -pedantic -# '*': # add '-foo' to compilation of all files not main.c or test files +# '*': # Add '-foo' to compilation of all files in all test executables # - -foo # Configuration Options specific to CMock. See CMock docs for details diff --git a/assets/project_with_guts_gcov.yml b/assets/project_with_guts_gcov.yml index 1cfc066c..81675166 100644 --- a/assets/project_with_guts_gcov.yml +++ b/assets/project_with_guts_gcov.yml @@ -108,38 +108,30 @@ :test: [] :source: [] -# Defines to be injected into the builds -# in order to add common defines: -# 1) remove the trailing [] from the :common: section -# 2) add entries to the :common: section (e.g. :test: has TEST defined) +# Compilation symbols to be injected into builds +# See documentation for advanced options: +# - Test name matchers for different symbols per test executable build +# - Referencing symbols in multiple lists using advanced YAML +# - Specifiying symbols used during test preprocessing :defines: - :common: &common_defines [] :test: - - *common_defines - - TEST - :test_preprocess: - - *common_defines - - TEST + - TEST # Simple list option to add symbol 'TEST' to compilation of all files in all test executables :release: [] - :release_preprocess: [] - # enable to have the name of the test defined with each test build. - # this is SLOW as it requires all files to be rebuilt for each test module + # Enable to inject name of a test as a unique compilation symbol into its respective executable build. :use_test_definition: FALSE -# flags allows you to configure the flags used when calling the different tools in -# your toolchain. It can be used to override flags for specific files. Overriding flags -# here is easier than building a new tool from scratch, but it only applies to when -# you're calling gcc +# Configure additional command line flags provided to tools used in each build step # :flags: # :release: +# :compile: # Add '-Wall' and '--02' to compilation of all files in release target +# - -Wall +# - --O2 +# :test: # :compile: -# 'main': -# - -Wall -# - --O2 -# 'test_.+': # add '-pedantic' to all test-files +# '(_|-)special': # Add '-pedantic' to compilation of all files in all test executables with '_special' or '-special' in their names # - -pedantic -# '*': # add '-foo' to compilation of all files not main.c or test files +# '*': # Add '-foo' to compilation of all files in all test executables # - -foo # Configuration Options specific to CMock. See CMock docs for details diff --git a/docs/CeedlingPacket.md b/docs/CeedlingPacket.md index 22309b1a..47c8f869 100644 --- a/docs/CeedlingPacket.md +++ b/docs/CeedlingPacket.md @@ -114,7 +114,8 @@ It's just all mixed together. 1. **[The Almighty Ceedling Project Configuration File (in Glorious YAML)][packet-section-9]** This is the exhaustive documentation for all of Ceedling's project file - configuration options. + configuration options — from project paths to command line tools to plugins and + much, much more. 1. **[Build Directive Macros][packet-section-10]** @@ -1196,16 +1197,16 @@ documentation. ## Unity Configuration Unity is wholly compiled C code. As such, its configuration is entirely -controlled by a variety of `#define` symbols. These can be configured -in Ceedling's `:defines` ↳ `:unity` project settings. +controlled by a variety of compilation symbols. These can be configured +in Ceedling's `:unity` project settings. ### Example Unity configurations #### Itty bitty processor & toolchain with limited test execution options ```yaml -:defines: - :unity: +:unity: + :defines: - UNITY_INT_WIDTH=16 # 16 bit processor without support for 32 bit instructions - UNITY_EXCLUDE_FLOAT # No floating point unit ``` @@ -1213,8 +1214,8 @@ in Ceedling's `:defines` ↳ `:unity` project settings. #### Great big gorilla processor that grunts and scratches ```yaml -:defines: - :unity: +:unity: + :defines: - UNITY_SUPPORT_64 # Big memory, big counters, big registers - UNITY_LINE_TYPE=\"unsigned int\" # Apparently, we're writing lengthy test files, - UNITY_COUNTER_TYPE=\"unsigned int\" # and we've got a ton of test cases in those test files @@ -1224,13 +1225,13 @@ in Ceedling's `:defines` ↳ `:unity` project settings. #### Example Unity configuration header file Sometimes, you may want to funnel all Unity configuration options into a -header file rather than organize a lengthy `:defines` ↳ `:unity` list. Perhaps your -`#define` symbol definitions include characters needing escape sequences -in YAML that are driving you bonkers. +header file rather than organize a lengthy `:unity` ↳ `:defines` list. Perhaps your +symbol definitions include characters needing escape sequences in YAML that are +driving you bonkers. ```yaml -:defines: - :unity: +:unity: + :defines: - UNITY_INCLUDE_CONFIG_H ``` @@ -1268,7 +1269,7 @@ very well. Consult your toolchain and shell documentation. If redefining the function and macros breaks your command line compilation, all necessary options and functionality can be defined in `unity_config.h`. Unity will need the `UNITY_INCLUDE_CONFIG_H` symbol in the -`:defines` list of your Ceedling project file (see example above). +`:unity` ↳ `:defines` list of your Ceedling project file (see example above). ## CMock Configuration @@ -1299,7 +1300,7 @@ section within Ceedling's project file. Like Unity and CException, CMock's C components are configured at compilation with symbols managed in your Ceedling project file's -`:defines` ↳ `:cmock` section. +`:cmock` ↳ `:defines` section. ### Example CMock configurations @@ -1308,14 +1309,12 @@ compilation with symbols managed in your Ceedling project file's # Shown for completeness -- CMock enabled by default in Ceedling :use_mocks: TRUE -:defines: - :cmock: - # Memory alignment (packing) on 16 bit boundaries - - CMOCK_MEM_ALIGN=1 - :cmock: :when_no_prototypes: :warn :enforce_strict_ordering: TRUE + :defines: + # Memory alignment (packing) on 16 bit boundaries + - CMOCK_MEM_ALIGN=1 :plugins: - :ignore :treat_as: @@ -1330,7 +1329,7 @@ compilation with symbols managed in your Ceedling project file's Like Unity, CException is wholly compiled C code. As such, its configuration is entirely controlled by a variety of `#define` symbols. -These can be configured in Ceedling's `:defines` ↳ `:cexception` project +These can be configured in Ceedling's `:cexception` ↳ `:defines` project settings. Unlike Unity which is always available in test builds and CMock that @@ -1344,8 +1343,8 @@ if you wish to use it in your project. # Enable CException for both test and release builds :use_exceptions: TRUE -:defines: - :cexception: +:cexception: + :defines: # Possible exception codes of -127 to +127 - CEXCEPTION_T='signed char' @@ -1682,13 +1681,16 @@ internally - thus leading to unexpected behavior without warning. directory the output of the release linker and (optionally) a map file. Many toolchains produce other important output files as well. Adding a file path to this list will cause Ceedling to copy that file - to the artifacts directory. The artifacts directory is helpful for - organizing important build output files and provides a central place - for tools such as Continuous Integration servers to point to build - output. Selectively copying files prevents incidental build cruft from - needlessly appearing in the artifacts directory. Note that inline Ruby - string replacement is available in the artifacts paths (see discussion - in the `:environment` section). + to the artifacts directory. + + The artifacts directory is helpful for organizing important build + output files and provides a central place for tools such as Continuous + Integration servers to point to build output. Selectively copying + files prevents incidental build cruft from needlessly appearing in the + artifacts directory. + + Note that inline Ruby string replacement is available in the artifacts + paths (see discussion in the `:environment` section). **Default**: `[]` (empty) @@ -2181,57 +2183,6 @@ matchers and the simpler list format cannot be mixed for `:defines` ↳ `:test`. **Default**: `[]` (empty) -*
:defines
↳ :unity
:defines
↳ :cmock
:defines
↳ :cexception
:defines
↳ :<plugin context>
Some advanced plugins make use of build contexts as well. For instance, the Ceedling
@@ -2727,6 +2678,27 @@ Using hashes:
:configB: path/to/another/config.yml
```
+## `:cexception` Configure CException’s features
+
+* `:defines`:
+
+ List of symbols used to configure CException's features in its source and header files
+ at compile time.
+
+ See [Using Unity, CMock & CException](#using-unity-cmock--cexception) for much more on
+ configuring and making use of these frameworks in your build.
+
+ To manage overall command line length, these symbols are only added to compilation when
+ a CException C source file is compiled.
+
+ No symbols must be set unless CException's defaults are inappropriate for your
+ environment and needs.
+
+ Note CException must be enabled for it to be added to a release or test build and for
+ these symbols to be added to a build of CException (see link referenced earlier for more).
+
+ **Default**: `[]` (empty)
+
## `:cmock` Configure CMock’s code generation & compilation
Ceedling sets values for a subset of CMock settings. All CMock
@@ -2734,7 +2706,10 @@ options are available to be set, but only those options set by
Ceedling in an automated fashion are documented below. See CMock
documentation.
-Ceedling sets values for a subset of CMock settings. All CMock options are available to be set, but only those options set by Ceedling in an automated fashion are documented below. See CMock documentation.
+Ceedling sets values for a subset of CMock settings. All CMock
+options are available to be set, but only those options set by
+Ceedling in an automated fashion are documented below.
+See [CMock] documentation.
* `:enforce_strict_ordering`:
@@ -2752,6 +2727,22 @@ Ceedling sets values for a subset of CMock settings. All CMock options are avail
If not set, defaults to Ceedling's verbosity level
+* `:defines`:
+
+ Adds list of symbols used to configure CMock's C code features in its source and header
+ files at compile time.
+
+ See [Using Unity, CMock & CException](#using-unity-cmock--cexception) for much more on
+ configuring and making use of these frameworks in your build.
+
+ To manage overall command line length, these symbols are only added to compilation when
+ a CMock C source file is compiled.
+
+ No symbols must be set unless CMock's defaults are inappropriate for your environment
+ and needs.
+
+ **Default**: `[]` (empty)
+
* `:plugins`:
To add to the list Ceedling provides CMock, simply add `:cmock` ↳ `:plugins`
@@ -2770,15 +2761,38 @@ Ceedling sets values for a subset of CMock settings. All CMock options are avail
above with regard to adding additional files to be inserted within
mocks as #include statements.
+### Notes on Ceedling’s nudges for CMock strict ordering
+
The last four settings above are directly tied to other Ceedling
-settings; hence, why they are listed and explained here. The
-first setting above, `:enforce_strict_ordering`, defaults
-to FALSE within CMock. It is set to TRUE by default in Ceedling
-as our way of encouraging you to use strict ordering. It's a teeny
-bit more expensive in terms of code generated, test execution
-time, and complication in deciphering test failures. However,
-it's good practice. And, of course, you can always disable it
-by overriding the value in the Ceedling YAML configuration file.
+settings; hence, why they are listed and explained here.
+
+The first setting above, `:enforce_strict_ordering`, defaults
+to `FALSE` within CMock. However, it is set to `TRUE` by default
+in Ceedling as our way of encouraging you to use strict ordering.
+
+Strict ordering is teeny bit more expensive in terms of code
+generated, test execution time, and complication in deciphering
+test failures. However, it's good practice. And, of course, you
+can always disable it by overriding the value in the Ceedling
+project configuration file.
+
+## `:unity` Configure Unity’s features
+
+* `:defines`:
+
+ Adds list of symbols used to configure Unity's features in its source and header files
+ at compile time.
+
+ See [Using Unity, CMock & CException](#using-unity-cmock--cexception) for much more on
+ configuring and making use of these frameworks in your build.
+
+ To manage overall command line length, these symbols are only added to compilation when
+ a Unity C source file is compiled.
+
+ No symbols must be set unless Unity's defaults are inappropriate for your environment
+ and needs.
+
+ **Default**: `[]` (empty)
## `:tools` Configuring command line tools used for build steps
diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md
index 3f2f46c6..2522e1ee 100644
--- a/docs/ReleaseNotes.md
+++ b/docs/ReleaseNotes.md
@@ -196,12 +196,12 @@ To better support per-test-executable configurations, the format of `:defines` h
In brief:
-1. A more logically named hierarchy differentiates `#define`s for test preprocessing, test compilation, and release compilation. The new format also allows a cleaner organization of `#define`s for configuration of tools like Unity.
-1. Previously, `#define`s could be specified for a specific C file by name, but these `#define`s were only applied when compiling that specific file. Further, this matching was only against a file's full name. Now, pattern matching is also an option against test file names (only test file names) and the configured `#define`s are applied to each C file that comprises a test executable.
+1. A more logically named hierarchy differentiates `#define`s for test preprocessing, test compilation, and release compilation.
+1. Previously, compilation symbols could be specified for a specific C file by name, but these symbols were only defined when compiling that specific file. Further, this matching was only against a file's full name. Now, pattern matching is also an option against test file names (_only_ test file names) and the configured symbols are applied in compilation of each C file that comprises a test executable.
### Format change for `:flags` in the project file
-To better support per-test-executable configurations, the format and function of `[flags]` has changed somewhat. See the [official documentation](CeedlingPacket.md) for specifics.
+To better support per-test-executable configurations, the format and function of `:flags` has changed somewhat. See the [official documentation](CeedlingPacket.md) for specifics.
In brief:
@@ -216,46 +216,6 @@ The previously undocumented `TEST_FILE()` build directive macro (#796) available
Differentiating components of the same name that are a part of multiple test executables built with differing configurations has required further subdirectories in the build directory structure. Generated mocks, compiled object files, linked executables, and preprocessed output all end up one directory deeper than in previous versions of Ceedling. In each case, these files are found inside a subdirectory named for their containing test.
-#### Tool `:defines`
-
-In previous versions of Ceedling, one option for configuring compiled elements of vendor tools was to specify their `#define`s in that tool's project file configuration section. In conjunction with the general improvements to handling `#define`s, vendor tools' `#define`s now live in the top-level `:defines` area of the project configuration.
-
-Note that to preserve some measure of backwards compatibility, Ceedling inserts a copy of a vendor tool's `#define` list into its top-level config.
-
-Example of the old way:
-
-```yaml
-:unity:
- :defines:
- - UNITY_EXCLUDE_STDINT_H
- - UNITY_EXCLUDE_LIMITS_H
- - UNITY_EXCLUDE_SIZEOF
- - UNITY_INCLUDE_DOUBLE
-
-:cmock:
- :defines:
- - CMOCK_MEM_STATIC
- - CMOCK_MEM_ALIGN=2
-```
-
-Example of the new way:
-
-```yaml
-:defines:
- :release:
- ... # Empty snippet
- :test:
- ... # Empty snippet
- :unity:
- - UNITY_EXCLUDE_STDINT_H
- - UNITY_EXCLUDE_LIMITS_H
- - UNITY_EXCLUDE_SIZEOF
- - UNITY_INCLUDE_DOUBLE
- :cmock:
- - CMOCK_MEM_STATIC
- - CMOCK_MEM_ALIGN=2
-```
-
### Changes to global collections
Some global “collections” that were previously key elements of Ceedling have changed or gone away as the build pipeline is now able to process a configuration for each individual test executable in favor of for the entire suite.
diff --git a/lib/ceedling/config_matchinator.rb b/lib/ceedling/config_matchinator.rb
index 47af59be..9ee14a89 100644
--- a/lib/ceedling/config_matchinator.rb
+++ b/lib/ceedling/config_matchinator.rb
@@ -12,69 +12,69 @@ class ConfigMatchinator
constructor :configurator, :streaminator
- def config_include?(section:, context:, operation:nil)
+ def config_include?(primary:, secondary:, tertiary:nil)
# Create configurator accessor method
- accessor = (section.to_s + '_' + context.to_s).to_sym
+ accessor = (primary.to_s + '_' + secondary.to_s).to_sym
- # If no entry in configuration for context in this section, bail out
+ # If no entry in configuration for secondary in primary, bail out
return false if not @configurator.respond_to?( accessor )
- # If operation undefined, we've progressed as far as we need and already know the config is present
- return true if operation.nil?
+ # If tertiary undefined, we've progressed as far as we need and already know the config is present
+ return true if tertiary.nil?
# Get element associated with this context
elem = @configurator.send( accessor )
- # If [section][context] is a simple array
+ # If [primary][secondary] is a simple array
if elem.is_a?(Array)
- # A list instead of a hash, means [operation] is not present
+ # A list instead of a hash, means [tertiary] is not present
return false
- # If [section][context] is a hash
+ # If [primary][secondary] is a hash
elsif elem.is_a?(Hash)
- return elem.include?( operation )
+ return elem.include?( tertiary )
end
- # Otherwise, [section][context] is something that cannot contain an [operation] sub-hash
+ # Otherwise, [primary][secondary] is something that cannot contain a [tertiary] sub-hash
return false
end
- def get_config(section:, context:, operation:nil)
+ def get_config(primary:, secondary:, tertiary:nil)
# Create configurator accessor method
- accessor = (section.to_s + '_' + context.to_s).to_sym
+ accessor = (primary.to_s + '_' + secondary.to_s).to_sym
- # If no entry in configuration for context in this section, bail out
+ # If no entry in configuration for secondary in primary, bail out
return nil if not @configurator.respond_to?( accessor )
- # Get config element associated with this context
+ # Get config element associated with this secondary
elem = @configurator.send( accessor )
- # If [section][context] is a simple array
+ # If [primary][secondary] is a simple array
if elem.class == Array
- # If no operation specified, then a simple array makes sense
- return elem if operation.nil?
+ # If no tertiary specified, then a simple array makes sense
+ return elem if tertiary.nil?
- # Otherwise, if an operation is specified but we have an array, go boom
- error = "ERROR: [#{section}][#{context}] present in project configuration but does not contain [#{operation}]."
+ # Otherwise, if an tertiary is specified but we have an array, go boom
+ error = "ERROR: [#{primary}][#{secondary}] present in project configuration but does not contain [#{tertiary}]."
raise CeedlingException.new(error)
- # If [section][context] is a hash
+ # If [primary][secondary] is a hash
elsif elem.class == Hash
- if not operation.nil?
- # Bail out if we're looking for an [operation] sub-hash, but it's not present
- return nil if not elem.include?( operation )
+ if not tertiary.nil?
+ # Bail out if we're looking for an [tertiary] sub-hash, but it's not present
+ return nil if not elem.include?( tertiary )
- # Return array or hash at operation
- return elem[operation]
+ # Return array or hash at tertiary
+ return elem[tertiary]
- # If operation is not being queried, but we have a hash, return the hash
+ # If tertiary is not being queried, but we have a hash, return the hash
else
return elem
end
- # If [section][context] is nothing we expect--something other than an array or hash
+ # If [primary][secondary] is nothing we expect--something other than an array or hash
else
- error = "ERROR: [#{section}][#{context}] in project configuration is neither a list nor hash."
+ error = "ERROR: [#{primary}][#{secondary}] in project configuration is neither a list nor hash."
raise CeedlingException.new(error)
end
diff --git a/lib/ceedling/configurator.rb b/lib/ceedling/configurator.rb
index 773e8125..d2c4d0a0 100644
--- a/lib/ceedling/configurator.rb
+++ b/lib/ceedling/configurator.rb
@@ -135,15 +135,6 @@ def populate_cmock_defaults(config)
end
- def copy_vendor_defines(config)
- # NOTE: To maintain any backwards compatibility following a refactoring of :defines: handling,
- # copy top-level vendor defines into the respective tool areas.
- config[UNITY_SYM].store(:defines, config[:defines][UNITY_SYM])
- config[CMOCK_SYM].store(:defines, config[:defines][CMOCK_SYM])
- config[CEXCEPTION_SYM].store(:defines, config[:defines][CEXCEPTION_SYM])
- end
-
-
def get_runner_config
return @runner_config.clone
end
diff --git a/lib/ceedling/defaults.rb b/lib/ceedling/defaults.rb
index 53ce9c57..49566116 100644
--- a/lib/ceedling/defaults.rb
+++ b/lib/ceedling/defaults.rb
@@ -343,10 +343,7 @@
:use_test_definition => false,
:test => [], # A hash/sub-hashes in config file can include operations and test executable matchers as keys
:preprocess => [], # A hash/sub-hashes in config file can include operations and test executable matchers as keys
- :release => [],
- :unity => [],
- :cmock => [],
- :cexception => []
+ :release => []
},
:flags => {
@@ -378,16 +375,19 @@
},
:unity => {
- :vendor_path => CEEDLING_VENDOR
+ :vendor_path => CEEDLING_VENDOR,
+ :defines => []
},
:cmock => {
:vendor_path => CEEDLING_VENDOR,
- :includes => []
+ :includes => [],
+ :defines => []
},
:cexception => {
- :vendor_path => CEEDLING_VENDOR
+ :vendor_path => CEEDLING_VENDOR,
+ :defines => []
},
:test_runner => {
diff --git a/lib/ceedling/defineinator.rb b/lib/ceedling/defineinator.rb
index d145e22b..18ba9be4 100644
--- a/lib/ceedling/defineinator.rb
+++ b/lib/ceedling/defineinator.rb
@@ -24,26 +24,28 @@ class Defineinator
constructor :configurator, :streaminator, :config_matchinator
def setup
- @section = :defines
+ @topkey = :defines
end
def defines_defined?(context:)
- return @config_matchinator.config_include?(section:@section, context:context)
+ return @config_matchinator.config_include?(primary:@topkey, secondary:context)
end
- def defines(context:, filepath:nil)
- defines = @config_matchinator.get_config(section:@section, context:context)
+ # Defaults to inspecting configurations beneath top-level :defines
+ # (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 YAML aliases
+ elsif defines.is_a?(Array) then return defines.flatten # Flatten to handle list-nested YAML aliases
elsif defines.is_a?(Hash)
- @config_matchinator.validate_matchers(hash:defines, section:@section, context:context)
+ @config_matchinator.validate_matchers(hash:defines, section:@topkey, context:subkey)
arg_hash = {
hash: defines,
filepath: filepath,
- section: @section,
- context: context
+ section: topkey,
+ context: subkey
}
return @config_matchinator.matches?(**arg_hash)
@@ -53,4 +55,32 @@ def defines(context:, filepath:nil)
return []
end
+ # Optionally create a command line compilation symbol that is a test file's sanitized/converted name
+ def generate_test_definition(filepath:)
+ defines = []
+
+ if @configurator.defines_use_test_definition
+ # Get filename with no path or extension
+ test_def = File.basename(filepath, '.*').strip
+
+ # Replace any non-ASCII characters with underscores
+ test_def = test_def.encode("ASCII", "UTF-8", invalid: :replace, undef: :replace, replace: "_")
+
+ # Replace all non-alphanumeric characters (including spaces/punctuation but excluding dashes and underscores) with underscores
+ test_def.gsub!(/[^0-9a-z_-]/i, '_')
+
+ # Convert to all caps
+ test_def.upcase!
+
+ # Add leading and trailiing underscores unless they already exist
+ test_def = test_def.start_with?('_') ? test_def : ('_' + test_def)
+ test_def = test_def.end_with?('_') ? test_def : (test_def + '_')
+
+ # Add the test filename as a #define symbol to the array
+ defines << test_def
+ end
+
+ return defines
+ end
+
end
diff --git a/lib/ceedling/flaginator.rb b/lib/ceedling/flaginator.rb
index 06b25e94..0d06ab7a 100644
--- a/lib/ceedling/flaginator.rb
+++ b/lib/ceedling/flaginator.rb
@@ -31,14 +31,14 @@ def setup
end
def flags_defined?(context:, operation:nil)
- return @config_matchinator.config_include?(section:@section, context:context, operation:operation)
+ return @config_matchinator.config_include?(primary:@section, secondary:context, tertiary:operation)
end
def flag_down(context:, operation:, filepath:nil)
- flags = @config_matchinator.get_config(section:@section, context:context, operation:operation)
+ flags = @config_matchinator.get_config(primary:@section, secondary:context, tertiary:operation)
if flags == nil then return []
- elsif flags.is_a?(Array) then return flags.flatten # Flatten to handle YAML aliases
+ elsif flags.is_a?(Array) then return flags.flatten # Flatten to handle list-nested YAML aliases
elsif flags.is_a?(Hash)
@config_matchinator.validate_matchers(hash:flags, section:@section, context:context, operation:operation)
diff --git a/lib/ceedling/setupinator.rb b/lib/ceedling/setupinator.rb
index 751f76cb..e0987305 100644
--- a/lib/ceedling/setupinator.rb
+++ b/lib/ceedling/setupinator.rb
@@ -24,7 +24,6 @@ def do_setup(config_hash)
@ceedling[:configurator].populate_defaults( config_hash )
@ceedling[:configurator].populate_unity_defaults( config_hash )
@ceedling[:configurator].populate_cmock_defaults( config_hash )
- @ceedling[:configurator].copy_vendor_defines( config_hash )
@ceedling[:configurator].find_and_merge_plugins( config_hash )
@ceedling[:configurator].merge_imports( config_hash )
@ceedling[:configurator].eval_environment_variables( config_hash )
diff --git a/lib/ceedling/test_invoker_helper.rb b/lib/ceedling/test_invoker_helper.rb
index a57dd132..672b39e2 100644
--- a/lib/ceedling/test_invoker_helper.rb
+++ b/lib/ceedling/test_invoker_helper.rb
@@ -60,28 +60,11 @@ def compile_defines(context:, filepath:)
# If this context exists ([:defines][context]), use it. Otherwise, default to test context.
context = TEST_SYM unless @defineinator.defines_defined?( context:context )
- defines = []
-
- # Optionally add a #define symbol that is the test file's sanitized/converted name
- if @configurator.defines_use_test_definition
- # Get filename with no path or extension
- test_def = File.basename(filepath, '.*').strip
- # Replace any non-ASCII characters with underscores
- test_def = test_def.encode("ASCII", "UTF-8", invalid: :replace, undef: :replace, replace: "_")
- # Replace all non-alphanumeric characters (including spaces/punctuation but excluding dashes and underscores) with underscores
- test_def.gsub!(/[^0-9a-z_-]/i, '_')
- # Convert to all caps
- test_def.upcase!
- # Add leading and trailiing underscores unless they already exist
- test_def = test_def.start_with?('_') ? test_def : ('_' + test_def)
- test_def = test_def.end_with?('_') ? test_def : (test_def + '_')
-
- # Add the test filename as a #define symbol to the array
- defines << test_def
- end
+ defines = @defineinator.generate_test_definition( filepath:filepath )
+ defines += @defineinator.defines( subkey:context, filepath:filepath )
# Defines for the test file
- return defines + @defineinator.defines( context:context, filepath:filepath )
+ return defines
end
def tailor_defines(filepath:, defines:)
@@ -89,24 +72,24 @@ def tailor_defines(filepath:, defines:)
# Unity defines
if filepath == File.join(PROJECT_BUILD_VENDOR_UNITY_PATH, UNITY_C_FILE)
- _defines += @defineinator.defines( context:UNITY_SYM )
+ _defines += @defineinator.defines( topkey:UNITY_SYM, subkey: :defines )
# CMock defines
elsif @configurator.project_use_mocks and
(filepath == File.join(PROJECT_BUILD_VENDOR_CMOCK_PATH, CMOCK_C_FILE))
- _defines += @defineinator.defines( context:CMOCK_SYM )
+ _defines += @defineinator.defines( topkey:CMOCK_SYM, subkey: :defines )
# CException defines
elsif @configurator.project_use_exceptions and
(filepath == File.join(PROJECT_BUILD_VENDOR_CEXCEPTION_PATH, CEXCEPTION_C_FILE))
- _defines += @defineinator.defines( context:CEXCEPTION_SYM )
+ _defines += @defineinator.defines( topkey:CEXCEPTION_SYM, subkey: :defines )
# Support files defines
elsif (@configurator.collection_all_support.include?(filepath))
_defines = defines
- _defines += @defineinator.defines( context:UNITY_SYM )
- _defines += @defineinator.defines( context:CMOCK_SYM ) if @configurator.project_use_mocks
- _defines += @defineinator.defines( context:CEXCEPTION_SYM ) if @configurator.project_use_exceptions
+ _defines += @defineinator.defines( topkey:UNITY_SYM, subkey: :defines )
+ _defines += @defineinator.defines( topkey:CMOCK_SYM, subkey: :defines ) if @configurator.project_use_mocks
+ _defines += @defineinator.defines( topkey:CEXCEPTION_SYM, subkey: :defines ) if @configurator.project_use_exceptions
end
# Not a vendor file, return original defines
@@ -158,7 +141,7 @@ def tailor_search_paths(filepath:, search_paths:)
def preprocess_defines(test_defines:, filepath:)
# Preprocessing defines for the test file
- preprocessing_defines = @defineinator.defines( context:PREPROCESS_SYM, filepath:filepath )
+ preprocessing_defines = @defineinator.defines( subkey:PREPROCESS_SYM, filepath:filepath )
# If no preprocessing defines are present, default to the test compilation defines
return (preprocessing_defines.empty? ? test_defines : preprocessing_defines)