diff options
| author | Christian Kandeler <christian.kandeler@digia.com> | 2012-11-29 17:55:50 +0100 |
|---|---|---|
| committer | Christian Kandeler <christian.kandeler@digia.com> | 2012-12-04 11:49:46 +0100 |
| commit | c552cb2ab5c3be9d2c6209b076a71c9e37209c29 (patch) | |
| tree | ddfb4e866597e4856b52ba0a9c7b10e023418df1 /src/lib/buildgraph/buildgraph.h | |
| parent | a1d3d727f53874451bb07e66f275969d9b0e9b02 (diff) | |
| download | qbs-c552cb2ab5c3be9d2c6209b076a71c9e37209c29.tar.gz | |
Split up buildgraph.h and buildgraph.cpp.
Move things to the appropriate places.
Change-Id: I2f201ccdf9c465a8c3201e229629b756cc258495
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/buildgraph/buildgraph.h')
| -rw-r--r-- | src/lib/buildgraph/buildgraph.h | 196 |
1 files changed, 11 insertions, 185 deletions
diff --git a/src/lib/buildgraph/buildgraph.h b/src/lib/buildgraph/buildgraph.h index 25dd664d5..c8c7ec546 100644 --- a/src/lib/buildgraph/buildgraph.h +++ b/src/lib/buildgraph/buildgraph.h @@ -30,116 +30,15 @@ #ifndef QBS_BUILDGRAPH_H #define QBS_BUILDGRAPH_H -#include "artifactlist.h" -#include "forward_decls.h" - #include <language/forward_decls.h> -#include <tools/error.h> -#include <tools/persistentobject.h> -#include <tools/weakpointer.h> -#include <QDir> -#include <QScriptProgram> #include <QScriptValue> -#include <QSet> #include <QStringList> -#include <QVariant> -#include <QVector> namespace qbs { namespace Internal { -class ProgressObserver; -class RulesEvaluationContext; +class Artifact; class ScriptEngine; -class Transformer; - -typedef QMap<QString, ArtifactList> ArtifactsPerFileTagMap; - -class BuildProduct : public PersistentObject -{ -public: - static BuildProductPtr create() { return BuildProductPtr(new BuildProduct); } - - ~BuildProduct(); - - void dump() const; - const QList<RuleConstPtr> &topSortedRules() const; - Artifact *lookupArtifact(const QString &dirPath, const QString &fileName) const; - Artifact *lookupArtifact(const QString &filePath) const; - Artifact *createArtifact(const SourceArtifactConstPtr &sourceArtifact); - void insertArtifact(Artifact *n); - void applyRules(ArtifactsPerFileTagMap &artifactsPerFileTag); - - WeakPointer<BuildProject> project; - ResolvedProductPtr rProduct; - QSet<Artifact *> targetArtifacts; - QList<BuildProductPtr> dependencies; - ArtifactList artifacts; - -private: - BuildProduct(); - - void load(PersistentPool &pool); - void store(PersistentPool &pool) const; - -private: - mutable QList<RuleConstPtr> m_topSortedRules; -}; - -class BuildGraph; -class BuildProjectLoader; -class BuildProjectResolver; - -class BuildProject : public PersistentObject -{ - friend class BuildProjectLoader; - friend class BuildProjectResolver; -public: - BuildProject(); - ~BuildProject(); - - void store() const; - static QString deriveBuildGraphFilePath(const QString &buildDir, const QString projectId); - QString buildGraphFilePath() const; - - void setEvaluationContext(RulesEvaluationContext *evalContext); - RulesEvaluationContext *evaluationContext() const { return m_evalContext; } - - ResolvedProjectPtr resolvedProject() const; - QSet<BuildProductPtr> buildProducts() const; - bool dirty() const; - void markDirty(); - void insertIntoArtifactLookupTable(Artifact *artifact); - void removeFromArtifactLookupTable(Artifact *artifact); - QList<Artifact *> lookupArtifacts(const QString &filePath) const; - QList<Artifact *> lookupArtifacts(const QString &dirPath, const QString &fileName) const; - void insertFileDependency(Artifact *artifact); - void rescueDependencies(const BuildProjectPtr &other); - void removeArtifact(Artifact *artifact); - void updateNodesThatMustGetNewTransformer(); - void removeFromArtifactsThatMustGetNewTransformers(Artifact *a) { - m_artifactsThatMustGetNewTransformers -= a; - } - void addToArtifactsThatMustGetNewTransformers(Artifact *a) { - m_artifactsThatMustGetNewTransformers += a; - } - -private: - void load(PersistentPool &pool); - void store(PersistentPool &pool) const; - void addBuildProduct(const BuildProductPtr &product); - void setResolvedProject(const ResolvedProjectPtr &resolvedProject); - void updateNodeThatMustGetNewTransformer(Artifact *artifact); - -private: - RulesEvaluationContext *m_evalContext; - ResolvedProjectPtr m_resolvedProject; - QSet<BuildProductPtr> m_buildProducts; - ArtifactList m_dependencyArtifacts; - QHash<QString, QHash<QString, QList<Artifact *> > > m_artifactLookupTable; - QSet<Artifact *> m_artifactsThatMustGetNewTransformers; - mutable bool m_dirty; -}; /** * N artifact, T transformer, parent -> child @@ -160,98 +59,25 @@ public: static bool safeConnect(Artifact *u, Artifact *v); static void removeGeneratedArtifactFromDisk(Artifact *artifact); static void disconnect(Artifact *u, Artifact *v); + static void setupScriptEngineForProduct(ScriptEngine *engine, const ResolvedProductConstPtr &product, const RuleConstPtr &rule, QScriptValue targetObject); -private: - BuildGraph(); -}; - -class RulesApplicator -{ -public: - RulesApplicator(BuildProduct *product, ArtifactsPerFileTagMap &artifactsPerFileTag); - void applyAllRules(); - void applyRule(const RuleConstPtr &rule); - -private: - void doApply(const ArtifactList &inputArtifacts); - void setupScriptEngineForArtifact(Artifact *artifact); - Artifact *createOutputArtifact(const RuleArtifactConstPtr &ruleArtifact, - const ArtifactList &inputArtifacts); - QString resolveOutPath(const QString &path) const; - RulesEvaluationContext *evalContext() const; - ScriptEngine *engine() const; - QScriptValue scope() const; - - BuildProduct * const m_buildProduct; - ArtifactsPerFileTagMap &m_artifactsPerFileTag; - - RuleConstPtr m_rule; - TransformerPtr m_transformer; -}; - -class BuildProjectResolver -{ -public: - BuildProjectPtr resolveProject(const ResolvedProjectPtr &resolvedProject, - RulesEvaluationContext *evalContext); - -private: - BuildProductPtr resolveProduct(const ResolvedProductPtr &rProduct); - - RulesEvaluationContext *evalContext() const; - ScriptEngine *engine() const; - QScriptValue scope() const; - - BuildProjectPtr m_project; - QHash<ResolvedProductPtr, BuildProductPtr> m_productCache; -}; - -class BuildProjectLoader -{ -public: - struct LoadResult + static QString fileName(const Artifact *n); // Debugging helpers + template <typename T> + static QStringList toStringList(const T &artifactContainer) { - LoadResult() : discardLoadedProject(false) {} - - ResolvedProjectPtr changedResolvedProject; - BuildProjectPtr loadedProject; - bool discardLoadedProject; - }; - - LoadResult load(const QString &projectFilePath, RulesEvaluationContext *evalContext, - const QString &buildRoot, const QVariantMap &cfg, - const QStringList &loaderSearchPaths); + QStringList l; + foreach (Artifact *n, artifactContainer) + l.append(fileName(n)); + return l; + } private: - void onProductRemoved(const BuildProductPtr &product); - void onProductChanged(const BuildProductPtr &product, - const ResolvedProductPtr &changedProduct); - void removeArtifactAndExclusiveDependents(Artifact *artifact, - QList<Artifact*> *removedArtifacts = 0); - - RulesEvaluationContext *m_evalContext; - LoadResult m_result; + BuildGraph(); }; -// debugging helper -QString fileName(Artifact *n); - -// debugging helper -template <typename T> -static QStringList toStringList(const T &artifactContainer) -{ - QStringList l; - foreach (Artifact *n, artifactContainer) - l.append(fileName(n)); - return l; -} - -char **createCFileTags(const QSet<QString> &fileTags); -void freeCFileTags(char **cFileTags, int numFileTags); - } // namespace Internal } // namespace qbs |
