diff options
Diffstat (limited to 'src/burn/engine/dependency.cpp')
-rw-r--r-- | src/burn/engine/dependency.cpp | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/src/burn/engine/dependency.cpp b/src/burn/engine/dependency.cpp index 876cd8b3..f6cfe2c6 100644 --- a/src/burn/engine/dependency.cpp +++ b/src/burn/engine/dependency.cpp | |||
@@ -171,38 +171,58 @@ LExit: | |||
171 | } | 171 | } |
172 | 172 | ||
173 | extern "C" HRESULT DependencyInitialize( | 173 | extern "C" HRESULT DependencyInitialize( |
174 | __in BURN_REGISTRATION* pRegistration, | 174 | __in BURN_ENGINE_COMMAND* pInternalCommand, |
175 | __in_z_opt LPCWSTR wzIgnoreDependencies | 175 | __in BURN_DEPENDENCIES* pDependencies, |
176 | __in BURN_REGISTRATION* pRegistration | ||
176 | ) | 177 | ) |
177 | { | 178 | { |
179 | AssertSz(!pDependencies->cIgnoredDependencies, "Dependencies already initalized."); | ||
180 | |||
178 | HRESULT hr = S_OK; | 181 | HRESULT hr = S_OK; |
179 | 182 | ||
180 | // If no parent was specified at all, use the bundle id as the self dependent. | 183 | // If no parent was specified at all, use the bundle id as the self dependent. |
181 | if (!pRegistration->sczActiveParent) | 184 | if (!pInternalCommand->sczActiveParent) |
182 | { | 185 | { |
183 | pRegistration->wzSelfDependent = pRegistration->sczId; | 186 | pDependencies->wzSelfDependent = pRegistration->sczId; |
184 | } | 187 | } |
185 | else if (*pRegistration->sczActiveParent) // if parent was specified use that as the self dependent. | 188 | else if (*pInternalCommand->sczActiveParent) // if parent was specified use that as the self dependent. |
186 | { | 189 | { |
187 | pRegistration->wzSelfDependent = pRegistration->sczActiveParent; | 190 | pDependencies->wzSelfDependent = pInternalCommand->sczActiveParent; |
188 | } | 191 | } |
189 | // else parent:none was used which means we should not register a dependency on ourself. | 192 | // else parent:none was used which means we should not register a dependency on ourself. |
190 | 193 | ||
194 | pDependencies->wzActiveParent = pInternalCommand->sczActiveParent; | ||
195 | |||
191 | // The current bundle provider key should always be ignored for dependency checks. | 196 | // The current bundle provider key should always be ignored for dependency checks. |
192 | hr = DepDependencyArrayAlloc(&pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, pRegistration->sczProviderKey, NULL); | 197 | hr = DepDependencyArrayAlloc(&pDependencies->rgIgnoredDependencies, &pDependencies->cIgnoredDependencies, pRegistration->sczProviderKey, NULL); |
193 | ExitOnFailure(hr, "Failed to add the bundle provider key to the list of dependencies to ignore."); | 198 | ExitOnFailure(hr, "Failed to add the bundle provider key to the list of dependencies to ignore."); |
194 | 199 | ||
195 | // Add the list of dependencies to ignore. | 200 | // Add the list of dependencies to ignore. |
196 | if (wzIgnoreDependencies) | 201 | if (pInternalCommand->sczIgnoreDependencies) |
197 | { | 202 | { |
198 | hr = SplitIgnoreDependencies(wzIgnoreDependencies, &pRegistration->rgIgnoredDependencies, &pRegistration->cIgnoredDependencies, &pRegistration->fIgnoreAllDependents); | 203 | hr = SplitIgnoreDependencies(pInternalCommand->sczIgnoreDependencies, &pDependencies->rgIgnoredDependencies, &pDependencies->cIgnoredDependencies, &pDependencies->fIgnoreAllDependents); |
199 | ExitOnFailure(hr, "Failed to split the list of dependencies to ignore."); | 204 | ExitOnFailure(hr, "Failed to split the list of dependencies to ignore."); |
200 | } | 205 | } |
201 | 206 | ||
207 | pDependencies->fSelfDependent = NULL != pDependencies->wzSelfDependent; | ||
208 | pDependencies->fActiveParent = NULL != pInternalCommand->sczActiveParent && NULL != *pInternalCommand->sczActiveParent; | ||
209 | |||
202 | LExit: | 210 | LExit: |
203 | return hr; | 211 | return hr; |
204 | } | 212 | } |
205 | 213 | ||
214 | extern "C" void DependencyUninitialize( | ||
215 | __in BURN_DEPENDENCIES* pDependencies | ||
216 | ) | ||
217 | { | ||
218 | if (pDependencies->rgIgnoredDependencies) | ||
219 | { | ||
220 | ReleaseDependencyArray(pDependencies->rgIgnoredDependencies, pDependencies->cIgnoredDependencies); | ||
221 | } | ||
222 | |||
223 | memset(pDependencies, 0, sizeof(BURN_DEPENDENCIES)); | ||
224 | } | ||
225 | |||
206 | extern "C" HRESULT DependencyDetectProviderKeyBundleId( | 226 | extern "C" HRESULT DependencyDetectProviderKeyBundleId( |
207 | __in BURN_REGISTRATION* pRegistration | 227 | __in BURN_REGISTRATION* pRegistration |
208 | ) | 228 | ) |
@@ -228,15 +248,14 @@ LExit: | |||
228 | } | 248 | } |
229 | 249 | ||
230 | extern "C" HRESULT DependencyDetect( | 250 | extern "C" HRESULT DependencyDetect( |
231 | __in BURN_ENGINE_STATE* pEngineState | 251 | __in BURN_DEPENDENCIES* pDependencies, |
252 | __in BURN_PACKAGES* pPackages, | ||
253 | __in BURN_REGISTRATION* pRegistration | ||
232 | ) | 254 | ) |
233 | { | 255 | { |
234 | HRESULT hr = S_OK; | 256 | HRESULT hr = S_OK; |
235 | BURN_REGISTRATION* pRegistration = &pEngineState->registration; | ||
236 | STRINGDICT_HANDLE sdIgnoredDependents = NULL; | 257 | STRINGDICT_HANDLE sdIgnoredDependents = NULL; |
237 | BURN_PACKAGE* pPackage = NULL; | 258 | BURN_PACKAGE* pPackage = NULL; |
238 | BOOL fSelfDependent = NULL != pRegistration->wzSelfDependent; | ||
239 | BOOL fActiveParent = NULL != pRegistration->sczActiveParent && NULL != *pRegistration->sczActiveParent; | ||
240 | 259 | ||
241 | // Always leave this empty so that all dependents get detected. Plan will ignore dependents based on its own logic. | 260 | // Always leave this empty so that all dependents get detected. Plan will ignore dependents based on its own logic. |
242 | hr = DictCreateStringList(&sdIgnoredDependents, INITIAL_STRINGDICT_SIZE, DICT_FLAG_CASEINSENSITIVE); | 261 | hr = DictCreateStringList(&sdIgnoredDependents, INITIAL_STRINGDICT_SIZE, DICT_FLAG_CASEINSENSITIVE); |
@@ -252,16 +271,16 @@ extern "C" HRESULT DependencyDetect( | |||
252 | hr = S_OK; | 271 | hr = S_OK; |
253 | } | 272 | } |
254 | 273 | ||
255 | for (DWORD iPackage = 0; iPackage < pEngineState->packages.cPackages; ++iPackage) | 274 | for (DWORD iPackage = 0; iPackage < pPackages->cPackages; ++iPackage) |
256 | { | 275 | { |
257 | pPackage = pEngineState->packages.rgPackages + iPackage; | 276 | pPackage = pPackages->rgPackages + iPackage; |
258 | hr = DetectPackageDependents(pPackage, sdIgnoredDependents, pRegistration); | 277 | hr = DetectPackageDependents(pPackage, sdIgnoredDependents, pRegistration); |
259 | ExitOnFailure(hr, "Failed to detect dependents for package '%ls'", pPackage->sczId); | 278 | ExitOnFailure(hr, "Failed to detect dependents for package '%ls'", pPackage->sczId); |
260 | } | 279 | } |
261 | 280 | ||
262 | for (DWORD iRelatedBundle = 0; iRelatedBundle < pEngineState->registration.relatedBundles.cRelatedBundles; ++iRelatedBundle) | 281 | for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) |
263 | { | 282 | { |
264 | BURN_RELATED_BUNDLE* pRelatedBundle = pEngineState->registration.relatedBundles.rgRelatedBundles + iRelatedBundle; | 283 | BURN_RELATED_BUNDLE* pRelatedBundle = pRegistration->relatedBundles.rgRelatedBundles + iRelatedBundle; |
265 | if (!pRelatedBundle->fPlannable) | 284 | if (!pRelatedBundle->fPlannable) |
266 | { | 285 | { |
267 | continue; | 286 | continue; |
@@ -272,18 +291,18 @@ extern "C" HRESULT DependencyDetect( | |||
272 | ExitOnFailure(hr, "Failed to detect dependents for related bundle '%ls'", pPackage->sczId); | 291 | ExitOnFailure(hr, "Failed to detect dependents for related bundle '%ls'", pPackage->sczId); |
273 | } | 292 | } |
274 | 293 | ||
275 | if (fSelfDependent || fActiveParent) | 294 | if (pDependencies->fSelfDependent || pDependencies->fActiveParent) |
276 | { | 295 | { |
277 | for (DWORD i = 0; i < pRegistration->cDependents; ++i) | 296 | for (DWORD i = 0; i < pRegistration->cDependents; ++i) |
278 | { | 297 | { |
279 | DEPENDENCY* pDependent = pRegistration->rgDependents + i; | 298 | DEPENDENCY* pDependent = pRegistration->rgDependents + i; |
280 | 299 | ||
281 | if (fActiveParent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->sczActiveParent, -1, pDependent->sczKey, -1)) | 300 | if (pDependencies->fActiveParent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pDependencies->wzActiveParent, -1, pDependent->sczKey, -1)) |
282 | { | 301 | { |
283 | pRegistration->fParentRegisteredAsDependent = TRUE; | 302 | pRegistration->fParentRegisteredAsDependent = TRUE; |
284 | } | 303 | } |
285 | 304 | ||
286 | if (fSelfDependent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pRegistration->wzSelfDependent, -1, pDependent->sczKey, -1)) | 305 | if (pDependencies->fSelfDependent && CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, pDependencies->wzSelfDependent, -1, pDependent->sczKey, -1)) |
287 | { | 306 | { |
288 | pRegistration->fSelfRegisteredAsDependent = TRUE; | 307 | pRegistration->fSelfRegisteredAsDependent = TRUE; |
289 | } | 308 | } |
@@ -297,16 +316,16 @@ LExit: | |||
297 | } | 316 | } |
298 | 317 | ||
299 | extern "C" HRESULT DependencyPlanInitialize( | 318 | extern "C" HRESULT DependencyPlanInitialize( |
300 | __in const BURN_REGISTRATION* pRegistration, | 319 | __in BURN_DEPENDENCIES* pDependencies, |
301 | __in BURN_PLAN* pPlan | 320 | __in BURN_PLAN* pPlan |
302 | ) | 321 | ) |
303 | { | 322 | { |
304 | HRESULT hr = S_OK; | 323 | HRESULT hr = S_OK; |
305 | 324 | ||
306 | // TODO: After adding enumeration to STRINGDICT, a single STRINGDICT_HANDLE can be used everywhere. | 325 | // TODO: After adding enumeration to STRINGDICT, a single STRINGDICT_HANDLE can be used everywhere. |
307 | for (DWORD i = 0; i < pRegistration->cIgnoredDependencies; ++i) | 326 | for (DWORD i = 0; i < pDependencies->cIgnoredDependencies; ++i) |
308 | { | 327 | { |
309 | DEPENDENCY* pDependency = pRegistration->rgIgnoredDependencies + i; | 328 | DEPENDENCY* pDependency = pDependencies->rgIgnoredDependencies + i; |
310 | 329 | ||
311 | hr = DepDependencyArrayAlloc(&pPlan->rgPlannedProviders, &pPlan->cPlannedProviders, pDependency->sczKey, pDependency->sczName); | 330 | hr = DepDependencyArrayAlloc(&pPlan->rgPlannedProviders, &pPlan->cPlannedProviders, pDependency->sczKey, pDependency->sczName); |
312 | ExitOnFailure(hr, "Failed to add the detected provider to the list of dependencies to ignore."); | 331 | ExitOnFailure(hr, "Failed to add the detected provider to the list of dependencies to ignore."); |
@@ -952,6 +971,7 @@ static HRESULT GetIgnoredDependents( | |||
952 | { | 971 | { |
953 | ExitOnFailure(hr, "Failed to get the package property: %ls", DEPENDENCY_IGNOREDEPENDENCIES); | 972 | ExitOnFailure(hr, "Failed to get the package property: %ls", DEPENDENCY_IGNOREDEPENDENCIES); |
954 | 973 | ||
974 | // TODO: this is the raw value of the property, all property values are currently formatted in a different part of planning. | ||
955 | hr = DependencyAddIgnoreDependencies(*psdIgnoredDependents, sczIgnoreDependencies); | 975 | hr = DependencyAddIgnoreDependencies(*psdIgnoredDependents, sczIgnoreDependencies); |
956 | ExitOnFailure(hr, "Failed to add the authored ignored dependencies to the cumulative list of ignored dependencies."); | 976 | ExitOnFailure(hr, "Failed to add the authored ignored dependencies to the cumulative list of ignored dependencies."); |
957 | } | 977 | } |