remake的使用

tech2025-09-24  18

SYNOPSIS

remake [OPTION]... [TARGET]...

OPTIONS

-c, --search-parent 如果一个makefile或者终极目标在当前目录无法找到,remake将会在父目录搜索Makefile.直到找到符合条件的最近的父目录中的Makefile 在这方面,除了-c无需指定目录,选项-c是很类似-C的-! | –post-mortem: 在出现错误时进入调试器。这与另一个选项相同:–debugger –debugger-stop = error-P, --profile: 创建callgrind配置文件输出。 Callgrind输出可与kcachegrind,callgrind_annotate或gprof2dot一起使用以分析数据。 您不仅可以获取时间,还可以查看目标依赖关系的图形--targets 打印出读入的makefile中显式目标名列表--tasks 打印出读入的makefile中含有注释的显式目标名列表。 一个注释可以在目标开始之前以#:开始描述 #: This is the main target all: @echo all here #: Test things check: @echo check here #: Build distribution dist: @echo dist here

Running remake –tasks gives:

all This is the main target check Test things dist Build distribution x, --trace [=FLAGS]: 除正常处理外,还打印调试信息。 如果省略标志,则行为与指定–trace = normal时的行为相同 flags can be one of: normal: basic tracing and shell tracing; this is the defaultread: for tracing all Makefiles read in,noshell: which is like `normal but shell tracing is disabledfull: for maximum tracing -X, --debugger [=TYPE]: 进入调试器 If type is given it may be one of: normal: basic tracing and shell tracing; this is the defaultgoal: for all tracing Makefiles readpreaction like normal but shell tracing is disabledfull: for maximum tracing.fatal: for entering the debugger on a fatal error. The –post-mortem option sets thiserror: for entering the debugger on an error.

The Remake Debugger

remake<<4>> help Command Short Name Aliases ---------------------- ---------- --------- break [TARGET|LINENUM] [all|run|prereq|end]* (b) L cd DIR (C)改变工作目录 comment TEXT (#)调试器不会读取以这个开头的命令 continue [TARGET [all|run|prereq|end]*] (c)继续执行调试后的Makefile,直到另一个断点或停止点。 如果指定了目标,则在continue之前在该目标上设置一个断点。 并可以与break一样对目标的不同阶段设置断点 delete BREAKPOINT_NUMBERS... (d)删除断点 down [AMOUNT] (D)向下移动 AMOUNT 个栈区,AMOUNT默认为1 edit (e)在当前目标进行编辑 expand STRING (x)如果STRING中有变量,扩展变量 finish [AMOUNT] (F)运行到目标完成时(跳过依赖),类似单步调试,AMOUNT指额外运行的次数,默认为0 frame N (f) 从当前目标改变到指定目标上,栈区跳转,N默认为0 help [ command [ subcommand ] (h) ? 帮助信息 info [SUBCOMMAND] (i) list [TARGET|LINE-NUMBER] (l)列出目标信息 load *file-glob* (M)读取指定的makefile next [AMOUNT] (n)运行到下一个认为你感兴趣的目标,如目标的依赖 print {VARIABLE [attrs...]} (p)打印变量的值 pwd (P)打印当前工作目录 quit [exit-status] (q) exit, return 退出remake一层嵌套 run [ARGS] (R) restart 从头开始运行Makefile,没有参数时,使用最后指定的参数(运行时) set OPTION {on|off|toggle} (=)修改调试器的设置相关环境变量 setq VARIABLE VALUE (")设置GNU Make变量,值内的变量定义时不扩展,使用时扩展 setqx VARIABLE VALUE (`)设置GNU Make变量,值内的变量定义在赋值发生之前展开。 shell STRING (!) !! 在debugger中执行shell命令 show [SUBCOMMAND] (S)显示调试器的设置相关环境变量 skip (k)跳过执行您当前目标的其余命令。 source *file-glob* (<)从文件(源文件)读取和运行调试器命令 step [AMOUNT] (s)逐步执行,直到遇到下一个目标。AMOUNT表示步数 target [TARGET-NAME] [info1 [info2...]] (t) up [AMOUNT] (u) 向上移动 AMOUNT 个栈区,AMOUNT默认为1 where [count] (T) backtrace, bt 打印目标的栈,默认打印全部,可以指定count显示最近的几个栈 write [TARGET [FILENAME]] (w) 将目标需要执行的命令写入到文件中 Readline command line editing (emacs/vi mode) is available. For more detailed help, type 'help COMAMND-NAME' or consult the online-documentation.

打印说明

Reading makefiles... Updating makefiles... Updating goal targets... -> (/home/hide_liao/Project/openwrt/include/toplevel.mk:226) 位置信息 prereq: prepare-tmpinfo .config remake<<0>>

->,事件图标 (/home/hide_liao/Project/openwrt/include/toplevel.mk:226),位置信息 prereq: prepare-tmpinfo .config,目标与依赖 remake<<0>>,提示符<0>中的0是命令历史编号。如果支持GNU Readline历史,那在我们输入命令时会增加它,否则它将保持为零。对于每个要重新执行的递归调用,我们将在该数字周围添加另一对尖括号<>。

Here is a list of event icons:

IconEvent->Stopped before checking target prerequisites.暂停在检查目标条件的之前..Stopped after checking target prerequisites.<-Stopped after running target commands.暂停在运行完目标的命令的时候rdAbout to read a Makefile!!Error encountered and --post-mortem flag given. In post-mortem debugging. 出现错误!!--Ran a debugger step of a Makefile target and it’s not one of the above.++Ran a debugger step in a POSIX command and it’s not one of the above.:oA call to the debugger using the $(debugger) function in the Makefile||Finished making the goal target

设置断点

Examples:

break # list all breakpoints break 10 # Break on line 10 of the Makefile we are # currently stopped at break tests # Break on the "tests" target break tests prereq # Break on the "tests" target before dependency checking is done

必须在执行对应目标或行号之前设置断点。 对于目标来设置断点,有三个地方,你可能想停下来;这个名称可以作为最后一个选项提供。

before target prerequisite checking(目标判断是否运行之前): prereqafter target prerequisite checking but before running commands(目标判断是否运行之后,命令运行之前,默认为该项): runafter target is complete(目标命令执行完毕之后): end

删除断点

delete [ bpnumber [bpnumber…] ]

参数为断点号,多个时使用空格分隔。不设置参数时,默认删除所有断点

打印变量

print [variable]

变量无需带$符号,并且大小写敏感

扩展变量

expand string

remake<0> expand MAKE (origin default) MAKE := /tmp/remake/src/./make /tmp/remake/src/Makefile:264: Makefile.in remake<1> print MAKE # note the difference with the print (origin default) MAKE = $(MAKE_COMMAND) remake<2> expand $(MAKE) # Note using $( ) doesn't matter here... /tmp/remake/src/./make # except in output format - no origin info

解析目标

target [target-name] [info1 [info2…]]

target-name是目标的名称,也可以是变量,如@(当前目标)或<(第一个依赖项)。如果省略了目标名称,则使用当前目标。 info可以有下列的选项:

attributes: rule attributesprecious,rule search,and pattern stem commands: 显示要更新目标所需执行的命令depends: 显示目标的依赖,包括order 和 non-order的依赖expand: 类似"commands",但是makefile的变量将会被扩展nonorder: non-order dependenciesorder: “order dependencies”previous:有多个双冒号时的前一个目标名称state: 目标的状态: successully updatedneeds to be updatedfailed to be udatedinvalid, an error of some sort occurred time: 最后修改时间和文件是否被更新。如果目标不是最新的,将会打印“File is very old.”。如果目标是伪目标,则会打印 “File does not exist.”,而不是时间。在某些情况下,您可能会看到“Modification time never checked.”variables: automatically set variables such as @ or <

将目标的命令写到一个文件中

write [target [[filename|here]]]

该命令会将target会执行的命令写入到filename中,如果指定的是here,则不写入文件中,直接在debugger中打印内容。 如:

$ remake -X -f tests/spec/example/simple.Makefile Reading makefiles... Updating makefiles.... Updating goal targets.... -> (/tmp/remake/tests/spec/example/simple.Makefile:2) all: remake<0> write File "/tmp/all.sh" written. remake<1> w all here #!/bin/sh ## /src/external-vcs/github/rocky/remake/tests/spec/example/simple.Makefile:2 ## all: #cd /src/external-vcs/github/rocky/remake echo all here

从文件中读取命令开始运行

source file-glob

Read debugger commands from the glob expansion of file-glob;

file-glob should resolve after glob expansion to single file.

Examples:

source /home/rocky/remake-dbgr.cmds # absolute path source ./remake-dbgr.cmds # relative path source remake-dbgr.cmds # relative path - same as above source ~/remake-dbgr.cmds # "~" is glob expanded source ~/[r]emake-dbgr.cmds # Same as above source ~/remake-dbgr.* # Includes the above, but is an error if not unique

列出目标信息

list [ target ] list line-number | -

列出目标依赖项和目标或行号的命令。 如果没有指定目标名称或行号,则使用当前目标。目标-意思为,将使用目标堆栈上的父目标。

显示与设置调试器的参数

显示参数:

remake<1> show show args -- Show the command-line invocation show basename -- Show if we are to show short or long filenames is off. show commands -- Show the history of commands you typed. show debug -- Show the value of the GNU Make debug mask (set via `--debug` or `-d`) is 3361. show ignore-errors -- Show the value of the GNU Make `--ignore-errors` (or `-i`) flag is off. show keep-going -- Show the value of the GNU Make `--keep-going` (or `-k`) flag is off. show silent -- Show the value of the GNU Make `--silent` (or `-s`) flag is off. show version -- Show the remake version.

设置参数,最后的is off表示当前这个选项的值:

remake<1> set set basename -- Set if we are to show short or long filenames(是否只显示文件名,隐藏路径名) is off. set debug -- Set GNU Make debug mask(设置make的debug掩码) (set via --debug or -d) is 3361. set ignore-errors -- Set value of GNU Make --ignore-errors (or -i) flag is off. set keep-going -- Set value of GNU Make --keep-going (or -k) flag is off. set silent -- Set value of GNU Make --silent (or -s) flags. is off. set variable -- Change a debugger setting

参考

https://remake.readthedocs.io/en/latest/

最新回复(0)