从 makefile 中的通配符 %.js 中排除 .min.js
Exclude .min.js from wildcard %.js in makefile
我的 makefile 中有一个用于压缩 .js 文件的构建目标,但它正在尝试重新压缩 .min.js 文件。我想从我的 $(wildcard) 文件列表中排除那些 .min.js 文件,但我不知道如何执行此操作。
想法?
目前有这套,returns。min.js 显然。
CSS_MIN := $(patsubst %.css, %.min.css, $(wildcard $(CSS)/*.css))
JS_MIN := $(patsubst %.js, %.min.js, $(wildcard $(JS)/*.js))
使用$(filter-out)
函数(Text Functions):
$(filter pattern…,text)
Returns all whitespace-separated words in text that do match any of the pattern words, removing any words that do not match. The patterns are written using ‘%’, just like the patterns used in the patsubst function above.
$(filter-out pattern…,text)
Returns all whitespace-separated words in text that do not match any of the pattern words, removing the words that do match one or more. This is the exact opposite of the filter function.
For example, given:
objects=main1.o foo.o main2.o bar.o
mains=main1.o main2.o
the following generates a list which contains all the object files not in ‘mains’:
$(filter-out $(mains),$(objects))
所以使用
JS_MIN := $(patsubst %.js, %.min.js, $(filter-out %.min.js,$(wildcard $(JS)/*.js)))
或
JS_MIN := $(filter-out %.min.min.js,$(patsubst %.js, %.min.js, $(wildcard $(JS)/*.js)))
我的 makefile 中有一个用于压缩 .js 文件的构建目标,但它正在尝试重新压缩 .min.js 文件。我想从我的 $(wildcard) 文件列表中排除那些 .min.js 文件,但我不知道如何执行此操作。
想法?
目前有这套,returns。min.js 显然。
CSS_MIN := $(patsubst %.css, %.min.css, $(wildcard $(CSS)/*.css))
JS_MIN := $(patsubst %.js, %.min.js, $(wildcard $(JS)/*.js))
使用$(filter-out)
函数(Text Functions):
$(filter pattern…,text)
Returns all whitespace-separated words in text that do match any of the pattern words, removing any words that do not match. The patterns are written using ‘%’, just like the patterns used in the patsubst function above.
$(filter-out pattern…,text)
Returns all whitespace-separated words in text that do not match any of the pattern words, removing the words that do match one or more. This is the exact opposite of the filter function.
For example, given:
objects=main1.o foo.o main2.o bar.o mains=main1.o main2.o
the following generates a list which contains all the object files not in ‘mains’:
$(filter-out $(mains),$(objects))
所以使用
JS_MIN := $(patsubst %.js, %.min.js, $(filter-out %.min.js,$(wildcard $(JS)/*.js)))
或
JS_MIN := $(filter-out %.min.min.js,$(patsubst %.js, %.min.js, $(wildcard $(JS)/*.js)))