2012-01-29 3 views
1

Eclipse에서 조건부 경로 변수를 설정할 수 있습니까? 이 기능은 예를 들어 사용자 정의 빌더 (예 : 인디고 프로젝트에 저장 됨 - 예전 Eclipse 버전에서는 그렇지 않은 것으로 생각합니다)가 다른 플랫폼에서 다른 프로그램을 호출 할 때 유용합니다. 내가의 라인을 따라 뭔가를위한 것입니다 찾고 있어요 그래서Eclipse 조건부 경로 변수

: 특별히 다른 플랫폼에 다른 컴파일러를 호출하고 싶은 경우에 당신이 개미 사용하거나 감지 할 수 있습니다,

${if{${system:OS}=='Windows'}compiler.exe${else}compiler.sh 

답변

1

당신의 플랫폼을 찾고 다른 프로그램을 호출하십시오.

프로젝트 속성에서 "빌더"로 이동하여 새 빌드 단계를 만듭니다. 당신이 GNU은 빌더로 확인 사용하는 경우, 당신은 당신의 메이크 파일에 다음과 같은 구문을 사용할 수 있습니다 : Ant 빌드 스크립트에서

# 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 

조건부 실행 if, unlessdepends 같은 속성에 의해 결정된다. <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> 
+0

답변 해 주셔서 감사합니다. 개미 (또는 그 문제에 대한 다른 빌드 도구)를 사용할 가능성을 알고 있지만 이클립스가 플랫폼 기반의 분기를 직접 지원할 수있는 방법이 있다고 생각합니다. 분명히 있지 않습니다. 따라서 귀하의 대답은 문제의 일반적인 해결책으로 가장 좋습니다. –

0

내가 빌드 후 단계로 창문 .exe 파일을 실행하여 그것을 해결.

이것은 Windows에서는 문제가 없지만 Linux에서는 wine으로 시작해야했습니다.

운영체제 조건 문제를 해결하기 위해, 나는 이클립스 환경 변수 만든 :

wineLinux=wine 

을 그리고 다음과 같이 포스트 빌드 단계 건설 :

${wine${OsType}} window_file.exe args 

시스템 변수 OsType 확장됩니다 Linux으로 변경하고 이전 단계에서 작성한 환경 변수 wineLinuxwine으로 확장됩니다.