CMake custom clean commands - command

In my CMake project I'd like to have some custom behavior happen when the clean target is run. However, if I do
add_dependencies(clean extra-clean)
it fails with
add_dependencies Adding dependency to non-existent target: clean
Is it even possible to have custom clean behavior?
EDIT: I am running some external tools as part of the build. These tools generate lots of files, but they can be cleaned up simply by asking the tool to do so. Ideally, I could add a custom target to the clean target to call the tool to do its cleanup.

What is the custom behavior you are looking for? If you need to remove files you can use
set_directory_properties.

Related

How can i change Configuration Properties of a VS Solution using Powershell?

I am compiling a solution and want to not include some projects in the build.
I can manually go to the solution properties and unmark the build check box for those projects , but i am automating this , so is there a way in powershell i can set certain projects as not to build ?
Instead building the solution you can build only the projects from the solution you want to build. Building is not really related to PowerShell. I suppose you use .NET Core that build the solution file. dotnet build is able to build a single project. You can chain dotnet build commands to builds each individual project you want, and exclude some of them.

How to add predefines to the .cproject file after running a Build Target

I'm trying to import a C project to eclipse (CDT) that is managed by waf. There is a list of predefines generated by waf (when running ./waf configure). That list has to be imported to Project->Properties->C/C++ General/Paths and Symbols/Symbols/GNU C so that the indexer knows about them and does not print errors. That list (when using the GUI) is stored to the .cproject file. I created a Build Target that runs ./waf configure and stores the list to a file named DEFINES.txt. How do I automatically update the list of .cproject with the values of DEFINES.txt after running the Build Target?
I thought about the following solutions and their follow-up problems:
Solution: Writing a plug-in.
Problem: What is the appropriate extension point?
Solution: Writing an external program that calls ./waf configure reads DEFINES.txt and writes the list to .cproject. That program replaces the old Build Target.
Problem: How safe is this? Am I allowed to change the .cproject file by an external program without causing any problems?
Solution: Implementing the .cproject updating algorithm in wscript file.
Problem: This is not a solution for me, because the project is used by others, too, that do not use eclipse as IDE. So the modified wscript will cause errors if the other developers want to build the project.
Does anybody have better ideas or some advice?
Here is how to go about it:
Writing a plug-in: What I recommend you do is write an extension to the LanguageSettingsProvider. The FAQ has some more info, but the summary is that provider does:
This extension point is used to contribute a new Language Settings
Provider. A Language Settings Provider is used to get additions to
compiler options such as include paths (-I) or preprocessor defines
(-D) and others into the project model.
CMake has an option to generate .cproject as part of its configure state, so you could do something similar. See the CMake Wiki for inspiration, but the summary is that you don't store and .cproject/.project in source control and have CMake (or waf in your case) generate the IDE specific files.
You could also just pick up the build settings using the build output parser and ignore the DEFINES.txt altogether. That requires running the build once from within Eclipse for CDT to see all the commands, and requires the commands to be parseable in the build output.

Eclipse: don't build if their are unsolved warnings

Is their a way to prevent Eclipse from building or compiling a project if unsolved warnings exist? I'm very lazy and know I am likely to ignore feedback from tools like checkstyle, so I was thinking it could be useful to force correct code before compiling.
Do you think this is a good idea? Do you know how I might do this in eclipse?
Thanks.
Eclipse
In the Preferences window, under Java|Compiler|Errors/Warnings, each of the various types of problems can be set to Ignore, Warning, or Error. You can change any or all of them to Error.
At the bottom of the page is a checkbox for:
Treat above errors like fatal compile errors (make compiled code not executable).
So, decide what messages you want to fail your build, and check that last checkbox.
Non-Eclipse Use
If you want to use checkstyle, findbugs, or pmd and have them fail your build, you will have to depend on an external build tool like Ant, Maven, or Gradle. You can create <checkstyle>, <findbugs> or <pmd> tasks, and have your real <package> target depend on them; that way if the audit task requires compilation, the target allows it, but you'll never get a [ejw]ar file out of it.
It's actually a good idea to have a build system that does not depend on the IDE. You may want to use a CI system, for example.

Using TeamCity, how to manually trigger a DEPLOY against a previously built and tested build run?

Using TeamCity 6.5, I am trying to figure out how to setup a manual deployment for a specific build run if it's possible.
What I would like to be able to do is to take an already built and tested TeamCity run (only the artifacts needs to be deployed - this is not a web application or site) and call an MSBuild step to publish the artifacts to somewhere else.
You can do what you want by setting up Artifact Dependency between the configurations where you want to do the manual deployment and the one where you have the built artifacts.
Once you have setup the Artifacts dependency, click on the Run custom build ellipsis near the "Run" button for the configuration. Here you will have the Artifacts dependencies part where it will say the configuration that this configuration you are running is dependent on and will also have a dropdown list from which you can choose the particular version of the other configuration from which to get the artifacts. Click run from here to run your custom build.
See here for more details: http://confluence.jetbrains.net/display/TCD65/Triggering+a+Custom+Build
You might be thinking about this a bit backwards. What you probably want is a build configuration that takes the previously known successful build (in TC terms it has a snapshot dependency) and then runs a different build targeted at dropping the artifacts somewhere. Pretty easily done by switching the output directories in MSBuild.
The most "integrated" way I could think to do it would be to add a dependency to your deployment configuration that depends on the latest pinned build for the dependent configuration. Then you just unpin any newer builds in the dependent configuration and pin the one you want and run the deploy...This is a bit kludgy and might not work very well if you depend on pinned builds for anything else in the dependent configuration.
The other built in way to do with would be to add an artifact dependency using a specific build number. The drawback of this method is that any time you want to deploy a different build, you will need to be able to edit the artifact dependency build number by hand and then hit run.

Deleting certain classes on running an external tool in eclipse?

I've set an external tool (sablecc) in eclipse (3.4) that generates a bunch of classes in the current project. I need to run this tool and regenerate these classes fairly frequently. This means that every time I want to run sablecc, I have to manually delete the packages/classes that sablecc creates in order to ensure that I don't have conflicts between the old and new generated classes. Is there some easy way to automate this from within eclipse or otherwise?
Not sure if I understand your point right, I suppose you need to delete old classes before running sablecc because some of them would not be eventually created in new run.
It is probably best to write short Ant build.xml with the target, which first removes the classes (Ant delete task) and then runs sablecc (Ant exec task). It is also possible to preset eclipse so that it refreshes workspace after Ant finishes.
Put the build.xml anywhere to project, right click, Run As/Ant Build.
Just for the sake of the clean style, you could then call sablecc with its Ant task (implemented by org.sablecc.ant.taskdef), instead of running it externally in new process.
You can tell Eclipse to refresh the workspace (or parts of it) after an external tool has been run. This should force Eclipse to detect any new/deleted classes.
JesperE is referring to the option Refresh->Refresh resources on completion in your external tools configuration for running sablecc.