How does InstallBuilder know Mac OS X 10.5 (32-bit) vs 10.6 (64-bit)
How does InstallBuilder know Mac OS X 10.5 (32-bit) vs 10.6 (64-bit) We have a single BitRock installer xml file that needs to support both 32-bit and 64-bit Mac OSX. That is, we need to copy 64-bit library if we install our application on a 64-bit Mac OSX, or 32-bit library, if we install on 32-bit Mac OSX. In both cases, we call platform “osx”. We just pull respective libraries from different origins, either 64-bit subfolder, or 32-bit subfolder on our source platform. Destination folder is the same for both platforms.
How will BitRock know if we need to copy a library from 32-bit source, or from 64-bit source during runtime?
The xml code that does this is as follows:
--32-BIT Part ---
<component> <name>macosx105files</name> <description>Mac OS X 10.5 Files</description> <folderlist> <folder> <description>Mac configuration folder for MacOS 10.5</description> <destination>${installdir}/modules/lib</destination>
<platforms>osx</platforms>
<distributionFileList>
<distributionFile>
<origin>../MacOSX/OSX_10.5/libusb-1.0.0.dylib </origin>
</distributionFile>
</distributionFileList>
</folder>
</folderList>
</component>
--64-BIT Part --
<component>
<name>macosx106files</name>
<description>Mac OS X 10.6 and Later Files</description>
<folderList>
<folder>
<description>Mac configuration folder - for MacOS 10.6 and later</description>
<folderList>
<folder>
<description>Mac configuration folder for MacOS 10.6+</description>
<destination>${installdir}/modules/lib</destination>
<platforms>osx</platforms>
<distributionFileList>
<distributionFile>
<origin>../MacOSX/OSX_10.6/libusb-1.0.0.dylib </origin>
</distributionFile>
</distributionFileList>
</folder>
</folderList>
</component>
-
For detecting version of OSX, you can use
<compareVersions>
and${osx_major_version}
variable to check the version. For example:<compareVersions> <logic>greater_or_equal</logic> <version1>${osx_major_version}</version1> <version2>10.6</version2> </compareVersions>
It is also possible to use
uname -m
command to detect if OSX is running in 32-bit or 64-bit mode. You can first check it at initialization:<initializationActionList> <setInstallerVariable> <name>osx_64bit</name> <value>0</value> </setInstallerVariable> <actionGroup> <actionList> <runProgram> <program>uname</program> <programArguments>-m</programArguments> </runProgram> <setInstallerVariable> <name>osx_64bit</name> <value>1</value> <ruleList> <compareText> <logic>contains</logic> <text>${program_stdout}</text> <value>x86_64</value> </compareText> </ruleList> </setInstallerVariable> </actionList> <ruleList> <platformTest> <type>osx</type> </platformTest> </ruleList> </actionGroup> </initializationActionList>
The
${osx_64bit}
variable will now be set to 1 if system is running in 64bit mode. You can then use folder's rules to determine which file(s) will get installed:<folder> <description>Library 32bit</description> <destination>${installdir}</destination> <name>library32</name> <platforms>osx</platforms> <ruleList> <isFalse> <value>${osx_64bit}</value> </isFalse> </ruleList> </folder> <folder> <description>Library 64bit</description> <destination>${installdir}</destination> <name>library64</name> <platforms>osx</platforms> <ruleList> <isTrue> <value>${osx_64bit}</value> </isTrue> </ruleList> </folder>
Please sign in to leave a comment.
Comments
1 comment