Skip to content

Commit

Permalink
Merge #71
Browse files Browse the repository at this point in the history
71: Update README r=qryxip a=qryxip

bors r+


Co-authored-by: Ryo Yamashita <[email protected]>
  • Loading branch information
bors[bot] and qryxip authored Dec 6, 2020
2 parents 8bc6cd5 + fc58b7d commit 932b114
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 75 deletions.
69 changes: 35 additions & 34 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ version = "0.0.0"
edition = "2018"

[dependencies]
ac-library-rs-parted = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-convolution = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-dsu = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-fenwicktree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-lazysegtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-math = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-maxflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-mincostflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-modint = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-scc = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-segtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-string = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-twosat = { git = "https://github.com/qryxip/ac-library-rs-parted" }
input = { git = "https://github.com/qryxip/oj-verify-playground" }
output = { git = "https://github.com/qryxip/oj-verify-playground" }
tonelli_shanks = { git = "https://github.com/qryxip/oj-verify-playground" }
ac-library-rs-parted = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-convolution = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-dsu = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-fenwicktree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-lazysegtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-math = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-maxflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-mincostflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-modint = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-scc = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-segtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-string = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-twosat = { git = "https://github.com/qryxip/ac-library-rs-parted" }
qryxips-competitive-programming-library-buffered-print = { git = "https://github.com/qryxip/oj-verify-playground" }
qryxips-competitive-programming-library-input = { git = "https://github.com/qryxip/oj-verify-playground" }
qryxips-competitive-programming-library-tonelli-shanks = { git = "https://github.com/qryxip/oj-verify-playground" }
# ...
```

Expand All @@ -56,7 +56,7 @@ fn main() {
yps: [(u32, u32)],
}

output::buf_print(|out| {
buffered_print::buf_print(|out| {
macro_rules! println(($($tt:tt)*) => (writeln!(out, $($tt)*).unwrap()));
for (y, p) in yps {
ModInt::set_modulus(p);
Expand All @@ -73,19 +73,19 @@ fn main() {

```console
cargo equip --resolve-cfgs --remove docs --minify libs --rustfmt --check -o ./bundled.rs
Running `/home/ryo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo check --message-format json -p -p 'ac-library-rs-parted:0.1.0' -p 'ac-library-rs-parted-build:0.1.0' -p 'ac-library-rs-parted-convolution:0.1.0' -p 'ac-library-rs-parted-dsu:0.1.0' -p 'ac-library-rs-parted-fenwicktree:0.1.0' -p 'ac-library-rs-parted-internal-bit:0.1.0' -p 'ac-library-rs-parted-internal-math:0.1.0' -p 'ac-library-rs-parted-internal-queue:0.1.0' -p 'ac-library-rs-parted-internal-scc:0.1.0' -p 'ac-library-rs-parted-internal-type-traits:0.1.0' -p 'ac-library-rs-parted-lazysegtree:0.1.0' -p 'ac-library-rs-parted-math:0.1.0' -p 'ac-library-rs-parted-maxflow:0.1.0' -p 'ac-library-rs-parted-mincostflow:0.1.0' -p 'ac-library-rs-parted-modint:0.1.0' -p 'ac-library-rs-parted-scc:0.1.0' -p 'ac-library-rs-parted-segtree:0.1.0' -p 'ac-library-rs-parted-string:0.1.0' -p 'ac-library-rs-parted-twosat:0.1.0' -p 'anyhow:1.0.34' -p 'byteorder:1.3.4' -p 'num-traits:0.2.14' -p 'proc-macro2:1.0.10' -p 'ryu:1.0.5' -p 'serde:1.0.113' -p 'serde_derive:1.0.113' -p 'serde_json:1.0.59' -p 'syn:1.0.17' -p 'typenum:1.12.0'`
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
cargo equip --resolve-cfgs --remove comments docs --rustfmt --check -o ./bundled.rs
Running `/home/ryo/.cargo/bin/rustup run nightly cargo udeps --output json -p solve --bin solve`
Checking solve v0.0.0 (/home/ryo/src/local/play-cargo-equip/solve)
Finished dev [unoptimized + debuginfo] target(s) in 0.58s
info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/target/debug/deps/save-analysis/solve-f295f9b7bca492c1.json"
Finished dev [unoptimized + debuginfo] target(s) in 0.48s
info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/target/debug/deps/save-analysis/solve-e847c5289cb48717.json"
Running `/home/ryo/.rustup/toolchains/1.42.0-x86_64-unknown-linux-gnu/bin/cargo check --message-format json -p 'solve:0.0.0' --bin solve`
Finished dev [unoptimized + debuginfo] target(s) in 0.21s
Bundling the code
Checking cargo-equip-check-output-gefn1vlt5c4e733x v0.1.0 (/tmp/cargo-equip-check-output-gefn1vlt5c4e733x)
Finished dev [unoptimized + debuginfo] target(s) in 0.36s
Checking cargo-equip-check-output-dmdk9q2orje3e2zl v0.1.0 (/tmp/cargo-equip-check-output-dmdk9q2orje3e2zl)
Finished dev [unoptimized + debuginfo] target(s) in 0.38s
```

[Submit Info #30787 - Library-Checker](https://judge.yosupo.jp/submission/30787)
[Submit Info #31638 - Library-Checker](https://judge.yosupo.jp/submission/31638)

## インストール

Expand Down Expand Up @@ -122,7 +122,7 @@ info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/tar
1. 各crate rootには`#[macro_export]`したマクロと同名なアイテムが存在しないようにする。

cargo-equipは`mod lib_name`直下に`pub use crate::{ それらの名前 };`を挿入するため、展開後の`use`で壊れます。
`bin`ではマクロは`#[macro_use]`で使ってください。
`bin`側ではマクロは`#[macro_use]`で使ってください。

```rust
// in main source code
Expand All @@ -144,10 +144,10 @@ info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/tar

**ルートモジュール以外のモジュールで**`extern crate`を宣言してマウントし、そこを相対パスで参照してください。

cargo-equipは`itertools`等のAtCoderやCodinGameで使えるクレートを除いて
cargo-equipは`--exclude <SPEC>...`, `--exclude-atcoder-crates`, `--exclude-codingame-crates`で指定されたクレートを除いて
`extern crate`を`use crate::extern_crate_name_in_main_crate;`に置き換えます。

誤って直接使わないように`lib` → `lib`の依存においては対象の名前は[リネーム](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml)しておくことを強く推奨します。
`lib`同士を`exter crate`で参照する場合、誤って直接使わないように対象の名前は[リネーム](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml)しておくことを強く推奨します。

```diff
mod extern_crates {
Expand All @@ -158,8 +158,9 @@ info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/tar
use self::extern_crates::another_lib::foo::Foo; // Prepend `self::` to make compatible with Rust 2015
```

AOJyukicoder等のRust2018が利用できないサイトにこのツールを使用しないなら不要です。
各ライブラリにこのような`mod __pseudo_extern_prelude`を作り、extern preludeの代用にします。
AOJ ~~やyukicoder~~ 等のRust2018が利用できないサイトにこのツールを使用しないなら不要です。

2018向けにはcargo-equipは各ライブラリにこのような`mod __pseudo_extern_prelude`を作り、extern preludeの代用にします。
この`mod __pseudo_extern_prelude`自体はRust 2015でもコンパイルできますが、Rust 2015は`use another_lib::A;`を解決できません。

```diff
Expand Down Expand Up @@ -192,7 +193,7 @@ info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/tar
5. 可能な限りライブラリを小さなクレートに分割する。

cargo-equipは「クレート内のアイテムの依存関係」を調べることはしません。
AtCoder以外に参加する場合は、出力結果を64KiBに収めるためにできるだけ小さなクレートに分割してください
AtCoder以外に参加する場合は、出力結果を制限内(たいてい64KiB程度)に収めるためにできるだけ小さなクレートに分割してください

```console
.
Expand Down Expand Up @@ -281,8 +282,8 @@ fn main() {
```diff
+//! # Bundled libraries
+//!
+//! - `input v0.0.0` → `crate::input` (source: `git+https://github.com/qryxip/oj-verify-playground#63ddefa84d96b16cdb7f85e70dcdc4f283f57391`, license: `CC0-1.0`)
+//! - `output v0.0.0` → `crate::output` (source: `git+https://github.com/qryxip/oj-verify-playground#63ddefa84d96b16cdb7f85e70dcdc4f283f57391`, license: `CC0-1.0`)
+//! - `qryxips-competitive-programming-library-buffered-print v0.0.0` → `crate::buffered_print` (source: `git+https://github.com/qryxip/oj-verify-playground#e5976f9187d4104de1c36accd939485a94651d2d`, license: `CC0-1.0`)
+//! - `qryxips-competitive-programming-library-input v0.0.0` → `crate::input` (source: `git+https://github.com/qryxip/oj-verify-playground#e5976f9187d4104de1c36accd939485a94651d2d`, license: `CC0-1.0`)
// Uncomment this line if you don't use your libraries. (`--check` still works)
//#![cfg_attr(cargo_equip, cargo_equip::skip)]

Expand Down Expand Up @@ -352,7 +353,7 @@ cargo-equipがやる操作は以下の通りです。
1. `#[cfg(恒真)]` (e.g. `cfg(feature = "enabled-feature")`)のアトリビュートを消去します。
2. `#[cfg(恒偽)]` (e.g. `cfg(test)`, `cfg(feature = "disable-feature")`)のアトリビュートが付いたアイテムを消去します。

これは次の基準で判定されます
これは次の割り当てで判定されます

- [`test`](https://doc.rust-lang.org/reference/conditional-compilation.html#test): `false`
- [`proc_macro`](https://doc.rust-lang.org/reference/conditional-compilation.html#proc_macro): `false`
Expand Down
72 changes: 31 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ version = "0.0.0"
edition = "2018"

[dependencies]
ac-library-rs-parted = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-convolution = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-dsu = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-fenwicktree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-lazysegtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-math = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-maxflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-mincostflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-modint = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-scc = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-segtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-string = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-twosat = { git = "https://github.com/qryxip/ac-library-rs-parted" }
input = { git = "https://github.com/qryxip/oj-verify-playground" }
output = { git = "https://github.com/qryxip/oj-verify-playground" }
tonelli_shanks = { git = "https://github.com/qryxip/oj-verify-playground" }
ac-library-rs-parted = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-convolution = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-dsu = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-fenwicktree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-lazysegtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-math = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-maxflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-mincostflow = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-modint = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-scc = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-segtree = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-string = { git = "https://github.com/qryxip/ac-library-rs-parted" }
ac-library-rs-parted-twosat = { git = "https://github.com/qryxip/ac-library-rs-parted" }
qryxips-competitive-programming-library-buffered-print = { git = "https://github.com/qryxip/oj-verify-playground" }
qryxips-competitive-programming-library-input = { git = "https://github.com/qryxip/oj-verify-playground" }
qryxips-competitive-programming-library-tonelli-shanks = { git = "https://github.com/qryxip/oj-verify-playground" }
# ...
```

Expand All @@ -56,7 +56,7 @@ fn main() {
yps: [(u32, u32)],
}

output::buf_print(|out| {
buffered_print::buf_print(|out| {
macro_rules! println(($($tt:tt)*) => (writeln!(out, $($tt)*).unwrap()));
for (y, p) in yps {
ModInt::set_modulus(p);
Expand All @@ -73,19 +73,19 @@ fn main() {

```console
cargo equip --resolve-cfgs --remove docs --minify libs --rustfmt --check -o ./bundled.rs
Running `/home/ryo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo check --message-format json -p -p 'ac-library-rs-parted:0.1.0' -p 'ac-library-rs-parted-build:0.1.0' -p 'ac-library-rs-parted-convolution:0.1.0' -p 'ac-library-rs-parted-dsu:0.1.0' -p 'ac-library-rs-parted-fenwicktree:0.1.0' -p 'ac-library-rs-parted-internal-bit:0.1.0' -p 'ac-library-rs-parted-internal-math:0.1.0' -p 'ac-library-rs-parted-internal-queue:0.1.0' -p 'ac-library-rs-parted-internal-scc:0.1.0' -p 'ac-library-rs-parted-internal-type-traits:0.1.0' -p 'ac-library-rs-parted-lazysegtree:0.1.0' -p 'ac-library-rs-parted-math:0.1.0' -p 'ac-library-rs-parted-maxflow:0.1.0' -p 'ac-library-rs-parted-mincostflow:0.1.0' -p 'ac-library-rs-parted-modint:0.1.0' -p 'ac-library-rs-parted-scc:0.1.0' -p 'ac-library-rs-parted-segtree:0.1.0' -p 'ac-library-rs-parted-string:0.1.0' -p 'ac-library-rs-parted-twosat:0.1.0' -p 'anyhow:1.0.34' -p 'byteorder:1.3.4' -p 'num-traits:0.2.14' -p 'proc-macro2:1.0.10' -p 'ryu:1.0.5' -p 'serde:1.0.113' -p 'serde_derive:1.0.113' -p 'serde_json:1.0.59' -p 'syn:1.0.17' -p 'typenum:1.12.0'`
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
cargo equip --resolve-cfgs --remove comments docs --rustfmt --check -o ./bundled.rs
Running `/home/ryo/.cargo/bin/rustup run nightly cargo udeps --output json -p solve --bin solve`
Checking solve v0.0.0 (/home/ryo/src/local/play-cargo-equip/solve)
Finished dev [unoptimized + debuginfo] target(s) in 0.58s
info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/target/debug/deps/save-analysis/solve-f295f9b7bca492c1.json"
Finished dev [unoptimized + debuginfo] target(s) in 0.48s
info: Loading save analysis from "/home/ryo/src/local/play-cargo-equip/solve/target/debug/deps/save-analysis/solve-e847c5289cb48717.json"
Running `/home/ryo/.rustup/toolchains/1.42.0-x86_64-unknown-linux-gnu/bin/cargo check --message-format json -p 'solve:0.0.0' --bin solve`
Finished dev [unoptimized + debuginfo] target(s) in 0.21s
Bundling the code
Checking cargo-equip-check-output-gefn1vlt5c4e733x v0.1.0 (/tmp/cargo-equip-check-output-gefn1vlt5c4e733x)
Finished dev [unoptimized + debuginfo] target(s) in 0.36s
Checking cargo-equip-check-output-dmdk9q2orje3e2zl v0.1.0 (/tmp/cargo-equip-check-output-dmdk9q2orje3e2zl)
Finished dev [unoptimized + debuginfo] target(s) in 0.38s
```

[Submit Info #30787 - Library-Checker](https://judge.yosupo.jp/submission/30787)
[Submit Info #31638 - Library-Checker](https://judge.yosupo.jp/submission/31638)

## Installation

Expand Down Expand Up @@ -144,7 +144,7 @@ Follow these constrants when you writing libraries to bundle.

Mount them in some module **except the root one** with a `extern crate` item and refer them with relative paths.

cargo-equip replaces `extern crate` items with `use crate::extern_crate_name_in_main_crate;` except for crates available on AtCoder or CodinGame (e.g. `itertools`).
cargo-equip replaces `extern crate` items with `use crate::extern_crate_name_in_main_crate;` except for crates specified with `--exclude <SPEC>...`, `--exclude-atcoder-crates`, or `--exclude-codingame-crates`.
[Rename](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml) the libraries not to use directly.

```diff
Expand All @@ -156,7 +156,7 @@ Follow these constrants when you writing libraries to bundle.
use self::extern_crates::another_lib::foo::Foo; // Prepend `self::` to make compatible with Rust 2015
```

If you don't use website where Rust 2018 is unavailable (e.g. AIZU ONLINE JUDGE, yukicoder), you don't have to do this.
If you don't use website where Rust 2018 is unavailable (e.g. AIZU ONLINE JUDGE, ~~yukicoder~~), you don't have to do this.
`mod __pseudo_extern_prelude` like this is created in each library as a substitute for extern prelude.
This `mod __pseudo_extern_prelude` itself is valid in Rust 2015 but unfortunately Rust 2015 cannot resolve the `use another_lib::A;`.

Expand Down Expand Up @@ -275,20 +275,10 @@ It gives tentative `extern_crate_name`s like `__package_name_0_1_0` to dependenc
```diff
+//! # Bundled libraries
+//!
+//! ## `input` (private)
+//!
+//! ### `extern_crate_name`
+//!
+//! `input`
+//!
+//! ## `output` (private)
+//!
+//! ### `extern_crate_name`
+//!
+//! `output`

// Uncomment this line if you don't use your libraries. (`--check` still works)
//#![cfg_attr(cargo_equip, cargo_equip::skip)]
+//! - `qryxips-competitive-programming-library-buffered-print v0.0.0` → `crate::buffered_print` (source: `git+https://github.com/qryxip/oj-verify-playground#e5976f9187d4104de1c36accd939485a94651d2d`, license: `CC0-1.0`)
+//! - `qryxips-competitive-programming-library-input v0.0.0` → `crate::input` (source: `git+https://github.com/qryxip/oj-verify-playground#e5976f9187d4104de1c36accd939485a94651d2d`, license: `CC0-1.0`)
// Uncomment this line if you don't use your libraries. (`--check` still works)
//#![cfg_attr(cargo_equip, cargo_equip::skip)]

-#[macro_use]
-extern crate input as _;
Expand Down

0 comments on commit 932b114

Please sign in to comment.