Skip to content

Commit

Permalink
Deploy TruffleSqueak language library for Windows
Browse files Browse the repository at this point in the history
Since the SDL2 backend is not supported on Windows, TruffleSqueak in native mode can only run without a display on Windows
  • Loading branch information
fniephaus committed Apr 21, 2022
1 parent 77e6c69 commit 1508238
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
26 changes: 8 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
os: [ubuntu-latest, ubuntu-20.04-aarch64, macos-latest, windows-latest]
java: [11, 17]
env:
BUILD_SVM: "${{ matrix.os != 'windows-latest' && matrix.java != 17 }}"
RUN_TESTS: "${{ matrix.os == 'ubuntu-latest' || matrix.java == 11 }}"
RUN_WITH_COVERAGE: "${{ matrix.os == 'ubuntu-latest' && matrix.java == 17 }}"
GRAALVM_HOME_ENV: "${{ matrix.os == 'windows-latest' && 'trufflesqueak-jvm' || 'trufflesqueak-svm' }}"
Expand All @@ -65,45 +64,36 @@ jobs:
- name: Set up dependencies
shell: bash
run: mx.trufflesqueak/utils.sh set-up-dependencies java${{ matrix.java }}
- name: Build TruffleSqueak JVM component
run: mx.trufflesqueak/utils.sh build-component trufflesqueak-jvm ${{ matrix.java }} ${{ env.INSTALLABLE_JVM_TARGET }}
if: ${{ env.BUILD_SVM != 'true' && matrix.os != 'windows-latest' }}
- name: Build TruffleSqueak JVM component via cmd.exe
- name: Build TruffleSqueak SVM component
run: mx.trufflesqueak/utils.sh build-component trufflesqueak-svm ${{ matrix.java }} ${{ env.INSTALLABLE_SVM_TARGET }}
if: ${{ matrix.os != 'windows-latest' }}
- name: Build TruffleSqueak SVM component via cmd.exe
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
call mx --env trufflesqueak-jvm --no-download-progress build --dependencies SMALLTALK_INSTALLABLE_JAVA${{ matrix.java }},GRAALVM_TRUFFLESQUEAK_JAVA${{ matrix.java }}
call mx --env trufflesqueak-jvm graalvm-home > graalvm-home-with-forward-slashes.txt
call mx --env trufflesqueak-svm --no-download-progress build --dependencies SMALLTALK_INSTALLABLE_SVM_JAVA${{ matrix.java }},GRAALVM_TRUFFLESQUEAK_SVM_JAVA${{ matrix.java }}
call mx --env trufflesqueak-svm graalvm-home > graalvm-home-with-forward-slashes.txt
set /p GRAALVM_HOME=<graalvm-home-with-forward-slashes.txt
setlocal enabledelayedexpansion
set "GRAALVM_HOME=%GRAALVM_HOME:/=\%"
echo %GRAALVM_HOME%\bin>>%GITHUB_PATH%
echo GRAALVM_HOME=%GRAALVM_HOME%>>%GITHUB_ENV%
echo [%GRAALVM_HOME% set as $GRAALVM_HOME]
call mx --env trufflesqueak-jvm paths SMALLTALK_INSTALLABLE_JAVA${{ matrix.java }} > installable-path-with-forward-slashes.txt
call mx --env trufflesqueak-svm paths SMALLTALK_INSTALLABLE_SVM_JAVA${{ matrix.java }} > installable-path-with-forward-slashes.txt
set /p INSTALLABLE_PATH=<installable-path-with-forward-slashes.txt
setlocal enabledelayedexpansion
set "INSTALLABLE_PATH=%INSTALLABLE_PATH:/=\%"
copy %INSTALLABLE_PATH% ${{ env.INSTALLABLE_JVM_TARGET }}
copy %INSTALLABLE_PATH% ${{ env.INSTALLABLE_SVM_TARGET }}
if: ${{ matrix.os == 'windows-latest' }}
- name: Build TruffleSqueak SVM component
run: mx.trufflesqueak/utils.sh build-component trufflesqueak-svm ${{ matrix.java }} ${{ env.INSTALLABLE_SVM_TARGET }}
if: ${{ env.BUILD_SVM == 'true' }}
- name: Run SystemReporter on TruffleSqueak in JVM mode
shell: bash
run: ${{ env.TRUFFLESQUEAK_EXEC }} --jvm --code "SystemReporter new reportText asString" images/test-64bit.image
- name: Run SystemReporter on TruffleSqueak in native mode
shell: bash
run: ${{ env.TRUFFLESQUEAK_EXEC }} --native --code "SystemReporter new reportText asString" images/test-64bit.image
if: ${{ env.BUILD_SVM == 'true' }}
- name: Upload TruffleSqueak JVM component
shell: bash
run: mx.trufflesqueak/utils.sh deploy-asset ${{ env.INSTALLABLE_JVM_TARGET }} ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.BUILD_SVM != 'true' && matrix.os != 'windows-latest' }}
- name: Upload TruffleSqueak SVM component
shell: bash
run: mx.trufflesqueak/utils.sh deploy-asset ${{ env.INSTALLABLE_SVM_TARGET }} ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.BUILD_SVM == 'true' }}
- name: Clone Graal.js repository
shell: bash
run: mx.trufflesqueak/utils.sh shallow-clone-graaljs
Expand Down
1 change: 1 addition & 0 deletions mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ def patched_init(self, *args, **kw_args):
jar_distributions=['trufflesqueak:TRUFFLESQUEAK_LAUNCHER'],
main_class='%s.launcher.TruffleSqueakLauncher' % PACKAGE_NAME,
build_args=[
'-H:+ReportExceptionStackTraces',
'-H:+DumpThreadStacksOnSignal',
'-H:+DetectUserDirectoriesInImageHeap',
'-H:+TruffleCheckBlockListMethods',
Expand Down
24 changes: 9 additions & 15 deletions mx.trufflesqueak/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,14 @@ set-up-dependencies() {
local java_version=$1
local test_image="${2:-trufflesqueak}"

if [[ "${BUILD_SVM:-}" == "true" ]]; then
case "$(uname -s)" in
"Linux")
sudo apt update --quiet --yes && sudo apt install --quiet --yes libsdl2-dev
;;
"Darwin")
HOMEBREW_NO_AUTO_UPDATE=1 brew install sdl2
;;
esac
fi
case "$(uname -s)" in
"Linux")
sudo apt update --quiet --yes && sudo apt install --quiet --yes libsdl2-dev
;;
"Darwin")
HOMEBREW_NO_AUTO_UPDATE=1 brew install sdl2
;;
esac

# Repository was shallow copied and Git did not fetch tags, so fetch the tag
# of the commit (if any) to make it available for other Git operations.
Expand Down Expand Up @@ -239,11 +237,7 @@ set-up-dependencies() {
;;
esac

if [[ "${BUILD_SVM:-}" == "true" ]]; then
set-env "INSTALLABLE_SVM_TARGET" "$(installable-filename "${java_version}" "-svm")"
else
set-env "INSTALLABLE_JVM_TARGET" "$(installable-filename "${java_version}" "")"
fi
set-env "INSTALLABLE_SVM_TARGET" "$(installable-filename "${java_version}" "-svm")"
}

set-up-labsjdk() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package de.hpi.swa.trufflesqueak.aot;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.constant.CConstant;
import org.graalvm.nativeimage.c.constant.CEnum;
Expand All @@ -32,6 +34,7 @@
*
*/
@CContext(SDLCContext.class)
@Platforms({Platform.LINUX.class, Platform.DARWIN.class})
public final class SDL {
/*
* SDL.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
import org.graalvm.nativeimage.c.CContext;

public final class SDLCContext implements CContext.Directives {
@Override
public boolean isInConfiguration() {
/* SDL2 backend only supported on Linux and Darwin */
return Platform.includedIn(Platform.LINUX.class) || Platform.includedIn(Platform.DARWIN.class);
}

@Override
public List<String> getHeaderFiles() {
return Collections.singletonList("<SDL2/SDL.h>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Arrays;

import org.graalvm.nativeimage.PinnedObject;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.UnmanagedMemory;
import org.graalvm.nativeimage.c.struct.SizeOf;
import org.graalvm.nativeimage.c.type.CIntPointer;
Expand Down Expand Up @@ -49,6 +51,7 @@
import de.hpi.swa.trufflesqueak.nodes.accessing.AbstractPointersObjectNodes.AbstractPointersObjectReadNode;
import de.hpi.swa.trufflesqueak.util.OS;

@Platforms({Platform.LINUX.class, Platform.DARWIN.class})
public final class SqueakSDL2Display implements SqueakDisplayInterface {
private static final String DEFAULT_WINDOW_TITLE = "TruffleSqueak + SubstrateVM + SDL2";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.nio.file.Paths;
import java.util.HashMap;

import org.graalvm.nativeimage.Platform;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
Expand Down Expand Up @@ -617,7 +619,14 @@ public boolean isHeadless() {
public void attachDisplayIfNecessary() {
if (!isHeadless) {
CompilerDirectives.transferToInterpreterAndInvalidate();
display = TruffleOptions.AOT ? new SqueakSDL2Display(this) : new SqueakDisplay(this);
if (TruffleOptions.AOT) {
/* SDL2 backend only supported on Linux and Darwin */
if (Platform.includedIn(Platform.LINUX.class) || Platform.includedIn(Platform.DARWIN.class)) {
display = new SqueakSDL2Display(this);
}
} else {
display = new SqueakDisplay(this);
}
}
}

Expand Down

0 comments on commit 1508238

Please sign in to comment.