From 8621465db2c7fa10eb014ef14d55ec7dd3e085a0 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Wed, 16 Dec 2020 10:05:05 +0100 Subject: Xcode: Fix XCode auto-detection If Xcode is moved to another location, we should use xcode-select -- print-path to find it rather than using hardcoded path. Change-Id: I9b5eba19c9e732e5e9da0322320fb0406249e020 Reviewed-by: Christian Kandeler --- .../qbs/imports/qbs/Probes/XcodeLocationProbe.qbs | 47 ++++++++++++++++++++++ share/qbs/modules/xcode/xcode.qbs | 9 ++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs diff --git a/share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs b/share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs new file mode 100644 index 000000000..3401315f7 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Process + +Probe { + property path developerPath + configure: { + var p = new Process(); + try { + p.exec("/usr/bin/xcode-select", ["--print-path"], true); + developerPath = p.readStdOut().trim(); + } catch (e) { + developerPath = "/Applications/Xcode.app/Contents/Developer"; + } finally { + p.close(); + found = true; + } + } +} diff --git a/share/qbs/modules/xcode/xcode.qbs b/share/qbs/modules/xcode/xcode.qbs index e4df1f20b..aeb0760ac 100644 --- a/share/qbs/modules/xcode/xcode.qbs +++ b/share/qbs/modules/xcode/xcode.qbs @@ -12,6 +12,11 @@ import 'xcode.js' as Xcode Module { id: xcodeModule + Probes.XcodeLocationProbe { + id: xcodeLocationProbe + condition: !xcodeModule.developerPath + } + Probes.XcodeProbe { id: xcodeProbe developerPath: xcodeModule.developerPath @@ -27,7 +32,9 @@ Module { version: xcodeProbe.xcodeVersion - property path developerPath: "/Applications/Xcode.app/Contents/Developer" + property path developerPath: xcodeLocationProbe.found + ? xcodeLocationProbe.developerPath + : undefined property string sdk: DarwinTools.applePlatformName(qbs.targetOS, platformType) property stringList targetDevices: DarwinTools.targetDevices(qbs.targetOS) -- cgit v1.2.3