Public Group

# How to re-compile only file that changed using Microsoft compiler?

## Recommended Posts

I'm not sure if this is the right place for this question, but I'll give it shot

Using Visual Studio Code, I have the task.json set up to launch a batch file that is set up like follow:

@echo off
call "Z:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86

set INC_PROJECT_PATH="Z:\Asus\Documenti\VS Code\Projects\Packman Clone 1"
set INC_SDL_PATH="Z:\Dependencies\SDL2-2.0.5\SLD2"

set SOURCE1_PATH="Z:\Asus\Documenti\VS Code\Projects\Packman Clone 1\source\*.cpp"
set SOURCE2_PATH="Z:\Asus\Documenti\VS Code\Projects\Packman Clone 1\Engine\*.cpp"

set LIB_SDL_PATH="Z:\Dependencies\SDL2-2.0.5\lib\x86"
set OUTPUT_PATH="Z:\Asus\Documenti\VS Code\Projects\Packman Clone 1\Debug\Pacman.exe"

cl /std:c++latest /W4 /ZI ^
/I %INC_SDL_PATH% /I %INC_PROJECT_PATH% ^
/EHsc %SOURCE1_PATH% %SOURCE2_PATH% ^
/LIBPATH:%LIB_SDL_PATH% SDL2main.lib SDL2.lib ^
/out:%OUTPUT_PATH%

I'm not totally sure about what it's doing and I'm piecing it togeter as I go (trial and error + google), so if I got it right, the *.cpp at the end of those paths,  it means that every time I build it will build all the .cpp that it finds in those 2 paths.

And that doesn't sounds good, so I was wondering, there is a way to tell it to re-compile only the files that have changed?

##### Share on other sites

Any particular reason your not using the IDE to compile your project?  It does this automatically.

##### Share on other sites
1 hour ago, Mike2343 said:

Any particular reason your not using the IDE to compile your project?  It does this automatically.

Yes, I'm using Visual Studio Code, not Visual Studio Community. The reason is it's VERY fast to launch and vastly superior color themes (in my opinion) compared to VS Community

I'd rather spend a week sorting this out once and for all than waiting 15-20sec every time I double click on VS Community...I just need to sort out this compilation matter and then I'm never going back to VS Community

By the way if is a time consuming to explain process no need to explain it to me, pointing me in the right direction (maybe a link) will do

Edited by MarcusAseth

##### Share on other sites

Weird, Community loads in < 10 seconds for me.  But I've read a few places where people were saying it loads slowly for them (mines installed on an SSD maybe that help, who knows).  Also, I think you will be losing time over your life instead of gaining it lol.  You can also download color themes online ;-)

But the cl command for minimal rebuild is /Gm, you'll need /Zi according to my command prompt tests though, /Zi is for debugging information, so maybe only with debug builds?).

Edit:

Also, found this, seems there is an option task.json file you can make: https://blogs.msdn.microsoft.com/vcblog/2016/10/24/building-your-c-application-with-visual-studio-code/

Edit #2: Fixed a few typos.

Edited by Mike2343

##### Share on other sites

Thanks, that was easier than expected!

Also I bet the fact you have VSC on SSD is a major factor, mine is on the hard drive x_x

Regarding VSC styles I don't like the fact that they only change the interior of the editor and rarely match the surrounding of the IDE, and even though VSC Themes plugin solves it the default themes it comes with are not so great (compared to VS Code) and I failed to find user made themes packs online. Also the visual simplicity of VS Code is a factor for me, VS Community clutter my brain with too many panels x_x

Many reasons   Anyway thanks

Edited by MarcusAseth

##### Share on other sites
On 04/02/2018 at 10:51 PM, MarcusAseth said:

Also I bet the fact you have VSC on SSD is a major factor, mine is on the hard drive x_x

Since the issue is resolved, and we're a little more free to drift off topic...

I can't emphasise nearly enough just how urgently you should save up the $150 for a basic SSD. Or better yet, the$230 for a ridiculously fast SSD.

It'll do more for your computer than a fairly significant CPU or GPU upgrade. Life is too short to run spinning platter drives for much other than backups...

##### Share on other sites

I actully have both on my pc, though when I purchased them people where talking about "short lifetime of SSD", so mine is used only to run the OS and everything else has to go in the hard drive. I'm just too afraid to break it

##### Share on other sites
36 minutes ago, MarcusAseth said:

I actully have both on my pc, though when I purchased them people where talking about "short lifetime of SSD", so mine is used only to run the OS and everything else has to go in the hard drive. I'm just too afraid to break it

You should be fine if you put all your software and your coding projects on the SSDs for performance reasons, and also keep a backup on another drive (and offsite, like GitHub or Bitbucket or even Dropbox).  I haven't had any of my SSDs fail..yet.  Knock on wood.

SSDs are just so noticably faster than HDDs, you should use it for anything that needs high random access throughput - loading programs, compiling, etc.  Use the bigger, cheaper HDD for larger files which don't need to be read as frequently or as quickly.

Edited by Nypyren

##### Share on other sites
5 hours ago, MarcusAseth said:

I actully have both on my pc, though when I purchased them people where talking about "short lifetime of SSD", so mine is used only to run the OS and everything else has to go in the hard drive. I'm just too afraid to break it

I have only a SSD (no HDD) in my notebook which I use for both programming and gaming. So far after 3 years of use, the SSD is still alive and running. You should not worry too much about the lifetime difference between SSD and HDD (I know lots of HDDs who eventually failed). Just make a backup independent of which drive you use.

On 2/5/2018 at 7:51 AM, MarcusAseth said:

though VSC Themes plugin solves it the default themes it comes with are not so great

You can tweak lots of colors yourself via the options, starting from a given theme of the Color Theme Editor for Visual Studio 2017.

##### Share on other sites
10 hours ago, MarcusAseth said:

I actully have both on my pc, though when I purchased them people where talking about "short lifetime of SSD", so mine is used only to run the OS and everything else has to go in the hard drive. I'm just too afraid to break it

This is probably going a bit off topic but I'll add my 5 cents.

I've had my 120 GB SSD for around 4 years. According to CrystalDiskInfo it has seen 56 TB of reads, 35 TB of writes, 1700 power on count, 28,110 power on hours (I suppose that makes an average of 16.5 hours per day) and it's still at 88% integrity. This leads me to believe average SSD will become morally and technologically obsolete way before it actually needs to be replaced. My pagefile, OS, all software, most games, and movies are on this SSD and it handles just fine. I did not torrent from it though (HDD has that role).

On a side note, my other HDD with 38,000 power on hours already has some reallocated sectors.

1. 1
2. 2
3. 3
4. 4
frob
13
5. 5

• 16
• 13
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632170
• Total Posts
3004550

×