Skip to content

Commit

Permalink
CI: respect 32/64bit and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
byeongkeunahn committed Oct 1, 2023
1 parent 75acc71 commit dd0d918
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 47 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@ jobs:
run: cargo test --lib -- --test-threads 1
env:
RUSTFLAGS: ""
- name: Check C
- name: Check C (x86_64)
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
run: |
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
- name: Check Rust
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release.sh C 64 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
- name: Check C (x86)
if: ${{ matrix.target == 'i686-unknown-linux-gnu' }}
run: |
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
- name: Check Rust (BOJ 1001)
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-32bit.sh C 32 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
- name: Check Rust (x86_64)
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
run: |
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
- name: Check Rust (BOJ 3745)
run: |
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./src/solution.rs ./tests/boj_1000.in ./tests/boj_1000.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_1001.rs ./tests/boj_1001.in ./tests/boj_1001.out
python ./scripts/build-and-judge.py ${{ runner.temp }} ./release-rs.sh Rust 64 ./tests/boj_3745.rs ./tests/boj_3745.in ./tests/boj_3745.out
18 changes: 8 additions & 10 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ jobs:
run: cargo test --lib -- --test-threads 1
env:
RUSTFLAGS: ""
- name: Check C
- name: Check C (x86_64)
run: |
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
- name: Check Rust
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_1001.rs .\tests\boj_1001.in .\tests\boj_1001.out
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows.cmd C 64 .\tests\boj_3745.rs .\tests\boj_3745.in .\tests\boj_3745.out
- name: Check Rust (x86_64)
run: |
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
- name: Check Rust (BOJ 1001)
run: |
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust .\tests\boj_1001.rs .\tests\boj_1001.in .\tests\boj_1001.out
- name: Check Rust (BOJ 3745)
run: |
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust .\tests\boj_3745.rs .\tests\boj_3745.in .\tests\boj_3745.out
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\src\solution.rs .\tests\boj_1000.in .\tests\boj_1000.out
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_1001.rs .\tests\boj_1001.in .\tests\boj_1001.out
python .\scripts\build-and-judge.py ${{ runner.temp }} .\release-64bit-windows-rs.cmd Rust 64 .\tests\boj_3745.rs .\tests\boj_3745.in .\tests\boj_3745.out
9 changes: 5 additions & 4 deletions scripts/build-and-judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def test_equal(x, y):
tmp_dir = sys.argv[1]
build_cmd = sys.argv[2]
language = sys.argv[3]
sol_path = sys.argv[4]
indata_path = sys.argv[5]
outdata_path = sys.argv[6]
bits = int(sys.argv[4])
sol_path = sys.argv[5]
indata_path = sys.argv[6]
outdata_path = sys.argv[7]
src_ext = {"C": "c", "Rust": "rs"}[language]

# Prepare environment
Expand Down Expand Up @@ -72,7 +73,7 @@ def test_equal(x, y):
if platform.system() == "Windows":
os.system("cl {0} /F268435456 /Fe{1} /link /SUBSYSTEM:CONSOLE".format(src_path, bin_path))
else:
os.system("gcc -o {1} -O3 {0}".format(src_path, bin_path))
os.system("gcc -o {1} {2} {0}".format(src_path, bin_path, "-O3 -m32" if bits == 32 else "-O3"))
else: # language == "Rust"
if platform.system() == "Windows":
os.system("rustc -C opt-level=3 -o {1} --crate-type=bin {0}".format(src_path, bin_path))
Expand Down
17 changes: 0 additions & 17 deletions scripts/check.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/static-pie-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
stub = f.read()

stub = bytearray(stub)
stub_raw = '"' + "".join("\\x{:02x}".format(x) for x in stub) + '"'
while len(stub) % 4 != 0:
stub.append(0)
stub_raw = '"' + "".join("\\x{:02x}".format(x) for x in stub) + '"'
stub_b85 = base64.b85encode(stub, pad=False).decode('ascii') + ']'
stub_b85_len = len(stub_b85)
if lang_name == "C":
Expand Down
6 changes: 0 additions & 6 deletions test.sh

This file was deleted.

0 comments on commit dd0d918

Please sign in to comment.