nmake - simulating eval function

淺唱寂寞╮ 提交于 2019-12-08 08:36:57

问题


I'd like to get value of variable named $(MYVAR)_SOME_SUFFIX in the b.mak makefile. Instead I get "b.mak(2) : fatal error U1001: syntax error : illegal character '$' in macro"

# ---- a.mak ----
all :
    set MYVAR=SOME_PREFIX
    nmake -f b.mak
#--- END ---

# ---- b.mak ----
all:
    @echo $($(MYVAR)_SOME_SUFFIX)
#--- END ---

回答1:


You can sort of do what you want with inline files.

# ---- piotr1.mak ----

all :
nmake -nologo -f piotr2.mak MYVAR=BBB

#--- END ---


# ---- piotr2.mak ----

AAA_SETTING=17
BBB_SETTING=24

AVAR=$(MYVAR)_SETTING


all:
# create and invoke a temporary cmd file
    @<<myecho.cmd
@echo off
setlocal
REM insert nMAKE  macros into environment of the command
set AAA_SETTING=$(AAA_SETTING)
set BBB_SETTING=$(BBB_SETTING)
REM now echo the value of whichever env var is named by the
REM nmake macro, AVAR.
echo %$(AVAR)%
endlocal
<<

#--- END ---

when I run nmake -f piotr1.mak I get the expected value echo'd to the console: 24.



来源:https://stackoverflow.com/questions/801778/nmake-simulating-eval-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!