Is there any way to say that开发者_如何学运维 if prerequisite for the given target doesn't exist then ignore that target?
For instance, I have the following set of folders
chrome_src_folders := $(chrome_src_folder)/content/* \
$(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*
This is where I use it
$(jar_path): $(chrome_src_folders)
zip -urq $(jar_path) $(chrome_src_folders)
Basically skin or locale may very well not be there, which will give me a nice error.
How to avoid that error and make the chrome_src_folders
mandatory? or should I filter somehow chrome_src_folders
and leave only those which exist?
There's more than one way to do this; the simplest is to filter the list using wildcard
chrome_src_folders := $(wildcard $(chrome_src_folder)/content/* \
$(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*)
Two thoughts; Since the skin and locale folders are optional, do you need to call them about as dependencies? Let the build commands take care of them if they need to. So something like:
chrome_content_folder := $(chrome_src_folder)/content/*
chrome_content_optional := $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*
$(jar_path): $(chrome_content_folder)
zip -urq $(jar_path) $(chrome_content_folder) $(chrome_content_optional)
If you have to have the right folders on the dependency line, so you catch errors, I would write some macros that define when and how you require them. Then update your targets accordingly to only require those directories when you know they are required.
精彩评论