1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

make and vself: cleanup make based on the new 'v self'

This commit is contained in:
Delyan Angelov 2020-02-28 17:04:22 +02:00 committed by GitHub
parent ccf4f61521
commit 10e15e5de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 39 deletions

23
.gitignore vendored
View File

@ -1,16 +1,29 @@
fns.txt fns.txt
*.dSYM *.dSYM
*_test *_test
/v /v
/v2 /v2
/v3
/vprod /vprod
/v-static
/v_old
/v_g
/v_cg
/v_prod
/v_prod_cg
/v_prod_g
/vjs
/v.c /v.c
/v.*.c /v.*.c
/v.c.out /v.c.out
/cmd/tools/check-md /cmd/tools/check-md
/cmd/tools/performance_compare /cmd/tools/performance_compare
/cmd/tools/oldv /cmd/tools/oldv
/cmd/tools/vrepl /cmd/tools/vrepl
/cmd/tools/vself
/cmd/tools/vtest /cmd/tools/vtest
/cmd/tools/vtest-compiler /cmd/tools/vtest-compiler
/cmd/tools/vtest-fmt /cmd/tools/vtest-fmt
@ -22,17 +35,12 @@ fns.txt
/cmd/tools/vbuild-examples /cmd/tools/vbuild-examples
/cmd/tools/vbuild-tools /cmd/tools/vbuild-tools
/cmd/tools/vbuild-vbinaries /cmd/tools/vbuild-vbinaries
/v_g
/v_cg
/v_prod
/v_prod_cg
/v_prod_g
*.exe *.exe
*.o *.o
*.so *.so
.*.c .*.c
*.tmp.c *.tmp.c
vjs
*.obj *.obj
*.exp *.exp
*.ilk *.ilk
@ -57,5 +65,8 @@ info.log
# vim/emacs editor backup files # vim/emacs editor backup files
*~ *~
thirdparty/freetype/ thirdparty/freetype/
cachegrind.out.* cachegrind.out.*
.gdb_history

View File

@ -46,20 +46,13 @@ endif
all: latest_vc latest_tcc all: latest_vc latest_tcc
ifdef WIN32 ifdef WIN32
$(CC) $(CFLAGS) -std=c99 -municode -w -o v2.exe $(TMPVC)/$(VCFILE) $(LDFLAGS) $(CC) $(CFLAGS) -std=c99 -municode -w -o v2.exe $(TMPVC)/$(VCFILE) $(LDFLAGS)
./v2.exe -o v3.exe cmd/v ./v.exe self
./v3.exe -o v.exe -prod cmd/v
rm -f v2.exe v3.exe
else else
$(CC) $(CFLAGS) -std=gnu11 -w -o v $(TMPVC)/$(VCFILE) $(LDFLAGS) -lm $(CC) $(CFLAGS) -std=gnu11 -w -o v $(TMPVC)/$(VCFILE) $(LDFLAGS) -lm
ifdef ANDROID ifdef ANDROID
chmod 755 v chmod 755 v
endif endif
@(VC_V=`./v version | cut -f 3 -d " "`; \ ./v self
V_V=`git rev-parse --short=7 HEAD`; \
if [ $$VC_V != $$V_V ]; then \
echo "Self rebuild ($$VC_V => $$V_V)"; \
$(MAKE) selfcompile; \
fi)
ifndef ANDROID ifndef ANDROID
$(MAKE) modules $(MAKE) modules
endif endif
@ -96,10 +89,10 @@ $(TMPVC)/.git/config:
$(MAKE) fresh_vc $(MAKE) fresh_vc
selfcompile: selfcompile:
./v -cg -o v cmd/v ./v -keep_c -cg -o v cmd/v
selfcompile-static: selfcompile-static:
./v -cg -cflags '--static' -o v-static cmd/v ./v -keep_c -cg -cflags '--static' -o v-static cmd/v
modules: module_builtin module_strings module_strconv modules: module_builtin module_strings module_strconv
module_builtin: module_builtin:

View File

@ -8,29 +8,24 @@ import (
fn main() { fn main() {
println('V Self Compiling...') println('V Self Compiling...')
vroot := filepath.dir(pref.vexe_path()) vexe := pref.vexe_path()
vroot := filepath.dir(vexe)
os.chdir(vroot) os.chdir(vroot)
s2 := os.exec('$vexe -o v2 cmd/v') or {
s2 := os.exec('v -o v2 cmd/v') or {
panic(err) panic(err)
} }
println(s2.output) if s2.output.len > 0 {
println(s2.output)
$if windows {
bak_file := 'v_old.exe'
if os.exists(bak_file) {
os.rm(bak_file)
}
os.mv('v.exe', bak_file)
os.mv('v2.exe', 'v.exe')
} $else {
bak_file := 'v_old'
if os.exists(bak_file) {
os.rm(bak_file)
}
os.mv('v', bak_file)
os.mv('v2', 'v')
} }
if s2.exit_code != 0 {
exit(1)
}
v_file := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
v2_file := if os.user_os() == 'windows' { 'v2.exe' } else { 'v2' }
bak_file := if os.user_os() == 'windows' { 'v_old.exe' } else { 'v_old' }
if os.exists(bak_file) {
os.rm(bak_file)
}
os.mv(v_file, bak_file)
os.mv(v2_file, v_file)
} }

View File

@ -39,9 +39,18 @@ fn launch_tool(is_verbose bool, tname string, cmdname string) {
// v was recompiled, maybe after v up ... // v was recompiled, maybe after v up ...
// rebuild the tool too just in case // rebuild the tool too just in case
should_compile = true should_compile = true
if tname == 'vself' || tname == 'vup' {
// The purpose of vself/up is to update and recompile v itself.
// After the first 'v self' execution, v will be modified, so
// then a second 'v self' will detect, that v is newer than the
// vself executable, and try to recompile vself/up again, which
// will slow down the next v recompilation needlessly.
should_compile = false
}
} }
if os.file_last_mod_unix(tool_exe) <= os.file_last_mod_unix(tool_source) { if os.file_last_mod_unix(tool_exe) <= os.file_last_mod_unix(tool_source) {
// the user changed the source code of the tool // the user changed the source code of the tool, or git updated it:
should_compile = true should_compile = true
} }
} }