我刚开始使用Travis-CI,而我开始使用的C++项目使用的是GNU Makefile,makefile包含许多函数,其中一个调用其他函数。我注意到在Travis-CI日志中,此函数没有成功调用其他函数,而是留下了一个空格,这会导致构建失败。尽管它可以在任何计算机上运行。
该函数为:
define Compile
mkdir -p $(@D)
if [[ $(2) == Linking ]]; then \
$(call Print,$(2) $(@F),$(WIDTH)); \
else \
$(call PrintCpp,$(2) $(@F),$(WIDTH)); \
fi
$(1) 2> $@.log; \
RESULT=$$?; \
if [ $$RESULT -ne 0 ]; then \
$(cross); \
else \
$(check); \
fi; \
cat $@.log; \
rm -f $@.log
endef调用的函数包括:
define Line =
$(shell printf '%0.1s' "$(2)"{1..$(1)})
endef
define Print
var="$(1)"; \
width="$(2)";\
printf '%s%*.*s' "$$var" 0 $$(($$width - $${#var} - 1)) "$(call
Line,$(2),.)"
endef
define PrintCpp
var="$(1)"; \
var=$${var%.*}.cpp; \
width="$(2)";\
printf '%s%*.*s' "$$var" 0 $$(($$width - $${#var} - 1)) "$(call
Line,$(2),.)"
endef
define check =
printf "%b\n" "$(OK_COLOR)\xE2\x9C\x94 $(NO_COLOR)"
endef
define cross =
printf "%b\n" "$(ERR_COLOR)\xE2\x9D\x8C $(NO_COLOR)"
endef可以在以下位置找到该项目的GitHub:https://github.com/LuxAtrumStudio/Pessum
Travis-CI日志在这里:https://travis-ci.org/LuxAtrumStudio/Pessum/builds/256427744
发布于 2018-07-11 16:08:08
我遇到了一个非常类似的问题,这是因为Travis在默认情况下仍然使用不推荐的Ubuntu Trusty发行版。Trusty只有GNU Make版本3,而我们要求GNU Make > 4。
当我将Travis切换到Ubuntu Xenial时,通过在我的.travis.yml中添加以下内容,我的问题得到了解决
dist: xenial在从Trusty转换到Xenial之前,make -v在GNU Make 3.81工作。转换后,make -v现在在GNU Make 4.1工作
切换到Xenial可能需要进行一些额外的更改。例如,我不得不将我的Python版本从3.4升级到3.7。
https://stackoverflow.com/questions/45260058
复制相似问题