-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have been preaching this for so long to other teams, I really better clean up my own backyard: Make sure that you can run moc --version and get a somewhat useful indication what version that is. This is important for when random people use `moc` from random versions of SDK or – later – build it themselves and then provide bug reports. When building locally, with `.git` around, this now injects the git revision: $ ./moc --version Motoko compiler (revision 9abae15e-dirty) (the `-dirty` indicates that my work-tee is not clean). When `.git` is _not_ available, as typially (and rightfully) when building with nix, it looks if Nix’s `$out` variable is set, and includes that: ~/dfinity/motoko $ $(nix-build -A moc)/bin/moc --version Motoko compiler (revision xx6fmamdh5bjph9law6x02d7f4hw8f84-moc-bin) This is less useful for end-users, but it still allows us to (hopefully) identify the version, in the worst case by running this command on all revisions to find the right one: $ nix-store --query --outputs $(nix-instantiate -A moc-bin) /nix/store/xx6fmamdh5bjph9law6x02d7f4hw8f84-moc-bin Or by querying hydra (as @basvandijk suggests in dfinity/sdk#383 (comment)) Once we do versioned releases, we can of course extend this to inject the version number there, and use `git describe --tag` to have `v1.0-200-9abae15e` like derscriptions. I _hope_ this will not cause extra recompilations with `dune`, and will work out-of-the box for everyone, but we’ll see.
- Loading branch information
Showing
8 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
source_id.ml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(library (name source_id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
cd "$(dirname "$BASH_SOURCE")" | ||
|
||
file="source_id.ml" | ||
|
||
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ] | ||
then echo "let id = \"$(git describe --always --dirty)\"" > $file.tmp | ||
elif [ -n "$out" ] | ||
then echo "let id = \"$(echo $out|cut -d/ -f4)\"" > $file.tmp | ||
else echo "let id = \"unidentified version\"" > $file.tmp | ||
fi | ||
if [ ! -e $file ] || ! cmp -s $file.tmp $file | ||
then mv $file.tmp $file | ||
else rm -f $file.tmp | ||
fi | ||
|
||
|