How to run multiple debuggers simultaneously in CLion? - c++

I am running a large project in CLion with 10 small projects inside. Each small project has a main function. These small projects should run in sequence, say a->b->c->d->... to ensure the large project run properly.
Currently when I try to debug this large project, I have to manually start the debug session of each small project in sequence, which is annoying.
My question is, is there any convenient way that it can start the debug processes of these small projects for me automatically by one click?

Use "Before Launch" in your Run/Debug configuration to add dependent projects.
From CLion web help:
Before Launch
Specify which tasks must be performed before applying the run/debug configuration. The specified tasks are performed in the order they appear in the list.
Run Another Configuration. Select this option to have another run/debug configuration executed. In the dialog that opens, select the configuration to run.
This option is available only if you have already at least one run/debug configuration in the current project.

Related

Visual Studio 2015 - Pre build event to determine which projects to compile

Motivation
PreBuild to disable compilation of redundant projects for faster compilation cycle.
Background
I have a VS15 ALL solution that contains many projects.
I have a single project, PreBuild, that all the other projects are dependent on, meaning, this PreBuild compiles first.
In addition, we also have a PostBuild project that do some more work once binaries are ready.
All projects are configured to build in Release mode (which is desired).
When a team member wants to release some binaries, he hits F7, Build Solution.
Now, the PreBuild, activates a separate dedicated process that calculates which projects should be released. The nature of the calculation is irrelevant to this discussion.
Problem
Out of the many many projects, it is often the case that only a few projects needs to be released. However, once the PreBuild process is done, ALL the projects are will compile which is very time consuming.
Question
Is it possible, after a solution build had started, to change the released projects?
Suggested unwanted approaches
A developer handpicks only the relevant projects and only build those.
PreBuild Kill & Revive. Once desired projects are calculated, PreBuild kills the VS15 process and activate a cmd compiling only the relevant projects.
Suggested approach
Change file ALL.sln and remove the the unwanted projects.
This would work had I changed that file prior to the process start but I'm not sure it would work if this change occurs during the process.
The simplest way I can think of, while still keeping most of the current infrastructure in place: have a dedicated project which invokes the release build (by calculating dependencies and invoking msbuild) and configure VS so it can be select just that project for a build. All from within your ALL.sln so the rest of the features remain. Steps:
Get rid of the PreBuild/PostBuild projects. I assume the PostBuild you mention is also meant for the actual release builds; if not just leave it there. Note by not requiring all projects to depend on the PreBuild project you already got rid of one maintainance burden.
Add one single project which will do the release building, say ReleaseBuild. Such name is also better than having PreBuild/PostBuild projects since it clearly states the intent of the project. A Makefile project is suitable, though technically it could be as simple as an msbuild file with just one Build target. Configure the build command line to do whatever is needed, i.e. figuring out what to build then build. For the sake of an example: say you use Powershell to do this you would configure the build commandline to be
Powershell -NoProfile -File BuildRelease.ps1 $(Platform)
and BuildRelease.ps1 contains something like
$projectsToRelease = CalculateMyProjectsForRelease()
$platform = $Args[0]
$projectsToRelease | %{& msbuild $_ "/p:Configuration=Release;Platform=$platform"}
In Configuration Manager add an extra Configuration called Deploy or so. This will be used to select what to build: you probably have Debug and Release configurations now already. Those stay in place, and are simply used to build everything. The idea is this extra configuration will take care of building the actual release. This is fairly consistent with the standard way of working in VS and easy to discover and understand for newcomers. Using the checkboxes, make it so that when the Deploy configuration is selected only the ReleaseBuild is built and none of the others whereas when Debug or Release is selected the ReleaseBuild project is not built. Looks like this:
To build a release, select Deploy from the configuration drop down menu in the VS toolbar and hit F7 (or whatever way you use to invoke Build Solution). Any build errors/warnings will be parsed and shown as usual in the Error List.
This is also easy to extend: suppose you only have a couple of release build versions just add more configurations like DeployA DeployB DeployC and adjust the build command line for them.

How do I use Build/Run Configurations in CDT using Eclipse Luna

Could someone please help me with an understanding of the Run Configurations in Eclipse?
Here is the issue I am trying to resolve:
I am developing a c++ application using CDT in Eclipse Luna. I have to two source files, let's say I have file_01.cpp and file_02.cpp. Both of them have main() function. Both of these files are in the same project. Essentially I want to compile and then run a configuration #1 and configuration #2 where the gcc compiler would only compile file_01.cpp and file_02.cpp respectfully. I achieved mixed success where under the same configuration I would apply a Resource Configuration filter, but this is inefficient since I have to do/undo same filtering operation many times. I believe this is what the configurations are used for.
I looked at the eclipse manual, found exact place where this topic is discussed. Unfortunately, there is not much info there and also I think that manual might be outdated (some of the menu items are not where manual claims them to be).
So my understanding is that I create a configuration, include whatever files I want to include, compile that configuration and then run that configuration. Question: How do I do that in Eclipse?
Many thanks!!
You can use build configurations for your purpose. You can exclude/include source files from specific build configurations. Run configurations can then be used to run the exe built using a specific build configuration. You can manage build configurations from the project context menu. You can exclude or include files or folders from a build configuration by choosing the potion from the context menu of the file or folder
I want to thank #Sasikanth for the pointer on the Eclipse. His answer helped me to understand how to do it. I just want to go over the process more in detail and explicitly for the benefit of others.
Situation:
let's say you have two files under the same project: file_01.cpp and file_02.cpp.
file_01.cpp has the following line:
int main(void){
cout<<"this is file_01"<<endl;
return 1;
}
file_02.cpp has the following line:
int main(void){
cout<<"this is file_02"<<endl;
return 1;
}
How do we work with two main() functions in the same project. How do we compile files separately and run them separately?
SOLUTION: (I am using eclipse-luna)
1) First, you want to go PROJECT->BUILD CONFIGURATIONS->MANAGE
A new window will open up and you can create some build profiles, lets say PROFILE_1 and PROFILE_2
2) Next, right click on file_01.cpp and choose RESOURCE CONFIGURATIONS->EXCLUDE FROM BUILD. In there choose whichever build profile you want to associate file_01.cpp. In our case: PROFILE_1. Do the same procedure for file_02.cpp
3) Now you are ready to compile each Build Configuration separately. First you need to choose the configuration you want to compile. go to PROJECT->BUILD CONFIGURATIONS->SET ACTIVE and choose the build config you want to compile. Then prese CTRL-B. Do the same thing for other configurations.
4) Now everything is compiled, but you need to tell Eclipse that it needs to run different configs. go to RUN->RUN CONFIGURATIONS. A new window will open up. Under c/c++ application, add a new profile. on the right hand side you will have an combo box choose "Build Configurations" where you can associate RUN config with BUILD config. This will tell the eclipse what to run and when. Once you create your run configs, press OK.
5) in last step, you want to run a specific configuration. For that, you go to toolbar and look for the "play" button. Right next to it, there will be an arrow. You click on it and choose the configuration you want to run.
That is it in detail!! Again big thanks to #Sasikanth for the pointer on how to do it. Feel free to ask questions is any. Thanks!!

What setting controls whether Visual Studio builds a solution when running tests or not?

We have two distinct team projects, both running in TFS 2013 / VS 2013. One of them always builds the whole solution when asked to run all tests in the Test Explorer window, while the other one does not build anything and just tries to run the tests again.
Sometimes we would like to prevent VS from building the whole solution, since we know it did not change or we just don't want to test against the modified changes, for instance.
What setting controls this behavior? I can't really see any differences between both projects to warrant different test behavior. I'm not using any settings file in neither of them, and this was tested with both projects completely cleaned (like deleting the .suo file for example).
I'm aware of two things that may help.
Set files in your solution to Do not copy or Copy if newer
In Tools -> Options -> Projects and Solutions -> Build and Run check the checkbox: Only build startup projects and dependencies on Run
I'm working with these settings and I don't have the issue thought I cannot guarantee it will help in your case.
To build only few projects, you can create a sub solution - meaning the solution will have only few projects and their dependencies.
To stop building every time, use the tools-options-Projects and solutions->Build and run
check, build only the Startup projects and dependencies
and select "never build" in the drop down "On run, when projects are out of date"

Managed target code requires a '\clr' option : Error

When I try to batch build my project, I encounter this error while I have enabled the clr runtime support.
My project can run with no problem and I only receive this error when I try to make a batch build.
I have made a lot of searched in google but most results are about enabling the clr option.
I'd like to know how I can fix this problem.
This is the kind of problem you'll run into when you make project setting changes while you are debugging your project. Settings are stored per configuration. A common mistake is to make the change for the Debug configuration but forgetting to make the same change for the Release configuration. Kaboom when you then try to get the Release configuration built, as would happen when you use Batch Build.
Go slower. Project + Properties, Configuration Properties, General. Note the combobox labeled "Configuration" in the upper left corner. It probably now says "Active (Debug)". Change it to "Release". And note how the "Common Language Runtime support" setting changes as you flip back and forth. Make them the same, /clr. Use Build + Configuration Manager to make the Release build the default configuration and use Build + Build to build it. Test it.
There might be other settings you've changed that need to be corrected for the Release build as well.

Run a script in eclipse before build

Simply put:
In eclipse how do I run a shell/batch script when I build? I have an external tool that can be run by hand but I want to trigger it when the project is built. Using build variables in the script would be an added bonus.
Why I want this:
I work on multi-platform games for mobile. The teams in the company I'm at use X-Code, Visual Studio, and Eclipse (Momentics) for our games. We want to be able to pick up a phone and see overlay on-top of it with information such as who built it, when it was built, what branch and revision it's from, and what library versions are being used. I've done this with X-Code by running a script on build that dumps some of that information to the resource directory of my game that I can then parse at runtime. It's really simple and I'm up for alternate suggestions if you have them; keeping in mind it must work for the three IDE's our developers use.
Bonus Sugar:
In X-Code we can use build variables which would be super nice to have for eclipse as well. I use them to change to the active cocos2d-x repository and get a git log to tell us when the last commit to that repository was made and by who. If that isn't possible in eclipse I can figure something out.
Thanks in advance!
Add a custom builder to your project: open Project properties from the popup menu, on the builders page add a new Program. That will open a "External tool configuration" page.
There you can define a script to run, and also add parameters, where you can add Eclipse variables, such as ${workspace}, etc.
Be careful though: this will run every time when the incremental project builder runs, and the configuration is shared through version control (so beware of absolute paths).