From fb3b51013323d76c301a36c20fb4b53cc93fb45b Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 12 Jun 2021 09:43:10 +0200 Subject: codesign: Fix checking if product is a framework It is not correct to check for the frameworkVersion to determine if product is a Framework - e.g. Xcode always sets this variable. Instead, product.type or product.bundle.packageType should be checked instead. This fixes the problem when codesign incorrectly determines bundle as a framework if product.version is set. Fixes: QBS-1649 Change-Id: I067e852df82a43897000d45e27908dd5e22eac70 Reviewed-by: Christian Kandeler --- share/qbs/modules/codesign/codesign.js | 4 ++-- tests/auto/blackbox/testdata-apple/codesign/codesign.qbs | 3 +++ tests/auto/blackbox/tst_blackboxapple.cpp | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/share/qbs/modules/codesign/codesign.js b/share/qbs/modules/codesign/codesign.js index 5aa303c9c..8159a77bc 100644 --- a/share/qbs/modules/codesign/codesign.js +++ b/share/qbs/modules/codesign/codesign.js @@ -301,8 +301,8 @@ function prepareSign(project, product, inputs, outputs, input, output) { // If this is a framework, we need to sign its versioned directory var subpath = ""; if (isBundle) { - var frameworkVersion = product.bundle.frameworkVersion; - if (frameworkVersion) { + var isFramework = product.bundle.packageType === "FMWK"; + if (isFramework) { subpath = product.bundle.contentsFolderPath; subpath = subpath.substring(product.bundle.bundleName.length); } diff --git a/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs b/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs index eafb0be84..08c8f730b 100644 --- a/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs +++ b/tests/auto/blackbox/testdata-apple/codesign/codesign.qbs @@ -9,6 +9,7 @@ Project { CppApplication { name: "A" + version: "1.0.0" bundle.isBundle: project.isBundle files: "app.cpp" codesign.enableCodeSigning: project.enableSigning @@ -23,6 +24,7 @@ Project { DynamicLibrary { Depends { name: "cpp" } name: "B" + version: "1.0.0" bundle.isBundle: project.isBundle files: "app.cpp" codesign.enableCodeSigning: project.enableSigning @@ -36,6 +38,7 @@ Project { LoadableModule { Depends { name: "cpp" } name: "C" + version: "1.0.0" bundle.isBundle: project.isBundle files: "app.cpp" codesign.enableCodeSigning: project.enableSigning diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp index 8c9792211..f8645bac6 100644 --- a/tests/auto/blackbox/tst_blackboxapple.cpp +++ b/tests/auto/blackbox/tst_blackboxapple.cpp @@ -751,7 +751,8 @@ void TestBlackboxApple::codesign() QCOMPARE(codeSignInfo.second.value(QByteArrayLiteral("Signature")), "adhoc"); } - const auto libName = isBundle ? QStringLiteral("B.framework") : QStringLiteral("libB.dylib"); + const auto libName = + isBundle ? QStringLiteral("B.framework") : QStringLiteral("libB.1.0.0.dylib"); const auto libPath = defaultInstallRoot + "/" + libName; QVERIFY(QFileInfo(libPath).exists()); codeSignInfo = getCodeSignInfo(libPath); -- cgit v1.2.1