-
Notifications
You must be signed in to change notification settings - Fork 255
Dump pkg version & build date & commit hash if run with --version
flag
#308
Conversation
How about this approach? |
…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
8be5005
to
123537b
Compare
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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, ()>
)
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"))) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@nrc I updated the changesets :) |
Thank you for the changes! |
rls <version> (<commit hash> <build date>)
.so I think there is no license problem.
Related Issues