Redo for: Bypass precompiled libs for up to date checks

Fixes to bundledArtifact handling

Review URL: https://chromereviews.googleplex.com/3579012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@302 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
jbrosenberg@google.com 2011-10-10 15:37:06 +00:00
parent f56cef3d57
commit 61f4d4472c
3 changed files with 24 additions and 18 deletions

View file

@ -188,6 +188,7 @@ public class DartCompiler {
try {
for (LibraryUnit lib : libraries.values()) {
LibrarySource libSrc = lib.getSource();
boolean libIsDartUri = SystemLibraryManager.isDartUri(libSrc.getUri());
LibraryUnit apiLib = new LibraryUnit(libSrc);
LibraryNode selfSourcePath = lib.getSelfSourcePath();
boolean persist = !incremental || !apiLib.loadApi(context, context);
@ -204,10 +205,9 @@ public class DartCompiler {
}
DartUnit apiUnit = apiLib.getUnit(dartSrc.getName());
if (apiUnit == null || isSourceOutOfDate(dartSrc, libSrc)) {
if (apiUnit == null || (!libIsDartUri && isSourceOutOfDate(dartSrc, libSrc))) {
DartUnit unit = parse(dartSrc, lib.getPrefixes());
if (unit != null) {
// if we are visiting the tu
if (libNode == selfSourcePath) {
lib.setSelfDartUnit(unit);
}
@ -381,6 +381,12 @@ public class DartCompiler {
TraceEvent logEvent = Tracer.canTrace() ? Tracer.start(DartEventType.ADD_OUTOFDATE) : null;
try {
for (LibraryUnit lib : libraries.values()) {
if (SystemLibraryManager.isDartUri(lib.getSource().getUri())) {
// embedded dart libs are always up to date
continue;
}
// Load the existing DEPS, or create an empty one.
LibraryDeps deps = lib.getDeps(context);

View file

@ -75,7 +75,7 @@ public class DefaultDartArtifactProvider extends DartArtifactProvider {
public boolean isOutOfDate(Source source, Source base, String extension) {
if (SystemLibraryManager.isDartUri(base.getUri())) {
Source bundledSource = getBundledArtifact(source, base, "", extension);
if (bundledSource != null) {
if (bundledSource != null && bundledSource.exists()) {
// Note: Artifacts bundled with sources are always up to date
return false;
}
@ -84,9 +84,22 @@ public class DefaultDartArtifactProvider extends DartArtifactProvider {
return artifactFile.lastModified() < source.getLastModified();
}
// TODO(jbrosenberg): remove 'source' argument from this method, it's not used
protected DartSource getBundledArtifact(Source source, Source base, String part, String extension) {
LibrarySource library = libraryOf(base);
URI relativeUri = library.getUri().resolve(".").normalize().relativize(base.getUri());
LibrarySource library;
URI relativeUri;
if (base instanceof LibrarySource) {
library = (LibrarySource) base;
relativeUri = library.getUri().resolve(".").normalize().relativize(base.getUri());
} else if (base instanceof DartSource){
library = ((DartSource) base).getLibrary();
String name = base.getName();
URI nameUri = URI.create(name).normalize();
relativeUri = library.getUri().resolve(".").normalize().relativize(nameUri);
} else {
throw new AssertionError(base.getClass().getName());
}
DartSource bundledSource;
if (!relativeUri.isAbsolute()) {
bundledSource = library.getSourceFor(fullname(relativeUri.getPath(), part, extension));
@ -96,16 +109,6 @@ public class DefaultDartArtifactProvider extends DartArtifactProvider {
return bundledSource;
}
private LibrarySource libraryOf(Source base) throws AssertionError {
if (base instanceof DartSource) {
return ((DartSource) base).getLibrary();
} else if (base instanceof LibrarySource){
return (LibrarySource) base;
} else {
throw new AssertionError(base.getClass().getName());
}
}
/**
* Answer the artifact file associated with the specified source. Only one
* artifact may be associated with the given extension.

View file

@ -88,9 +88,6 @@ public abstract class UrlSource implements Source {
@Override
public long getLastModified() {
if (!shouldCareAboutLastModified) {
return 0;
}
initProperties();
return lastModified;
}