source: trunk/dports/_resources/port1.0/group/xcodeversion-1.0.tcl @ 74403

Last change on this file since 74403 was 74403, checked in by ryandesign@…, 9 years ago

xcodeversion-1.0.tcl: check for existence of Xcode before trying to check its version; see #27682

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1# $Id: xcodeversion-1.0.tcl 74403 2010-12-15 19:33:15Z ryandesign@macports.org $
2#
3# Copyright (c) 2009 The MacPorts Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. Neither the name of The MacPorts Project nor the names of its
16#    contributors may be used to endorse or promote products derived from
17#    this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30#
31#
32# This PortGroup lets a port check that the user's Xcode is sufficiently new.
33#
34# Usage:
35#
36#   PortGroup               xcodeversion 1.0
37#   minimum_xcodeversions   {darwin_major minimum_xcodeversion}
38#
39# where darwin_major is the major version of the underlying Darwin OS (e.g. 9
40# for Mac OS X 10.5 Leopard) and minimum_xcodeversion is the minimum version
41# of Xcode the port requires (e.g. 3.1).
42
43options minimum_xcodeversions
44default minimum_xcodeversions {}
45
46platform macosx {
47    pre-extract {
48        set xcode_app ${developer_dir}/Applications/Xcode.app
49        if {![file exists ${xcode_app}]} {
50            ui_error "Couldn't find Xcode; expected it to be at ${xcode_app}."
51            ui_error ""
52            ui_error "If you have not installed Xcode, install it now; see:"
53            ui_error "http://guide.macports.org/chunked/installing.xcode.html"
54            ui_error ""
55            ui_error "If you have installed Xcode in a nonstandard location, inform MacPorts"
56            ui_error "of that location by changing the 'developer_dir' variable in"
57            ui_error "${prefix}/etc/macports/macports.conf"
58            ui_error ""
59            return -code error "unable to find Xcode"
60        }
61        set current_xcodeversion [exec defaults read ${xcode_app}/Contents/Info CFBundleShortVersionString]
62        foreach {darwin_major minimum_xcodeversion} [join ${minimum_xcodeversions}] {
63            if {${darwin_major} == ${os.major}} {
64                if {[rpm-vercomp ${current_xcodeversion} ${minimum_xcodeversion}] < 0} {
65                    ui_error "On Mac OS X ${macosx_version}, ${name} ${version} requires Xcode ${minimum_xcodeversion} or later but you have Xcode ${current_xcodeversion}."
66                    return -code error "incompatible Xcode version"
67                }
68            }
69        }
70    }
71}
Note: See TracBrowser for help on using the repository browser.