Makefile: ignore precondition if none exists

Is it possible to say that if the precondition for this goal does not exist, then ignore this goal?

For example, I have the following set of folders

chrome_src_folders := $(chrome_src_folder)/content/* \ $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/* 

Here i use it

 $(jar_path): $(chrome_src_folders) zip -urq $(jar_path) $(chrome_src_folders) 

Basically, the skin or locale may not be there, which will give me a good mistake. How to avoid this error and make chrome_src_folders mandatory? or should I somehow filter the chrome_src_folders and leave only those that exist?

+4
source share
2 answers

Two thoughts; Since folders of skins and locales are optional, do I need to call them dependent? Let build teams 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 the correct folders in the dependency line so that you break errors, I would write several macros that determine when and how you require them. Then update your goals so that they only require directories when you know that they are required.

0
source

There is more than one way to do this; the easiest way is to filter the list using wildcard

 chrome_src_folders := $(wildcard $(chrome_src_folder)/content/* \ $(chrome_src_folder)/locale/* $(chrome_src_folder)/skin/*) 
+3
source

Source: https://habr.com/ru/post/1309117/


All Articles