Skip to content

Commit 8b8c169

Browse files
committed
Support cargo-simple-bundler
1 parent 8e5e8e9 commit 8b8c169

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

.github/run-cargo-simple-bundler.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/python3
2+
3+
from tempfile import TemporaryDirectory
4+
from pathlib import Path
5+
import subprocess
6+
from subprocess import PIPE
7+
from argparse import ArgumentParser
8+
import platform
9+
10+
MODULES = [
11+
'convolution',
12+
'dsu',
13+
'fenwicktree',
14+
'lazysegtree',
15+
'math',
16+
'maxflow',
17+
'mincostflow',
18+
'modint',
19+
'scc',
20+
'segtree',
21+
'string',
22+
'twosat',
23+
]
24+
25+
26+
def main() -> None:
27+
ArgumentParser().parse_args()
28+
29+
manifest_path = Path(__file__).absolute().parent.parent \
30+
.joinpath('Cargo.toml')
31+
32+
with TemporaryDirectory(prefix='ac-library-rs-run-cargo-simple-bundler-',
33+
) as tempdir:
34+
tempdir = Path(tempdir)
35+
36+
for module in MODULES:
37+
rs = tempdir.joinpath(f'with-{module}.rs')
38+
39+
with open(rs, 'a') as file:
40+
file.write(f'use ac_library_rs::{module} as _; fn main() {{}}')
41+
file.flush()
42+
43+
output = subprocess.run(
44+
['cargo', 'simple-bundler', '--manifest-path',
45+
manifest_path, '-e', rs], check=True, stdout=PIPE,
46+
).stdout.decode()
47+
file.write(output)
48+
49+
output = tempdir.joinpath('a')
50+
if platform.system() == 'Windows':
51+
output = output.with_suffix('.exe')
52+
subprocess.run(['rustc', '--edition', '2018', '-o', output, rs],
53+
check=True)
54+
55+
56+
if __name__ == '__main__':
57+
main()

.github/workflows/ci.yml

+41-3
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,17 @@ jobs:
9696
env:
9797
RUST_BACKTRACE: full
9898

99-
expander_test:
99+
expand-py:
100100
strategy:
101101
fail-fast: false
102102
matrix:
103103
toolchain:
104104
- 1.42.0-x86_64-unknown-linux-gnu
105-
- stable-x86_64-unknown-linux-gnu
106105
python-version:
107106
- '3.6' # https://packages.ubuntu.com/bionic/python3
108107
- '3.8' # https://packages.ubuntu.com/focal/python3
109108

110-
name: Expand_test (${{ matrix.toolchain }}, ${{ matrix.python-version }})
109+
name: expand.py (Python ${{ matrix.python-version }})
111110
runs-on: ubuntu-18.04
112111

113112
steps:
@@ -129,3 +128,42 @@ jobs:
129128

130129
- name: expand.py tests
131130
run: bash ./.github/workflows/test-expand.sh
131+
132+
cargo-simple-bundler:
133+
strategy:
134+
fail-fast: false
135+
136+
name: cargo-simple-bundler
137+
runs-on: ubuntu-18.04
138+
139+
steps:
140+
- name: Checkout
141+
uses: actions/checkout@v2
142+
143+
- name: 'Setup `1.42.0-x86_64-unknown-linux-gnu`'
144+
uses: actions-rs/toolchain@v1
145+
with:
146+
toolchain: 1.42.0-x86_64-unknown-linux-gnu
147+
profile: minimal
148+
149+
- name: 'Setup `stable-x86_64-unknown-linux-gnu`'
150+
uses: actions-rs/toolchain@v1
151+
with:
152+
toolchain: stable-x86_64-unknown-linux-gnu
153+
override: true
154+
profile: minimal
155+
156+
- name: Setup Python 3.8
157+
uses: actions/setup-python@v2
158+
with:
159+
python-version: 3.8
160+
161+
- name: Install cargo-simple-bundler
162+
uses: actions-rs/cargo@v1
163+
with:
164+
command: install
165+
args: --git https://github.com/kuretchi/cargo-simple-bundler --branch main
166+
toolchain: stable
167+
168+
- name: run-cargo-simple-bundler.py
169+
run: python ./.github/run-cargo-simple-bundler.py

0 commit comments

Comments
 (0)