Skip to content
This repository has been 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
merged 4 commits into from
May 11, 2017

Conversation

tetsuharuohzeki
Copy link
Contributor

  • 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
Contributor Author

@nrc @jonathandturner

How about this approach?

@nrc nrc mentioned this pull request May 10, 2017
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
Copy link
Member

@nrc nrc left a comment

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.

build.rs Outdated
}

fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
Copy link
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

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

struct Ignore;
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

Fixed by c3d99ad

src/main.rs Outdated
@@ -51,8 +51,13 @@ type Span = span::Span<span::ZeroIndexed>;
pub fn main() {
env_logger::init().unwrap();

let arg_count = ::std::env::args().count();
if arg_count > 1 {
let args: Vec<String> = ::std::env::args().collect();
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

Fixed by 0384629

src/version.rs Outdated
@@ -0,0 +1,6 @@
use getopts::{Options, Matches};
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

fixed by 4fde1ff

src/main.rs Outdated
@@ -62,3 +67,7 @@ pub fn main() {
server::run_server(analysis, vfs, build_queue);
}
}

fn version() -> &'static str {
concat!(env!("CARGO_PKG_VERSION"), include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")))
Copy link
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
Contributor 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
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
Contributor Author

@nrc I updated the changesets :)

@nrc
Copy link
Member

nrc commented May 11, 2017

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