Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate boilerplate logic into the build.java script itself #75

Open
Karm opened this issue Nov 12, 2020 · 4 comments
Open

Integrate boilerplate logic into the build.java script itself #75

Karm opened this issue Nov 12, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request not-stale

Comments

@Karm
Copy link
Collaborator

Karm commented Nov 12, 2020

During the Windows CI automation it turned out some (for me) serious batch-fu was needed. It might have been easier if written in PowerShell entirely, but it would have been definitely easier if those preparation tasks were actually carried out by the build.java script itself. The goal of this issue is to translate these steps to Java and integrate nicely into build.java.

Current Windows build code:

@echo off
set PYTHONHTTPSVERIFY=0
set "JAVA_HOME=C:\Program Files\AdoptOpenJDK\%OPENJDK%"
set "PATH=%JAVA_HOME%\bin;%PATH%"
set MAVEN_REPO=C:\tmp\.m2\repository
set "MANDREL_REPO=%WORKSPACE%\mandrel"
set "MX_HOME=%WORKSPACE%\mx"

pushd mandrel
for /F "tokens=*" %%i in ('"git log --pretty=format:%%h -n1"') do set VER=%%i
set "MANDREL_VERSION=%MANDREL_VERSION_SUBSTRING% %VER%"
for /f "tokens=1 delims= " %%a IN ("%MANDREL_VERSION%") do set MANDREL_VERSION_UNTIL_SPACE=%%a
for /f "tokens=6" %%g in ('java --version 2^>^&1 ^| findstr /R "Runtime.*build "') do set JAVA_VERSION=%%g
set JAVA_VERSION=%JAVA_VERSION:~0,-1%
set MANDREL_HOME=%WORKSPACE%\mandrel-java11-%MANDREL_VERSION_UNTIL_SPACE%
popd

call vcvars64
IF NOT %ERRORLEVEL% == 0 ( exit 1 )

"%JAVA_HOME%\bin\java" -ea build.java --maven-local-repository "%MAVEN_REPO%" --mandrel-repo "%MANDREL_REPO%" --mx-home "%MX_HOME%" --mandrel-version "%MANDREL_VERSION%" --mandrel-home "%MANDREL_HOME%" --archive-suffix zip
IF NOT %ERRORLEVEL% == 0 ( exit 1 )

for /f "tokens=5" %%g in ('dir mandrel-*.zip ^| findstr /R mandrel-.*.zip') do set ZIP_NAME=%%g
powershell -c "$hash=(Get-FileHash %ZIP_NAME% -Algorithm SHA1).Hash;echo \"$hash %ZIP_NAME%\"">%ZIP_NAME%.sha1
IF NOT %ERRORLEVEL% == 0 ( exit 1 )

(
echo This is a dev build of Mandrel from https://github.com/graalvm/mandrel.
echo Mandrel %MANDREL_VERSION%
echo OpenJDK used: %JAVA_VERSION%
) >MANDREL.md

if not exist "%MANDREL_HOME%\bin\native-image.cmd" (
  echo "Cannot find native-image tool. Quitting..."
  exit 1
) else (
  echo "native-image.cmd is present, good."
)

(
echo|set /p=" public class Hello {"
echo|set /p=" public static void main(String[] args) {"
echo|set /p="     System.out.println("Hello.");"
echo|set /p=" }"
echo|set /p=" }"
) >Hello.java

set "JAVA_HOME=%MANDREL_HOME%"
set "PATH=%JAVA_HOME%\bin;%PATH%"
javac Hello.java
native-image Hello

for /F "tokens=*" %%i in ('hello.exe') do set HELLO_OUT=%%i
if "%HELLO_OUT%" == "Hello." (
  echo Done
) else (
  echo Native image fail
  exit 1
)
@Karm Karm added the enhancement New feature or request label Nov 12, 2020
@Karm Karm self-assigned this Nov 12, 2020
@github-actions
Copy link

This issue appears to be stale because it has been open 30 days with no activity. This issue will be closed in 7 days unless Stale label is removed or a new comment is made.

@github-actions
Copy link

This issue appears to be stale because it has been open 30 days with no activity. This issue will be closed in 7 days unless Stale label is removed or a new comment is made.

@github-actions github-actions bot added the Stale label Jan 14, 2021
@jerboaa jerboaa removed the Stale label Jan 14, 2021
@github-actions
Copy link

This issue appears to be stale because it has been open 30 days with no activity. This issue will be closed in 7 days unless Stale label is removed or a new comment is made.

@github-actions github-actions bot added the Stale label Feb 14, 2021
@jerboaa jerboaa removed the Stale label Feb 15, 2021
@github-actions
Copy link

This issue appears to be stale because it has been open 30 days with no activity. This issue will be closed in 7 days unless Stale label is removed or a new comment is made.

@github-actions github-actions bot added the Stale label Mar 18, 2021
@jerboaa jerboaa added not-stale and removed Stale labels Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not-stale
Projects
None yet
Development

No branches or pull requests

2 participants