Skip to content

Commit

Permalink
Respect CARGO_TARGET_DIR for cargo-bisect-rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
byeongkeunahn committed Nov 30, 2024
1 parent 0a26039 commit d59afb7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
8 changes: 7 additions & 1 deletion debug-64bit-windows.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
@echo off
setlocal
IF [%CARGO_TARGET_DIR%] == [] (
SET CARGO_TARGET_DIR=target
)
cargo +nightly build --target x86_64-pc-windows-msvc || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc target/x86_64-pc-windows-msvc/debug/basm.exe scripts/static-pie-stub-amd64.bin C static-pie-template-amd64.c || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc "%CARGO_TARGET_DIR%"/x86_64-pc-windows-msvc/debug/basm.exe scripts/static-pie-stub-amd64.bin C static-pie-template-amd64.c || goto :error

:; exit 0
endlocal
exit /b 0

:error
endlocal
exit /b %errorlevel%
8 changes: 7 additions & 1 deletion release-64bit-windows-fn-impl.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
@echo off
setlocal
IF [%CARGO_TARGET_DIR%] == [] (
SET CARGO_TARGET_DIR=target
)
cargo +nightly build --target x86_64-pc-windows-msvc --bin basm-submit --features=submit --release || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc target/x86_64-pc-windows-msvc/release/basm-submit.exe static-pie-stub-amd64.bin C static-pie-template-amd64-fn-impl.c || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc "%CARGO_TARGET_DIR%"/x86_64-pc-windows-msvc/release/basm-submit.exe static-pie-stub-amd64.bin C static-pie-template-amd64-fn-impl.c || goto :error

:; exit 0
endlocal
exit /b 0

:error
endlocal
exit /b %errorlevel%
8 changes: 7 additions & 1 deletion release-64bit-windows-rs.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
@echo off
setlocal
IF [%CARGO_TARGET_DIR%] == [] (
SET CARGO_TARGET_DIR=target
)
cargo +nightly build --target x86_64-pc-windows-msvc --bin basm-submit --features=submit --release || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc target/x86_64-pc-windows-msvc/release/basm-submit.exe static-pie-stub-amd64.bin Rust static-pie-template-amd64.rs || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc "%CARGO_TARGET_DIR%"/x86_64-pc-windows-msvc/release/basm-submit.exe static-pie-stub-amd64.bin Rust static-pie-template-amd64.rs || goto :error

:; exit 0
endlocal
exit /b 0

:error
endlocal
exit /b %errorlevel%
8 changes: 7 additions & 1 deletion release-64bit-windows.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
@echo off
setlocal
IF [%CARGO_TARGET_DIR%] == [] (
SET CARGO_TARGET_DIR=target
)
cargo +nightly build --target x86_64-pc-windows-msvc --bin basm-submit --features=submit --release || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc target/x86_64-pc-windows-msvc/release/basm-submit.exe static-pie-stub-amd64.bin C static-pie-template-amd64.c || goto :error
python scripts/static-pie-gen.py basm/src/solution.rs x86_64-pc-windows-msvc "%CARGO_TARGET_DIR%"/x86_64-pc-windows-msvc/release/basm-submit.exe static-pie-stub-amd64.bin C static-pie-template-amd64.c || goto :error

:; exit 0
endlocal
exit /b 0

:error
endlocal
exit /b %errorlevel%
12 changes: 7 additions & 5 deletions scripts/static-pie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ if [[ "$lang_name" == "CFnImpl" ]]; then
lang_name="C"
fi

cargo_target_dir=${CARGO_TARGET_DIR:-"target"}

>&2 echo "Building project for target ${target_name}, language ${lang_name}, build mode ${build_mode}"

if [[ "$build_mode" == "Debug" ]]; then
Expand All @@ -83,10 +85,10 @@ else
fi

if [[ "$target_name" == "x86_64-pc-windows-msvc" ]] || [[ "$target_name" == "x86_64-pc-windows-gnu" ]]; then
python3 scripts/static-pie-gen.py basm/ "$target_name" target/"$target_name"/"$build_mode_dir"/basm-submit.exe "$stub" "$lang_name" "$template"
python3 scripts/static-pie-gen.py basm/ "$target_name" "$cargo_target_dir"/"$target_name"/"$build_mode_dir"/basm-submit.exe "$stub" "$lang_name" "$template"
else
cp target/"$target_name"/"$build_mode_dir"/basm-submit target/"$target_name"/"$build_mode_dir"/basm-submit-stripped
objcopy --strip-all target/"$target_name"/"$build_mode_dir"/basm-submit-stripped
objcopy --remove-section .eh_frame --remove-section .gcc_except_table --remove-section .gnu.hash target/"$target_name"/"$build_mode_dir"/basm-submit-stripped
python3 scripts/static-pie-gen.py basm/ "$target_name" target/"$target_name"/"$build_mode_dir"/basm-submit-stripped "$stub" "$lang_name" "$template"
cp "$cargo_target_dir"/"$target_name"/"$build_mode_dir"/basm-submit "$cargo_target_dir"/"$target_name"/"$build_mode_dir"/basm-submit-stripped
objcopy --strip-all "$cargo_target_dir"/"$target_name"/"$build_mode_dir"/basm-submit-stripped
objcopy --remove-section .eh_frame --remove-section .gcc_except_table --remove-section .gnu.hash "$cargo_target_dir"/"$target_name"/"$build_mode_dir"/basm-submit-stripped
python3 scripts/static-pie-gen.py basm/ "$target_name" "$cargo_target_dir"/"$target_name"/"$build_mode_dir"/basm-submit-stripped "$stub" "$lang_name" "$template"
fi
5 changes: 4 additions & 1 deletion scripts/wasm-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def deflate_raw(input_bytes):
sol_b64 = base64.b64encode(deflate_raw(sol.encode('utf8'))).decode('ascii')

# binary
with open("target/wasm32-unknown-unknown/release/basm-submit.wasm", "rb") as f:
target = os.environ.get("CARGO_TARGET_DIR", "target")
if len(target) == 0:
target = "target"
with open(f"{target}/wasm32-unknown-unknown/release/basm-submit.wasm", "rb") as f:
code = f.read()
code = base64.b64encode(deflate_raw(code)).decode('ascii')

Expand Down

0 comments on commit d59afb7

Please sign in to comment.