diff options
-rw-r--r-- | .github/workflows/main.yml | 39 | ||||
-rw-r--r-- | changelogs/changes-2.0.1.md | 8 | ||||
-rwxr-xr-x | scripts/install-qt.sh | 7 | ||||
-rw-r--r-- | share/qbs/module-providers/Qt/setup-qt.js | 2 | ||||
-rw-r--r-- | share/qbs/module-providers/Qt/templates/qml.js | 24 | ||||
-rw-r--r-- | share/qbs/module-providers/Qt/templates/qml.qbs | 8 | ||||
-rw-r--r-- | src/app/qbs-setup-toolchains/xcodeprobe.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/language/evaluator.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/language/scriptengine.cpp | 63 | ||||
-rw-r--r-- | src/lib/corelib/language/scriptengine.h | 15 | ||||
-rw-r--r-- | src/lib/corelib/language/scriptimporter.cpp | 5 | ||||
-rw-r--r-- | tests/auto/language/testdata/erroneous/missing-js-file.qbs | 3 | ||||
-rw-r--r-- | tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file-module.qbs | 3 | ||||
-rw-r--r-- | tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file.js | 1 | ||||
-rw-r--r-- | tests/auto/language/tst_language.cpp | 2 |
15 files changed, 129 insertions, 59 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 80c5c0228..dacf54a9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -629,43 +629,43 @@ jobs: matrix: config: - { - name: 'Run macOS tests (Xcode 14.1)', + name: 'Run macOS tests (Xcode 14.2)', runner: 'macos-12', target: 'desktop', toolchain: 'clang_64', - xcodeVersion: '14.1', - testProfile: 'xcode_14_1-macosx-x86_64', - qtVersion: '5.15.2', + xcodeVersion: '14.2', + testProfile: 'xcode_14_2-macosx-x86_64', + qtVersion: '6.5.0', script: './scripts/test-qbs.sh', } - { - name: 'Run macOS tests (Xcode 14.1, Qt 6.3)', + name: 'Run macOS tests (Xcode 14.2, Qt 5.15)', runner: 'macos-12', target: 'desktop', toolchain: 'clang_64', - xcodeVersion: '14.1', - testProfile: 'xcode_14_1-macosx-x86_64', - qtVersion: '6.3.1', + xcodeVersion: '14.2', + testProfile: 'xcode_14_2-macosx-x86_64', + qtVersion: '5.15.2', script: './scripts/test-qt.sh', } - { - name: 'Run iOS tests (Xcode 14.1)', + name: 'Run iOS tests (Xcode 14.2)', runner: 'macos-12', target: 'ios', toolchain: 'ios', - xcodeVersion: '14.1', + xcodeVersion: '14.2', testProfile: 'xcode_14_1-iphoneos-arm64', - qtVersion: '5.15.2', + qtVersion: '6.3.2', script: './scripts/test-qbs.sh', } - { - name: 'Run iOS-sim tests (Xcode 14.1)', + name: 'Run iOS-sim tests (Xcode 14.2)', runner: 'macos-12', target: 'ios', toolchain: 'ios', - xcodeVersion: '14.1', + xcodeVersion: '14.2', testProfile: 'xcode_14_1-iphonesimulator-x86_64', - qtVersion: '5.15.2', + qtVersion: '6.3.2', script: './scripts/test-qbs.sh', } - { @@ -675,7 +675,7 @@ jobs: toolchain: 'clang_64', xcodeVersion: '13.4.1', testProfile: 'xcode_13_4_1-macosx-x86_64', - qtVersion: '5.15.2', + qtVersion: '6.5.0', script: './scripts/test-qbs.sh', } @@ -686,7 +686,7 @@ jobs: toolchain: 'clang_64', xcodeVersion: '12.5.1', testProfile: 'xcode_12_5_1-macosx-x86_64', - qtVersion: '5.15.2', + qtVersion: '6.5.0', script: './scripts/test-qbs.sh', } steps: @@ -702,6 +702,13 @@ jobs: run: echo "./release/install-root/usr/local/bin" >> $GITHUB_PATH - name: Install required packages run: brew install capnp ccache grpc icoutils makensis protobuf p7zip + - name: Install Host Qt + if: matrix.config.toolchain == 'ios' + uses: ./.github/actions/download-qt + with: + target: 'desktop' + toolchain: 'clang_64' + version: ${{ matrix.config.qtVersion }} - name: Install Qt uses: ./.github/actions/download-qt with: diff --git a/changelogs/changes-2.0.1.md b/changelogs/changes-2.0.1.md index 8213c9eed..0f1bf4973 100644 --- a/changelogs/changes-2.0.1.md +++ b/changelogs/changes-2.0.1.md @@ -1,8 +1,12 @@ +# C/C++ Support +* Fixed building applications with mingw toolchain and Qt6 (QBS-1724). + # Apple Support -* Added support for Xcode 14.3 +* Added support for Xcode 14.3. +* Fixed codesigning on macOS (QBS-1722). # Build System -* Fixed qbsbuildconfig module +* Fixed qbsbuildconfig module. # Contributors * Christian Kandeler diff --git a/scripts/install-qt.sh b/scripts/install-qt.sh index 717bab6af..0931693e5 100755 --- a/scripts/install-qt.sh +++ b/scripts/install-qt.sh @@ -367,6 +367,13 @@ for COMPONENT in ${COMPONENTS}; do QMAKE_FILE="${UNPACK_DIR}/${VERSION}/gcc_64/bin/qmake" sed -i "s|\/home\/qt\/work\/install\/bin\/qmake|$QMAKE_FILE|g" "${ANDROID_QMAKE_FILE}" sed -i "s|\/Users\/qt\/work\/install\/bin\/qmake|$QMAKE_FILE|g" "${ANDROID_QMAKE_FILE}" + elif [ "${TARGET_PLATFORM}" == "ios" ] && [ ! "${VERSION}" \< "6.0.0" ]; then + CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/target_qt.conf" + sed -i.bak "s|HostData=target|HostData=../$TOOLCHAIN|g" "${CONF_FILE}" + sed -i.bak "s|HostPrefix=..\/..\/|HostPrefix=..\/..\/macos|g" "${CONF_FILE}" + IOS_QMAKE_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qmake" + QMAKE_FILE="${UNPACK_DIR}/${VERSION}/macos/bin/qmake" + sed -i.bak "s|\/Users\/qt\/work\/install\/bin\/qmake|${QMAKE_FILE}|g" "${IOS_QMAKE_FILE}" else CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qt.conf" echo "[Paths]" > ${CONF_FILE} diff --git a/share/qbs/module-providers/Qt/setup-qt.js b/share/qbs/module-providers/Qt/setup-qt.js index 896b5a457..9fcef7897 100644 --- a/share/qbs/module-providers/Qt/setup-qt.js +++ b/share/qbs/module-providers/Qt/setup-qt.js @@ -766,9 +766,11 @@ function doSetupLibraries(modInfo, qtProps, debugBuild, nonExistingPrlFiles, and var parts = extractPaths(line.slice(equalsOffset + 1).trim(), prlFilePath); for (i = 0; i < parts.length; ++i) { var part = parts[i]; + var defaultInstallPrefix = "/Users/qt/work/qt/qtbase/build/target"; part = part.replace("$$[QT_INSTALL_LIBS]", qtProps.libraryPath); part = part.replace("$$[QT_INSTALL_PLUGINS]", qtProps.pluginPath); part = part.replace("$$[QT_INSTALL_PREFIX]", qtProps.installPrefixPath); + part = part.replace(defaultInstallPrefix, qtProps.installPrefixPath); if (part.startsWith("-l")) { libs.push(part.slice(2)); } else if (part.startsWith("-L")) { diff --git a/share/qbs/module-providers/Qt/templates/qml.js b/share/qbs/module-providers/Qt/templates/qml.js index 2a2ff85ab..ad76a0d0f 100644 --- a/share/qbs/module-providers/Qt/templates/qml.js +++ b/share/qbs/module-providers/Qt/templates/qml.js @@ -39,17 +39,32 @@ function getPrlRhs(line) return line.split('=')[1].trim(); } -function getLibsForPlugin(pluginData, buildVariant, targetOS, toolchain, qtLibDir, qtPluginDir, - qtDir) +function getLibsForPlugin(pluginData, product) { + var targetOS = product.qbs.targetOS; + var toolchain = product.qbs.toolchain; + var buildVariant = product.Qt.core.qtBuildVariant; + var qtLibDir = product.Qt.core.libPath; + var qtPluginDir = product.Qt.core.pluginPath; + var qtDir = product.Qt.core.installPrefixPath; + var qtQmlPath = product.Qt.qml.qmlPath; + if (!pluginData.path) return ""; var prlFileName = ""; if (!targetOS.contains("windows")) prlFileName += "lib"; prlFileName += pluginData.plugin; - if (buildVariant === "debug" && targetOS.contains("windows")) - prlFileName += "d"; + if (buildVariant === "debug") { + if (targetOS.contains("windows")) { + prlFileName += "d"; + } else if (product.Qt.core.versionMajor >= 6 && + (targetOS.contains("ios") + || targetOS.contains("tvos") + || targetOS.contains("watchos"))) { + prlFileName += "_debug"; + } + } prlFileName += ".prl"; var prlFilePath = FileInfo.joinPaths(pluginData.path, prlFileName); if (!File.exists(prlFilePath)) { @@ -77,6 +92,7 @@ function getLibsForPlugin(pluginData, buildVariant, targetOS, toolchain, qtLibDi otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_LIBS\]/g, qtLibDir); otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_PLUGINS\]/g, qtPluginDir); otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_PREFIX\]/g, qtDir); + otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_QML\]/g, qtQmlPath); otherLibs = otherLibs.concat(otherLibsLine.split(' ')); } } diff --git a/share/qbs/module-providers/Qt/templates/qml.qbs b/share/qbs/module-providers/Qt/templates/qml.qbs index f15705cc5..de1318695 100644 --- a/share/qbs/module-providers/Qt/templates/qml.qbs +++ b/share/qbs/module-providers/Qt/templates/qml.qbs @@ -170,13 +170,7 @@ QtModule { } if (cppFile) cppFile.writeLine("Q_IMPORT_PLUGIN(" + className + ")"); - var libs = Qml.getLibsForPlugin(scannerData[p], - product.Qt.core.qtBuildVariant, - product.qbs.targetOS, - product.qbs.toolchain, - product.Qt.core.libPath, - product.Qt.core.pluginPath, - product.Qt.core.installPrefixPath); + var libs = Qml.getLibsForPlugin(scannerData[p], product); for (var i = 0; i < libs.length; ++i) { var lib = libs[i]; if (!lib.endsWith(product.cpp.objectSuffix) diff --git a/src/app/qbs-setup-toolchains/xcodeprobe.cpp b/src/app/qbs-setup-toolchains/xcodeprobe.cpp index bb246742f..5fbfcc4e6 100644 --- a/src/app/qbs-setup-toolchains/xcodeprobe.cpp +++ b/src/app/qbs-setup-toolchains/xcodeprobe.cpp @@ -150,7 +150,7 @@ void XcodeProbe::detectDeveloperPaths() if (!selectedXcode.waitForFinished(-1) || selectedXcode.exitCode()) { qbsInfo() << Tr::tr("Could not detect selected Xcode with /usr/bin/xcode-select"); } else { - QString path = QString::fromLocal8Bit(selectedXcode.readAllStandardOutput()); + QString path = QString::fromLocal8Bit(selectedXcode.readAllStandardOutput().trimmed()); addDeveloperPath(path); } addDeveloperPath(defaultDeveloperPath); diff --git a/src/lib/corelib/language/evaluator.cpp b/src/lib/corelib/language/evaluator.cpp index 833ab96f2..4d85f5f8a 100644 --- a/src/lib/corelib/language/evaluator.cpp +++ b/src/lib/corelib/language/evaluator.cpp @@ -268,9 +268,9 @@ Evaluator::FileContextScopes Evaluator::fileContextScopes(const FileContextConst } if (!JS_IsObject(result.importScope)) { try { - result.importScope = m_scriptEngine->newObject(); - setupScriptEngineForFile(m_scriptEngine, file, result.importScope, - ObserveMode::Enabled); + ScopedJsValue importScope(m_scriptEngine->context(), m_scriptEngine->newObject()); + setupScriptEngineForFile(m_scriptEngine, file, importScope, ObserveMode::Enabled); + result.importScope = importScope.release(); } catch (const ErrorInfo &e) { result.importScope = throwError(m_scriptEngine->context(), e.toString()); } diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp index c5d4656cb..58c2817c6 100644 --- a/src/lib/corelib/language/scriptengine.cpp +++ b/src/lib/corelib/language/scriptengine.cpp @@ -226,22 +226,7 @@ void ScriptEngine::reset() void ScriptEngine::import(const FileContextBaseConstPtr &fileCtx, JSValue &targetObject, ObserveMode observeMode) { - installImportFunctions(targetObject); - m_currentDirPathStack.push(FileInfo::path(fileCtx->filePath())); - m_extensionSearchPathsStack.push(fileCtx->searchPaths()); - m_observeMode = observeMode; - - for (const JsImport &jsImport : fileCtx->jsImports()) - import(jsImport, targetObject); - if (m_observeMode == ObserveMode::Enabled) { - for (JSValue &sv : m_requireResults) - observeImport(sv); - m_requireResults.clear(); - } - - m_currentDirPathStack.pop(); - m_extensionSearchPathsStack.pop(); - uninstallImportFunctions(); + Importer(*this, fileCtx, targetObject, observeMode).run(); } void ScriptEngine::import(const JsImport &jsImport, JSValue &targetObject) @@ -259,9 +244,10 @@ void ScriptEngine::import(const JsImport &jsImport, JSValue &targetObject) if (debugJSImports) qDebug() << "[ENGINE] " << jsImport.filePaths << " (cache miss)"; - jsImportValue = JS_NewObject(m_context); + ScopedJsValue scopedImportValue(m_context, JS_NewObject(m_context)); for (const QString &filePath : jsImport.filePaths) - importFile(filePath, jsImportValue); + importFile(filePath, scopedImportValue); + jsImportValue = scopedImportValue.release(); m_jsImportCache.insert(jsImport, jsImportValue); std::vector<QString> &filePathsForScriptValue = m_filePathsPerImport[jsObjectId(jsImportValue)]; @@ -437,7 +423,7 @@ void ScriptEngine::setEnvironment(const QProcessEnvironment &env) m_environment = env; } -void ScriptEngine::importFile(const QString &filePath, JSValue &targetObject) +void ScriptEngine::importFile(const QString &filePath, JSValue targetObject) { AccumulatingTimer importTimer(m_elapsedTimeImporting != -1 ? &m_elapsedTimeImporting : nullptr); JSValue &evaluationResult = m_jsFileCache[filePath]; @@ -591,9 +577,9 @@ JSValue ScriptEngine::js_require(JSContext *ctx, JSValueConst this_val, engine->m_logger.qbsDebug() << "[require] importing file " << filePath; } - JSValue obj = engine->newObject(); + ScopedJsValue obj(engine->context(), engine->newObject()); engine->importFile(filePath, obj); - values << obj; + values << obj.release(); filePaths.push_back(filePath); } } catch (const ErrorInfo &e) { @@ -624,8 +610,9 @@ JSValue ScriptEngine::js_require(JSContext *ctx, JSValueConst this_val, result = getJsProperty(ctx, func_data[0], scopeName); if (JS_IsObject(result)) return result; // Same JS file imported from same qbs file via different JS files (e.g. codesign.js from DarwinGCC.qbs via gcc.js and darwin.js). - result = engine->newObject(); - engine->importFile(filePath, result); + ScopedJsValue scopedResult(engine->context(), engine->newObject()); + engine->importFile(filePath, scopedResult); + result = scopedResult.release(); setJsProperty(ctx, result, StringConstants::importScopeNamePropertyInternal(), scopeName); setJsProperty(ctx, func_data[0], scopeName, result); engine->m_requireResults.push_back(result); @@ -1020,5 +1007,35 @@ void ScriptEngine::takeOwnership(JSValue v) ++m_evalResults[v]; } +ScriptEngine::Importer::Importer( + ScriptEngine &engine, const FileContextBaseConstPtr &fileCtx, JSValue &targetObject, + ObserveMode observeMode) + : m_engine(engine), m_fileCtx(fileCtx), m_targetObject(targetObject) +{ + m_engine.installImportFunctions(targetObject); + m_engine.m_currentDirPathStack.push(FileInfo::path(fileCtx->filePath())); + m_engine.m_extensionSearchPathsStack.push(fileCtx->searchPaths()); + m_engine.m_observeMode = observeMode; +} + +ScriptEngine::Importer::~Importer() +{ + if (m_engine.m_observeMode == ObserveMode::Enabled) + m_engine.m_requireResults.clear(); + m_engine.m_currentDirPathStack.pop(); + m_engine.m_extensionSearchPathsStack.pop(); + m_engine.uninstallImportFunctions(); +} + +void ScriptEngine::Importer::run() +{ + for (const JsImport &jsImport : m_fileCtx->jsImports()) + m_engine.import(jsImport, m_targetObject); + if (m_engine.m_observeMode == ObserveMode::Enabled) { + for (JSValue &sv : m_engine.m_requireResults) + m_engine.observeImport(sv); + } +} + } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/language/scriptengine.h b/src/lib/corelib/language/scriptengine.h index d7798decf..8c97e3079 100644 --- a/src/lib/corelib/language/scriptengine.h +++ b/src/lib/corelib/language/scriptengine.h @@ -292,6 +292,19 @@ public: void setProperty(const char *k, const QVariant &v) { m_properties.insert(QLatin1String(k), v); } private: + class Importer { + public: + Importer(ScriptEngine &engine, const FileContextBaseConstPtr &fileCtx, + JSValue &targetObject, ObserveMode observeMode); + ~Importer(); + void run(); + + private: + ScriptEngine &m_engine; + const FileContextBaseConstPtr &m_fileCtx; + JSValue &m_targetObject; + }; + static int interruptor(JSRuntime *rt, void *opaqueEngine); bool gatherFileResults() const; @@ -305,7 +318,7 @@ private: void uninstallImportFunctions(); void import(const JsImport &jsImport, JSValue &targetObject); void observeImport(JSValue &jsImport); - void importFile(const QString &filePath, JSValue &targetObject); + void importFile(const QString &filePath, JSValue targetObject); static JSValue js_require(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic, JSValue *func_data); JSValue mergeExtensionObjects(const JSValueList &lst); diff --git a/src/lib/corelib/language/scriptimporter.cpp b/src/lib/corelib/language/scriptimporter.cpp index 1b012f3c3..fdb0689ad 100644 --- a/src/lib/corelib/language/scriptimporter.cpp +++ b/src/lib/corelib/language/scriptimporter.cpp @@ -142,10 +142,11 @@ JSValue ScriptImporter::importSourceCode(const QString &sourceCode, const QStrin code = QLatin1String("(function(){\n") + sourceCode + extractor.suffix(); } - JSValue result = m_engine->evaluate(JsValueOwner::Caller, code, filePath, 0); + ScopedJsValue result(m_engine->context(), + m_engine->evaluate(JsValueOwner::Caller, code, filePath, 0)); throwOnEvaluationError(m_engine, [&filePath] () { return CodeLocation(filePath, 0); }); copyProperties(m_engine->context(), result, targetObject); - return result; + return result.release(); } void ScriptImporter::copyProperties(JSContext *ctx, const JSValue &src, JSValue &dst) diff --git a/tests/auto/language/testdata/erroneous/missing-js-file.qbs b/tests/auto/language/testdata/erroneous/missing-js-file.qbs new file mode 100644 index 000000000..a3274a35b --- /dev/null +++ b/tests/auto/language/testdata/erroneous/missing-js-file.qbs @@ -0,0 +1,3 @@ +Product { + Depends { name: "missing-js-file-module" } +} diff --git a/tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file-module.qbs b/tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file-module.qbs new file mode 100644 index 000000000..31302b5c2 --- /dev/null +++ b/tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file-module.qbs @@ -0,0 +1,3 @@ +import "missing-js-file.js" as MissingJsFile + +Module { } diff --git a/tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file.js b/tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file.js new file mode 100644 index 000000000..b66048a8f --- /dev/null +++ b/tests/auto/language/testdata/erroneous/modules/missing-js-file-module/missing-js-file.js @@ -0,0 +1 @@ +var userfile = require("javascriptfile.js") diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index 0ac71c8a0..376b737e1 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -945,6 +945,8 @@ void TestLanguage::erroneousFiles_data() "Product.multiplexByQbsProperties."; QTest::newRow("invalid-references") << "invalid-references.qbs:2:17.*Cannot open '.*nosuchproject.qbs'"; + QTest::newRow("missing-js-file") + << "missing-js-file-module.qbs.*Cannot open '.*javascriptfile.js'"; } void TestLanguage::erroneousFiles() |