| 124 | | if(commit) { |
| 125 | | // find subarray for this dep type |
| 126 | | CFStringRef cfdep = cfstr(type); |
| 127 | | CFStringRef cfval = cfstr(dep); |
| 128 | | CFMutableArrayRef deparray = (CFMutableArrayRef)CFDictionaryGetValue(finalDeps, cfdep); |
| 129 | | if(deparray == NULL) { |
| 130 | | deparray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); |
| 131 | | CFDictionarySetValue(finalDeps, cfdep, deparray); |
| 132 | | CFRelease(deparray); // still retained by dict |
| 133 | | } |
| 134 | | if(!CFArrayContainsValue(deparray, |
| 135 | | CFRangeMake(0, CFArrayGetCount(deparray)), |
| 136 | | cfval)) { |
| 137 | | CFArrayAppendValue(deparray, cfval); |
| 138 | | } |
| 139 | | CFRelease(cfdep); |
| 140 | | CFRelease(cfval); |
| 141 | | } |
| | 128 | |
| | 129 | // If committing, merge resolved dependencies to the dependencies property dictionary. |
| | 130 | // Deletes resolved dependencies after they are processed. |
| | 131 | if (commit) { |
| | 132 | CFMutableArrayRef types = CFArrayCreateMutable(NULL, 0, &cfArrayCStringCallBacks); |
| | 133 | CFMutableArrayRef projs = CFArrayCreateMutable(NULL, 0, &cfArrayCStringCallBacks); |
| | 134 | CFMutableArrayRef params[2] = { projs, types }; |
| | 135 | CFMutableDictionaryRef dependencies = (CFMutableDictionaryRef)DBCopyPropDictionary(cfstr(build), cfstr(project), CFSTR("dependencies")); |
| | 136 | if (dependencies == NULL) { |
| | 137 | dependencies = CFDictionaryCreateMutable(NULL, 0, |
| | 138 | &kCFCopyStringDictionaryKeyCallBacks, |
| | 139 | &kCFTypeDictionaryValueCallBacks); |
| | 140 | } |
| | 141 | |
| | 142 | SQL_CALLBACK(&addToCStrArrays, params, |
| | 143 | "SELECT DISTINCT dependency,type FROM dependencies WHERE build=%Q AND project=%Q", |
| | 144 | build, project); |
| | 145 | |
| | 146 | CFIndex i, count = CFArrayGetCount(projs); |
| | 147 | for (i = 0; i < count; ++i) { |
| | 148 | CFStringRef proj = cfstr(CFArrayGetValueAtIndex(projs, i)); |
| | 149 | CFStringRef type = cfstr(CFArrayGetValueAtIndex(types, i)); |
| | 150 | |
| | 151 | CFMutableArrayRef deparray = (CFMutableArrayRef)CFDictionaryGetValue(dependencies, type); |
| | 152 | if (deparray == NULL) { |
| | 153 | deparray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); |
| | 154 | CFDictionarySetValue(dependencies, type, deparray); |
| | 155 | CFRelease(deparray); // still retained by dict |
| | 156 | } |
| | 157 | if (!CFArrayContainsValue(deparray, |
| | 158 | CFRangeMake(0, CFArrayGetCount(deparray)), |
| | 159 | proj)) { |
| | 160 | CFArrayAppendValue(deparray, proj); |
| | 161 | } |
| | 162 | CFRelease(proj); |
| | 163 | CFRelease(type); |
| | 164 | } |
| | 165 | |
| | 166 | DBSetProp(cfstr(build), cfstr(project), CFSTR("dependencies"), dependencies); |
| | 167 | CFRelease(dependencies); |
| | 168 | CFRelease(types); |
| | 169 | CFRelease(projs); |
| | 170 | |
| | 171 | SQL("DELETE FROM dependencies WHERE build=%Q AND project=%Q", build, project); |
| | 172 | } |
| | 173 | |
| | 174 | if (SQL("COMMIT")) { return -1; } |