⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parallelism

📁 make的源代码
💻
字号:
#                                                                    -*-perl-*-$description = "Test parallelism (-j) option.";$details = "This test creates a makefile with two double-colon defaultrules.  The first rule has a series of sleep and echo commandsintended to run in series.  The second and third have just anecho statement.  When make is called in this test, it is giventhe -j option with a value of 4.  This tells make that it maystart up to four jobs simultaneously.  In this case, since thefirst command is a sleep command, the output of the secondand third commands will appear before the first if indeedmake is running all of these commands in parallel.";if (!$parallel_jobs) {  return -1;}if ($vos) {  $delete_command = "delete_file -no_ask";  $sleep_command = "sleep -seconds";}else {  $delete_command = "rm -f";  $sleep_command = "sleep";}open(MAKEFILE,"> $makefile");print MAKEFILE <<"EOF";all : def_1 def_2 def_3def_1 : ; \@echo ONE; $sleep_command 3 ; echo TWOdef_2 : ; \@$sleep_command 2 ; echo THREEdef_3 : ; \@$sleep_command 1 ; echo FOUREOFclose(MAKEFILE);&run_make_with_options($makefile, "-j 4", &get_logfile);$answer = "ONE\nFOUR\nTHREE\nTWO\n";&compare_output($answer, &get_logfile(1));# Test parallelism with included files.  Here we sleep/echo while# building the included files, to test that they are being built in# parallel.$makefile2 = &get_tmpfile;open(MAKEFILE,"> $makefile2");print MAKEFILE <<"EOF";all: 1 2; \@echo success-include 1.inc 2.inc1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@2.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@EOFclose(MAKEFILE);&run_make_with_options("$makefile2", "-j 4", &get_logfile);$answer = "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n";&compare_output($answer, &get_logfile(1));unlink('1.inc', '2.inc');# Test parallelism with included files--this time recurse first and make# sure the jobserver works.$makefile3 = &get_tmpfile;open(MAKEFILE,"> $makefile3");print MAKEFILE <<"EOF";recurse: ; \@\$(MAKE) --no-print-directory -f $makefile3 INC=yes allall: 1 2; \@echo successINC = noifeq (\$(INC),yes)-include 1.inc 2.incendif1.inc: ; \@echo ONE.inc; $sleep_command 2; echo TWO.inc; echo "1: ; \@echo ONE; $sleep_command 2; echo TWO" > \$\@2.inc: ; \@$sleep_command 1; echo THREE.inc; echo "2: ; \@$sleep_command 1; echo THREE" > \$\@EOFclose(MAKEFILE);&run_make_with_options("$makefile3", "-j 4", &get_logfile);$answer = "ONE.inc\nTHREE.inc\nTWO.inc\nONE\nTHREE\nTWO\nsuccess\n";&compare_output($answer, &get_logfile(1));unlink('1.inc', '2.inc');1;

⌨️ 快捷键说明

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