File: eclipse_javac.py

package info (click to toggle)
java-imaging-utilities 0.14.3-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,556 kB
  • sloc: java: 31,233; python: 71; xml: 31; makefile: 26; sh: 5
file content (29 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''
Use the Eclipse java compiler from the command-line (like javac).
Set ECLIPSE_HOME in the OS or scons environment to make this work.
This is still experimental, but seems to work...
'''
import os, glob

def find_eclipse_core_jar(env):
    if env.has_key('ECLIPSE_HOME'):
        eclipse_home = env['ECLIPSE_HOME']
    elif os.environ.has_key('ECLIPSE_HOME'):
        eclipse_home = os.environ['ECLIPSE_HOME']
    else:
        return False
    jars = glob.glob(os.path.join(eclipse_home, 'plugins', 'org.eclipse.jdt.core_*.jar'))
    if jars:
        return jars[0]
    else:
        return False

def generate(env):
    jar = find_eclipse_core_jar(env)
    env['JAVAC'] = 'java -classpath %s org.eclipse.jdt.internal.compiler.batch.Main' % jar
    # Have to change JAVACCOM to use a tempfile, but only for sources, not the whole java command
    # Assume that _JAVACCOM defines the normal command.
    env['JAVACCOM'] = env['_JAVACCOM'].replace('$SOURCES', "${TEMPFILE('$SOURCES')}")

def exists(env):
    return find_eclipse_core_jar(env)