linux - 参见 make 命令和之后所有调用的 make 文件
问题描述
我正在尝试分解一个非常大的代码库的 make 构建系统,但是我无法看到 make 调用的每个命令,因为它调用了当前目录之外的许多目录中的各种 make 文件。我遵循了这个答案和其他各种在不使用 CMake 时执行之前的 make print 命令
尽管上述内容取得了一些进步并且很有启发性,但这不是我需要的本垒打。它提供了查看进行调用的命令的解决方案。这比伟大更好。但是,问题在于之后调用的各种 sub make 命令。我只看到打印的那些命令,没有关于正在发生的事情的附加信息。我试图别名 make 这样
alias make='make SHELL='\''/bin/bash -x'\'''
# or
alias make='make -n'
但是,上面无法用别名替换调用的 make 命令。有没有另一种方法可以剖析大型代码库构建系统?
> make
rmdir --ignore-fail-on-non-empty /somefolder* 2> /dev/null; true
cd /someotherfolder/; make cur-dir=somefolder dirs-to-build=somemorefolders/ env_variable another_variable someMakeRule # no output from this make
make TARGET=someTarget env_variable gdbinit source_dir someMakeRule; # no output from this make
# ...
# output from first top makefile
# ...
make[1]: Nothing to be done for 'someMakeRule'.
解决方案
--trace
您可以使用选项轻松跟踪执行。考虑以下示例,其中有人想只显示干净的输出而没有任何冗长的选项:
$ cat Makefile
all: foo
@echo Done with $@
foo: bar
@echo Done with $@
bar:
@$(MAKE) -f Makefile2 bar
.SILENT:
$ cat Makefile2
bar: baz
@echo Done with $@
baz:
@echo Done with $@
常规构建不允许检查正在发生的事情:
$ make
Done with baz
Done with bar
Done with foo
Done with all
但--trace
会显示正在发生的事情以及原因:
$ make --trace
Makefile:8: target 'bar' does not exist
make -f Makefile2 bar
Makefile2:5: target 'baz' does not exist
echo Done with baz
Done with baz
Makefile2:2: update target 'bar' due to: baz
echo Done with bar
Done with bar
Makefile:5: update target 'foo' due to: bar
echo Done with foo
Done with foo
Makefile:2: update target 'all' due to: foo
echo Done with all
Done with all
推荐阅读
- java - 在 Maven 中包含两个不在同一文件夹结构中的源目录
- css - 使用 Bootstrap 和 flex 同时拉伸和垂直对齐中心?
- grails - ACL Grails 插件
- django - 如何将css和html文件放在django的单个目录中
- kotlin - 设置 Netty(或 Spark)以将 kotlin-js 模块的输出提供为静态
- java - Eclipse 内容辅助在不需要时在构造函数中插入 Java 泛型类型 - 如何禁用?
- vuejs2 - 从指令参数访问组件道具
- react-native - 应用程序因 PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION 而崩溃
- android - MapBox 设置样式回调有时不起作用,mapbox 地图变灰
- c# - BizTalk 自定义管道组件 - 消息行为不一致