aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-02-15 12:47:46 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2018-06-22 05:12:02 +0000
commitf68de01740a3b550a12ec0dbea7bce2ff2e1a382 (patch)
tree7f9b55d0b53ad6525026156904019654eb67fb3d
parent9d3f5a783a4642bc4a22f2fcab5d95bb4df7daa3 (diff)
Get rid of the need for "import qbs"
It is difficult to place why the "import qbs" statement is needed. What it does is providing the default imports like CppApplication. There's no advantage in having a project file without this base import, so we always import "qbs" implicitly now. [ChangeLog] Removed the need to add "import qbs" to project files. Change-Id: I5954fbbade361188d1d54815cc3bf806fb461e9d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--doc/howtos.qdoc8
-rw-r--r--doc/qbs.qdoc12
-rw-r--r--doc/reference/items/convenience/androidapk.qdoc2
-rw-r--r--doc/reference/items/convenience/appleapplicationdiskimage.qdoc2
-rw-r--r--doc/reference/items/language/group.qbs2
-rw-r--r--doc/reference/items/language/module.qdoc1
-rw-r--r--doc/reference/modules/android-ndk-module.qdoc2
-rw-r--r--doc/targets/qbs-target-qnx.qdoc2
-rw-r--r--src/lib/corelib/language/astimportshandler.cpp13
-rw-r--r--src/lib/corelib/language/astimportshandler.h2
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.cpp6
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.h2
12 files changed, 16 insertions, 38 deletions
diff --git a/doc/howtos.qdoc b/doc/howtos.qdoc
index 6039a23fb..cc982023d 100644
--- a/doc/howtos.qdoc
+++ b/doc/howtos.qdoc
@@ -72,7 +72,6 @@
This is achieved by introducing a \e dependency between the two products using the
\l{Depends} item. Here is a simple, but complete example:
\code
- import qbs
Project {
CppApplication {
name : "the-app"
@@ -120,8 +119,6 @@
For example:
\code
- import qbs
-
CppApplication {
name: "the-app"
files: ["main.cpp"]
@@ -210,7 +207,6 @@
Finally, declare dependencies on \c ThirdParty in your project:
\code
- import qbs
CppApplication {
name: "the-app"
files: ["main.cpp"]
@@ -227,8 +223,6 @@
Here is a simple example for an application:
\code
- import qbs
-
Application {
Depends { name: "cpp" }
Depends { name: "bundle" }
@@ -241,8 +235,6 @@
and for a framework:
\code
- import qbs
-
DynamicLibrary {
Depends { name: "cpp" }
Depends { name: "bundle" }
diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc
index bfeda503a..c73b3f148 100644
--- a/doc/qbs.qdoc
+++ b/doc/qbs.qdoc
@@ -170,8 +170,6 @@
\l{cpp} module:
\code
- import qbs
-
Application {
name: "helloworld"
files: "main.cpp"
@@ -330,8 +328,6 @@
The following example product contains one file tag, \e application:
\code
- import qbs
-
Product {
Depends { name: "cpp" }
type: ["application"]
@@ -350,7 +346,6 @@
artifacts that takes \c .cpp artifacts as input.
\code
- import qbs
Module {
// ...
Rule {
@@ -819,8 +814,6 @@
A very simple C++ hello world project looks like this:
\code
---helloworld.qbs---
- import qbs 1.0
-
Application {
name: "helloworld"
files: "main.cpp"
@@ -862,8 +855,6 @@
\code
---CrazyProduct.qbs---
- import qbs 1.0
-
Product {
property string craziness: "low"
}
@@ -887,7 +878,6 @@
}
---myproject.qbs---
- import qbs 1.0
import "helpers.js" as Helpers
Product {
@@ -934,8 +924,6 @@
module. You specify the optimization level for your product (and all build variants) like this:
\code ---helloworld.qbs---
- import qbs 1.0
-
Application {
name: "helloworld"
files: ["main.cpp"]
diff --git a/doc/reference/items/convenience/androidapk.qdoc b/doc/reference/items/convenience/androidapk.qdoc
index 89a4112b6..19c4541ec 100644
--- a/doc/reference/items/convenience/androidapk.qdoc
+++ b/doc/reference/items/convenience/androidapk.qdoc
@@ -43,8 +43,6 @@
example that comes with the Android SDK:
\code
- import qbs
-
AndroidApk {
name: "Basic Media Decoder"
packageName: "com.example.android.basicmediadecoder"
diff --git a/doc/reference/items/convenience/appleapplicationdiskimage.qdoc b/doc/reference/items/convenience/appleapplicationdiskimage.qdoc
index d8011d66a..87129169d 100644
--- a/doc/reference/items/convenience/appleapplicationdiskimage.qdoc
+++ b/doc/reference/items/convenience/appleapplicationdiskimage.qdoc
@@ -51,8 +51,6 @@
Here is what the project file could look like for a simple DMG installer:
\code
- import qbs
-
AppleApplicationDiskImage {
Depends { name: "myapp" }
name: "My App"
diff --git a/doc/reference/items/language/group.qbs b/doc/reference/items/language/group.qbs
index 4b478bfa5..c6bbae875 100644
--- a/doc/reference/items/language/group.qbs
+++ b/doc/reference/items/language/group.qbs
@@ -28,8 +28,6 @@
**
****************************************************************************/
-import qbs 1.0
-
Project {
Product {
//! [0]
diff --git a/doc/reference/items/language/module.qdoc b/doc/reference/items/language/module.qdoc
index fb2238e0c..bfaedacc9 100644
--- a/doc/reference/items/language/module.qdoc
+++ b/doc/reference/items/language/module.qdoc
@@ -41,7 +41,6 @@
characters from them. The module's name is \c{txt_processor}.
\code
- import qbs
import qbs.FileInfo
import qbs.TextFile
diff --git a/doc/reference/modules/android-ndk-module.qdoc b/doc/reference/modules/android-ndk-module.qdoc
index 23c70eec7..032cca97f 100644
--- a/doc/reference/modules/android-ndk-module.qdoc
+++ b/doc/reference/modules/android-ndk-module.qdoc
@@ -43,8 +43,6 @@
the NDK could look like:
\code
- import qbs
-
Project {
DynamicLibrary {
name: "hello-jni"
diff --git a/doc/targets/qbs-target-qnx.qdoc b/doc/targets/qbs-target-qnx.qdoc
index fc03ce677..c7e28d905 100644
--- a/doc/targets/qbs-target-qnx.qdoc
+++ b/doc/targets/qbs-target-qnx.qdoc
@@ -48,8 +48,6 @@
\l{qnx::sdkDir}{qnx.sdkDir} property:
\code
- import qbs
-
Application {
name: "helloworld"
files: "main.cpp"
diff --git a/src/lib/corelib/language/astimportshandler.cpp b/src/lib/corelib/language/astimportshandler.cpp
index f1d103718..960af4cda 100644
--- a/src/lib/corelib/language/astimportshandler.cpp
+++ b/src/lib/corelib/language/astimportshandler.cpp
@@ -75,14 +75,22 @@ void ASTImportsHandler::handleImports(const QbsQmlJS::AST::UiImportList *uiImpor
// files in the same directory are available as prototypes
collectPrototypes(m_directory, QString());
+ bool baseImported = false;
for (const auto *it = uiImportList; it; it = it->next)
- handleImport(it->import);
+ handleImport(it->import, &baseImported);
+ if (!baseImported) {
+ QStringRef qbsref(&StringConstants::qbsModule());
+ QbsQmlJS::AST::UiQualifiedId qbsURI(qbsref);
+ qbsURI.finish();
+ QbsQmlJS::AST::UiImport imp(&qbsURI);
+ handleImport(&imp, &baseImported);
+ }
for (auto it = m_jsImports.constBegin(); it != m_jsImports.constEnd(); ++it)
m_file->addJsImport(it.value());
}
-void ASTImportsHandler::handleImport(const QbsQmlJS::AST::UiImport *import)
+void ASTImportsHandler::handleImport(const QbsQmlJS::AST::UiImport *import, bool *baseImported)
{
QStringList importUri;
bool isBase = false;
@@ -92,6 +100,7 @@ void ASTImportsHandler::handleImport(const QbsQmlJS::AST::UiImport *import)
|| (importUri.size() == 2 && importUri.front() == StringConstants::qbsModule()
&& importUri.last() == StringConstants::baseVar());
if (isBase) {
+ *baseImported = true;
checkImportVersion(import->versionToken);
} else if (import->versionToken.length) {
m_logger.printWarning(ErrorInfo(Tr::tr("Superfluous version specification."),
diff --git a/src/lib/corelib/language/astimportshandler.h b/src/lib/corelib/language/astimportshandler.h
index b69a8fab7..e9c2b6c27 100644
--- a/src/lib/corelib/language/astimportshandler.h
+++ b/src/lib/corelib/language/astimportshandler.h
@@ -75,7 +75,7 @@ private:
void collectPrototypes(const QString &path, const QString &as);
void collectPrototypesAndJsCollections(const QString &path, const QString &as,
const CodeLocation &location);
- void handleImport(const QbsQmlJS::AST::UiImport *import);
+ void handleImport(const QbsQmlJS::AST::UiImport *import, bool *baseImported);
ItemReaderVisitorState &m_visitorState;
Logger &m_logger;
diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp
index 5b042ffb4..2ea306138 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.cpp
+++ b/src/lib/corelib/language/itemreaderastvisitor.cpp
@@ -75,12 +75,12 @@ ItemReaderASTVisitor::ItemReaderASTVisitor(ItemReaderVisitorState &visitorState,
{
}
-bool ItemReaderASTVisitor::visit(AST::UiImportList *uiImportList)
+bool ItemReaderASTVisitor::visit(AST::UiProgram *uiProgram)
{
ASTImportsHandler importsHandler(m_visitorState, m_logger, m_file);
- importsHandler.handleImports(uiImportList);
+ importsHandler.handleImports(uiProgram->imports);
m_typeNameToFile = importsHandler.typeNameFileMap();
- return false;
+ return true;
}
static ItemValuePtr findItemProperty(const Item *container, const Item *item)
diff --git a/src/lib/corelib/language/itemreaderastvisitor.h b/src/lib/corelib/language/itemreaderastvisitor.h
index 6bd39ceb2..4a0bedc91 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.h
+++ b/src/lib/corelib/language/itemreaderastvisitor.h
@@ -67,7 +67,7 @@ public:
Item *rootItem() const { return m_item; }
private:
- bool visit(QbsQmlJS::AST::UiImportList *uiImportList) override;
+ bool visit(QbsQmlJS::AST::UiProgram *uiProgram) override;
bool visit(QbsQmlJS::AST::UiObjectDefinition *ast) override;
bool visit(QbsQmlJS::AST::UiPublicMember *ast) override;
bool visit(QbsQmlJS::AST::UiScriptBinding *ast) override;