0

I am setting up a Ceedling project and I need to configure the project to use MSVC. I've got everything working except that I don't want fixed paths in this project file as not every developer will have visual studio installed at the same location.

I want to move the visual studio and windows kits to a system environment variable, but I can't seem to get it to work. Someone suggested using <%= ENV['FOOVAR'] %> but that did not seem to do the trick.

Config snippet as follows:

:tools:
  :test_linker:
     :executable: 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\link.exe'
     :name: 'msvc'
     :arguments:
        - "${1}"
        - /OUT:"${2}"
        - /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64"
        - /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64"
Daan Timmer
  • 14,771
  • 6
  • 34
  • 66

2 Answers2

1

In your ceedling project configuration YAML file add the section ":environment:" and define therein a variable that is derived from a windows environmental variable

:environment:
  - foovar: "#{ENV['FOOVAR']}"

Then you can evaluate this variable in your paths like that

:arguments:
  - /LIBPATH:#{ENV['FOOBAR']}/VC/lib/amd64

You can find more details here https://github.com/ThrowTheSwitch/Ceedling/blob/master/docs/CeedlingPacket.md

0

Since there's already an answer to that, here just to give another complete example how you can make use of the environment variable as part of extra -D in the compilation.

in shell: export MY_LOG_LEVEL=LOG_INFO

project.yml

:environment:
  - MY_LOG_LEVEL: "LIBRARY_LOG_LEVEL=#{ENV['MY_LOG_LEVEL']}"

:tools:
  :test_compiler:
     :executable: gcc              #exists in system search path
     :name: 'gcc compiler'
     :arguments:
        - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE               #expands to -I search paths
        - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR   #expands to -I search paths
        - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR  #expands to all -D defined symbols
        - -D#{ENV['MY_LOG_LEVEL']}
        - -c ${1}                       #source code input file (Ruby method call param list sub)
        - -o ${2}                       #object file output (Ruby method call param list sub)
ITW
  • 432
  • 5
  • 12