diff options
author | Akira Yokosawa <akiyks@gmail.com> | 2018-09-29 20:01:46 +0900 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.ibm.com> | 2018-10-01 07:57:10 -0700 |
commit | 83c1004b53ad8680c77089144a48ce69f3e8e45c (patch) | |
tree | b2225d9834c6269b9ad10e9f74f18e6473937a18 /utilities | |
parent | 380ce73fb0f3f73c9bd7bf800c666add34bd9c0d (diff) | |
download | perfbook-83c1004b53ad8680c77089144a48ce69f3e8e45c.tar.gz |
CodeSamples: Exclude meta command lines in building api.h
api.h is built by concatenating several header files including
api-pthreads.h, which has meta commands for the new code snippet
scheme.
This commit adds "sed" scripts to prevent those meta commands
to appear in api.h.
The added pattern "begin{snippet}" in CodeSamples/Makefile
revealed a few issues in gen_snippet_d.pl and top level
Makefile.
Regex handling in gen_snippet_d.pl didn't work as I intended.
The pattern matched "begin{snippet}" (without leading "\").
Fix it by tweaking the patterns and properly using single quotes
around them.
In Makefile, $(shell ...) function uses /bin/sh by default.
By setting a variable "SHELL" in the Makefile, we can override
the default. On Ubuntu, "bash" and "dash" behaves slightly
different in the way the argument '\begin{snippet}' is passed
to grep. For compatibility, we set /bin/bash to SHELL.
Also fix typo in the assignment to SOURCES_OF_LTMS. The typo
caused redundant runs of commands after a build is complete.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
Diffstat (limited to 'utilities')
-rwxr-xr-x | utilities/gen_snippet_d.pl | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/utilities/gen_snippet_d.pl b/utilities/gen_snippet_d.pl index d8e3bc7d..8ba31b56 100755 --- a/utilities/gen_snippet_d.pl +++ b/utilities/gen_snippet_d.pl @@ -18,10 +18,10 @@ my $snippet_key; my $snippet_key_ltms; my $source; -$snippet_key = '\\begin\{snippet\}' ; -$snippet_key_ltms = '\\begin\[snippet\]' ; -@fcvsources = `grep -l -r -F $snippet_key CodeSamples` ; -@fcvsources_ltms = `grep -l -r -F $snippet_key_ltms CodeSamples` ; +$snippet_key = '\begin{snippet}' ; +$snippet_key_ltms = '\begin[snippet]' ; +@fcvsources = `grep -l -r -F '$snippet_key' CodeSamples` ; +@fcvsources_ltms = `grep -l -r -F '$snippet_key_ltms' CodeSamples` ; chomp @fcvsources ; chomp @fcvsources_ltms ; @@ -35,7 +35,7 @@ foreach $source (@fcvsources) { if ($source =~ /\.ltms$/) { next; } - @snippet_commands1 = `grep -F $snippet_key $source` ; + @snippet_commands1 = `grep -F '$snippet_key' $source` ; chomp @snippet_commands1 ; $source =~ m!(.*/[^/]+)/[^/]+! ; $subdir = $1 ; @@ -51,7 +51,7 @@ foreach $source (@fcvsources_ltms) { my @snippet_commands1 ; my $subdir ; my $snippet ; - @snippet_commands1 = `grep -F $snippet_key_ltms $source` ; + @snippet_commands1 = `grep -F '$snippet_key_ltms' $source` ; chomp @snippet_commands1 ; $source =~ m!(.*/[^/]+)/[^/]+! ; $subdir = $1 ; @@ -80,7 +80,7 @@ foreach $source (@fcvsources) { if ($source =~ /\.ltms$/) { next; } - @snippet_commands2 = `grep -F $snippet_key $source` ; + @snippet_commands2 = `grep -F '$snippet_key' $source` ; chomp @snippet_commands2 ; $src_under_sub = $source ; $source =~ m!(.*/[^/]+)/[^/]+! ; @@ -101,7 +101,7 @@ foreach $source (@fcvsources_ltms) { my $src_under_sub ; my $subdir ; my $snippet ; - @snippet_commands2 = `grep -F $snippet_key_ltms $source` ; + @snippet_commands2 = `grep -F '$snippet_key_ltms' $source` ; chomp @snippet_commands2 ; $src_under_sub = $source ; $source =~ m!(.*/[^/]+)/[^/]+! ; |