Skip to content

cp: compile without clap (for nushell) - #5358

Closed
tommady wants to merge 28 commits into
uutils:mainfrom
tommady:fix-5203
Closed

tommady wants to merge 28 commits into
uutils:mainfrom
tommady:fix-5203

Conversation

@tommady

@tommady tommady commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

fulfill #5203

❯ cargo tree
uu_cp v0.0.21 (/home/arch/code/tommady/coreutils/src/uu/cp)
├── clap v4.4.2
│   └── clap_builder v4.4.2
│       ├── anstream v0.5.0
│       │   ├── anstyle v1.0.0
│       │   ├── anstyle-parse v0.2.0
│       │   │   └── utf8parse v0.2.1
│       │   ├── anstyle-query v1.0.0
│       │   ├── colorchoice v1.0.0
│       │   └── utf8parse v0.2.1
│       ├── anstyle v1.0.0
│       ├── clap_lex v0.5.0
│       ├── strsim v0.10.0
│       └── terminal_size v0.2.6
│           └── rustix v0.37.23
│               ├── bitflags v1.3.2
│               ├── io-lifetimes v1.0.11
│               │   └── libc v0.2.148
│               ├── libc v0.2.148
│               └── linux-raw-sys v0.3.8
├── filetime v0.2.22
│   ├── cfg-if v1.0.0
│   └── libc v0.2.148
├── indicatif v0.17.3
│   ├── console v0.15.7
│   │   ├── lazy_static v1.4.0
│   │   ├── libc v0.2.148
│   │   └── unicode-width v0.1.11
│   ├── number_prefix v0.4.0
│   ├── portable-atomic v0.3.15
│   └── unicode-width v0.1.11
├── libc v0.2.148
├── quick-error v2.0.1
├── uucore v0.0.21 (/home/arch/code/tommady/coreutils/src/uucore)
│   ├── clap v4.4.2 (*)
│   ├── dunce v1.0.4
│   ├── glob v0.3.1
│   ├── libc v0.2.148
│   ├── nix v0.27.1
│   │   ├── bitflags v2.4.0
│   │   ├── cfg-if v1.0.0
│   │   └── libc v0.2.148
│   ├── once_cell v1.18.0
│   ├── os_display v0.1.3
│   │   └── unicode-width v0.1.11
│   ├── uucore_procs v0.0.21 (proc-macro) (/home/arch/code/tommady/coreutils/src/uucore_procs)
│   │   ├── proc-macro2 v1.0.63
│   │   │   └── unicode-ident v1.0.5
│   │   ├── quote v1.0.29
│   │   │   └── proc-macro2 v1.0.63 (*)
│   │   └── uuhelp_parser v0.0.21 (/home/arch/code/tommady/coreutils/src/uuhelp_parser)
│   ├── walkdir v2.4.0
│   │   └── same-file v1.0.6
│   └── wild v2.2.0
├── walkdir v2.4.0 (*)
└── xattr v1.0.1
    └── libc v0.2.148

❯ cargo tree --no-default-features
uu_cp v0.0.21 (/home/arch/code/tommady/coreutils/src/uu/cp)
├── filetime v0.2.22
│   ├── cfg-if v1.0.0
│   └── libc v0.2.148
├── indicatif v0.17.3
│   ├── console v0.15.7
│   │   ├── lazy_static v1.4.0
│   │   ├── libc v0.2.148
│   │   └── unicode-width v0.1.11
│   ├── number_prefix v0.4.0
│   ├── portable-atomic v0.3.15
│   └── unicode-width v0.1.11
├── libc v0.2.148
├── quick-error v2.0.1
├── uucore v0.0.21 (/home/arch/code/tommady/coreutils/src/uucore)
│   ├── dunce v1.0.4
│   ├── glob v0.3.1
│   ├── libc v0.2.148
│   ├── nix v0.27.1
│   │   ├── bitflags v2.4.0
│   │   ├── cfg-if v1.0.0
│   │   └── libc v0.2.148
│   ├── once_cell v1.18.0
│   ├── os_display v0.1.3
│   │   └── unicode-width v0.1.11
│   ├── uucore_procs v0.0.21 (proc-macro) (/home/arch/code/tommady/coreutils/src/uucore_procs)
│   │   ├── proc-macro2 v1.0.63
│   │   │   └── unicode-ident v1.0.5
│   │   ├── quote v1.0.29
│   │   │   └── proc-macro2 v1.0.63 (*)
│   │   └── uuhelp_parser v0.0.21 (/home/arch/code/tommady/coreutils/src/uuhelp_parser)
│   ├── walkdir v2.4.0
│   │   └── same-file v1.0.6
│   └── wild v2.2.0
├── walkdir v2.4.0 (*)
└── xattr v1.0.1
    └── libc v0.2.148

@cakebaker cakebaker linked an issue Oct 5, 2023 that may be closed by this pull request
Comment thread src/uucore/src/lib/mods/error.rs Resolved
@tommady
tommady marked this pull request as ready for review October 5, 2023 12:13

@tertsdiepraam tertsdiepraam left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I think there's a few bits missing:

  • clap is referred to in more parts of uucore:
    • perms.rs
    • shortcut_value_parser.rs
    • backup_control.rs
    • update_control.rs
  • Because of those, the dependency isn't actually removed. Try for instance cargo check --no-default-features in the src/uu/cp folder.
  • cli-parser should be a default feature on uucore, because otherwise none of the utils will compile individually. (Try for example cargo run --no-default--features --features arch)

Comment thread src/uu/date/Cargo.toml Resolved
Comment thread src/uu/cp/Cargo.toml Resolved
@tommady

tommady commented Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

Hi @tertsdiepraam
I am facing a problem ( or maybe just I don't know how

as you can see in the latest commit I tried to fulfill the requirements but still when you run

❯ cargo tree --no-default-features
uu_cp v0.0.21 (/home/arch/code/tommady/coreutils/src/uu/cp)
├── filetime v0.2.22
│   ├── cfg-if v1.0.0
│   └── libc v0.2.148
├── indicatif v0.17.3
│   ├── console v0.15.7
│   │   ├── lazy_static v1.4.0
│   │   ├── libc v0.2.148
│   │   └── unicode-width v0.1.11
│   ├── number_prefix v0.4.0
│   ├── portable-atomic v0.3.15
│   └── unicode-width v0.1.11
├── libc v0.2.148
├── quick-error v2.0.1
├── uucore v0.0.21 (/home/arch/code/tommady/coreutils/src/uucore)
│   ├── clap v4.4.2
│   │   └── clap_builder v4.4.2
│   │       ├── anstream v0.5.0
│   │       │   ├── anstyle v1.0.0
│   │       │   ├── anstyle-parse v0.2.0
│   │       │   │   └── utf8parse v0.2.1
│   │       │   ├── anstyle-query v1.0.0
│   │       │   ├── colorchoice v1.0.0
│   │       │   └── utf8parse v0.2.1
│   │       ├── anstyle v1.0.0
│   │       ├── clap_lex v0.5.0
│   │       ├── strsim v0.10.0
│   │       └── terminal_size v0.2.6
│   │           └── rustix v0.37.23
│   │               ├── bitflags v1.3.2
│   │               ├── io-lifetimes v1.0.11
│   │               │   └── libc v0.2.148
│   │               ├── libc v0.2.148
│   │               └── linux-raw-sys v0.3.8
│   ├── dunce v1.0.4
│   ├── glob v0.3.1
│   ├── libc v0.2.148
│   ├── nix v0.27.1
│   │   ├── bitflags v2.4.0
│   │   ├── cfg-if v1.0.0
│   │   └── libc v0.2.148
│   ├── once_cell v1.18.0
│   ├── os_display v0.1.3
│   │   └── unicode-width v0.1.11
│   ├── uucore_procs v0.0.21 (proc-macro) (/home/arch/code/tommady/coreutils/src/uucore_procs)
│   │   ├── proc-macro2 v1.0.63
│   │   │   └── unicode-ident v1.0.5
│   │   ├── quote v1.0.29
│   │   │   └── proc-macro2 v1.0.63 (*)
│   │   └── uuhelp_parser v0.0.21 (/home/arch/code/tommady/coreutils/src/uuhelp_parser)
│   ├── walkdir v2.4.0
│   │   └── same-file v1.0.6
│   └── wild v2.2.0
├── walkdir v2.4.0 (*)
└── xattr v1.0.1
    └── libc v0.2.148

under the cp folder, the clap dep stands still.

I tried a lot of ways to remove that but if any one of these features is used then the clap dep cannot be removed...

  • "entries"
  • "fs"
  • "mode"
  • "perms"
  • "update-control"
  • "backup-control"

please guide me when you have time.
thanks.

@tertsdiepraam

Copy link
Copy Markdown
Collaborator

I had to look around for a bit but I think this fixed it! Default features and workspaces are a bit weird together :)

diff --git a/Cargo.toml b/Cargo.toml
index e7fc2851b..2beaf7630 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -343,7 +343,7 @@ blake3 = "1.5.0"
 sm3 = "0.4.2"
 digest = "0.10.7"
 
-uucore = { version = ">=0.0.19", package = "uucore", path = "src/uucore" }
+uucore = { version = ">=0.0.19", package = "uucore", path = "src/uucore", default-features = false }
 uucore_procs = { version = ">=0.0.19", package = "uucore_procs", path = "src/uucore_procs" }
 uu_ls = { version = ">=0.0.18", path = "src/uu/ls" }
 uu_base32 = { version = ">=0.0.18", path = "src/uu/base32" }

@tommady

tommady commented Oct 7, 2023

Copy link
Copy Markdown
Contributor Author

I had to look around for a bit but I think this fixed it! Default features and workspaces are a bit weird together :)

diff --git a/Cargo.toml b/Cargo.toml
index e7fc2851b..2beaf7630 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -343,7 +343,7 @@ blake3 = "1.5.0"
 sm3 = "0.4.2"
 digest = "0.10.7"
 
-uucore = { version = ">=0.0.19", package = "uucore", path = "src/uucore" }
+uucore = { version = ">=0.0.19", package = "uucore", path = "src/uucore", default-features = false }
 uucore_procs = { version = ">=0.0.19", package = "uucore_procs", path = "src/uucore_procs" }
 uu_ls = { version = ">=0.0.18", path = "src/uu/ls" }
 uu_base32 = { version = ">=0.0.18", path = "src/uu/base32" }

wonderful it did! thanks!

Comment thread src/uu/cp/Cargo.toml Resolved
Comment thread src/uu/cp/src/cp.rs Resolved
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?

Comment thread src/uu/cp/Cargo.toml Resolved
@sylvestre

Copy link
Copy Markdown
Contributor

@tommady sorry but it needs to be rebased

@sylvestre

Copy link
Copy Markdown
Contributor

@tommady sorry, i noticed that it never landed, is it still relevant ? if so, can you please rebase it and i will merge it
sorry about that again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

cp: compile without clap (for nushell)

4 participants