Skip to content

Commit

Permalink
Support cargo-simple-bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Oct 27, 2020
1 parent 8e5e8e9 commit 8b8c169
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
57 changes: 57 additions & 0 deletions .github/run-cargo-simple-bundler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python3

from tempfile import TemporaryDirectory
from pathlib import Path
import subprocess
from subprocess import PIPE
from argparse import ArgumentParser
import platform

MODULES = [
'convolution',
'dsu',
'fenwicktree',
'lazysegtree',
'math',
'maxflow',
'mincostflow',
'modint',
'scc',
'segtree',
'string',
'twosat',
]


def main() -> None:
ArgumentParser().parse_args()

manifest_path = Path(__file__).absolute().parent.parent \
.joinpath('Cargo.toml')

with TemporaryDirectory(prefix='ac-library-rs-run-cargo-simple-bundler-',
) as tempdir:
tempdir = Path(tempdir)

for module in MODULES:
rs = tempdir.joinpath(f'with-{module}.rs')

with open(rs, 'a') as file:
file.write(f'use ac_library_rs::{module} as _; fn main() {{}}')
file.flush()

output = subprocess.run(
['cargo', 'simple-bundler', '--manifest-path',
manifest_path, '-e', rs], check=True, stdout=PIPE,
).stdout.decode()
file.write(output)

output = tempdir.joinpath('a')
if platform.system() == 'Windows':
output = output.with_suffix('.exe')
subprocess.run(['rustc', '--edition', '2018', '-o', output, rs],
check=True)


if __name__ == '__main__':
main()
44 changes: 41 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ jobs:
env:
RUST_BACKTRACE: full

expander_test:
expand-py:
strategy:
fail-fast: false
matrix:
toolchain:
- 1.42.0-x86_64-unknown-linux-gnu
- stable-x86_64-unknown-linux-gnu
python-version:
- '3.6' # https://packages.ubuntu.com/bionic/python3
- '3.8' # https://packages.ubuntu.com/focal/python3

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

steps:
Expand All @@ -129,3 +128,42 @@ jobs:

- name: expand.py tests
run: bash ./.github/workflows/test-expand.sh

cargo-simple-bundler:
strategy:
fail-fast: false

name: cargo-simple-bundler
runs-on: ubuntu-18.04

steps:
- name: Checkout
uses: actions/checkout@v2

- name: 'Setup `1.42.0-x86_64-unknown-linux-gnu`'
uses: actions-rs/toolchain@v1
with:
toolchain: 1.42.0-x86_64-unknown-linux-gnu
profile: minimal

- name: 'Setup `stable-x86_64-unknown-linux-gnu`'
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
override: true
profile: minimal

- name: Setup Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install cargo-simple-bundler
uses: actions-rs/cargo@v1
with:
command: install
args: --git https://github.com/kuretchi/cargo-simple-bundler --branch main
toolchain: stable

- name: run-cargo-simple-bundler.py
run: python ./.github/run-cargo-simple-bundler.py

0 comments on commit 8b8c169

Please sign in to comment.