Skip to content

Commit

Permalink
Tentatively put an end to all libcache woes. Closes #541
Browse files Browse the repository at this point in the history
  • Loading branch information
nddrylliog committed Nov 27, 2013
1 parent c62e553 commit ab8e858
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
30 changes: 17 additions & 13 deletions source/rock/frontend/drivers/Archive.ooc
Expand Up @@ -20,6 +20,8 @@ Archive: class {
supportedVersion := static "0.4"

map := static HashMap<Module, Archive> new()
dirtyModules := ArrayList<Module> new()
structuralDirties := ArrayList<Module> new()

/** Source folder that this archive is for */
sourceFolder: SourceFolder
Expand Down Expand Up @@ -199,15 +201,16 @@ Archive: class {
}
}

dirtyModules: func -> List<Module> {
updateDirtyModules: func -> List<Module> {

modules := sourceFolder modules
dirtyModules := ArrayList<Module> new()
structuralDirties := ArrayList<Module> new()
transModules := ArrayList<Module> new()
cleanModules := ArrayList<Module> new()
cleanModules addAll(modules)

dirtyModules clear()
structuralDirties clear()

running := true
while(running) {
debug("Analyzing %s, %d cleanModules, %d dirtyModules",
Expand Down Expand Up @@ -247,7 +250,8 @@ Archive: class {
ImportClassifier classify(module)
for(imp in module getAllImports()) {
candidate := imp getModule()
if(structuralDirties contains?(candidate)) {
archive := map get(candidate)
if(archive && archive structuralDirties contains?(candidate)) {
debug("%s is dirty because of import %s", module getFullName(),
candidate getFullName())
if(!trans) {
Expand Down Expand Up @@ -424,51 +428,51 @@ ArchiveModule: class {
for (variable in tDecl getVariables()) {
if(variable isStatic) {
if(!statVarIter hasNext?()) {
if(archive params debugLibcache) "Static var %s has changed, %s not up-to-date\n" printfln(variable getName(), oocPath)
if(archive params debugLibcache) "Static var %s has changed, %s not up-to-date" printfln(variable getName(), oocPath)
return false
}
next := statVarIter next()
if(next != variable getName()) {
if(archive params debugLibcache) "Static var %s has changed, %s not up-to-date\n" printfln(variable getName(), oocPath)
if(archive params debugLibcache) "Static var %s has changed, %s not up-to-date" printfln(variable getName(), oocPath)
return false
}
} else {
if(!instanceVarIter hasNext?()) {
if(archive params debugLibcache) "Instance var %s has changed, %s not up-to-date\n" printfln(variable getName(), oocPath)
if(archive params debugLibcache) "Instance var %s has changed, %s not up-to-date" printfln(variable getName(), oocPath)
return false
}
next := instanceVarIter next()
if(next != variable getName()) {
if(archive params debugLibcache) "Instance var %s has changed, %s not up-to-date\n" printfln(variable getName(), oocPath)
if(archive params debugLibcache) "Instance var %s has changed, %s not up-to-date" printfln(variable getName(), oocPath)
return false
}
}
}
if(statVarIter hasNext?()) {
if(archive params debugLibcache) "Fewer static vars, %s not up-to-date\n" printfln(oocPath)
if(archive params debugLibcache) "Fewer static vars, %s not up-to-date" printfln(oocPath)
return false
}
if(instanceVarIter hasNext?()) {
if(archive params debugLibcache) "Fewer instance vars, %s not up-to-date\n" printfln(oocPath)
if(archive params debugLibcache) "Fewer instance vars, %s not up-to-date" printfln(oocPath)
return false
}

functionIter := archType functions iterator()

for (function in tDecl getFunctions()) {
if(!functionIter hasNext?()) {
if(archive params debugLibcache) "Function %s has changed (%d vs %d), %s not up-to-date\n" printfln(function getFullName(), archType functions getSize(), tDecl getFunctions() getSize(), oocPath)
if(archive params debugLibcache) "Function %s has changed (%d vs %d), %s not up-to-date" printfln(function getFullName(), archType functions getSize(), tDecl getFunctions() getSize(), oocPath)
return false
}
next := functionIter next()
if(next != function getFullName()) {
if(archive params debugLibcache) "Function %s has changed (vs %s), %s not up-to-date\n" printfln(function getFullName(), next, oocPath)
if(archive params debugLibcache) "Function %s has changed (vs %s), %s not up-to-date" printfln(function getFullName(), next, oocPath)
return false
}
}

if(functionIter hasNext?()) {
if(archive params debugLibcache) "Fewer methods, %s not up-to-date\n" printfln(oocPath)
if(archive params debugLibcache) "Fewer methods, %s not up-to-date" printfln(oocPath)
return false
}
}
Expand Down
10 changes: 6 additions & 4 deletions source/rock/frontend/drivers/SequenceDriver.ooc
Expand Up @@ -37,20 +37,21 @@ SequenceDriver: class extends Driver {
dirtyModules := HashMap<SourceFolder, List<Module>> new()

graph = DependencyGraph new(params, sourceFolders)
reverseList := graph list reverse()

// step 1: generate C sources
if (params verbose) {
"Generating C sources..." println()
}
for (sourceFolder in graph list) {
for (sourceFolder in reverseList) {
dirtyModules put(sourceFolder, generateSources(sourceFolder))
}

// step 2: compile
if (params verbose) {
"Compiling with %d thread%s..." printfln(pool parallelism, pool parallelism > 1 ? "s" : "")
}
for (sourceFolder in graph list) {
for (sourceFolder in reverseList) {
if(params verbose) {
// generate random colors for every source folder
hash := ac_X31_hash(sourceFolder identifier) + 42
Expand All @@ -72,7 +73,7 @@ SequenceDriver: class extends Driver {
}

// step 3: archive
for (sourceFolder in graph list) {
for (sourceFolder in reverseList) {
archive := sourceFolder archive
archive save(params, false, true)
}
Expand Down Expand Up @@ -161,7 +162,8 @@ SequenceDriver: class extends Driver {

archive := sourceFolder archive
if(archive exists?) {
dirtyModules addAll(archive dirtyModules())
archive updateDirtyModules()
dirtyModules addAll(archive dirtyModules)
} else {
// on first compile, we have no archive info
dirtyModules addAll(sourceFolder modules)
Expand Down

0 comments on commit ab8e858

Please sign in to comment.