where is the doc about #if exist for NMAKE - nmake

I can use #if exist to test a file does exist or not, but did not find the document via Google. For example, in my makefile for nmake ;
clean:
#if exist $(BIN_DIR) rmdir /S /Q $(BIN_DIR)
#if exist $(OBJ_DIR) rmdir /S /Q $(OBJ_DIR)

You won't find any documentation regarding "#if exist" in nmake documentation. These are plain shell commands.
So just open a cmd window and at the prompt enter "help if". By the way the "#" sign suppresses the echo in a shell script.
Thats's why most of .bat scripts start with "#echo off".

You can find nmake documentation here (I'm surprised you did not find it):
VS 2012:
http://msdn.microsoft.com/en-us/library/dd9y37ha.aspx
VS 2010:
http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.100).aspx
VS 2008:
http://msdn.microsoft.com/en-us/library/dd9y37ha(v=vs.90).aspx
Earlier versions are also available but nmake has not changed much.
Variables that are accessed using the $(VARNAME) syntax are either environment variables, or variables declared inside the makefile itself.
Here's a really simple makefile that declares a variable, and the single rule (ALL) ouputs the PATH (from the environment) then the locally-declared variable.
MY_VAR=12345
ALL:
#echo $(PATH) $(MY_VAR)

Related

Alacritty: run a startup script?

I'm on Windows 10 and trying to run a startup script (vcvars64.bat) to setup the MSVC compiler before using the Alacritty prompt.
I have tried the -e switch with the command and also with the alacritty.yml shell: option, but both options open Alacritty, run the command, then exit.
How do I run a script on startup as the first command then continue into Alacritty?
Thanks,
Matic
What I ended up with is:
Specify program: cmd.exe in Alacritty alacritty.yml:
shell:
program: cmd.exe
Create a shortcut to Alacritty.exe and place it eg. in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ (so that it shows up in Windows search).
In properties for the shortcut, under target, specify:
"C:\Program Files\Alacritty\alacritty.exe" --command "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat >/NUL" && bash.exe
Modify Visual Studio path to whatever you have, and which varsall.bat you want to use.
The tricky part was how sensitive cmd.exe is regarding quotes. Eg., it does not work for me to specify an absolute path to which bash.exe to use, it would fail on the first whitespace in the path no matter how I tried to quote it. So make sure the correct bash.exe is first in your PATH (open plain cmd.exe and run where bash.exe to see order). Another solution is of course to create a shortcut to the bash.exe of your liking to a place without spaces in its path then specify it's absolute path (tested to work).

automating the linking of library to the llc exe

Hi Linux noob here,
I wanted to link the LLC.exe with one of the shared libraries , the thing what I do is in order to make the llc -c to work I have to link them like these
PATH="/usr/local/bin:/usr/bin:/bin:/opt/noob/bin"
LD_LIBRARY_PATH="/opt/noob/lib"
export PATH LD_LIBRARY_PATH
If I give these commands it works , Now I want to automate this so I wrote a this in a .sh (bash script ) file and called it in rc.local file but it does-not work, also I tried to put the above lines in the rc.local still it "llc" doesnt work. Please tell me what I am doing wrong.
I tried giving
echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/noob/bin
is the output
But when I give
echo $LD_LIBRARY_PATH
It gives me nothing. I just want to execute this lines on startup. The huddle is I dont want to edit anything in /etc/ directory. PLEASE HELP ME !!
The first snippet shows that you setting the PATH and LD_LIBRARY_PATH environment variables. PATH is used by the shell to binaries, and LD_LIBRARY_PATH to find libraries when you execute a program. None of those commands are linking anything.
$echo PATH will try to deference the echo variable. If that $ is your prompt then it will print "PATH" not the value of the PATH variable.
This is how you echo variables:
echo $PATH
echo $LD_LIBRARY_PATH

Getting node version via batch script

I am learning both nodeJS and batch scripting and I would like to get the node version using a batch script.
Current code is this:
FOR /F "tokens=* USEBACKQ" %%F IN (`node --version`) DO (
SET NODE_VER=%%F
)
ECHO %NODE_VER%
pause
But I do not understand why this doesn't work. It just freezes after calling command node --version. I also tried calling node -v but same behavior. This exact command works when replacing node --version with python --version. Help!
cmd commands will always first read the local directory for a matching command, then it will go to the environment %path% to search for the command. In this instance, Node exists inside of the %path% variable, but you also have a node.??? file in the local directory and will therefore be used. Therefore the following measures are important:
Never name batch files the same as executables. i.e use my_node_script.cmd
Always try and use the full executable name inside of the batch file node.exe --version and if possible rather use the full path to the executable, should you require a duplicate name such as node inside your working directory. Something like:
"C:\Program Files\nodejs\node.exe" --version
or
"%ProgramFiles%\nodejs\node.exe" --version
Try this:
#ECHO OFF
FOR /F %%F IN ('node.exe --version') DO ECHO %%F
PAUSE
GOTO :EOF

Changes in Environment Variable is not working and applying - Windows 8

Hi I'm working with hugo and I will change the path variable but its not applying. My question is about the settings on path variable that is not working properly when i type to cmd
echo %PATH%
Can you show what was the echo %PATH% output ?
Please take note that you need to make sure that there is no character spaces between the path that you are setting. For example
Incorrect:
C:\Program Files\nodejs\; ;C:\Hugo\bin;
Correct:
C:\Program Files\nodejs\;C:\Hugo\bin;
If it don't works just try to restart your command prompt then type
echo %PATH% output
to see if it works.

/p cmd option is resolved as a drive letter in git-bash

I used to call this command to popup a simple balloon message when gradle build is complete. It had worked fine on cygwin's bash.
notifu /p "Gradle build complete" /m "Now you can take a look at the results" /d 0 > /dev/null
However, after switching to git's bash, the windows-style command line options such as /p /m have become resolved as cygwin drive letters: p:/ m:/. Obviously, notifu couldn't accept them.
Could anybody please tell me why it had been perfectly working on cygwin's bash, but not on git-bash now?
#astrounaut use like this in git-bash:
notifu //p "title" //m "message.."
I used previously (in here) or seen (in that answer) the escape character '^' for Cygwin msys bash.
Try a ^ in front of the /, in order to convince Cygwin that /p isn't a drive path:
notifu ^/p "Gradle build complete" ^/m "Now you can take a look at the results" ^/d 0 > /dev/null

Resources