Skip to content

Commit

Permalink
Javet v0.9.10 (#85)
Browse files Browse the repository at this point in the history
* Added `JavetVirtualObject`
* Updated `JavetUniversalProxyHandler` to allow passing `V8Value`
* Updated `JavetUniversalProxyHandler` to allow passing `V8ValueFunction` as anonymous function
* Updated `JavetUniversalProxyHandler` to allow passing `V8ValueObject` as anonymous object
* Added `isClosed()` to `IJavetClosable`
* Added error code 602 and 603
  • Loading branch information
caoccao authored Aug 30, 2021
1 parent 9ffcadf commit 80b160c
Show file tree
Hide file tree
Showing 50 changed files with 1,331 additions and 320 deletions.
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ Maven
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet</artifactId>
<version>0.9.9</version>
<version>0.9.10</version>
</dependency>
<!-- Mac OS (x86_64 Only) -->
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet-macos</artifactId>
<version>0.9.9</version>
<version>0.9.10</version>
</dependency>
Gradle Kotlin DSL
^^^^^^^^^^^^^^^^^

.. code-block:: kotlin
implementation("com.caoccao.javet:javet:0.9.9") // Linux or Windows
implementation("com.caoccao.javet:javet-macos:0.9.9") // Mac OS (x86_64 Only)
implementation("com.caoccao.javet:javet:0.9.10") // Linux or Windows
implementation("com.caoccao.javet:javet-macos:0.9.10") // Mac OS (x86_64 Only)
Gradle Groovy DSL
^^^^^^^^^^^^^^^^^

.. code-block:: groovy
implementation 'com.caoccao.javet:javet:0.9.9' // Linux or Windows
implementation 'com.caoccao.javet:javet-macos:0.9.9' // Mac OS (x86_64 Only)
implementation 'com.caoccao.javet:javet:0.9.10' // Linux or Windows
implementation 'com.caoccao.javet:javet-macos:0.9.10' // Mac OS (x86_64 Only)
Hello Javet
-----------
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
}

group = "com.caoccao.javet"
version = "0.9.9"
version = "0.9.10"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Usage for V8: sh build-linux.sh -DV8_DIR=${HOME}/v8
# Usage for Node: sh build-linux.sh -DNODE_DIR=${HOME}/node
JAVET_VERSION=0.9.9
JAVET_VERSION=0.9.10
rm -rf build
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Usage for V8: sh build-macos.sh -DV8_DIR=${HOME}/v8
# Usage for Node: sh build-macos.sh -DNODE_DIR=${HOME}/node
JAVET_VERSION=0.9.9
JAVET_VERSION=0.9.10
rm -rf build
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-windows.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
REM Usage for V8: build -DV8_DIR=C:\v8
REM Usage for Node: build -DNODE_DIR=C:\node
SET JAVET_VERSION=0.9.9
SET JAVET_VERSION=0.9.10
rd /s/q build
mkdir build
cd build
Expand Down
12 changes: 6 additions & 6 deletions cpp/jni/javet_resource_node.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,9,0
PRODUCTVERSION 0,9,9,0
FILEVERSION 0,9,10,0
PRODUCTVERSION 0,9,10,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "caoccao.com"
VALUE "FileDescription", "caoccao.com"
VALUE "FileVersion", "0.9.9.0"
VALUE "InternalName", "libjavet-node-windows-x86_64.v.0.9.9.dll"
VALUE "FileVersion", "0.9.10.0"
VALUE "InternalName", "libjavet-node-windows-x86_64.v.0.9.10.dll"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.0.9.9.dll"
VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.0.9.10.dll"
VALUE "ProductName", "Javet Windows"
VALUE "ProductVersion", "0.9.9.0"
VALUE "ProductVersion", "0.9.10.0"
END
END
BLOCK "VarFileInfo"
Expand Down
12 changes: 6 additions & 6 deletions cpp/jni/javet_resource_v8.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,9,0
PRODUCTVERSION 0,9,9,0
FILEVERSION 0,9,10,0
PRODUCTVERSION 0,9,10,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "caoccao.com"
VALUE "FileDescription", "caoccao.com"
VALUE "FileVersion", "0.9.9.0"
VALUE "InternalName", "libjavet-v8-windows-x86_64.v.0.9.9.dll"
VALUE "FileVersion", "0.9.10.0"
VALUE "InternalName", "libjavet-v8-windows-x86_64.v.0.9.10.dll"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.0.9.9.dll"
VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.0.9.10.dll"
VALUE "ProductName", "Javet Windows"
VALUE "ProductVersion", "0.9.9.0"
VALUE "ProductVersion", "0.9.10.0"
END
END
BLOCK "VarFileInfo"
Expand Down
110 changes: 100 additions & 10 deletions docker/windows-x86_64/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,111 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Usage: docker build -t sjtucaocao/javet-windows:0.9.9 -f docker/windows-x86_64/base.Dockerfile .

# Note: This is experimental and it doesn't work as expected yet.
# Preparation:
# Visual Studio installer validates free disk space and refuses to work with the docker default one.
# Please follow the steps to set free disk space to 120GB.
# 1. Update daemon.json
# "storage-opts": [
# "dm.basesize=120GB",
# "size=120GB"
# ]
# 2. Restart WSL2
# 3. Restart docker

# https://hub.docker.com/_/microsoft-dotnet-framework-sdk/
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-20H2
# Usage: docker build -t sjtucaocao/javet-windows:0.9.10 -m 4G -f docker/windows-x86_64/base.Dockerfile .

# https://hub.docker.com/_/microsoft-windows
FROM mcr.microsoft.com/windows:20H2-amd64

SHELL ["cmd", "/S", "/C"]
RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe
RUN start /w vs_buildtools.exe --quiet --wait --norestart --nocache modify \
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" \
WORKDIR /

# Install Python 3
RUN curl -SL --output python-3.9.6-amd64.exe https://www.python.org/ftp/python/3.9.6/python-3.9.6-amd64.exe
RUN start /w python-3.9.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=0
RUN del /q python-3.9.6-amd64.exe

# Install Python 2
RUN curl -SL --output python-2.7.18.msi https://www.python.org/ftp/python/2.7.18/python-2.7.18.msi
RUN start /w msiexec.exe /i python-2.7.18.msi ALLUSERS=1 ADDLOCAL=ALL /qn
RUN del /q python-2.7.18.msi

# Install Git for Windows
# https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation
RUN curl -SL --output Git-2.32.0.2-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.32.0.windows.2/Git-2.32.0.2-64-bit.exe
RUN start /w Git-2.32.0.2-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh"
RUN del /q Git-2.32.0.2-64-bit.exe

# Prepare V8
RUN mkdir google
WORKDIR /google
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
WORKDIR /google/depot_tools
RUN git checkout remotes/origin/master
RUN setx /M PATH "C:\google\depot_tools;%PATH%"
ENV DEPOT_TOOLS_WIN_TOOLCHAIN=0
WORKDIR /google
RUN fetch v8
WORKDIR /google/v8
RUN git checkout 9.2.230.21
WORKDIR /google
RUN gclient sync
RUN echo V8 preparation is completed.

# Install Visual Studio 2019 Community
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?view=vs-2019
# https://docs.microsoft.com/en-us/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019
WORKDIR /
RUN curl -SL --output vs_community.exe https://aka.ms/vs/16/release/vs_community.exe
RUN echo Installing Visual Studio 2019 Community
RUN start /w vs_community.exe \
--wait --quiet --norestart --nocache --includeRecommended --includeOptional \
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community" \
--add Microsoft.VisualStudio.Workload.NativeDesktop \
--add Microsoft.VisualStudio.Workload.NativeCrossPlat \
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 \
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 \
--remove Microsoft.VisualStudio.Component.Windows81SDK \
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
RUN del /q vs_buildtools.exe

ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
# Install Windows SDK 10.0.19041.x
RUN curl -SL --output winsdksetup.exe https://go.microsoft.com/fwlink/p/?linkid=2120843
RUN start /w winsdksetup.exe /norestart /quiet /ceip off /features +
RUN del /q vs_community.exe
RUN del /q winsdksetup.exe

# Build V8
WORKDIR /google/v8
RUN setx /M PATH "C:\Python27;C:\Python27\Scripts;%PATH%"
RUN python tools/dev/v8gen.py x64.release -vv -- v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false
RUN ninja -C out.gn/x64.release v8_monolith || EXIT 0
COPY ./scripts/python/patch_v8_build.py .
RUN ["C:\\Program Files\\Python39\\python.exe", "C:\\google\\v8\\patch_v8_build.py", "-p", "C:\\google\\v8\\"]
RUN ninja -C out.gn/x64.release v8_monolith
RUN del patch_v8_build.py
RUN echo V8 build is completed.

# Prepare Node.js
WORKDIR /
RUN powershell -ExecutionPolicy Bypass -c "iex(New-Object Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')"
RUN choco install -y nasm
RUN git clone https://github.com/nodejs/node.git
WORKDIR /node
RUN git checkout v14.17.4
RUN echo Node.js preparation is completed.

# Build Node.js
RUN vcbuild.bat static without-intl
RUN echo Node.js build is completed.

# Prepare Javet Build Environment
RUN choco install -y openjdk8
RUN setx /M PATH "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;%PATH%"
RUN setx /M PATH "C:\Program Files\Git\usr\bin;%PATH%"

# Shrink
WORKDIR /
RUN rd /s /q "C:\Users\ContainerAdministrator\AppData\Local\Temp"

# Completed
RUN echo Javet build base image is completed.
43 changes: 43 additions & 0 deletions docker/windows-x86_64/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2021 caoccao.com Sam Cao
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Usage: docker build -t javet:local -f docker/windows-x86_64/build.Dockerfile .

FROM sjtucaocao/javet-windows:0.9.10

SHELL ["cmd", "/S", "/C"]
WORKDIR /

# Copy Javet
RUN mkdir Javet
WORKDIR /Javet
COPY . .

# Build JNI
WORKDIR /Javet/cpp
RUN build-windows.cmd -DV8_DIR="C:\google\v8"
RUN build-windows.cmd -DNODE_DIR="C:\node"

# Build Jar
WORKDIR /Javet
RUN touch src/main/resources/libjavet-v8*
RUN gradlew build test --rerun-tasks
RUN touch src/main/resources/libjavet-node*
RUN gradlew test --rerun-tasks

VOLUME C:\\output

# Completed
RUN echo Javet build is completed.
2 changes: 1 addition & 1 deletion docs/development/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It's quite hard for developers to build Javet successfully for various reasons.

Here are 3 ways of building Javet.

1. `Build Javet with Docker <build_javet_with_docker.rst>`_ (Linux)
1. `Build Javet with Docker <build_javet_with_docker.rst>`_ (Linux and Windows)
2. `Build Javet with Pre-built Binaries <build_javet_with_pre_built_binaries.rst>`_ (Linux, Mac OS and Windows)
3. `Build Javet from Scratch <build_javet_from_scratch.rst>`_ (Linux, Mac OS and Windows)

Expand Down
34 changes: 29 additions & 5 deletions docs/development/build_javet_with_docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Build Javet with Docker
=======================

For now, the Docker build only supports building Javet on Linux. As Docker supports Linux and Windows with WSL2, Javet for Linux can also be built on Windows.
The Docker build supports building Javet for Linux and Windows. As Docker supports Linux and Windows with WSL2, Javet for Linux can also be built on Windows.

Regarding Docker build for Mac OS or Windows, contributors are welcome if you are interested. Or, you will have to wait for a long while.
Regarding Docker build for Mac OS, contributors are welcome if you are interested. Or, you will have to wait for a long while.

Build Environment
=================
Expand All @@ -27,10 +27,10 @@ Windows Environment
Docker Hub and Github
---------------------

Please make sure the network connection to the Docker Hub and Github is up and running. The Docker repository of the Javet images are available at https://hub.docker.com/repository/docker/sjtucaocao/javet.
Please make sure the network connection to the Docker Hub and Github is up and running. The Docker repository of the Javet images are available at https://hub.docker.com/repository/docker/sjtucaocao.

Build Javet on Linux
====================
Build Javet for Linux on Linux or Windows
=========================================

1. Clone Javet.
2. Navigate to the root directory of the Javet repository.
Expand All @@ -39,4 +39,28 @@ Build Javet on Linux
* Docker will pull the corresponding image (~10GB) from Docker Hub.
* The actual build takes few minutes including pulling dependent libraries from Maven Central, building and testing.

Build Javet for Windows on Windows
==================================

1. Update daemon.json

.. code-block:: json
"storage-opts": [
"dm.basesize=120GB",
"size=120GB"
]
2. Restart WSL2
3. Restart docker
4. Clone Javet.
5. Navigate to the root directory of the Javet repository.
6. Execute ``docker build -t sjtucaocao/javet-windows:x.x.x -m 4G -f docker/windows-x86_64/base.Dockerfile .`` (Be careful, please include the last ``.``).
7. Execute ``docker build -f docker/windows-x86_64/build.Dockerfile .`` (Be careful, please include the last ``.``).

Note:

* The base image is so large (60+GB) that it's not efficient to push the base image to docker hub. Of course, without the base image at docker hub, it's not wise to enable the github workflow for Windows build.
* Building the base image takes many hours and may experience intermittent errors.

[`Home <../../README.rst>`_] [`Development <index.rst>`_]
2 changes: 2 additions & 0 deletions docs/development/build_javet_with_pre_built_binaries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Download Pre-built Node.js and V8

I have prepared pre-built Linux and Windows version of Node.js ``v14.17.4`` and V8 ``v9.2.230.21``. Please download the zipped headers and binaries from this `drive <https://drive.google.com/drive/folders/18wcF8c-zjZg9iZeGfNSL8-bxqJwDZVEL?usp=sharing>`_ and unzip them to local folders respectively.

Note: As the docker builds are available, I'll stop publishing pre-built binaries. If you really need them, please contact the maintainer wisely.

Build Javet JNI Library
=======================

Expand Down
2 changes: 1 addition & 1 deletion docs/development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Development
* `Development Tools <tools.rst>`_
* `Build <build.rst>`_

* `Build Javet with Docker <build_javet_with_docker.rst>`_ (Linux)
* `Build Javet with Docker <build_javet_with_docker.rst>`_ (Linux and Windows)
* `Build Javet with Pre-built Binaries <build_javet_with_pre_built_binaries.rst>`_ (Linux, Mac OS and Windows)
* `Build Javet from Scratch <build_javet_from_scratch.rst>`_ (Linux, Mac OS and Windows)

Expand Down
2 changes: 2 additions & 0 deletions docs/reference/error_codes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Code Type Name Format
501 Converter ConverterFailure Failed to convert values with error message ${message}
502 Converter ConverterCircularStructure Circular structure is detected with max depth ${maxDepth} reached
601 Module ModuleNameEmpty Module name is empty
602 Module ModuleNotFound Module ${moduleName} is not found
603 Module ModulePermissionDenied Denied access to module ${moduleName}
701 Lock LockAcquisitionFailure Failed to acquire the lock
702 Lock LockReleaseFailure Failed to release the lock
703 Lock LockConflictThreadIdMismatch Runtime lock conflict is detected with locked thread ID ${lockedThreadID} and current thread ID ${currentThreadID}
Expand Down
Loading

0 comments on commit 80b160c

Please sign in to comment.