So, for some reason the .bat files don't work properly for me as well. I'm not sure why, but their effects only last in that cmd window. That is, if I open a cmd window and add something to the path, that addition can only be used in that cmd window. So if I close it and relaunch cmd, the path resets.
Because of this reason, I made some changes to the batch files. I'm doing this in the C:/HandmadeHero folder. So I put a shortcut to it on the desktop. Then inside that (where you put the handmade folder), I have a setupHandmade.bat file with the following code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | REM Start
@echo off
subst w: c:/HandmadeHero
REM subst the fake drive
w:
REM go inside w:/handmade/code and call build.bat
cd handmade
cd code
call build.bat
start notepad++ handmade.cpp
cd ..
cd ..
cd build
REM Call devenv with the exe name.
devenv win32_handmade.exe
REM End
|
This does everything for me. It:
1. Creates the w: drive.
2. Runs the build.bat
3. Opens my editor of choice
4. Run devenv with the require argument to load the solution.
Now, as I said, the changes made in the PATH aren't sticky, so if I run the build.bat from inside Notepadd++, it wouldn't work because everything shell.bat does has been reset. So, I run shell.bat everytime from inside the build.bat batch file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | REM Start
@echo off
REM make sure the command line is in w:/
c:
w:
cd w:/
REM Run shell.bat as its effects only last in that cmd window
cd handmade
cd misc
call shell.bat
cd ..
cd code
REM Do the building.
set CommonCompilerFlags=-MTd -nologo -Gm- -GR- -EHa- -Od -Oi -WX -W4 -wd4201 -wd4100 -wd4189 -wd4505 -DHANDMADE_INTERNAL=1 -DHANDMADE_SLOW=1 -DHANDMADE_WIN32=1 -FC -Z7
set CommonLinkerFlags= -incremental:no -opt:ref user32.lib gdi32.lib winmm.lib
REM TODO - can we just build both with one exe?
IF NOT EXIST ..\..\build mkdir ..\..\build
pushd ..\..\build
REM 32-bit build
REM cl %CommonCompilerFlags% ..\handmade\code\win32_handmade.cpp /link -subsystem:windows,5.1 %CommonLinkerFlags%
REM 64-bit build
del *.pdb > NUL 2> NUL
cl %CommonCompilerFlags% ..\handmade\code\handmade.cpp -Fmhandmade.map -LD /link -incremental:no -opt:ref -PDB:handmade_%random%.pdb -EXPORT:GameGetSoundSamples -EXPORT:GameUpdateAndRender
cl %CommonCompilerFlags% ..\handmade\code\win32_handmade.cpp -Fmwin32_handmade.map /link %CommonLinkerFlags%
popd
REM End
|
New CMD Calls:
1) start :- execute the argument and give back control to the batch file.
2) call:- call a batch file from another batch file and tell windows that after the child batch file completes, the parent batch file must continue
3) REM: remark. Like comments.