AW: RE: How to set an env. var. in a sources file?

Hi Shivas,

thanks for your response.

Maybe I was’nt clear enough:

I have several sources files and each sources file sets an individual target name (TARGETPATH=mySpecialName). Now, I’d like to have acces to the ‘individual target name’ (the value of TARGETPATH) after a build happened.

Therefore, I’d like to store $(TARGETNAME) within the sources files in an environment variable during the build process. After the build, I want to use the already set environment variable for further object processing (of mySpecialName.*).

regards,
Dieter

-----Urspr?ngliche Nachricht-----
Von: Shiva_Shankar [mailto:xxxxx@Satyam.com]
Gesendet: Donnerstag, 5. September 2002 12:25
An: NT Developers Interest List
Betreff: [ntdev] RE: How to set an env. var. in a sources file?

Hi,
I think this is what you need to do…

Right click on MyComputer, Properties, settings, advanced,environment
variables and add what ever you want.
regards,
shivas

> ----------
> From: xxxxx@men.de[SMTP:xxxxx@men.de]
> Reply To: NT Developers Interest List
> Sent: Thursday, September 05, 2002 3:12 AM
> To: NT Developers Interest List
> Subject: [ntdev] How to set an env. var. in a sources file?
>
> Hi,
>
> is it possible to set an environment variable whithin a
sources file?
>
> I want to use the $(TARGETNAME) value of a sources file
outside the build
> utility to do some additional action with the generated
object file (e.g.
> copy mydriver.sys). Therefore, I’d like to store $(TARGETNAME) in an
> environment variable which is accessible from the Build Environment
> Console.
>
> Any suggestions?
>
> Thanks in advance!
>
> :)Dieter
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@satyam.com
> To unsubscribe send a blank email to %%email.unsub%%
>
**************************************************************
************
This email (including any attachments) is intended for the
sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others
or copying or
distribution or forwarding of any or all of the contents in
this message is
STRICTLY PROHIBITED. If you are not the intended recipient,
please contact
the sender by email and delete all copies; your cooperation
in this regard
is appreciated.
**************************************************************
************


You are currently subscribed to ntdev as: xxxxx@men.de
To unsubscribe send a blank email to %%email.unsub%%

Dieter,

I’ve never tried it and doubt there is a straightforward way because you
need to set env. var in grandparent process (cmd -> build.exe -> nmake.exe
which processes SOURCES). There are several things you can try. You can
examine resource kit setx utility which is able to change machine or user
environment. However, you’d have to restart command prompt to see changes.
Next you can print $(TARGETNAME) to temp file and later use its contents in
a batch as necessary value. Also, you can simply try “set
myvar=$(TARGETNAME)” command to see if works. As I said, I doubt about it.

External commands can be called using nmake rules in makefile.inc file in
the same directory as SOURCES file. No magic, this file is automatically
included to main makefile during build process. Also, it is necessary to add
target to NTTARGETFILES list. For details please see XP DDK docs. An example
from my old project which builds SoftICE debug info:

makefile.inc:

$(TARGETPATH)$(TARGET_DIRECTORY)$(TARGETNAME).nms:
$(TARGETPATH)$(TARGET_DIRECTORY)$(TARGETNAME).sys
$(NTICE)\nmsym /translate $?

SOURCES:

NTTARGETFILES=$(TARGETPATH)$(TARGET_DIRECTORY)$(TARGETNAME).nms

I would try following (haven’t tested, can be completely wrong):

makefile.inc:

phony_target:
set myvar=$(TARGETNAME)
echo $(TARGETNAME) > myvar.txt

SOURCES:

NTARGETFILES=phony_target

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]


From: xxxxx@men.de[SMTP:xxxxx@men.de]
Reply To: xxxxx@lists.osr.com
Sent: Thursday, September 05, 2002 12:12 PM
To: xxxxx@lists.osr.com
Subject: [ntdev] How to set an env. var. in a sources file?

Hi,

is it possible to set an environment variable whithin a sources file?

I want to use the $(TARGETNAME) value of a sources file outside the build
utility to do some additional action with the generated object file (e.g.
copy mydriver.sys). Therefore, I’d like to store $(TARGETNAME) in an
environment variable which is accessible from the Build Environment
Console.

Any suggestions?

Thanks in advance!

:)Dieter


You are currently subscribed to ntdev as: michal.vodicka@st.com
To unsubscribe send a blank email to %%email.unsub%%

Maybe this will work too:

makefile.inc:

phony_target:
cmd.exe /c <<doit.bat> set myvar=$(TARGETNAME)
do_your_post_processing.exe
<<

phony_target_later:
copy <<postprocess.bat nul> set myvar=$(TARGETNAME)
do_your_post_processing.exe
<
‘phony_target’ should build the ‘doIt.bat’ on the fly.
‘phony_target_later’ generates a batch ‘postProcess.bat’ that you can
call later.

Norbert.
--------
“Pride makes us do things well, but it is love that makes us do them
to perfection. - H. Jackson Brown, Sr.”
---- snip ----
> I would try following (haven’t tested, can be completely wrong):

> makefile.inc:

> phony_target:
> set myvar=$(TARGETNAME)
> echo $(TARGETNAME) > myvar.txt

> SOURCES:

> NTARGETFILES=phony_target

---- snip ----</postprocess.bat></doit.bat>