Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330204 - Headless build always cleans active configuration
Summary: Headless build always cleans active configuration
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: 9.5.0   Edit
Assignee: Torbjörn Svensson CLA
QA Contact: Andrew Gvozdev CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 571134
  Show dependency tree
 
Reported: 2010-11-14 17:57 EST by Nobody - feel free to take it CLA
Modified: 2021-02-11 12:51 EST (History)
10 users (show)

See Also:


Attachments
[Patch 1/2] Add method preserving builder specific arguments to base class (4.33 KB, patch)
2016-12-04 08:16 EST, Torbjörn Svensson CLA
torbjorn.svensson: review?
Details | Diff
[Patch 2/2] Implement the argument preserving clean (1.33 KB, patch)
2016-12-04 08:21 EST, Torbjörn Svensson CLA
torbjorn.svensson: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nobody - feel free to take it CLA 2010-11-14 17:57:30 EST
Headless build ignores <configuration> argument for -cleanBuild <project>/<configuration> and always cleans the active configuration.
Comment 1 Henry CLA 2011-03-07 04:41:55 EST
Mikhail is right: I discovered this bug too.  Anybody knows how to fix this?
Comment 2 Torbjörn Svensson CLA 2016-12-04 08:16:49 EST
Created attachment 265712 [details]
[Patch 1/2] Add method preserving builder specific arguments to base class

In order to clean the correct configuration, the builder specific arguments needs to be preserved when calling clean. If the builder specific arguments are lost, the active configuration will be cleaned and this is usually not what the user expects if a non-active configuration was selected for the clean operation.
Comment 3 Torbjörn Svensson CLA 2016-12-04 08:21:23 EST
Created attachment 265713 [details]
[Patch 2/2] Implement the argument preserving clean

The 2'nd part implements the clean method with builder specific arguments preserved so that the correct project/configuration is cleaned rather than the active configuration for the project.
Comment 4 Torbjörn Svensson CLA 2016-12-04 08:29:04 EST
Steps to reproduce:
1. Create a new "Hello World ANSI C Project" with default settings, call it "helloc" for simplicity.
2. Make sure "Debug" is the active build configuration for the newly created project.
3. Run the headless builder application with the following arguments: -importAll /path/to/helloc -cleanAll helloc/Debug
4. Verify that the configuration Debug in helloc is both cleaned and compiled.
5. Run the headless builder application with the following arguments: -importAll /path/to/helloc -cleanAll helloc/Release
6. Verify that the configuration Release in helloc is both cleaned and compiled.


Without the attached set of patches, step 6 above will clean configuration "Debug" but build configuration "Release" and that's obviously not what the user expected to happen.
Comment 5 Eclipse Genie CLA 2018-03-16 17:56:19 EDT
New Gerrit change created: https://git.eclipse.org/r/119602
Comment 6 Eclipse Genie CLA 2018-03-16 18:21:59 EDT
New Gerrit change created: https://git.eclipse.org/r/119605
Comment 7 Mickael Istria CLA 2018-03-21 10:00:47 EDT
Is there a workaround possible somewhere, such as storing in the builder state or project state what are the files to be cleaned?
Couldn't/Shouldn't the clean operation perform a full clean which would be independent of args?
Comment 8 Eclipse Genie CLA 2018-03-21 16:22:37 EDT
New Gerrit change created: https://git.eclipse.org/r/119915
Comment 9 Torbjörn Svensson CLA 2018-03-21 16:36:18 EDT
Thanks for the comments on both the Gerrit review and here.

I've debugged this a bit further and came up with another solution that does not require an API change, but will instead rely on a race condition (nothing new since the UI is already using it) by switching the "active configuration" when invoking builder to clean a configuration.
In the ManagedBuildManager.buildConfigrations method, there is a comment about clean not taking arguments and I think the solution there should be considered a workaround, but not actually a proper solution for the problem. (https://git.eclipse.org/r/plugins/gitiles/cdt/org.eclipse.cdt/+/master/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java#4591)

With https://git.eclipse.org/r/119915 the HeadlessBuilder can at least reach the same functionality as the UI although not optimal. I think this is a good compromise for the short run, but I really think that the argument to clean should be considered for future releases since it is more flexible than this solution.
Comment 10 Jonah Graham CLA 2018-04-18 17:31:50 EDT
Lets see if we can make sure this gets reviewed in time for 9.5. It looks promising, but I want to have a closer look.