@@ -46,81 +46,61 @@ The build process produces these files:
4646| -------| -----------------| -------------------| ---------------| -------------------| -------------------------------------------------|
4747| JRI | ` jri-ev3.zip ` | Minimal runtime | Brick | Java developer | Running Java programs on ev3dev. |
4848| JDK | ` jdk-ev3.zip ` | Full JDK | Brick | ev3dev power user | Compiling Java programs directly on the brick. |
49- | JMODs | ` jmods-ev3.zip ` | Runtime precursor | Developer PC | both | Creating runtime images with more Java modules. |
49+ | JMODs | ` jmods-ev3.zip ` | Runtime modules | Developer PC | both | Creating custom JRIs. |
5050
5151_ JRI stands for "Java Runtime Image". The term itself is not specific to this project,
5252it is equivalent to [ Modular Run-Time Image] ( https://openjdk.java.net/jeps/220 ) .
53- To see which modules are included in our case, take a look at the jlink commandline in ` scripts/zip .sh ` ._
53+ To see which modules are included in our case, take a look at the ` JRI_MODULES ` variable in ` scripts/config .sh ` ._
5454
55- ## Building
55+ ## Building locally
5656
57- 0 . Clone this repository.
58571 . Install [ Docker] ( https://docs.docker.com/engine/installation/ ) for your operating system.
59- 2 . Build the base cross-compilation image:
60- ``` sh
61- sudo docker build -t ev3dev-lang-java:jdk-stretch -f system/stretch/Dockerfile.armel system
58+ 2 . Follow this script:
59+ ``` bash
60+ # define parameters
61+ TARGET_WORKSPACE=" $( pwd) /build" # 10 GB of free space should be sufficient, probably less
62+ TARGET_DEBIAN_VERSION=" stretch" # stretch or buster
63+ TARGET_OPENJDK_VERSION=" 11" # 9, 10 - retired, may not be working
64+ # 11, 12, 13 - most likely working
65+ # loom or tip - experimental, may be broken
66+
67+ # clone repository
68+ git clone https://github.com/ev3dev-lang-java/openjdk-ev3.git
69+ cd openjdk-ev3
70+
71+ # prepare working directory
72+ mkdir -p " $TARGET_WORKSPACE "
73+ chmod -R 777 " $TARGET_WORKSPACE " # docker may not share UID with the current user
74+
75+ # build base system container
76+ docker build --build-arg DEBIAN_RELEASE=" $TARGET_DEBIAN_VERSION " \
77+ --build-arg ARCH=" armel" \
78+ --tag " ev3dev-lang-java:jdk-cross-$TARGET_DEBIAN_VERSION " \
79+ --file ./system/Dockerfile.cross \
80+ ./system
81+
82+ # on top of that, create a build scripts container
83+ docker build --build-arg commit=" $( git rev-parse HEAD) " \
84+ --build-arg extra=" Manual build by $( whoami) " \
85+ --build-arg DEBIAN_RELEASE=" $TARGET_DEBIAN_VERSION " \
86+ --build-arg BUILD_TYPE=" cross" \
87+ --tag " ev3dev-lang-java:jdk-cross-build" \
88+ ./scripts
89+
90+ # now run the build
91+ docker run --rm \
92+ --interactive \
93+ --tty \
94+ --volume " $TARGET_WORKSPACE :/build" \
95+ --env JDKVER=" $TARGET_OPENJDK_VERSION " \
96+ --env JDKVM=" client" \
97+ --env JDKPLATFORM=" ev3" \
98+ --env JDKDEBUG=" release" \
99+ --env AUTOBUILD=" 1" \
100+ ev3dev-lang-java:jdk-cross-build
101+
102+ # finally, make workspace accessible for all users (i.e. current one too) and list files in its root
103+ chmod -R 777 " $TARGET_WORKSPACE "
104+ # and list the output directory (now it should contain three *-ev3.tar.gz files)
105+ ls " $TARGET_WORKSPACE "
62106```
63- To use Debian Buster, replace occurences of ` stretch ` with ` buster ` .
64- 3 . Build the image with OpenJDK cross-compilation scripts:
65- ``` sh
66- sudo docker build -t ev3dev-lang-java:jdk-build --build-arg DEBIAN_RELEASE=stretch -f scripts/Dockerfile scripts
67- ```
68- Again, you can replace ` stretch ` with ` buster ` .
69-
70- Next steps depend on whether you want to navigate the build yourself, or if you want the build to run automatically.
71-
72- ### Semi-manual build
73- 4 . Run the newly prepared container. You have to mount a host directory to the the ` /build ` directory in the container,
74- otherwise the build would get discarded. The final build needs at least 6.5 GB of free space (in the build directory).
75- ```
76- sudo docker run --rm -it -v $BUILD_DIRECTORY:/build ev3dev-lang-java:jdk-build
77- ```
78- Please change the ` $BUILD_DIRECTORY ` to a valid path.
79-
80- 5 . Select the OpenJDK version and VM you want to cross-compile (select only one for each variable):
81- ```
82- export JDKVER=9 # OpenJDK 9
83- export JDKVER=10 # OpenJDK 10
84- export JDKVER=11 # OpenJDK 11
85- export JDKVER=12 # OpenJDK 12
86- export JDKVER=13 # OpenJDK 13
87- export JDKVM=zero # Use Zero interpreter
88- export JDKVM=client # Use full ARM32 JIT
89- export JDKVM=minimal # Use minimal ARM32 JIT (https://openjdk.java.net/jeps/148)
90- export JDKPLATFORM=ev3 # Use EV3 build flags
91- ```
92- 6 . Before we can start the build process, Boot JDK must be downloaded:
93- ```
94- ./prepare.sh
95- ```
96- 7 . Now we can download the OpenJDK sources:
97- ```
98- ./fetch.sh
99- ```
100- 8 . The OpenJDK source tree should be ready. Now you can start the cross-build itself:
101- ```
102- ./build.sh
103- ```
104- 9 . Create the zipped images:
105- ```
106- ./zip.sh
107- ```
108- 10 . If the build was successful, JDK packages were created in ` /build/jri-ev3.tar.gz ` , ` /build/jdk-ev3.tar.gz ` and ` /build/jmods.tar.gz ` .
109- If you have mounted ` /build ` , you can access the files from the host.
110-
111- ### Automatic build
112- 4 . Run the newly prepared container. You have to mount a host directory to the the ` /build ` directory in the container,
113- otherwise the build would get discarded. The final build needs at least 6.5 GB of free space (in the build directory).
114- ```
115- sudo docker run --rm -v $BUILD_DIRECTORY:/build -e JDKVER='X' -e JDKVM='Y' -e JDKPLATFORM='Z' -e AUTOBUILD='yes' ev3dev-lang-java:jdk-build
116- ```
117- For values of ` X ` , ` Y ` and ` Z ` see above. Please change the ` $BUILD_DIRECTORY ` to a valid path.
118-
119- 5 . If the build was successful, JDK packages were created in ` $BUILD_DIRECTORY/jri-ev3.tar.gz ` , ` $BUILD_DIRECTORY/jdk-ev3.tar.gz ` and ` $BUILD_DIRECTORY/jmods.tar.gz ` .
120-
121-
122- ## LeJOS support
123-
124- LeJOS is not supported. To create a build, it is needed to build Java dependencies
125- for the old LEGO-provided rootfs. Also, the rootfs build compiler is needed for building OpenJDK itself.
126- [ linux-devkit] ( https://github.com/mindboards/ev3sources/tree/master/extra/linux-devkit ) + CodeSourcery GCC could be used for the cross-compilation.
0 commit comments