aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-07-18 11:10:22 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-07-18 16:09:57 +0200
commit0ebf1bfa336b8d1fdf864925cd0cb45f0f56c572 (patch)
tree954348e80efa2d3110c79342729bf6fe2967d4d3
parentcc864b59e10358aa9470a0e03b16bd507bf02033 (diff)
API: Make the ability to update project files optional.
This is the functionality that allows callers to add files to groups etc. Unfortunately, the QML/JS rewriter we use for this purpose pulls in the Qt GUI module, which results in unnecessary library dependencies if one only wants to use the command-line frontend. Therefore, allow this feature to be compiled out. Task-number: QBS-565 Change-Id: Ic134ff9cf37bd552ad493b388c05bcece983fd65 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--qbs.qbs1
-rw-r--r--src/lib/corelib/api/api.pri23
-rw-r--r--src/lib/corelib/api/project.cpp9
-rw-r--r--src/lib/corelib/api/project.h2
-rw-r--r--src/lib/corelib/api/projectfileupdater.h1
-rw-r--r--src/lib/corelib/corelib.qbs25
-rw-r--r--tests/auto/api/api.pro2
-rw-r--r--tests/auto/api/api.qbs4
-rw-r--r--tests/auto/api/tst_api.cpp2
-rw-r--r--tests/auto/api/tst_api.h2
10 files changed, 52 insertions, 19 deletions
diff --git a/qbs.qbs b/qbs.qbs
index 8f8939cbd..8d3a45fd4 100644
--- a/qbs.qbs
+++ b/qbs.qbs
@@ -2,6 +2,7 @@ import qbs 1.0
Project {
property bool enableUnitTests: false
+ property bool enableProjectFileUpdates: false
property bool enableRPath: true
property bool installApiHeaders: true
property bool withExamples: true
diff --git a/src/lib/corelib/api/api.pri b/src/lib/corelib/api/api.pri
index a4b9c4dd7..2bd59b5b6 100644
--- a/src/lib/corelib/api/api.pri
+++ b/src/lib/corelib/api/api.pri
@@ -1,27 +1,21 @@
HEADERS += \
- $$PWD/changeset.h \
$$PWD/internaljobs.h \
$$PWD/projectdata.h \
- $$PWD/projectfileupdater.h \
$$PWD/runenvironment.h \
$$PWD/jobs.h \
$$PWD/languageinfo.h \
$$PWD/project.h \
$$PWD/project_p.h \
$$PWD/propertymap_p.h \
- $$PWD/projectdata_p.h \
- $$PWD/qmljsrewriter.h
+ $$PWD/projectdata_p.h
SOURCES += \
- $$PWD/changeset.cpp \
$$PWD/internaljobs.cpp \
- $$PWD/projectfileupdater.cpp \
$$PWD/runenvironment.cpp \
$$PWD/projectdata.cpp \
$$PWD/jobs.cpp \
$$PWD/languageinfo.cpp \
- $$PWD/project.cpp \
- $$PWD/qmljsrewriter.cpp
+ $$PWD/project.cpp
!qbs_no_dev_install {
api_headers.files = \
@@ -33,3 +27,16 @@ SOURCES += \
api_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/api
INSTALLS += api_headers
}
+
+qbs_enable_project_file_updates {
+ HEADERS += \
+ $$PWD/changeset.h \
+ $$PWD/projectfileupdater.h \
+ $$PWD/qmljsrewriter.h
+
+ SOURCES += \
+ $$PWD/changeset.cpp \
+ $$PWD/projectfileupdater.cpp \
+ $$PWD/qmljsrewriter.cpp
+ DEFINES += QBS_ENABLE_PROJECT_FILE_UPDATES
+}
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp
index 80b5f6632..c83471dbb 100644
--- a/src/lib/corelib/api/project.cpp
+++ b/src/lib/corelib/api/project.cpp
@@ -29,10 +29,13 @@
#include "project.h"
#include "project_p.h"
+#ifdef QBS_ENABLE_PROJECT_FILE_UPDATES
+#include "projectfileupdater.h"
+#endif
+
#include "internaljobs.h"
#include "jobs.h"
#include "projectdata_p.h"
-#include "projectfileupdater.h"
#include "propertymap_p.h"
#include "runenvironment.h"
#include <buildgraph/artifact.h>
@@ -242,6 +245,7 @@ GroupData ProjectPrivate::createGroupDataFromGroup(const GroupPtr &resolvedGroup
return group;
}
+#ifdef QBS_ENABLE_PROJECT_FILE_UPDATES
void ProjectPrivate::addGroup(const ProductData &product, const QString &groupName)
{
if (groupName.isEmpty())
@@ -472,6 +476,7 @@ void ProjectPrivate::removeGroup(const ProductData &product, const GroupData &gr
QBS_CHECK(removed);
}
}
+#endif // QBS_ENABLE_PROJECT_FILE_UPDATES
void ProjectPrivate::removeFilesFromBuildGraph(const ResolvedProductConstPtr &product,
const QList<SourceArtifactPtr> &files)
@@ -936,6 +941,7 @@ QSet<QString> Project::buildSystemFiles() const
return d->internalProject->buildSystemFiles;
}
+#ifdef QBS_ENABLE_PROJECT_FILE_UPDATES
/*!
* \brief Adds a new empty group to the given product.
* Returns an \c ErrorInfo object for which \c hasError() is false in case of a success
@@ -1021,5 +1027,6 @@ ErrorInfo Project::removeGroup(const ProductData &product, const GroupData &grou
return errorInfo;
}
}
+#endif // QBS_ENABLE_PROJECT_FILE_UPDATES
} // namespace qbs
diff --git a/src/lib/corelib/api/project.h b/src/lib/corelib/api/project.h
index a68bbc1c0..efe6e35dc 100644
--- a/src/lib/corelib/api/project.h
+++ b/src/lib/corelib/api/project.h
@@ -123,12 +123,14 @@ public:
QSet<QString> buildSystemFiles() const;
+#ifdef QBS_ENABLE_PROJECT_FILE_UPDATES
ErrorInfo addGroup(const ProductData &product, const QString &groupName);
ErrorInfo addFiles(const ProductData &product, const GroupData &group,
const QStringList &filePaths);
ErrorInfo removeFiles(const ProductData &product, const GroupData &group,
const QStringList &filePaths);
ErrorInfo removeGroup(const ProductData &product, const GroupData &group);
+#endif // QBS_ENABLE_PROJECT_FILE_UPDATES
private:
Project(const Internal::TopLevelProjectPtr &internalProject, const Internal::Logger &logger);
diff --git a/src/lib/corelib/api/projectfileupdater.h b/src/lib/corelib/api/projectfileupdater.h
index 2ff1566ce..552ae9149 100644
--- a/src/lib/corelib/api/projectfileupdater.h
+++ b/src/lib/corelib/api/projectfileupdater.h
@@ -134,5 +134,4 @@ private:
} // namespace Internal
} // namespace qbs
-
#endif // Include guard.
diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs
index ac121783b..e3819cf67 100644
--- a/src/lib/corelib/corelib.qbs
+++ b/src/lib/corelib/corelib.qbs
@@ -3,7 +3,8 @@ import "../Library.qbs" as QbsLibrary
QbsLibrary {
Depends { name: "cpp" }
- Depends { name: "Qt"; submodules: ["gui", "script", "xml"] }
+ Depends { name: "Qt"; submodules: ["script", "xml"] }
+ Depends { condition: project.enableProjectFileUpdates; name: "Qt.gui" }
Depends { condition: project.enableUnitTests; name: "Qt.test" }
name: "qbscore"
cpp.includePaths: base.concat([
@@ -14,7 +15,7 @@ QbsLibrary {
"QBS_VERSION=\"" + version + "\"",
"QT_CREATOR", "QML_BUILD_STATIC_LIB", // needed for QmlJS
"SRCDIR=\"" + path + "\""
- ])
+ ].concat(project.enableProjectFileUpdates ? ["QBS_ENABLE_PROJECT_FILE_UPDATES"] : []))
Properties {
condition: qbs.targetOS.contains("darwin")
@@ -28,11 +29,23 @@ QbsLibrary {
qbs.installDir: headerInstallPrefix
}
Group {
- name: "api"
- prefix: name + '/'
+ name: "project file updating"
+ condition: project.enableProjectFileUpdates
+ prefix: "api/"
files: [
"changeset.cpp",
"changeset.h",
+ "projectfileupdater.cpp",
+ "projectfileupdater.h",
+ "qmljsrewriter.cpp",
+ "qmljsrewriter.h",
+ ]
+ }
+
+ Group {
+ name: "api"
+ prefix: name + '/'
+ files: [
"internaljobs.cpp",
"internaljobs.h",
"jobs.cpp",
@@ -41,10 +54,6 @@ QbsLibrary {
"project_p.h",
"projectdata.cpp",
"projectdata_p.h",
- "projectfileupdater.cpp",
- "projectfileupdater.h",
- "qmljsrewriter.cpp",
- "qmljsrewriter.h",
"propertymap_p.h",
"runenvironment.cpp",
]
diff --git a/tests/auto/api/api.pro b/tests/auto/api/api.pro
index 672947144..0adfa22db 100644
--- a/tests/auto/api/api.pro
+++ b/tests/auto/api/api.pro
@@ -3,4 +3,6 @@ TARGET = tst_api
HEADERS = tst_api.h
SOURCES = tst_api.cpp
+qbs_enable_project_file_updates:DEFINES += QBS_ENABLE_PROJECT_FILE_UPDATES
+
include(../auto.pri)
diff --git a/tests/auto/api/api.qbs b/tests/auto/api/api.qbs
index 9d0e2c0b4..df42afc89 100644
--- a/tests/auto/api/api.qbs
+++ b/tests/auto/api/api.qbs
@@ -3,5 +3,7 @@ import "../autotest.qbs" as AutoTest
AutoTest {
testName: "api"
files: ["tst_api.h", "tst_api.cpp"]
- cpp.defines: base.concat(['SRCDIR="' + path + '"'])
+ cpp.defines: base
+ .concat(['SRCDIR="' + path + '"'])
+ .concat(project.enableProjectFileUpdates ? ["QBS_ENABLE_PROJECT_FILE_UPDATES"] : [])
}
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp
index ef3cf9801..b981ce6f2 100644
--- a/tests/auto/api/tst_api.cpp
+++ b/tests/auto/api/tst_api.cpp
@@ -177,6 +177,7 @@ qbs::GroupData findGroup(const qbs::ProductData &product, const QString &name)
return qbs::GroupData();
}
+#ifdef QBS_ENABLE_PROJECT_FILE_UPDATES
void TestApi::changeContent()
{
qbs::SetupProjectParameters setupParams = defaultSetupParameters();
@@ -423,6 +424,7 @@ void TestApi::changeContent()
}
QVERIFY(job->project().projectData() == projectData);
}
+#endif // QBS_ENABLE_PROJECT_FILE_UPDATES
static qbs::ErrorInfo forceRuleEvaluation(const qbs::Project project)
{
diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h
index 756eb1ed3..473b20c80 100644
--- a/tests/auto/api/tst_api.h
+++ b/tests/auto/api/tst_api.h
@@ -49,7 +49,9 @@ private slots:
void buildGraphLocking();
void buildSingleFile();
+#ifdef QBS_ENABLE_PROJECT_FILE_UPDATES
void changeContent();
+#endif
void disabledInstallGroup();
void fileTagsFilterOverride();
void infiniteLoopBuilding();