Commit Graph

167 Commits

Author SHA1 Message Date
Dale Wijnand 83075a90f5 Fixes #2654 Silence macro recompilation info message
As well as add a test for the macro recompilation info message feature.
2016-07-08 01:03:32 +01:00
Eugene Yokota bd2e02aeaa Inform the build user about macro recompilation 2016-06-08 00:39:04 -04:00
Eugene Yokota c75a386a82 Adds withIncludeSynthToNameHashing. Ref #2537
Provides a workaround flag `incOptions :=
incOptions.value.withIncludeSynthToNameHashing(true)` for name hashing
not including synthetic methods. This will not be enabled by default in
sbt 0.13. It can also enabled by passing `sbt.inc.include_synth=true`
to JVM.
2016-04-05 22:57:59 -04:00
Eugene Yokota 2fe5eabd6e Merge branch '0.13.10' into wip/0.13.10-merge 2016-02-22 13:19:38 -05:00
Martin Duhem 6576844698 Hash of traits: include private fields, objects and super accessors 2016-02-10 18:15:44 +01:00
Martin Duhem 34d2aabfa9 Attempt at fixing Codacy's complaints 2016-02-04 13:24:22 +01:00
Martin Duhem b7b1f2453d Do not rely on filename of package objects
Add a new field in `Source` that indicates whether this `Source`
represents a package object. This field is used in the incrmental
compiler to perform recompilation of package objects rather than relying
on the file name being `package.scala`.

Mark pending test `source-dependencies/package-object-name` as passing.
2016-02-03 16:32:35 +01:00
Grzegorz Kossakowski 65f7958898 Invalidate package objects transitively in name hashing
Modify `invalidatedPackageObjects` to look for package objects that
transitively inherit from an invalidated class instead of just inheriting
directly. This is the correct behavior that should have been implemented
in the first place. The bug comes from a subtle copy&paste mistake. The old
implementation used `publicInherited` relation and new one looks identical
but uses `inheritance` relation. The difference is that `publicInherited`
was a relation that was expanded transitively along inheritance chain but
`inheritance` is not. We have to perform the transitive walk in
`IncrementalNameHashing.invalidatedPackageObjects` implementation.

Mark `pkg-self` test as passing.

Fixes #2326
2016-02-02 01:33:43 +01:00
Grzegorz Kossakowski f78b7112a2 Print both memberRef and inheritance relations.
To aid debugging, modify Relations.toString to include `inheritance` in
addition to already printed `memberRef` relation.

Modify it for both name hashing and old implementation.
2016-02-01 19:23:12 +01:00
Adriaan Moors 81786a2206 Prefix name hashing debug output with [naha]
Further categorize debug output as api diff ([diff]), and
invalidation ([inv]). Since we log a ton of diagnostics,
make it a bit easier to find the relevant bits.
2016-01-06 13:56:54 -05:00
Adriaan Moors 3e03e0d1b5 Clean up ShowApi implicit overload
Motivated because we want to make it more robust & configurable.
Original motivation was to diagnose a cyclic type representation,
likely due to an f-bounded existential type, as illustrated by the following:

```
class Dep {
  // The API representation for `bla`'s result type contains a cycle
  // (an existential's type variable's bound is the existential type itself)
  // This results in a stack overflow while showing the API diff.
  // Note that the actual result type in the compiler is not cyclic
  // (the f-bounded existential for Comparable is truncated)
  def bla(c: Boolean) = if (c) new Value else "bla"
}

class Value extends java.lang.Comparable[Value] { def compareTo(that: Value): Int = 1 }
```

Limit nesting (`-Dsbt.inc.apidiff.depth=N`, where N defaults to `2`),
and number of declarations shown for a class/structural type
(via `sbt.inc.apidiff.decls`, which defaults to `0` -- no limit).

Limiting nesting is crucial in keeping the size of api diffs of large programs
within a reasonable amount of RAM...

For example, compiling the Scala library, the API diff with nesting at `4`
exhausts 4G of RAM...
2016-01-06 13:56:54 -05:00
eugene yokota 9349094e65 Merge pull request #2158 from twitter-forks/stuhood/fix-error-message-when-name-hashing-is-enabled
Fix error when name hashing is enabled and mixed with non-enabled
2015-08-18 17:55:43 -04:00
Stu Hood 1b6dbc90c1 Fix error message when name hashing is enabled and mixed with non-enabled. 2015-08-15 11:55:31 -07:00
Pierre DAL-PRA 8f1fb2d232 Fix additional warnings 2015-08-07 00:23:14 +02:00
Pierre DAL-PRA 54d54b9f4f Replace procedure syntax by explicit Unit annotation 2015-08-04 10:07:38 +02:00
Pierre DAL-PRA f0bd9001e6 Remove redundant collection conversions 2015-08-01 12:05:35 +02:00
Pierre DAL-PRA b9171e59ad Simplify operations on collections 2015-08-01 02:25:17 +02:00
James Roper 18fb684143 Update incremental compile debug message
sbt 0.13.1 was changed so that products were invalidated
not just when they were deleted, but also when they were
modified, however the debug message was not updated to
reflect this, causing people to think invalidated class files
had been deleted.
2015-04-15 14:29:10 +10:00
eugene yokota be78b7fc4c Merge pull request #1759 from jedesah/topic/minor_cleanup
Minor code cleanup
2015-01-14 16:13:06 -05:00
Jean-Rémi Desjardins ca736e55d3 Minor code cleanup 2014-12-03 09:56:34 -08:00
eugene yokota 7df9802f0c Merge pull request #1714 from sbt/wip/bytecode-enhancement
Expose mechanism whereby bytecode enhancement can be run *before* saving incremental compiler hashes.
2014-12-03 08:46:52 -05:00
Josh Suereth 3c4bc23cdb First set of refactorings from review.
* Split Java analyzing compile into its own class.
* MixedAnalyzingCompiler now only does the mixing
* Start moving methods around to more-final locations
* Static analyzingCompile method now constructs a MixedAnalyzingCOmpiler and delegates to incremental compile.
2014-12-01 13:35:51 -05:00
Josh Suereth ae4721aba0 Adding more scaladoc to incremental compiler library. 2014-12-01 13:35:51 -05:00
Josh Suereth 067479f59e Debug issues with implicit usage for CompileSetup.
* Force CompileSetup Equiv typeclass to use Equiv relations defined locally.
* Add toString methods on many of the incremental compiler datatypes.
* Remove remaining binary compatibility issues in Defaults.scala.
2014-12-01 13:35:51 -05:00
Martin Duhem 98c789b826 Abstract over dependency context in Compile
This commit completes the abstraction over dependency kinds in the
incremental compiler, started with #1340.
2014-11-19 10:35:07 +01:00
Martin Duhem deda8eee70 Remove trait `DependencyContext` in favor of enum
Since `DependencyContext` is needed in the compiler interface
subproject, it has to be defined in this same subproject.

`DependencyContext` is needed in this subproject because the
`AnalysisCallback` interface uses it.
2014-11-19 10:35:07 +01:00
Martin Duhem 191c3ed675 Use new infrastructure in `AnalysisTest`
A new infrastructure to register sources and their dependencies has
been introduced in `c09a391`.

This commit brings the required modifications to `AnalysisTest`,
so that it uses it.
2014-11-18 13:09:07 +01:00
Martin Duhem b1a608cf1d Use new infrastructure in `AnalysisCallback`
A new infrastructure to register sources and their dependencies has
been introduced in `c09a391`.

This commit brings the required modifications to `AnalysisCallback`,
so that it uses it.
2014-11-18 13:08:51 +01:00
Martin Duhem c09a3912d1 Implement abstraction over dependency kinds
This commit implements the abstraction over the dependency kinds and
deprecates the methods that were used to register files and their
dependencies.

Dependencies are now divided into two categories : Internal and
External dependencies. Moreover, each internal or external dependency
has a Context, which describes what introduced the dependency (for
instance, a dependency may be introduced by member reference or by
inheritance).

Dependencies must now be registered using the method `addSource` in
`Analysis` and in `Relations`. This method has the advantage of being
independent from the existing dependency contexts. That is, its
signature does not need to be modified whenever a new dependency
context is introduced.
2014-11-18 13:07:58 +01:00
Grzegorz Kossakowski f7c00ab581 Sketch of abstracting over dependency details in incremental compiler
This represents a sketch of the idea that we can abstract over details
of a specific dependency kind. The goal would that only a few
implementations of methods in incremental would be sensitive to specific
dependency kind:

  1. Dependency extraction logic
  2. Implementation of Relations which adds dependencies to specific
     relations (or abstract over specific relations)
  3. Invalidation algorithm (Incremental.scala) which has different
     of each kind of dependency
  4. TextAnalysisFormat

In particular, adding a new dependency kind would not affect signatures
of existing methods.

What needs to be done:

  - finish refactoring so the code compiles again and previous semantics
    are preserved
  - introduce deprecated overloads that preserve old method signatures
    (this is required for preserving binary compatibility)
2014-09-12 08:52:06 +02:00
Martin Duhem 82152b8905 Don't hardcode existing relations in TextAnalysisFormat
The previous implementation of TextAnalysisFormat contained the list
of all the existing relations that sbt knew of, and used this
information to write to and read from the disk the persisted analyses.

In this knew implementation, TextAnalysisFormat gets from the
Relations object what are the existing relations, and then persists
them to disk.

The previous situation was not optimal since it meant that, in order
to add a new dependency kind, one had to modify both the Relations
and TextAnalysisFormat.

Using this new implementation, no change to TextAnalysisFormat is
required whenever a new dependency kind is added.
2014-09-11 14:45:47 +02:00
Martin Duhem c55ae4fd18 Fix random Analysis generator for ScalaCheck
Unit tests in incremental-compiler subproject use a generator to
create random Analysis objects. This generator was unfortunately
not working properly and generated only empty Analyses (it failed
to generate any non-empty Analysis because of a bug in the `unique`
generator).
2014-09-03 23:10:22 +02:00
Eugene Yokota bb20310922 Run AnalysisTest without name hashing 2014-08-23 02:58:44 -04:00
Eugene Yokota 112052241c #1550. Fixes scripted/join that broke with #1546
Name hashing is now turned on by default, so I’m changing the value for
inc.Relations.empty, so inc.Analysis.empty functions as expected when
it’s joined with name hashing analyses.
2014-08-22 19:12:27 -04:00
Grzegorz Kossakowski c440c578fc Enable name hashing incremental compilation by default.
This commit changes the default value of `IncOptions.nameHashing` to be
set to true. It means, the improved incremental compilation algorithm
known as "name hashing" will be enabled by default.

In order to disable it, users should add this to their sbt configuration:

  incOptions := incOptions.value.withNameHashing(false)

Number of tests has been cleaned up as part of this change. All tests
that were marked as name hashing specific are removed. The list includes:

  * constants-name-hashing
  * import-class-name-hashing
  * java-static-name-hashing
  * macro-name-hashing
  * struct-name-hashing

We'll keep just regular version of those tests. The tests will just
exercise the default algorithm: name hashing. This is the first step
towards phasing out of the old incremental compilation algorithm.

Apart from that, a few tests changed its status due to enabling name
hashing algorithm.

The `constants` test has been marked pending due to issue described in
#1543.

The `import-class` test has been marked as passing because name hashing
tracks dependencies introduced by import statements correctly, now.

The `macro` test has been marked as pending due to issue described in
#1544.

The `struct` test has been marked as pending due to issue described in
#1545.

The `java-static` has been slightly modified to exercise just static field
and not run into the same issue as with `constants` test.

There are no other known issues related to name hashing so we conclude
that name hashing is ready to be shipped to all sbt, Scala IDE and zinc
users.
2014-08-22 02:08:07 +02:00
Grzegorz Kossakowski 129c870a1d Break Incremental.scala into smaller files.
Incremental.scala contained all three strategies of incremental
compilation:

  * ant-style
  * the default one (before name hashing)
  * name hashing

Let's move all those classes into separate files. Also, move common code
into a separate file.
2014-05-21 16:23:55 +02:00
Grzegorz Kossakowski 7849361c82 Remove stale, commented out code from Incremental.scala
The commented out code was sitting here since 2010. It bit-rotted to the
point of not being useful anymore. Let's remove it.
2014-05-20 19:51:28 +02:00
Grzegorz Kossakowski 680713f666 Add Ant-style incremental compilation mode.
This commit implements an Ant-style incremental compilation mode. This mode
emulates what Ant's scalac command does. It recompiles just changed source
files and does not perform any invalidation of dependencies.
This is a very naive mode of incremental compilation that very often leads
to broken binaries.

The Ant-style mode is being introduced because Scala team needs it for
migration of Scala compiler to sbt. The name hashing algorithm doesn't
work well with Scala compiler sources due to deep inheritance chains.
There's a plan to refactor compiler's code to use more composition instead
of inheritance.

Once Scala compiler sources are refactored to work well with name hashing
algorithm, Ant-style mode will be deleted immediately.
2014-05-08 20:29:02 +02:00
Grzegorz Kossakowski ba88236b31 Add `antStyle` to IncOptions.
Add an option that enables (to be implemented) Ant-style mode of
incremental compilation.

This option is unsupported and may go away at any point in the future.

NOTE: Either `antStyle` or `nameHashing` mode can be enabled. This is
being enforced with runtime assertion.
2014-05-08 20:28:16 +02:00
Josh Suereth 244abd3b6f Scalariforming test code 2014-05-07 11:52:23 -04:00
Eugene Yokota adb41611cf added scalariform 2014-05-01 12:50:07 -04:00
Grzegorz Kossakowski d27a699715 Merge pull request #1250 from gkossakowski/namehashing-cleanup
Move NameHashing from incremental to api subproject.
2014-04-16 00:18:27 +02:00
Grzegorz Kossakowski a7fb54e4df Add debug logging in ClassfileManager
Add logging of various operations the transactional class file manager is
doing. You can pass logger to be used by the transactional class file
manager by using overloaded definition of `ClassfileManager.transactional`
method. The old overload has been deprecated.

The factory methods for class file manager in IncOptions companion object
has been deprecated in favor of using ClassfileManager companion object
directly. The code in Defaults.scala has been updated to use non-deprecated
methods. The logging is turned off by default.

The canonical way of enabling transactional class file manager in sbt
project is:

```
incOptions := incOptions.value.withNewClassfileManager(
  sbt.inc.ClassfileManager.transactional(
    crossTarget.value / "classes.bak",
    (streams in (compile, Compile)).value.log
  )
)
```

It's a bit verbose which shows that the api for this is not the best.
However, I don't expect sbt users to need this code very often.

This patch should help debug the problem described in #1184
2014-04-11 13:42:21 +02:00
Grzegorz Kossakowski 36db1207cf Move NameHashing from incremental to api subproject.
It should have been there from the beginning because NameHashing is tied
to internals of the API subproject.

It was added to incremental subproject by mistake.
2014-04-10 20:21:42 +02:00
Grzegorz Kossakowski 3673f53119 Clarify the role and uses cases of Analysis.compilations.
It's mainly debugging tool. I added documentation describing the intent
of Analysis.compilations field.
2014-04-08 23:26:39 +02:00
Grzegorz Kossakowski 19ca7a1edc Make change to CompileSetup backwards compatible.
The c7f435026f introduced a new parameter
to the constructor of `CompileSetup` but it turns out that this class
is being used in zinc. Introduce an overloaded variant of that constructor
that preserves backwards compatibility.
2014-02-18 12:18:07 +01:00
Grzegorz Kossakowski c7f435026f Include value of `nameHashing` flag in `CompileSetup`.
The CompileSetup class is being used to detect changes to arguments of
incremental compiler that affect result of compilation and trigger
recompilation. Examples of such arguments include, the target (output)
directory, Scala compiler options, Scala compiler version, etc.

By adding `nameHashing` to CompileSetup we have a chance to handle change
to that flag smoothly by throwing away old Analysis object and starting
with an empty one. That's implemented in AggressiveComile by extending
the logic that was responsible for detection of changes to CompileSetup
values. Thanks to this change we fix #1081.

Analysis formats has been updated to support persisting of newly added
value in CompileSetup. We used to not store the value of `nameHashing`
flag in persisted Analysis file and infer it from contents of relations
but that leads to issue #1071 when empty relations are involved. Given
the fact that CompileSetup stores `nameHashing` value now, we can just
use it when reading relations and fix #1071. This requires reading/writing
compile setup before reading relations. I decided to make that change even
if there's a comment saying that reading/writing relations first was done
intentionally.
2014-02-17 17:00:19 +01:00
Grzegorz Kossakowski 9e7e93c632 Bring back and deprecate `Incremental.incDebugProp`.
The ae15eccd9c accidentally removed
`Incremental.incDebugProp` which broke Scala IDE build that relies on it.

We bring back that val but at the same time we deprecate it because we
have better mechanism for configuring incremental compiler now.

I also added a little comment with the history of `incDebugProp` which
explains proper migration path.
2014-01-13 16:29:16 +01:00
Grzegorz Kossakowski dcb327e6f4 Do not compute name hashes when name hashing is disabled
We should compute name hashes only when name hashing is enabled.
Otherwise, we just store an empty value for name hashes.
2014-01-08 17:37:43 -05:00
Grzegorz Kossakowski b581b60aa4 Merge pull request #1069 from benjyw/0.13-format-v4-A
Make analysis file portable.
2014-01-07 15:50:23 -08:00