开发者

Generating dependencies for a makefile

I'm trying to use a makefile to generate assets for web application. I have a script which generates dependencies for a开发者_开发问答 given CSS or JS file as a list of filenames. How can I modify it and use in makefile?

UPD: Here's what I came up with for CSS. It's tailored for our workflow, we use lots of CSS imports in development environment.

#CSS_SRCs should contain only import directives
CSS_SRC = base.css base-inner.css
CSS_MIN = $(CSS_SRC:.css=.min.css)
#CSS compression tool of your choice 
CSS_COMPRESSOR=cat

%.min.css:
    $(CSS_COMPRESSOR) $^ > $@

all: $(CSS_MIN)

%.d: %.css
    rm -f $@; \
    printf '$*.min.css $@: ' >> $@; \
    sed -e 's|@import url(\"\([^\"]*\)\");|\1|' $< | tr '\n' ' '>> $@

include $(CSS_SRC:.css=.d)

With JavaScripts it's a little bit trickier cause I need to pull dependencies out of Google Closure library.


Write the dependencies out as 'make' rules, and then include the file in the Makefile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜