Skip to content

Commit c49b9df

Browse files
authored
Merge pull request #6 from infinity0/j2s-eclipse-3.8
Add a Makefile to auto-build everything in a headless environment
2 parents babf5de + 19f470b commit c49b9df

File tree

5 files changed

+222
-39
lines changed

5 files changed

+222
-39
lines changed

Makefile

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# To use this file, run:
2+
#
3+
# $ make CONFIGURE_FLAGS="-Dplugin.path=/path/to/your/eclipse/plugins"
4+
#
5+
# For example, on Debian GNU/Linux:
6+
#
7+
# $ make CONFIGURE_FLAGS="-Dplugin.path=/usr/lib/eclipse:/usr/share/eclipse/dropins/jdt"
8+
#
9+
# You can also add e.g. "-DforceContextQualifier=none" to make the jars be
10+
# output under a stable filename.
11+
#
12+
# Due to https://github.com/zhourenjian/java2script/issues/7 you may need to
13+
# run this using xvfb https://packages.debian.org/sid/xvfb
14+
#
15+
CONFIGURE_FLAGS +=
16+
CORE_FLAGS += -DjavacFailOnError=true
17+
INCUBATOR_FLAGS += -DjavacFailOnError=true -DjavacSource=1.6 -DjavacTarget=1.6
18+
19+
# Order is important; dependencies must go earlier.
20+
CORE_PLUGINS = net.sf.j2s.core net.sf.j2s.ajax net.sf.j2s.ui net.sf.j2s.lib
21+
INCUBATOR_PLUGINS = net.sf.j2s.ui.template.velocity net.sf.j2s.ui.cmdline
22+
CORE_J2SLIB = net.sf.j2s.ajax net.sf.j2s.java.core net.sf.j2s.java.org.eclipse.swt
23+
24+
BUILD_WORKSPACE := $(PWD)/autobuild
25+
ECLIPSE_AUTO = eclipse \
26+
-configuration $(BUILD_WORKSPACE)/configuration \
27+
-user $(BUILD_WORKSPACE) \
28+
-data $(BUILD_WORKSPACE) \
29+
-nosplash -clean
30+
31+
ECLIPSE_ANT = $(ECLIPSE_AUTO) \
32+
-application org.eclipse.ant.core.antRunner
33+
ECLIPSE_ANT_BUILD = $(ECLIPSE_ANT) build.update.jar
34+
ECLIPSE_ANT_CLEAN = if [ -f build.xml ]; then \
35+
$(ECLIPSE_ANT) clean; \
36+
rm -rf build.xml javaCompiler...args; \
37+
fi
38+
ECLIPSE_J2S = $(ECLIPSE_AUTO) \
39+
-application net.sf.j2s.ui.cmdlineApi
40+
41+
all: build-libs
42+
43+
configure:
44+
$(ECLIPSE_ANT) -f configure.xml $(CONFIGURE_FLAGS)
45+
46+
build-plugins: configure
47+
sh switch-build-command.sh sources/net.sf.j2s.ajax/.project \
48+
-net.sf.j2s.core.java2scriptbuilder +org.eclipse.jdt.core.javabuilder
49+
set -e; for i in $(CORE_PLUGINS:%=sources/%); do \
50+
( cd $$i && $(ECLIPSE_ANT_BUILD) $(CORE_FLAGS); ) \
51+
done
52+
set -e; for i in $(INCUBATOR_PLUGINS:%=incubator/%); do \
53+
( cd $$i && $(ECLIPSE_ANT_BUILD) $(INCUBATOR_FLAGS); ) \
54+
done
55+
56+
local-install-plugins: build-plugins
57+
$(MAKE) DESTDIR=$(BUILD_WORKSPACE) eclipsedir= install-plugins
58+
mkdir -p $(BUILD_WORKSPACE)/features
59+
touch $(BUILD_WORKSPACE)/artifacts.xml
60+
$(ECLIPSE_AUTO) -initialize
61+
62+
# Work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=465693 (actually a JDK bug)
63+
# Otherwise the net.sf.j2s.java.core build wil segfault about half of the time.
64+
# Annoyingly, the segfault causes java to exit 0; I was unable to figure out why.
65+
# So we add some extra checks, testing for the absence of crash logs.
66+
BADMETHOD1 = org/eclipse/jdt/internal/compiler/parser/TypeConverter.decodeType
67+
WORKAROUND1 = -vmargs -XX:CompileCommand=exclude,$(BADMETHOD1)
68+
build-libs: local-install-plugins
69+
sh switch-build-command.sh sources/net.sf.j2s.ajax/.project \
70+
+net.sf.j2s.core.java2scriptbuilder -org.eclipse.jdt.core.javabuilder
71+
test ! -f *err*.log
72+
set -e; for i in $(CORE_J2SLIB); do \
73+
$(ECLIPSE_J2S) -cmd build -path $$PWD/sources/$$i $(WORKAROUND1); \
74+
test ! -f *err*.log; \
75+
done
76+
mkdir -p sources/net.sf.j2s.lib/bin sources/net.sf.j2s.lib/j2slib
77+
cd sources/net.sf.j2s.lib/bin && jar xf ../library.jar
78+
cd sources/net.sf.j2s.lib && ant -f build/build.xml
79+
cd sources/net.sf.j2s.lib && zip -r j2slib.zip j2slib
80+
81+
clean:
82+
for i in $(INCUBATOR_PLUGINS:%=incubator/%); do \
83+
( cd $$i && $(ECLIPSE_ANT_CLEAN); ) \
84+
done
85+
for i in $(CORE_PLUGINS:%=sources/%); do \
86+
( cd $$i && $(ECLIPSE_ANT_CLEAN); ) \
87+
done
88+
rm -rf $(BUILD_WORKSPACE)/.metadata
89+
90+
prefix ?= /usr/local
91+
eclipsedir ?= $(prefix)/share/eclipse
92+
datadir ?= $(prefix)/share/java2script
93+
pluginsdir ?= $(eclipsedir)/plugins
94+
95+
install-plugins:
96+
test -z "$(DESTDIR)$(pluginsdir)" || mkdir -p "$(DESTDIR)$(pluginsdir)"
97+
install -t "$(DESTDIR)$(pluginsdir)" \
98+
$(join $(CORE_PLUGINS:%=sources/%/),$(CORE_PLUGINS:%=%_2.0.0.jar)) \
99+
$(join $(INCUBATOR_PLUGINS:%=incubator/%/),$(INCUBATOR_PLUGINS:%=%_1.0.0.*.jar))
100+
101+
install: install-plugins
102+
test -z "$(DESTDIR)$(datadir)" || mkdir -p "$(DESTDIR)$(datadir)"
103+
install -t "$(DESTDIR)$(datadir)" \
104+
sources/net.sf.j2s.lib/j2slib.zip
105+
106+
.PHONY: all configure build-plugins local-install-plugins build-libs clean install-plugins install

configure.xml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="java2script" default="configure" basedir=".">
3+
<!-- IMPORTANT!
4+
5+
This is not a normal ant build file. You need to run it via the Eclipse
6+
AntRunner, like this Unix shell example:
7+
8+
$ eclipse -nosplash -clean \
9+
-configuration $PWD/autobuild/configuration \
10+
-user $PWD/autobuild \
11+
-data $PWD/autobuild \
12+
-application org.eclipse.ant.core.antRunner \
13+
-buildfile build.xml \
14+
-Dplugin.path=/usr/lib/eclipse:/usr/share/eclipse/dropins/jdt
15+
16+
Setting the -configuration, -user, and -data options are important in an
17+
automated build process where you don't want to clobber the default locations.
18+
19+
For more details see http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Ftasks%2Fpde_feature_generating_antcommandline.htm
20+
-->
21+
<target name="configure">
22+
<eclipse.buildScript elements="plugin@net.sf.j2s.core"
23+
buildDirectory="sources"
24+
pluginPath="${plugin.path}"
25+
forceContextQualifier="${forceContextQualifier}" />
26+
<eclipse.buildScript elements="plugin@net.sf.j2s.ajax"
27+
buildDirectory="sources"
28+
pluginPath="${plugin.path}"
29+
forceContextQualifier="${forceContextQualifier}" />
30+
<eclipse.buildScript elements="plugin@net.sf.j2s.lib"
31+
buildDirectory="sources"
32+
pluginPath="${plugin.path}"
33+
forceContextQualifier="${forceContextQualifier}" />
34+
<eclipse.buildScript elements="plugin@net.sf.j2s.ui"
35+
buildDirectory="sources"
36+
pluginPath="${plugin.path}"
37+
forceContextQualifier="${forceContextQualifier}" />
38+
<eclipse.buildScript elements="plugin@net.sf.j2s.ui.template.velocity"
39+
buildDirectory="incubator"
40+
pluginPath="${plugin.path}${path.separator}sources"
41+
forceContextQualifier="${forceContextQualifier}" />
42+
<eclipse.buildScript elements="plugin@net.sf.j2s.ui.cmdline"
43+
buildDirectory="incubator"
44+
pluginPath="${plugin.path}${path.separator}sources"
45+
forceContextQualifier="${forceContextQualifier}" />
46+
</target>
47+
</project>

0 commit comments

Comments
 (0)