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

Cannot use variables in the defines sction in project.yml #630

Closed
tiagomanczak opened this issue Sep 9, 2021 · 1 comment
Closed

Cannot use variables in the defines sction in project.yml #630

tiagomanczak opened this issue Sep 9, 2021 · 1 comment

Comments

@tiagomanczak
Copy link

I want to pass defines to Ceedling using variables like in my project file below:

---

# Notes:
# Sample project C code is not presently written to produce a release artifact.
# As such, release build options are disabled.
# This sample, therefore, only demonstrates running a collection of unit tests.
:environment:
    - my_test_define: "{`echo | set /p= %MY_DEFINE%`}"

:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: build
#  :release_build: TRUE
  :test_file_prefix: test_
  :which_ceedling: gem
  :default_tasks:
    - test:all

#:release_build:
#  :output: MyApp.out
#  :use_assembly: FALSE

:environment:

:extension:
  :executable: .out

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - src/**
  :support:
    - test/support

:defines:
  # 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)
  :common: &common_defines []
  :test:
    - *common_defines
    - TEST
    - "#{ENV['MY_TEST_DEFINE']}"
  :test_preprocess:
    - *common_defines
    - TEST
    - "#{ENV['MY_TEST_DEFINE']}"

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8
    bool:     UINT8

:gcov:
    :html_report: true # Enables the output of an HTML report for utils:gcov
    :html_report_type: basic  # Options are 'basic' or 'detailed'.
    :xml_report: false # Enables the output of an XML report for utils:gcov

#:tools:
# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use

# LIBRARIES
# These libraries are automatically injected into the build process. Those specified as
# common will be used in all types of builds. Otherwise, libraries can be injected in just
# tests or releases. These options are MERGED with the options in supplemental yaml files.
:libraries:
  :placement: :end
  :flag: "${1}"  # or "-L ${1}" for example
  :common: &common_libraries []
  :test:
    - *common_libraries
  :release:
    - *common_libraries

:plugins:
  :load_paths:
    - "#{Ceedling.load_path}"
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
...

But when I call the command ceedling on this I get the following error message, where we can see the define was not resolved by ceedling and it is still -D#{ENV['MY_TEST']} and not the content of the Environment Variable as I expected like -DMY_DEFINE_A.

Test 'test_check_define.c'
--------------------------
<command-line>: error: macro names must be identifiers
<command-line>: error: macro names must be identifiers
ERROR: Shell command failed.
> Shell executed command:
'gcc.exe -E -MM -MG -I"C:/Ruby25/lib/ruby/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src" -I"C:/Ruby25/lib/ruby/gems/2.5.0/gems/ceedling-0.31.1/vendor/cmock/src" -I"build/test/mocks" -I"test" -I"test/support" -I"src" -DTEST -D#{ENV['MY_TEST']} -DTEST -D#{ENV['MY_TEST']} -DGNU_COMPILER "build/temp/_test_check_define.c"'
> Produced output:
_test_check_define.o: build/temp/_test_check_define.c \
 C:/Ruby25/lib/ruby/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
 C:/Ruby25/lib/ruby/gems/2.5.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \
 @@@@unity.h
> And exited with status: [1].

rake aborted!
ShellExecutionException: ShellExecutionException
c:/Ruby25/bin/ceedling:23:in `load'
c:/Ruby25/bin/ceedling:23:in `<main>'
Tasks: TOP => default => test:all
(See full trace by running task with --trace)
ERROR: Ceedling Failed

For other sections line project or paths it the same approach with variables works, but for the defines not. How can I get it working for the defines?

@mkarlesky
Copy link
Member

This long ago requested feature will be implemented with a coming pre-release version of the latest Ceedling as discussed in #879.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants