Bazel:为cc_binary/cc_test设置运行时环境变量和配置文件位置 [英] Bazel: set runtime environment variable and configuration file location for cc_binary/cc_test

查看:1071
本文介绍了Bazel:为cc_binary/cc_test设置运行时环境变量和配置文件位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Linux上的C ++应用程序中使用odbc ++.以下构建文件用于将库包含为外部依赖项

I am trying to use odbc++ in a C++ application on linux. The following build file is used to include the library as an external dependency

licenses(["notice"])
cc_library(
    name = "lib",
    srcs=["lib/libodbc.so","lib64/libodbc++-mt.so"],
    hdrs=glob(["include/**/*.h","include/*.h"]),
    includes = ["include"],
    visibility = ["//visibility:public"],
    linkstatic = 1,
    data = [ "odbc.ini", "odbcinst.ini" ]
)

我的bash配置文件设置了ODBCINI和OBCDINST,因此可以直接从命令行运行二进制文件.但是,运行bazel测试时未设置环境变量ODBCINI和ODBCINST.

My bash profile has ODBCINI and OBCDINST set so running the binary directly from command line is fine. However, the environment variable ODBCINI and ODBCINST are not set when running bazel test.

总有没有包括配置文件并为其设置运行时环境变量?

Is there anyway to include the configuration files and set the run time environment variables to them?

谢谢

推荐答案

您可以使用--test_env标志在bazel中为测试执行设置环境变量.文档在这里: https://docs.bazel.build/versions/master/command-line-reference.html

You can set environment variables for test execution in bazel with the --test_env flag. The documentation is here: https://docs.bazel.build/versions/master/command-line-reference.html

例如bazel build --test_env ODBCINI=foo //my:test

这篇关于Bazel:为cc_binary/cc_test设置运行时环境变量和配置文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆