Skip to content

Commit 7f19126

Browse files
authored
Merge pull request #27293 from fadeevab/master
Makefile colorizing improvement: colorize at the beginning of line, handling the '\' symbol and other.
2 parents b2aebcd + 5e72e9e commit 7f19126

File tree

3 files changed

+903
-60
lines changed

3 files changed

+903
-60
lines changed

extensions/make/syntaxes/Makefile.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
{
1717
"include": "#comment"
1818
},
19+
{
20+
"include": "#variables"
21+
},
1922
{
2023
"include": "#variable-assignment"
2124
},
@@ -43,7 +46,7 @@
4346
"name": "punctuation.definition.comment.makefile"
4447
}
4548
},
46-
"end": "\\n",
49+
"end": "(?=[^\\\\])$",
4750
"name": "comment.line.number-sign.makefile",
4851
"patterns": [
4952
{
@@ -323,12 +326,12 @@
323326
"name": "punctuation.separator.key-value.makefile"
324327
}
325328
},
326-
"end": "^(?!\\t)",
329+
"end": "[^\\\\]$",
327330
"name": "meta.scope.target.makefile",
328331
"patterns": [
329332
{
330333
"begin": "\\G",
331-
"end": "^",
334+
"end": "(?=[^\\\\])$",
332335
"name": "meta.scope.prerequisites.makefile",
333336
"patterns": [
334337
{
@@ -427,11 +430,11 @@
427430
"include": "#variables"
428431
},
429432
{
430-
"match": "\\G(MAKEFILES|VPATH|SHELL|MAKESHELL|MAKE|MAKELEVEL|MAKEFLAGS|MAKECMDGOALS|CURDIR|SUFFIXES|\\.LIBPATTERNS)(?=\\s*\\))",
433+
"match": "(?<=\\()(MAKEFILES|VPATH|SHELL|MAKESHELL|MAKE|MAKELEVEL|MAKEFLAGS|MAKECMDGOALS|CURDIR|SUFFIXES|\\.LIBPATTERNS)(?=\\s*\\))",
431434
"name": "variable.language.makefile"
432435
},
433436
{
434-
"begin": "\\G(subst|patsubst|strip|findstring|filter(-out)?|sort|word(list)?|firstword|lastword|dir|notdir|suffix|basename|addsuffix|addprefix|join|wildcard|realpath|abspath|info|error|warning|shell|foreach|if|or|and|call|eval|value|file|guile)\\s",
437+
"begin": "(?<=\\()(subst|patsubst|strip|findstring|filter(-out)?|sort|word(list)?|firstword|lastword|dir|notdir|suffix|basename|addsuffix|addprefix|join|wildcard|realpath|abspath|info|error|warning|shell|foreach|if|or|and|call|eval|value|file|guile)\\s",
435438
"beginCaptures": {
436439
"1": {
437440
"name": "support.function.$1.makefile"
@@ -450,8 +453,13 @@
450453
]
451454
},
452455
{
453-
"begin": "\\G(origin|flavor)\\s(?=[^\\s)]+\\s*\\))",
456+
"begin": "(?<=\\()(origin|flavor)\\s(?=[^\\s)]+\\s*\\))",
454457
"contentName": "variable.other.makefile",
458+
"beginCaptures": {
459+
"1": {
460+
"name": "support.function.$1.makefile"
461+
}
462+
},
455463
"end": "(?=\\))",
456464
"name": "meta.scope.function-call.makefile",
457465
"patterns": [
@@ -461,7 +469,7 @@
461469
]
462470
},
463471
{
464-
"begin": "\\G(?!\\))",
472+
"begin": "(?<=\\()(?!\\))",
465473
"end": "(?=\\))",
466474
"name": "variable.other.makefile",
467475
"patterns": [
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1+
.PHONY: all
12
all: hello
23

3-
hello: main.o factorial.o hello.o
4-
g++ main.o factorial.o hello.o -o hello
4+
.PHONY: hello
5+
hello: main.o factorial.o \
6+
hello.o $(first) $($(filter second,second)) \
7+
# This is a long \
8+
comment inside prerequisites.
9+
g++ main.o factorial.o hello.o -o hello
10+
11+
# There are a building steps \
12+
below. And the tab is at the beginning of this line.
513

614
main.o: main.cpp
7-
g++ -c main.cpp
15+
g++ -c main.cpp
816

917
factorial.o: factorial.cpp
10-
g++ -c factorial.cpp
18+
g++ -c factorial.cpp $(fake_variable)
1119

12-
hello.o: hello.cpp
13-
g++ -c hello.cpp
20+
hello.o: hello.cpp \
21+
$(Colorizing with tabs at the beginning of the second line of prerequisites)
22+
g++ -c hello.cpp -o $@
1423

24+
.PHONY: clean
1525
clean:
16-
rm *o hello
26+
rm *o hello
1727

1828
define defined
19-
$(info Checkng existance of $(1))
20-
$(if ifeq "$(flavor $(1))" "undefined",0,1)
29+
$(info Checking existance of $(1) $(flavor $(1)))
30+
$(if $(filter undefined,$(flavor $(1))),0,1)
2131
endef
2232

23-
ifeq ($(call defined,TOP_DIR),0)
24-
TOP_DIR must be set before including paths.mk
33+
ifeq ($(strip $(call defined,TOP_DIR)),0)
34+
$(info TOP_DIR must be set before including paths.mk)
2535
endif
2636

27-
include $(TOP_DIR)3rdparty.mk
37+
-include $(TOP_DIR)3rdparty.mk
2838

29-
ifeq ($(call defined,CODIT_DIR),0)
30-
CODIT_DIR must be set in $(TOP_DIR)3rdparty.mk
39+
ifeq ($(strip $(call defined,CODIT_DIR)),0)
40+
$(info CODIT_DIR must be set in $(TOP_DIR)3rdparty.mk)
3141
endif

0 commit comments

Comments
 (0)