Если вы конкретно хотите вызывать разные компиляторы на разных платформах, вы можете использовать Ant или Make для обнаружения вашей платформы и вызова разных программ.
В свойствах вашего проекта перейдите к «Builders» и создайтеновый шаг сборки.Если вы используете GNU Make в качестве сборщика, вы можете использовать синтаксис, подобный следующему, в вашем Makefile:
# Only MS-DOS/Windows builds of GNU Make check for the MAKESHELL variable
# On those platforms, the default is command.com, which is not what you want
MAKESHELL := cmd.exe
# Ask make what OS it's running on
MAKE_OS := $(shell $(MAKE) -v)
# On Windows, GNU Make is built using either MinGW or Cygwin
ifeq ($(findstring mingw, $(MAKE_OS)), mingw)
BUILD_COMMAND := compiler.exe
else ifeq ($(findstring cygwin, $(MAKE_OS)), cygwin)
BUILD_COMMAND := compiler.exe
else ifeq ($(findstring darwin, $(MAKE_OS)), darwin)
BUILD_COMMAND := compiler-osx.sh
else ifeq ($(findstring linux, $(MAKE_OS)), linux)
BUILD_COMMAND := compiler.sh
endif
В скриптах сборки Ant условное выполнение определяется такими атрибутами, как if
, unless
и depends
.Тег <os family=xxx>
сообщает вам, на какой ОС вы работаете.Вот пример из devdaily:
<?xml version="1.0"?>
<!--
An Ant build script that demonstrates how to test to see
which operating system (computer platform) the Ant build
script is currently running on. Currently tests for Mac OS X,
Windows, and Unix systems.
Created by Alvin Alexander, DevDaily.com
-->
<project default="OS-TEST" name="Ant Operating System Test" >
<!-- set the operating system test properties -->
<condition property="isMac">
<os family="mac" />
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isUnix">
<os family="unix" />
</condition>
<!-- define the operating system specific targets -->
<target name="doMac" if="isMac">
<echo message="Came into the Mac target" />
<!-- do whatever you want to do here for Mac systems -->
</target>
<target name="doWindows" if="isWindows">
<echo message="Came into the Windows target" />
</target>
<target name="doUnix" if="isUnix">
<echo message="Came into the Unix target" />
</target>
<!-- define our main/default target -->
<target name="OS-TEST" depends="doMac, doWindows, doUnix">
<echo message="Running OS-TEST target" />
</target>
</project>