Skip to content

Commit

Permalink
vab: get version from vmod at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
Larpon committed Feb 22, 2021
1 parent 549312b commit 9c93ea8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion v.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Module {
name: 'vab'
description: 'V Android Bootstrapper'
version: '0.0.3'
version: '0.2.1'
dependencies: []
}
14 changes: 13 additions & 1 deletion vab.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import android.ndk
import android.env

const (
exe_version = '0.2.1'
exe_version = version()
exe_name = os.file_name(os.executable())
exe_dir = os.dir(os.real_path(os.executable()))
exe_git_hash = vab_commit_hash()
Expand Down Expand Up @@ -838,3 +838,15 @@ fn launch_cmd(args []string) int {
eprintln(@MOD + '.' + @FN + ' failed executing "$exec"$v_message')
return 1
}

fn version() string {
mut v := '0.0.0'
vmod := @VMOD_FILE
if vmod.len > 0 {
if vmod.contains('version:') {
v = vmod.all_after('version:').all_before('\n').replace("'", '').replace('"',
'').trim(' ')
}
}
return v
}

0 comments on commit 9c93ea8

Please sign in to comment.