Giter Site home page Giter Site logo

Comments (9)

danyspin97 avatar danyspin97 commented on May 20, 2024 1

This is one of the two ideas that I have considered doing. I actually went the other way around, taken from the changelog:

For rust packages, all the files will be searched inside of the output directory (usually target) and, if they don't exist, inside the project directory. This allows rinstall to correctly get files generated by build.rs without adding too much clutter in the install.yml. To force rinstall to get a file in the project directory, use the $PROJECTDIR placeholder.

However I had some problems with cargo directory structure and I wasn't able to made upstream change their mind, this is way the development of rinstall have been slowed down in the last months.

While OUT_DIR is a good solution, the disadvantage is that the install.yml becomes cluttered, especially in huge projects like kanidm. With the repetition of $OUT_DIR throughout all the install.yml I thought that it would be harder to advocate in favor of rinstall (which I admit is also a big part of

from rinstall.

classabbyamp avatar classabbyamp commented on May 20, 2024

what about having something like this?

   completions:
      bash:
        - $OUT_DIR/completions/kanidmd.bash
        - $OUT_DIR/completions/kanidm_badlist_preprocess.bash
        - $OUT_DIR/completions/kanidm.bash

I don't think this env var would be available directly for use, but it should be derivable similar to how the exes are found

edit: or maybe @OUT_DIR@ instead of $OUT_DIR

from rinstall.

classabbyamp avatar classabbyamp commented on May 20, 2024

However I had some problems with cargo directory structure

what kind of problems?

from rinstall.

danyspin97 avatar danyspin97 commented on May 20, 2024

The issues have been described here by kanidm developer (@Firstyear):

rust-lang/cargo#9858

I have also opened a thread in the official Rust Zulip instance:

https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/New.20.60GEN_DIR.60.20var.20for.20generated.20files.20in.20build.2Ers/near/302814870

from rinstall.

classabbyamp avatar classabbyamp commented on May 20, 2024

ok wow, that sounds impossible to work around on rinstall's side.

what about going through $cratename-*/ and finding the one worth the newest mtime? kinda ugly and hacky, but I think it would work.

another option might be to require printing the value of OUT_DIR in build.rs but that seems bad to require devs to do something

from rinstall.

danyspin97 avatar danyspin97 commented on May 20, 2024

what about going through $cratename-*/ and finding the one worth the newest mtime? kinda ugly and hacky, but I think it would work.

The issue here is that there could be multiple crates and we don't know their names.

another option might be to require printing the value of OUT_DIR in build.rs but that seems bad to require devs to do something

Agreed, advocating in favor of rinstall would be harder with this.

from rinstall.

danyspin97 avatar danyspin97 commented on May 20, 2024

This is the current setting of outdir in build.rs for rinstall:

    let outdir = PathBuf::from(std::env::var("OUT_DIR").unwrap())
        .ancestors()
        .nth(3)
        .unwrap()
        .to_path_buf();

And this is the current install.yml file for rinstall:

rinstall: 0.2.0
pkgs:
  rinstall:
    type: rust
    exe:
      - rinstall
    docs:
      - README.md
    licenses:
      - LICENSE.md
    man:
      - man/rinstall.1
    completions:
      bash:
        - completions/rinstall.bash
      elvish:
        - completions/rinstall.elv
      fish:
        - completions/rinstall.fish
      zsh:
        - completions/_rinstall

With this configuration, the generated files (completions and man page) are correctly handled by rinstall:

> ./target/x86_64-unknown-linux-musl/release/rinstall install --rust-target-triple x86_64-unknown-linux-musl --system
>>> Package rinstall
Would install target/x86_64-unknown-linux-musl/release/rinstall -> /usr/local/bin/rinstall
Would install target/x86_64-unknown-linux-musl/release/man/rinstall.1 -> /usr/local/share/man/man1/rinstall.1
Would install README.md -> /usr/local/share/doc/rinstall/README.md
Would install target/x86_64-unknown-linux-musl/release/completions/rinstall.bash -> /usr/local/share/bash-completion/completions/rinstall.bash
Would install target/x86_64-unknown-linux-musl/release/completions/rinstall.elv -> /usr/local/share/elvish/lib/rinstall.elv
Would install target/x86_64-unknown-linux-musl/release/completions/rinstall.fish -> /usr/local/share/fish/vendor_completions.d/rinstall.fish
Would install target/x86_64-unknown-linux-musl/release/completions/_rinstall -> /usr/local/share/zsh/site-functions/_rinstall
Would install LICENSE.md -> /usr/local/share/licenses/rinstall/LICENSE.md
Would install pkginfo -> /usr/local/var/rinstall/rinstall.pkg

One possible disadvantage is that there could be files or directories with the same name as the the generated files. Since rinstall allows to rename later, temporary names can be used in the build.rs file, so I don't think this could be an issue.

I will try again with kanidm, and if it works fine I'd propose to close this issue as fixed. Let me know your thoughts, I am sure that there is something I am missing.

from rinstall.

classabbyamp avatar classabbyamp commented on May 20, 2024

seems reasonable to me 👍

from rinstall.

Firstyear avatar Firstyear commented on May 20, 2024

Yeah, cargo really isn't setup to output files for anything 3rd party like shell completions. Which is a bit annoying since cargo is very baked-into rust.

from rinstall.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.