Eclipseで条件付きパス変数を設定することは可能ですか? これは、たとえば、カスタム ビルダー (プロジェクトと共に Indigo に保存されています。古い Eclipse バージョンではそうではなかったと思います) が別のプラットフォームで別のプログラムを呼び出すのに役立ちます。
だから私が探しているのは、次のようなものです:
${if{${system:OS}=='Windows'}compiler.exe${else}compiler.sh
Eclipseで条件付きパス変数を設定することは可能ですか? これは、たとえば、カスタム ビルダー (プロジェクトと共に Indigo に保存されています。古い Eclipse バージョンではそうではなかったと思います) が別のプラットフォームで別のプログラムを呼び出すのに役立ちます。
だから私が探しているのは、次のようなものです:
${if{${system:OS}=='Windows'}compiler.exe${else}compiler.sh
異なるプラットフォームで異なるコンパイラを起動したい場合は、Ant または Make を使用してプラットフォームを検出し、異なるプログラムを呼び出すことができます。
プロジェクトのプロパティで、[ビルダー] に移動し、新しいビルド ステップを作成します。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>
実行している OS を示します。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>