nmake: can a batch file run as part of a make command block, affect the environment of the nmake.exe process?

蹲街弑〆低调 提交于 2020-01-24 18:27:21

问题


I think in nmake if I do this:

 example :
        set value=77
        echo %%value%%

The result will display 77 on the console.

Is there a way for me to invoke a .cmd or .bat file that will affect the environment of the nmake.exe process? Suppose I put the statement set value=77 in a file called "setvalue.cmd". Then change the makefile to this:

 example :
        setvalue
        echo %%value%%

I get:

%value%

Alternatively, if there's a way to set a macro within a command block, that would also work. Or, a way to set the value of a macro from a batch file, even outside a command block.


回答1:


You can create an nmake snippet during makefile pre-processing, and read that in. Assuming batch.cmd outputs valid nmake syntax, then

!if [batch.cmd >makefile.auto]
!error *** Could not create makefile.auto
!endif
!include makefile.auto

You should ensure batch.cmd sets %errorlevel% appropriately (e.g., exit /b 22).

makefile.auto can contain anything, but you would probably want stuff like value=77. A couple of points:

  • Dereference value using nmake syntax ($(value))
  • You can pass parameters to batch.cmd if necessary ([batch.cmd $(OBJECTS) >makefile.auto])



回答2:


No, I don't think so.



来源:https://stackoverflow.com/questions/2806463/nmake-can-a-batch-file-run-as-part-of-a-make-command-block-affect-the-environm

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