windows - Windows GNU Make 在某些情况下会破坏 POSIX 颜色代码,但为什么呢?
问题描述
我在 Windows 10 上的 GNU make 项目有一些问题。我正在尝试在我的 Makefile 中添加 google 单元测试,并开始尝试以下目标:
utest_compile:
@echo Compile unit test
g++ -o Utest.exe $(COMPILE_FLAGS) $(SOURCES)
@echo Compile finished!
utest_run:
@echo Running unit tests
Utest.exe --gtest_color="yes"
@echo Run finished!
utest: utest_compile utest_run
运行utest_complie
和utest_run
单独运行完美,但是当尝试运行时utest
,输出中的颜色代码不知何故变得一团糟,比如[0;32m[ OK ] [mDummytest
以默认颜色打印而不[ OK ] Dummytest
是以绿色打印。
我试图搜索 GNU make 如何解析输出并将其传递,特别是关于虚假目标及其依赖项,但我能找到的任何规则似乎都不适用于这种情况。(例如,将输出存储在变量中或重定向到文件时的规则等)
你知道这里应用了什么样的解析/格式化规则,以及如何防止颜色代码被破坏吗?
编辑 同时我发现了以下内容:这很好用(打印彩色文本):
utest: utest_compile
@echo Run unit tests...
-$(TARGET_DIR)/UTest.exe --gtest_color="yes" > ut.log
@echo Result:
@tail -n 1 ut.log
@echo Unit test execution finished.
但这失败了(打印无色的模糊文本):
utest: utest_compile
@echo Run unit tests...
$(RM) -f ut.log
-$(TARGET_DIR)/UTest.exe --gtest_color="yes" > ut.log
@echo Result:
@tail -n 1 ut.log
@echo Unit test execution finished.
我的怀疑是额外的行 - 使用 rm - 可能在终端模式之间切换。我正在使用 Windows 10 内置的 linux 终端解释器,它很可能仍处于测试阶段,因此它可以解释问题,但我仍然不知道这里的实际细节,我很乐意提供任何信息。
解决方案
推荐阅读
- javascript - webRTC - 视频导致互联网上的呼叫顶部掉线
- apache-kafka - 持久性密钥存储不起作用 kafka 流 2.20
- python - 不同api输入参数的函数调用每次都返回相同的输出,Flask api
- r - 将表从 oracle 导入到 R 时,如何不要舍入我的 keyid
- vue.js - vue.js - 传递选定的选项字符串数据
到 - c# - 从本地映射的工作区文件路径中查找 TFS 服务器文件路径
- javascript - 如何不丢失从父组件到子组件的状态
- php - 使用 Crinsane Laravel 下订单后将购物车产品插入数据库
- sql - ODI 12c 中的性能调优
- c# - 带有按钮的 Windows 窗体隐藏面板仍处于活动状态