Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile colorizing improvement: colorize at the beginning of line, handling the '\' symbol and other. #27293

Merged
merged 3 commits into from Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 15 additions & 7 deletions extensions/make/syntaxes/Makefile.json
Expand Up @@ -15,6 +15,9 @@
{
"include": "#comment"
},
{
"include": "#variables"
},
{
"include": "#variable-assignment"
},
Expand Down Expand Up @@ -42,7 +45,7 @@
"name": "punctuation.definition.comment.makefile"
}
},
"end": "\\n",
"end": "(?=[^\\\\])$",
"name": "comment.line.number-sign.makefile",
"patterns": [
{
Expand Down Expand Up @@ -322,12 +325,12 @@
"name": "punctuation.separator.key-value.makefile"
}
},
"end": "^(?!\\t)",
"end": "[^\\\\]$",
"name": "meta.scope.target.makefile",
"patterns": [
{
"begin": "\\G",
"end": "^",
"end": "(?=[^\\\\])$",
"name": "meta.scope.prerequisites.makefile",
"patterns": [
{
Expand Down Expand Up @@ -426,11 +429,11 @@
"include": "#variables"
},
{
"match": "\\G(MAKEFILES|VPATH|SHELL|MAKESHELL|MAKE|MAKELEVEL|MAKEFLAGS|MAKECMDGOALS|CURDIR|SUFFIXES|\\.LIBPATTERNS)(?=\\s*\\))",
"match": "(?<=\\()(MAKEFILES|VPATH|SHELL|MAKESHELL|MAKE|MAKELEVEL|MAKEFLAGS|MAKECMDGOALS|CURDIR|SUFFIXES|\\.LIBPATTERNS)(?=\\s*\\))",
"name": "variable.language.makefile"
},
{
"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",
"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",
"beginCaptures": {
"1": {
"name": "support.function.$1.makefile"
Expand All @@ -449,8 +452,13 @@
]
},
{
"begin": "\\G(origin|flavor)\\s(?=[^\\s)]+\\s*\\))",
"begin": "(?<=\\()(origin|flavor)\\s(?=[^\\s)]+\\s*\\))",
"contentName": "variable.other.makefile",
"beginCaptures": {
"1": {
"name": "support.function.$1.makefile"
}
},
"end": "(?=\\))",
"name": "meta.scope.function-call.makefile",
"patterns": [
Expand All @@ -460,7 +468,7 @@
]
},
{
"begin": "\\G(?!\\))",
"begin": "(?<=\\()(?!\\))",
"end": "(?=\\))",
"name": "variable.other.makefile",
"patterns": [
Expand Down
38 changes: 24 additions & 14 deletions extensions/make/test/colorize-fixtures/makefile
@@ -1,31 +1,41 @@
.PHONY: all
all: hello

hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello
.PHONY: hello
hello: main.o factorial.o \
hello.o $(first) $($(filter second,second)) \
# This is a long \
comment inside prerequisites.
g++ main.o factorial.o hello.o -o hello

# There are a building steps \
below. And the tab is at the beginning of this line.

main.o: main.cpp
g++ -c main.cpp
g++ -c main.cpp

factorial.o: factorial.cpp
g++ -c factorial.cpp
g++ -c factorial.cpp $(fake_variable)

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

.PHONY: clean
clean:
rm *o hello
rm *o hello

define defined
$(info Checkng existance of $(1))
$(if ifeq "$(flavor $(1))" "undefined",0,1)
$(info Checking existance of $(1) $(flavor $(1)))
$(if $(filter undefined,$(flavor $(1))),0,1)
endef

ifeq ($(call defined,TOP_DIR),0)
TOP_DIR must be set before including paths.mk
ifeq ($(strip $(call defined,TOP_DIR)),0)
$(info TOP_DIR must be set before including paths.mk)
endif

include $(TOP_DIR)3rdparty.mk
-include $(TOP_DIR)3rdparty.mk

ifeq ($(call defined,CODIT_DIR),0)
CODIT_DIR must be set in $(TOP_DIR)3rdparty.mk
ifeq ($(strip $(call defined,CODIT_DIR)),0)
$(info CODIT_DIR must be set in $(TOP_DIR)3rdparty.mk)
endif