Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Dump pkg version & build date & commit hash if run with --version flag - #308

Merged
nrc merged 4 commits into
rust-lang:masterfrom
tetsuharuohzeki:version-flag
May 11, 2017
Merged

nrc merged 4 commits into
rust-lang:masterfrom
tetsuharuohzeki:version-flag

Conversation

@tetsuharuohzeki

Copy link
Copy Markdown
  • The output format is rls <version> (<commit hash> <build date>).
  • This embed approach is based on rustup.rs's code.
    • rustup.rs is licensed under same licenses (Apache 2.0/MIT),
      so I think there is no license problem.

Related Issues

@tetsuharuohzeki

Copy link
Copy Markdown
Author

@nrc @jonathandturner

How about this approach?

@nrc nrc mentioned this pull request May 10, 2017
5 of 6 tasks
…lag.

- The output format is `rls <version> (<commit hash> <build date>)`
- This embed approach is based on [rustup.rs][rustup]'s code.
  - rustup.rs is licensed under same licenses (Apache 2.0/MIT),
    so I think there is no license problem.

[rustup]: https://github.com/rust-lang-nursery/rustup.rs/tree/a1c6be19add9c99f8d8868ec384aa76057fe7f70

@nrc nrc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, there's a few comments to address, but all minor.

Comment thread build.rs
}

fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sadly (and ironically), this means we will no longer be able to build the RLS inside the RLS (#290), but the fix is fairly straightforward

Comment thread build.rs Outdated
use std::path::PathBuf;
use std::process::Command;

struct Ignore;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems unnecessary - just use an Option rather than a Result (or Result<String, ()>)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed by c3d99ad

Comment thread src/main.rs Outdated

let arg_count = ::std::env::args().count();
if arg_count > 1 {
let args: Vec<String> = ::std::env::args().collect();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: one could do this without collecting by using next on the args iterator. Not really necessary though.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed by 0384629

Comment thread src/version.rs Outdated
@@ -0,0 +1,6 @@
use getopts::{Options, Matches};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this file is an orphan and should be removed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed by 4fde1ff

Comment thread src/main.rs
}

fn version() -> &'static str {
concat!(env!("CARGO_PKG_VERSION"), include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should use Path::join rather than string concatenation of the path so that this works on Windows

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@nrc the argument for include_str! must be a string literal. So we cannot do it without const fn.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, we could just open the file and read it rather than using include_str, but this is certainly nicer. I guess we can wait and see if someone breaks

@tetsuharuohzeki

Copy link
Copy Markdown
Author

@nrc I updated the changesets :)

@nrc

nrc commented May 11, 2017

Copy link
Copy Markdown
Member

Thank you for the changes!

@nrc
nrc merged commit 5551c4e into rust-lang:master May 11, 2017
@tetsuharuohzeki
tetsuharuohzeki deleted the version-flag branch May 11, 2017 04:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants