[英]Environment variable in YAML file for Ceedling
I am setting up a Ceedling project and I need to configure the project to use MSVC.我正在设置一个Ceedling项目,我需要将该项目配置为使用 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.
除了我不想在这个项目文件中使用固定路径之外,我已经让一切正常工作,因为并非每个开发人员都会在同一位置安装 Visual Studio。
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.我想将 Visual Studio 和 Windows 工具包移动到系统环境变量,但我似乎无法让它工作。 Someone suggested using
<%= ENV['FOOVAR'] %>
but that did not seem to do the trick.有人建议使用
<%= ENV['FOOVAR'] %>
但这似乎没有用。
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"
In your ceedling project configuration YAML file add the section ":environment:" and define therein a variable that is derived from a windows environmental variable 在ceedling项目配置YAML文件中,添加“:environment:”部分,并在其中定义从Windows环境变量派生的变量
: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 您可以在这里找到更多详细信息https://github.com/ThrowTheSwitch/Ceedling/blob/master/docs/CeedlingPacket.md
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.既然已经有了答案,这里只是给出另一个完整的例子,你可以如何在编译中使用环境变量作为额外 -D 的一部分。
in shell: export MY_LOG_LEVEL=LOG_INFO
在外壳中:
export MY_LOG_LEVEL=LOG_INFO
project.yml项目.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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.