Added targets for Eclipse environment descriptor.

Someone on the Google Groups site asked how to set up an Eclipse
project with Avian classpath. This patch creates the descriptor
that you can you use to do that at `$(build)/eclipse/jdk/avian.ee`.
The descriptor includes the Avian version, platform, architecture,
and build options to allow for multiple versions to exist side by
side.  Users can import the descriptor into Eclipse via:

    Window >> Preferences >> Java >> Installed JREs >> Add >> Execution
    Environment Description

Once the descriptor is imported, Avian can be used just like any other
JVM installation for Eclipse projects. Personally I use this in
conjunction with Eclim to gain code completion for Avian in vim.

The new targets also create symlinks to loosely mimic OpenJDK's
filenames and folder layout:

    build/linux-x86_64-tails-continuations/eclipse/jdk/
    ├── avian.ee
    ├── bin
    │   └── java -> ../../../avian
    ├── jre
    │   └── lib
    │       └── rt.jar -> ../../../../classpath.jar
    └── src -> ../../classpath

Annoyingly, Eclipse for some reason expects this layout to exist
even though the descriptor format has required parameters for
specifying these locations. I suppose that other software may
look for this "standard" layout in a JVM installation so it may be
generally useful.

These artifacts are only built if the platform is one of `windows`,
`linux`, or `macosx`. The symlinks might not actually work at all on
Windows, I'm not sure how things like cygwin/msys handle that and I
do not have the means to test it. If they do not work a fallback
for windows might be to actually copy the files instead of symlinking.

I realize this can be done outside of the makefile but it seemed
useful to put it here to gain access to the information about the
build location, platform, architecture, and other build options.

For the record, this contribution is my original work and is released
under the same license that Avian uses, found in the license.txt
file in this repository.
This commit is contained in:
BCG 2015-07-16 09:44:55 -04:00
parent e7dbe89c74
commit 0a11724f15

View File

@ -1580,11 +1580,32 @@ test-flags = -Djava.library.path=$(build) \
test-args = $(test-flags) $(input)
ifneq ($(filter linux windows macosx,$(platform)),)
eclipse-exec-env = eclipse-ee
eclipse-jdk-dir = $(build)/eclipse/jdk
eclipse-ee-file = $(eclipse-jdk-dir)/avian.ee
eclipse-bin-dir = $(eclipse-jdk-dir)/bin
eclipse-lib-dir = $(eclipse-jdk-dir)/jre/lib
eclipse-src-dir = $(eclipse-jdk-dir)/src
define eclipse-ee-descriptor
# An Eclipse execution environment for the Avian JVM\
\n-Dee.executable=bin/java${exe-suffix}\
\n-Dee.bootclasspath=jre/lib/rt.jar\
\n-Dee.language.level=1.7\
\n-Dee.name=$(name)-$(version)-$(platform)-$(arch)$(options)\
\n-Dee.src=src\
\n-Dee.javadoc=file://$${ee.home}/doc\
\n-Djava.home=$${ee.home}\n
endef
else
eclipse-exec-env =
endif
.PHONY: build
ifneq ($(supports_avian_executable),false)
build: $(static-library) $(executable) $(dynamic-library) $(lzma-library) \
$(lzma-encoder) $(executable-dynamic) $(classpath-dep) $(test-dep) \
$(test-extra-dep) $(embed) $(build)/classpath.jar
$(test-extra-dep) $(embed) $(build)/classpath.jar $(eclipse-exec-env)
else
build: $(static-library) $(dynamic-library) $(lzma-library) \
$(lzma-encoder) $(classpath-dep) $(test-dep) \
@ -1646,6 +1667,39 @@ clean:
@echo "removing build directories"
rm -rf build cmake-build distrib lib
.PHONY: eclipse-ee
ifneq ($(strip $(eclipse-exec-env)),)
eclipse-ee: $(eclipse-ee-file) $(eclipse-lib-dir)/rt.jar $(eclipse-bin-dir)/java${exe-suffix} $(eclipse-src-dir)
$(eclipse-bin-dir):
@mkdir -p $(@)
$(eclipse-lib-dir):
@mkdir -p $(@)
$(eclipse-jdk-dir):
@mkdir -p $(@)
$(eclipse-ee-file): $(eclipse-jdk-dir)
@echo "writing eclipse execution environment descriptor to $(@)"
@printf '${eclipse-ee-descriptor}' > $(@)
$(eclipse-src-dir): $(eclipse-jdk-dir)
@echo "symlinking classpath for $(@)"
@ln -sf ../../classpath $(@)
$(eclipse-bin-dir)/java$(exe-suffix): $(eclipse-bin-dir) $(executable)
@echo "symlinking $(executable) for $(@)"
@ln -sf ../../../$(name)${exe-suffix} $(@)
$(eclipse-lib-dir)/rt.jar: $(eclipse-lib-dir) $(build)/classpath.jar
@echo "symlinking $(build)/classpath.jar for $(@)"
@ln -sf ../../../../classpath.jar $(@)
else
eclipse-ee:
$(error "Eclipse execution environment for platform '$(platform)' is not supported")
endif
ifeq ($(continuations),true)
$(build)/compile-x86-asm.o: $(src)/continuations-x86.$(asm-format)
endif