Changes between Version 21 and Version 22 of PortfileRecipes


Ignore:
Timestamp:
Oct 18, 2010, 4:29:08 AM (13 years ago)
Author:
ryandesign (Ryan Carsten Schmidt)
Comment:

update Xcode version checking section to use xcodeversion portgroup

Legend:

Unmodified
Added
Removed
Modified
  • PortfileRecipes

    v21 v22  
    118118== Xcode version checking == #xcode_version
    119119
    120 MacPorts [ticket:12794 does not check the version of Xcode] being used at runtime, but many ports will fail to build if the version of Xcode is too old. If you discover that your port requires a particular minimum version of Xcode, add this code to the port to print an error if the user's Xcode is too old:
    121 
    122 {{{
    123 pre-extract {
    124     if {"darwin" == ${os.platform} && 9 == ${os.major}} {
    125         set minimum_xcodeversion 3.1
    126         set current_xcodeversion [exec defaults read /Developer/Applications/Xcode.app/Contents/Info CFBundleShortVersionString]
    127         if {[rpm-vercomp ${current_xcodeversion} ${minimum_xcodeversion}] < 0} {
    128             ui_error "On Mac OS X ${macosx_version}, ${name} ${version} requires Xcode ${minimum_xcodeversion} or later but you have Xcode ${current_xcodeversion}."
    129             return -code error "incompatible Xcode version"
    130         }
    131     }
    132 }
    133 }}}
    134 
    135 This example is from [browser:trunk/dports/multimedia/x264 x264].
    136 Note that the check [http://lists.macosforge.org/pipermail/macports-dev/2009-April/008112.html is done at pre-extract time].
    137 
    138 You can change the "9" in the os.major check to "8" if you're checking Tiger (Xcode 2.x) or "7" for Panther (Xcode 1.x) and update the minimum_xcodeversion accordingly.
     120MacPorts [ticket:12794 checks the version of Xcode] being used at runtime and warns if it is an old version known to cause problems, but for specific ports that are known to fail to build with older versions of Xcode, you may want to actively prevent the installation from continuing, rather than just printing a warning.
     121If you discover that your port requires a particular minimum version of Xcode, use the xcodeversion portgroup to print an error and exit if the user's Xcode is too old.
     122At the top of the portfile, after the PortSystem line and near any other PortGroup lines you may have, add this line:
     123
     124{{{
     125PortGroup               xcodeversion 1.0
     126}}}
     127
     128Then somewhere in the body of the portfile you can write a line like this:
     129
     130{{{
     131minimum_xcodeversions {9 3.1}
     132}}}
     133
     134This example is from [browser:trunk/dports/multimedia/x264 x264] and ensures that, on Darwin 9 (Mac OS X 10.5 Leopard), Xcode 3.1 or greater is used.
     135
     136If you need to check the minimum Xcode version of more than one OS version, simply add more pairs of arguments. For example, to check for a minimum of Xcode 3.1 on Darwin 9 and a minimum of Xcode 2.5 on Darwin 8 (Mac OS X 10.4 Tiger), you would write:
     137
     138{{{
     139minimum_xcodeversions {9 3.1 8 2.5}
     140}}}
     141
    139142If you don't know what minimum version of Xcode would work, it's ok to just put whatever version you found that the port worked with.
    140 For example, libpixman is known to work with Xcode 1.5 but fail with 1.1, so [changeset:45892 libpixman now requires Xcode 1.5] on Panther, even though compatibility with Xcode 1.2 was not tested.
     143For example if someone reports a problem building a port on Leopard with Xcode 3.0, and you verified it works fine with Xcode 3.1.4, it's ok to list 3.1.4 as the minimum Xcode version, even without testing whether earlier 3.1.x versions would have worked.
    141144It is better to make a user upgrade to a newer Xcode than for a port maintainer to spend time testing old versions.
    142145