forked from vlang/coreutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.vsh
executable file
·66 lines (54 loc) · 1.44 KB
/
build.vsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/env v
import os // v has a bug that you can't use args
const ignore_dirs = {
'windows': [
// avoid *nix-dependent utils
'nohup',
'stat',
'tty',
// avoid utmp-dependent utils (WinOS has no utmp support)
'uptime',
'users',
'who',
]
'macos': ['stat', 'sync', 'uptime']
}[os.user_os()] or { [] }
dump(os.user_os())
dump(ignore_dirs)
vargs := if os.args.len > 1 { os.args[1..] } else { []string{} }
curdir := getwd()
chdir('src')!
dirs := ls('.')!.filter(is_dir(it)).sorted()
if !exists('${curdir}/bin') {
mkdir('${curdir}/bin')!
}
for dir in dirs {
if dir in ignore_dirs {
continue
}
if !ls(dir)!.any(it.ends_with('.v')) {
continue
}
// Get all of the of v files in the directory and get unix modifed time
mut modification_time := []i64{}
for src_file in ls(dir)!.filter(it.ends_with('.v')) {
modification_time << os.file_last_mod_unix('${dir}/${src_file}')
}
// Check if the binary exists and is newer than the source files
// If it is, skip it
if exists('${curdir}/bin/${dir}') {
bin_mod_time := os.file_last_mod_unix('${curdir}/bin/${dir}')
// If the binary is newer than the source files, skip it
if modification_time.filter(it < bin_mod_time).len == modification_time.len {
continue
}
}
mut final_args := '-Wimpure-v'
for arg in vargs {
final_args += ' ' + arg
}
println('compiling ${dir}...')
cmd := @VEXE + ' ${final_args} -o ${curdir}/bin/${dir} ./${dir}'
execute_or_panic(cmd)
}
chdir(curdir)!