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

all: add support for @BUILD_DATE, @BUILD_TIME and @BUILD_TIMESTAMP, all using v.util.get_build_time(), and overridable through SOURCE_DATE_EPOCH #22213

Merged
merged 3 commits into from
Sep 14, 2024

Conversation

spytheman
Copy link
Member

@spytheman spytheman commented Sep 13, 2024

With this PR, this code:

dump(@BUILD_DATE)
dump(@BUILD_TIME)
dump(@BUILD_TIMESTAMP)

will produce something like this (fixed at compile time), each time it is run:

[/v/misc/2024_09_13__12/a.v:2] @BUILD_DATE: 2024-09-13
[/v/misc/2024_09_13__12/a.v:3] @BUILD_TIME: 09:31:25
[/v/misc/2024_09_13__12/a.v:4] @BUILD_TIMESTAMP: 1726219885

... which eliminates one more common use of a separate build system.

@spytheman spytheman merged commit 4c68f85 into vlang:master Sep 14, 2024
79 checks passed
@koplenov
Copy link
Contributor

koplenov commented Oct 7, 2024

I think we still need a git commit hash

@koplenov
Copy link
Contributor

koplenov commented Oct 7, 2024

Hmm, I did it this way

@["/utils/get/server/version"]
pub fn (mut server Server) utils_get_server_version(mut ctx Context) veb.Result {
	return ctx.json[map[string]string](
		{
			"commit": $embed_file('.git/refs/heads/master', .zlib).to_string()
			"build_date": @BUILD_DATE
			"build_time": @BUILD_TIME
			"build_timestamp": @BUILD_TIMESTAMP
		}
	)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants