xaizek / zograscope (License: AGPLv3 only) (since 2018-12-07)
Mainly a syntax-aware diff that also provides a number of additional tools.
Commit b91ee93b614069fee9aa3a7893599dd3bb2de66c

Fix conditionals gluing recipes in Makefiles
Again, recipes were merged into big blobs which prevented matching them
individually.
Author: xaizek
Author date (UTC): 2022-11-29 22:37
Committer name: xaizek
Committer date (UTC): 2022-11-29 22:37
Parent(s): 6b1e7605dbd0b5bfdfd8ebafd656f77b5edeb43c
Signing key: 99DC5E4DB05F6BE2
Tree: e08cf41c12327e041d33b170f9d07afed340baa2
File Lines added Lines deleted
src/make/make-parser.ypp 6 5
tests/make/make-parsing.cpp 30 0
File src/make/make-parser.ypp changed (mode: 100644) (index dfc156f..b4dd3d7)
... ... targets
725 725 ; ;
726 726
727 727 recipes recipes
728 : mid_recipes last_recipe
729 { $$ = tb->append($1, tb->addNode($2, @2, +MakeSType::Recipe)); }
728 : mid_recipes last_recipe { $$ = tb->append($1, $2); }
730 729 ; ;
731 730
732 731 mid_recipes mid_recipes
733 732 : %empty : %empty
734 733 { $$ = tb->addNode({ }, +MakeSType::TemporaryContainer); } { $$ = tb->addNode({ }, +MakeSType::TemporaryContainer); }
735 734 | mid_recipes recipe | mid_recipes recipe
736 { $$ = tb->append($1, tb->addNode($2, @2, +MakeSType::Recipe)); }
735 { $$ = tb->append($1, $2); }
737 736 ; ;
738 737
739 738 recipes_opt recipes_opt
 
... ... recipe
752 751 ; ;
753 752
754 753 last_recipe last_recipe
755 : LEADING_TAB exprs_in_recipe { $$ = $2; }
756 | NL conditional_in_recipe { $$ = $2; }
754 : LEADING_TAB exprs_in_recipe
755 { $$ = tb->addNode($2, @2, +MakeSType::Recipe); }
756 | NL conditional_in_recipe
757 { $$ = $2; }
757 758 ; ;
758 759
759 760 identifier identifier
File tests/make/make-parsing.cpp changed (mode: 100644) (index 49180e5..3834faf)
... ... ifeq ($(VAR),)
73 73 endif endif
74 74 )"); )");
75 75 } }
76
77 TEST_CASE("Conditionals don't mess up recipes", "[make][comparison][parsing]")
78 {
79 diffMake(R"(
80 target:
81 ifeq ($(COND),y)
82 command arg1 \ ## Moves
83 arg2 \ ## Moves
84 arg3 ## Moves
85 do something \
86 else here
87 some other test command ## Moves
88 endif # COND
89 )", R"(
90 target:
91 ifeq ($(COND),y)
92 do something \
93 else here
94 ifeq ($(NEW_COND),y) ## Additions
95 @printf "if block" ## Additions
96 else ## Additions
97 @printf "else block" ## Additions
98 command arg1 \ ## Moves
99 arg2 \ ## Moves
100 arg3 ## Moves
101 some other test command ## Moves
102 endif # NEW_COND ## Additions
103 endif # COND
104 )");
105 }
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/zograscope

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/zograscope

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master