What I want is:
Given an array of names, e.g., dependency1, dependency2, .., dependencyN:
Append "_DEP_DIR" to each name, to form, e.g., dependency1_DEP_DIR, .., dependencyN_DEP_DIR. (XXX_DEP_DIR is predefined as a variable which points to the local disk path of each dependency.)
Invoke a particular batch file(setup.bat) of each dependency.
What I tried is:
DEP_NAMES=dependency1 dependency2 dependency3 dependency4 dependency5 dependency6
DEP_DIRS=$(foreach name,$(DEP_NAMES),$(name)_DEP_DIR)
for dependency in $(DEP_DIRS); do \
ECHO Copy $$dependency ; \
ECHO $($$dependency)/installers/windows ; \
"$($$dependency)/installers/windows/setup.bat" ; \
done
Problem
The first echo can successfully display the appended name, e.g., "dependency1_DEP_DIR
". However, $($$dependency)
doesn't work as expected, "/installers/windows
" is printed out, not to say the following call to the batch file.
Toubleshooting
I guess the problem is that the value of my loop counter($$dependency
) happens to be the name of a variable that I need to use($(..)
). And the form($($$dependency)
) is not right(or even not supported?)
Any one got any idea?
Also, if you guys can come up with other ways to meet my requirements which bypass this issue, happy to know that;)