Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329338 - [Build] Add context on why a project builder is being run
Summary: [Build] Add context on why a project builder is being run
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.7   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: James Blackburn CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 325489
Blocks: 216836 331364 332296
  Show dependency tree
 
Reported: 2010-11-03 08:23 EDT by James Blackburn CLA
Modified: 2010-12-10 06:33 EST (History)
3 users (show)

See Also:
Szymon.Brandys: review+


Attachments
patch 1 (24.05 KB, patch)
2010-11-03 08:26 EDT, James Blackburn CLA
no flags Details | Diff
tests v1 (19.60 KB, patch)
2010-11-03 08:27 EDT, James Blackburn CLA
no flags Details | Diff
patch + tests 2 (46.18 KB, patch)
2010-11-26 11:19 EST, James Blackburn CLA
no flags Details | Diff
core.resources patch 3 (26.21 KB, patch)
2010-11-29 07:02 EST, James Blackburn CLA
no flags Details | Diff
core.tests.resources patch 3 (18.82 KB, patch)
2010-11-29 07:03 EST, James Blackburn CLA
no flags Details | Diff
core.tests.resources patch 4 (18.45 KB, patch)
2010-11-29 07:37 EST, James Blackburn CLA
no flags Details | Diff
example of how build context is used (2.66 KB, text/plain)
2010-11-29 08:36 EST, James Blackburn CLA
no flags Details
Minor changes in core.resources patch 3 (25.59 KB, patch)
2010-11-29 11:21 EST, Szymon Brandys CLA
no flags Details | Diff
Syzmon's patch + remove BuildManager#setBuildOrder (22.97 KB, patch)
2010-11-29 11:40 EST, James Blackburn CLA
Szymon.Brandys: iplog+
Details | Diff
tests patch 4 (20.60 KB, patch)
2010-11-29 13:10 EST, James Blackburn CLA
no flags Details | Diff
tests patch 5 (20.60 KB, patch)
2010-11-30 04:57 EST, James Blackburn CLA
Szymon.Brandys: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Blackburn CLA 2010-11-03 08:23:44 EDT

    
Comment 1 James Blackburn CLA 2010-11-03 08:26:41 EDT
Created attachment 182286 [details]
patch 1

This patch adds a Build context to the build. Allowing the IncrementalProjectBuilder to discover why it's being built: either as the result of a direct call to IProject#build or due to a IWorkspace#build.  The builder can then make intelligent decisions about whether it needs to run.

See bug 216836 for further detail on why this is useful.
Comment 2 James Blackburn CLA 2010-11-03 08:27:03 EDT
Created attachment 182287 [details]
tests v1
Comment 3 James Blackburn CLA 2010-11-03 08:28:24 EDT
Depends on the patch in bug 325489 being applied first.
Comment 4 John Arthorne CLA 2010-11-03 14:41:52 EDT
Putting on the radar for M4.
Comment 5 James Blackburn CLA 2010-11-26 11:19:38 EST
Created attachment 183936 [details]
patch + tests 2

Patch 2 re-based against HEAD.
Comment 6 James Blackburn CLA 2010-11-29 07:02:04 EST
Created attachment 184027 [details]
core.resources patch 3

#Configuration => #Config
Re-base against bug 330197
Comment 7 James Blackburn CLA 2010-11-29 07:03:14 EST
Created attachment 184028 [details]
core.tests.resources patch 3
Comment 8 James Blackburn CLA 2010-11-29 07:37:37 EST
Created attachment 184031 [details]
core.tests.resources patch 4

Fix out of date API usage
Comment 9 James Blackburn CLA 2010-11-29 08:36:19 EST
Created attachment 184036 [details]
example of how build context is used

Szymon's asked that I provide some detail on how / why this API is useful.

The API provides the builder the ability to examine the build order, and potentially optimise a particular build invocation based on what's been built already, and more importantly which configurations will be built subsequently.

Taking a C/C++ example, we have two types of build-time dependencies:
  1) #include's resolved at compile time by the pre-processor
  2) Static archive libraries resolved at link time.

Both of these are represented with build configuration references. 
So actions like: open project + references continue to work correctly.

Consider the following dependencies:
  ExeConfig -> HigherLibConfig
  ExeConfig -> BaseLibConfig
  HigherLibConfig-> BaseLibConfig

ExeConfig, has both kinds of dependency, on HigherLibConfig And BaseLibConfig.  Compiling ExeConfig's files requires source from HigherLib and BaseLib, and linking Exe requires archives built in BaseConfig & HigherLibConfig.

However when the user is working on source in one of those libraries, we can optimise the amount of building done based on the project build configurations being built.
If they're working on HigherLibConfig, we need to rebuild the HigherLibConfig.a whenever source exported (usually .h files) from BaseLib change.  However we don't need to rebuild the BaseLibConfig .a.  This is because the library artifact is only required when linking the final executable.  The BaseLib builder can look at the context in which the builder was called, and short-circuit the particular build invocation using #rememberLastBuiltState() if its build output isn't required in this build invocation.

Similar behaviour could be achieved by not resolving references, and specifying explicitly the configurations to build. However we want, where possible, to be able to re-use platform build actions, and centralise our build logic within the builder.

Note there is already: IncProjBuilder#hasBeenBuilt(IProject). 
This patch generalises the context information within an IBuildContext type.  So it provides: 
  - which build configurations have been built
  - which build configurations will be built next
  - which build configurations the API user requested were built
Comment 10 James Blackburn CLA 2010-11-29 09:10:58 EST
(In reply to comment #9)
> However we want, where possible, to be
> able to re-use platform build actions, and centralise our build logic within
> the builder.

I think for the general case, it would be hard to centralise this logic in the build action. While the simple make builder may not want to be run, other build commands registered on the configuration -- such as a source generation step -- might want to run on each invocation.

Giving the builder visibility of the build order seems to me a relatively clean and powerful way of providing this capability.
Comment 11 Szymon Brandys CLA 2010-11-29 11:21:04 EST
Created attachment 184048 [details]
Minor changes in core.resources patch 3
Comment 12 James Blackburn CLA 2010-11-29 11:40:50 EST
Created attachment 184052 [details]
Syzmon's patch + remove BuildManager#setBuildOrder

BuildManager#setBuildOrder is unneeded as #getRule is only ever called from the context of IProject#build.
Comment 13 James Blackburn CLA 2010-11-29 13:10:45 EST
Created attachment 184062 [details]
tests patch 4
Comment 14 James Blackburn CLA 2010-11-30 04:57:13 EST
Created attachment 184102 [details]
tests patch 5

Tidy up assertion message strings.
Comment 15 Szymon Brandys CLA 2010-11-30 05:13:14 EST
The fix and tests are in HEAD. Thanks James.