-
Notifications
You must be signed in to change notification settings - Fork 48
Add build scritps for Windows, macOs and Linux #109
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
Open
peacefulprogram
wants to merge
3
commits into
HarlonWang:main
Choose a base branch
from
peacefulprogram:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| @echo off | ||
| setlocal | ||
|
|
||
| cd wrapper-java\src\main | ||
|
|
||
| set args= | ||
| set build_args= | ||
|
|
||
| where ninja >nul 2>nul | ||
| if errorlevel 1 ( | ||
| set args=%args% -G "MinGW Makefiles" | ||
| ) else ( | ||
| set args=%args% -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ | ||
| set build_args=%build_args% -j %NUMBER_OF_PROCESSORS% | ||
| ) | ||
|
|
||
| if exist build ( | ||
| echo Deleting old build folder... | ||
| rmdir /s /q build | ||
| ) | ||
|
|
||
| call :run cmake -B build -S . %args% -DCMAKE_BUILD_TYPE=Release || exit /b 1 | ||
| call :run cmake --build build %build_args% || exit /b 1 | ||
| call :run copy build\libquickjs-java-wrapper.dll ..\..\.. || exit /b 1 | ||
|
|
||
| echo Build success | ||
| exit /b | ||
|
|
||
| :run | ||
| echo ^> %* | ||
| %* | ||
| exit /b %errorlevel% | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
|
|
||
| run() { | ||
| echo "> $*" | ||
| "$@" | ||
| } | ||
|
|
||
| cd wrapper-java/src/main | ||
|
|
||
| if [ -d build ]; then | ||
| echo "Deleting old build folder..." | ||
| rm -rf build | ||
| fi | ||
|
|
||
| if command -v ninja >/dev/null 2>&1; then | ||
| GENERATOR_ARGS="-G Ninja" | ||
| BUILD_ARGS="-j $(nproc 2>/dev/null || sysctl -n hw.ncpu)" | ||
| else | ||
| GENERATOR_ARGS="" | ||
| BUILD_ARGS="" | ||
| fi | ||
|
|
||
| run cmake -B build -S . $GENERATOR_ARGS -DCMAKE_BUILD_TYPE=Release | ||
| run cmake --build build $BUILD_ARGS | ||
|
|
||
| OS_NAME=$(uname) | ||
| if [[ "$OS_NAME" == "Darwin" ]]; then | ||
| DYLIB_EXT="dylib" | ||
| else | ||
| DYLIB_EXT="so" | ||
| fi | ||
|
|
||
| run cp "build/libquickjs-java-wrapper.$DYLIB_EXT" ../../.. | ||
|
|
||
| echo "Build success" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: 批处理脚本中的相对
cd和未加引号路径在某些环境下会导致失败这些命令假定脚本从仓库根目录运行,并且目录路径中没有空格。为了提高健壮性,建议基于脚本所在路径构造路径(例如
cd /d "%~dp0wrapper-java\src\main"),并为所有路径参数加上引号。Original comment in English
suggestion: Relative
cdand unquoted paths in the batch script can cause failures in some environmentsThese commands assume the script is run from the repo root and that no directories contain spaces. To make it more robust, base paths on the script location (e.g.
cd /d "%~dp0wrapper-java\src\main") and quote all path arguments.