eval

来自「make debug tool. You can use this tool t」· 代码 · 共 92 行

TXT
92
字号
#                                                                    -*-perl-*-$description = "Test the eval function.";$details = "This is a test of the eval function in GNU make.This function will evaluate inline makefile syntax and incorporate theresults into its internal database.\n";open(MAKEFILE,"> $makefile");print MAKEFILE <<'EOF';define Y  all:: ; @echo $AA  A = BendefX = $(eval $(value Y))$(eval $(shell echo A = A))$(eval $(Y))$(eval A = C)$(eval $(X))EOFclose(MAKEFILE);&run_make_with_options($makefile, "", &get_logfile);# Create the answer to what should be produced by this Makefile$answer = "AA\nBA\n";&compare_output($answer,&get_logfile(1));# Test to make sure defining variables when we have extra scope pushed works# as expected.$makefile2 = &get_tmpfile;open(MAKEFILE,"> $makefile2");print MAKEFILE <<'EOF';VARS = A BVARSET = $(1) = $(2)$(foreach v,$(VARS),$(eval $(call VARSET,$v,$v)))all: ; @echo A = $(A) B = $(B)EOFclose(MAKEFILE);&run_make_with_options($makefile2, "", &get_logfile);# Create the answer to what should be produced by this Makefile$answer = "A = A B = B\n";&compare_output($answer,&get_logfile(1));# Test to make sure eval'ing inside conditionals works properly$makefile3 = &get_tmpfile;open(MAKEFILE,"> $makefile3");print MAKEFILE <<'EOF';FOO = fooall:: ; @echo itdefine Y  all:: ; @echo workedendefifdef BAR$(eval $(Y))endifEOFclose(MAKEFILE);&run_make_with_options($makefile3, "", &get_logfile);$answer = "it\n";&compare_output($answer,&get_logfile(1));&run_make_with_options($makefile3, "BAR=1", &get_logfile);$answer = "it\nworked\n";&compare_output($answer,&get_logfile(1));1;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?