Skip to content

Commit 20fd795

Browse files
committed
tools: support v run cmd/tools/oldv.v --show_VC_commit weekly.2024.03
1 parent 66ba112 commit 20fd795

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cmd/tools/modules/vgit/vgit.v

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ pub mut:
137137
vexepath string // the full absolute path to the prepared v/v.exe
138138
vvlocation string // v.v or compiler/ or cmd/v, depending on v version
139139
make_fresh_tcc bool // whether to do 'make fresh_tcc' before compiling an old V.
140+
show_vccommit bool // show the V and VC commits, corresponding to the V commit-ish, that can be used to build V
140141
}
141142

142143
pub fn (mut vgit_context VGitContext) compile_oldv_if_needed() {
143144
vgit_context.vexename = if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
144145
vgit_context.vexepath = os.real_path(os.join_path_single(vgit_context.path_v, vgit_context.vexename))
145-
if os.is_dir(vgit_context.path_v) && os.is_executable(vgit_context.vexepath) {
146+
if os.is_dir(vgit_context.path_v) && os.is_executable(vgit_context.vexepath)
147+
&& !vgit_context.show_vccommit {
146148
// already compiled, no need to compile that specific v executable again
147149
vgit_context.commit_v__hash = get_current_folder_commit_hash()
148150
return
@@ -152,7 +154,8 @@ pub fn (mut vgit_context VGitContext) compile_oldv_if_needed() {
152154
clone_or_pull(vgit_context.vc_repo_url, vgit_context.path_vc)
153155
scripting.chdir(vgit_context.path_v)
154156
scripting.run('git checkout --quiet ${vgit_context.commit_v}')
155-
if os.is_dir(vgit_context.path_v) && os.exists(vgit_context.vexepath) {
157+
if os.is_dir(vgit_context.path_v) && os.exists(vgit_context.vexepath)
158+
&& !vgit_context.show_vccommit {
156159
// already compiled, so no need to compile v again
157160
vgit_context.commit_v__hash = get_current_folder_commit_hash()
158161
return
@@ -162,6 +165,13 @@ pub fn (mut vgit_context VGitContext) compile_oldv_if_needed() {
162165
vgit_context.commit_v__hash = v_commithash
163166
vgit_context.commit_v__ts = v_timestamp
164167
vgit_context.commit_vc_hash = vccommit_before
168+
169+
if vgit_context.show_vccommit {
170+
println('VHASH=${vgit_context.commit_v__hash}')
171+
println('VCHASH=${vgit_context.commit_vc_hash}')
172+
exit(0)
173+
}
174+
165175
if os.exists('cmd/v') {
166176
vgit_context.vvlocation = 'cmd/v'
167177
} else {

cmd/tools/oldv.v

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mut:
3939
use_cache bool // use local cached copies for --vrepo and --vcrepo in
4040
fresh_tcc bool // do use `make fresh_tcc`
4141
is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'`
42+
show_vccommit bool // show the V and VC commits, corresponding to the V commit-ish, that can be used to build V
4243
}
4344

4445
fn (mut c Context) compile_oldv_if_needed() {
@@ -51,6 +52,7 @@ fn (mut c Context) compile_oldv_if_needed() {
5152
path_v: c.path_v
5253
path_vc: c.path_vc
5354
make_fresh_tcc: c.fresh_tcc
55+
show_vccommit: c.show_vccommit
5456
}
5557
c.vgcontext.compile_oldv_if_needed()
5658
c.commit_v_hash = c.vgcontext.commit_v__hash
@@ -133,6 +135,7 @@ fn main() {
133135
context.cleanup = fp.bool('clean', 0, false, 'Clean before running (slower).')
134136
context.fresh_tcc = fp.bool('fresh_tcc', 0, true, 'Do `make fresh_tcc` when preparing a V compiler.')
135137
context.cmd_to_run = fp.string('command', `c`, '', 'Command to run in the old V repo.\n')
138+
context.show_vccommit = fp.bool('show_VC_commit', 0, false, 'Show the VC commit, that can be used to compile the given V commit, and exit.\n')
136139
commits := vgit.add_common_tool_options(mut context.vgo, mut fp)
137140
if should_sync {
138141
sync_cache()
@@ -152,7 +155,9 @@ fn main() {
152155
} else {
153156
context.commit_v = scripting.run('git rev-list -n1 HEAD')
154157
}
155-
scripting.cprintln('################# context.commit_v: ${context.commit_v} #####################')
158+
if !context.show_vccommit {
159+
scripting.cprintln('################# context.commit_v: ${context.commit_v} #####################')
160+
}
156161
context.path_v = vgit.normalized_workpath_for_commit(context.vgo.workdir, context.commit_v)
157162
context.path_vc = vgit.normalized_workpath_for_commit(context.vgo.workdir, 'vc')
158163
if !os.is_dir(context.vgo.workdir) {

0 commit comments

Comments
 (0)