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. |
| 120 | MacPorts [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. |
| 121 | If 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. |
| 122 | At the top of the portfile, after the PortSystem line and near any other PortGroup lines you may have, add this line: |
| 123 | |
| 124 | {{{ |
| 125 | PortGroup xcodeversion 1.0 |
| 126 | }}} |
| 127 | |
| 128 | Then somewhere in the body of the portfile you can write a line like this: |
| 129 | |
| 130 | {{{ |
| 131 | minimum_xcodeversions {9 3.1} |
| 132 | }}} |
| 133 | |
| 134 | This 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 | |
| 136 | If 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 | {{{ |
| 139 | minimum_xcodeversions {9 3.1 8 2.5} |
| 140 | }}} |
| 141 | |