From 8b8c16978a96f29812d57d084de8394e6900b2fd Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 28 Oct 2020 08:50:03 +0900 Subject: [PATCH] Support cargo-simple-bundler --- .github/run-cargo-simple-bundler.py | 57 +++++++++++++++++++++++++++++ .github/workflows/ci.yml | 44 ++++++++++++++++++++-- 2 files changed, 98 insertions(+), 3 deletions(-) create mode 100755 .github/run-cargo-simple-bundler.py diff --git a/.github/run-cargo-simple-bundler.py b/.github/run-cargo-simple-bundler.py new file mode 100755 index 0000000..45d82af --- /dev/null +++ b/.github/run-cargo-simple-bundler.py @@ -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() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9658366..dd2f2f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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