Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print git hash in version output and add -version #204

Closed
Timmmm opened this issue Jan 30, 2023 · 6 comments · Fixed by #866
Closed

Print git hash in version output and add -version #204

Timmmm opened this issue Jan 30, 2023 · 6 comments · Fixed by #866

Comments

@Timmmm
Copy link
Contributor

Timmmm commented Jan 30, 2023

Hi, I've been recompiling a Sail a bit and finding Opam very confusing. It would be really helpful if sail had a sail -version option that printed the version and git hash so I know if Opam has actually built the version I want. Also add -version as an alias to -v because I only just realised that there even was a version option.

(Also make sure it doesn't require the source code to be a git repo - I've seen projects do that before and it's quite annoying because then you can't build from source tarballs.)

@Alasdair
Copy link
Collaborator

Currently sail -v includes the git commit number when not built using opam, i.e. when using make install (which just uses dune). If you are recompiling a lot, you can have opam only manage dependencies using opam install . --deps-only then build manually.

@Timmmm
Copy link
Contributor Author

Timmmm commented Jan 30, 2023

Ah ok, sounds like I just need to read how to use opam!

@Timmmm Timmmm closed this as completed Jan 30, 2023
@Timmmm
Copy link
Contributor Author

Timmmm commented Jan 31, 2023

FWIW I don't think the git hash in the output is quite right - you can make install sail, then checkout a different commit, make install again and it will still show the old commit. make clean; make install updates it to the new one, so something is missing in the dependency graph.

Also I'm going to reopen this because I keep trying to run sail --version and getting shouted at! :-)

@Timmmm Timmmm reopened this Jan 31, 2023
@Alasdair
Copy link
Collaborator

I hadn't noticed this before, but it seems dune doesn't pick up that things have changed after a git checkout. Maybe we could add dune clean as a post-commit hook, but not sure how well that would work.

@Alasdair
Copy link
Collaborator

Or it might be that the rule that generates the file containing the commit needs to run every build

@Alasdair
Copy link
Collaborator

Yes, the problem is that after git checkout the manifest.ml from the previous checkout still exists, so the build rule:

(rule
  (target manifest.ml)
  (mode fallback)
  (action
    (with-outputs-to %{target}
      (chdir %{workspace_root}
        (run sail_manifest -gen_manifest)))))

doesn't fire

I think everything else should be fine, just the version info will be incorrect until a dune clean is run.

Alasdair added a commit that referenced this issue Jan 8, 2025
Adds (deps (universe)) to the action that builds manifest.ml so it is
always rebuilt (unless it was generated from manifest.ml.in by opam, as
the action still has fallback mode).

Fixes #204, and based on PR #863
Alasdair added a commit that referenced this issue Jan 16, 2025
Adds (deps (universe)) to the action that builds manifest.ml so it is
always rebuilt (unless it was generated from manifest.ml.in by opam, as
the action still has fallback mode).

Fixes #204, and based on PR #863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants