@@ -49,19 +49,23 @@ namespace Internal {
4949class TrafoChangeTracker
5050{
5151public:
52- TrafoChangeTracker (const Transformer *transformer,
53- const ResolvedProduct *product,
54- const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
55- const std::unordered_map<QString, const ResolvedProject *> &projectsByName)
56- : m_transformer(transformer),
57- m_product (product),
58- m_productsByName(productsByName),
59- m_projectsByName(projectsByName)
52+ TrafoChangeTracker (
53+ const Transformer *transformer,
54+ const ResolvedScanner *scanner,
55+ const ResolvedProduct *product,
56+ const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
57+ const std::unordered_map<QString, const ResolvedProject *> &projectsByName)
58+ : m_transformer(transformer)
59+ , m_scanner(scanner)
60+ , m_product(product)
61+ , m_productsByName(productsByName)
62+ , m_projectsByName(projectsByName)
6063 {
6164 }
6265
6366 bool prepareScriptNeedsRerun () const ;
6467 bool commandsNeedRerun () const ;
68+ bool scannerNeedsInvalidation () const ;
6569
6670private:
6771 QVariantMap propertyMapByKind (const Property &property) const ;
@@ -77,6 +81,7 @@ class TrafoChangeTracker
7781 const ResolvedProduct *getProduct (const QString &name) const ;
7882
7983 const Transformer * const m_transformer;
84+ const ResolvedScanner * const m_scanner;
8085 const ResolvedProduct * const m_product;
8186 const std::unordered_map<QString, const ResolvedProduct *> &m_productsByName;
8287 const std::unordered_map<QString, const ResolvedProject *> &m_projectsByName;
@@ -352,6 +357,35 @@ bool TrafoChangeTracker::commandsNeedRerun() const
352357 return false ;
353358}
354359
360+ bool TrafoChangeTracker::scannerNeedsInvalidation () const
361+ {
362+ for (const Property &property : std::as_const (m_scanner->propertiesRequested )) {
363+ if (checkForPropertyChange (property, propertyMapByKind (property)))
364+ return true ;
365+ }
366+
367+ // TODO: imports, deps, artifacts map, exported modules? (See prepare script checker)
368+
369+ for (auto it = m_scanner->propertiesRequestedFromArtifacts .cbegin ();
370+ it != m_scanner->propertiesRequestedFromArtifacts .cend ();
371+ ++it) {
372+ for (const Property &property : std::as_const (it.value ())) {
373+ const Artifact * const artifact = getArtifact (it.key (), property.productName );
374+ if (!artifact)
375+ return true ;
376+ if (property.kind == Property::PropertyInArtifact) {
377+ if (sorted (artifact->fileTags ().toStringList ()) != property.value .toStringList ())
378+ return true ;
379+ continue ;
380+ }
381+ if (checkForPropertyChange (property, artifact->properties ->value ()))
382+ return true ;
383+ }
384+ }
385+
386+ return false ;
387+ }
388+
355389bool prepareScriptNeedsRerun (
356390 Transformer *transformer, const ResolvedProduct *product,
357391 const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
@@ -360,8 +394,8 @@ bool prepareScriptNeedsRerun(
360394 if (!transformer->prepareScriptNeedsChangeTracking )
361395 return false ;
362396 transformer->prepareScriptNeedsChangeTracking = false ;
363- return TrafoChangeTracker (transformer, product, productsByName, projectsByName)
364- .prepareScriptNeedsRerun ();
397+ return TrafoChangeTracker (transformer, nullptr , product, productsByName, projectsByName)
398+ .prepareScriptNeedsRerun ();
365399}
366400
367401bool commandsNeedRerun (Transformer *transformer, const ResolvedProduct *product,
@@ -371,8 +405,18 @@ bool commandsNeedRerun(Transformer *transformer, const ResolvedProduct *product,
371405 if (!transformer->commandsNeedChangeTracking )
372406 return false ;
373407 transformer->commandsNeedChangeTracking = false ;
374- return TrafoChangeTracker (transformer, product, productsByName, projectsByName)
375- .commandsNeedRerun ();
408+ return TrafoChangeTracker (transformer, nullptr , product, productsByName, projectsByName)
409+ .commandsNeedRerun ();
410+ }
411+
412+ bool scannerNeedsInvalidation (
413+ const ResolvedScanner *scanner,
414+ const ResolvedProduct *product,
415+ const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
416+ const std::unordered_map<QString, const ResolvedProject *> &projectsByName)
417+ {
418+ return TrafoChangeTracker (nullptr , scanner, product, productsByName, projectsByName)
419+ .scannerNeedsInvalidation ();
376420}
377421
378422} // namespace Internal
0 commit comments