tools: support `./v symlink -githubci` (#13403)
parent
1dbde05267
commit
5d2995c4d5
|
@ -8,13 +8,26 @@ $if windows {
|
||||||
#flag -luser32
|
#flag -luser32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
C.atexit(cleanup_vtmp_folder)
|
C.atexit(cleanup_vtmp_folder)
|
||||||
|
|
||||||
|
if os.args.len > 3 {
|
||||||
|
print('usage: v symlink [OPTIONS]')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
ci_mode := '-githubci' in os.args
|
||||||
|
|
||||||
vexe := os.real_path(pref.vexe_path())
|
vexe := os.real_path(pref.vexe_path())
|
||||||
$if windows {
|
if ci_mode {
|
||||||
setup_symlink_windows(vexe)
|
setup_symlink_github()
|
||||||
} $else {
|
} else {
|
||||||
setup_symlink_unix(vexe)
|
$if windows {
|
||||||
|
setup_symlink_windows(vexe)
|
||||||
|
} $else {
|
||||||
|
setup_symlink_unix(vexe)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +35,20 @@ fn cleanup_vtmp_folder() {
|
||||||
os.rmdir_all(util.get_vtmp_folder()) or {}
|
os.rmdir_all(util.get_vtmp_folder()) or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn setup_symlink_github() {
|
||||||
|
// We append V's install location (which should
|
||||||
|
// be the current directory) to the PATH environment variable.
|
||||||
|
|
||||||
|
// Resources:
|
||||||
|
// 1. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
|
||||||
|
// 2. https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
|
||||||
|
mut content := os.read_file(os.getenv('GITHUB_PATH')) or {
|
||||||
|
panic('Failed to read GITHUB_PATH.')
|
||||||
|
}
|
||||||
|
content += '\n$os.getwd()\n'
|
||||||
|
os.write_file(os.getenv('GITHUB_PATH'), content) or { panic('Failed to write to GITHUB_PATH.') }
|
||||||
|
}
|
||||||
|
|
||||||
fn setup_symlink_unix(vexe string) {
|
fn setup_symlink_unix(vexe string) {
|
||||||
mut link_path := '/data/data/com.termux/files/usr/bin/v'
|
mut link_path := '/data/data/com.termux/files/usr/bin/v'
|
||||||
if !os.is_dir('/data/data/com.termux/files') {
|
if !os.is_dir('/data/data/com.termux/files') {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
Usage: v symlink
|
Usage: v symlink [OPTIONS]
|
||||||
|
|
||||||
This command adds a symlink for the V compiler executable.
|
This command adds a symlink for the V compiler executable.
|
||||||
|
|
||||||
Note that on Unix systems this command requires write permissions to /usr/local/bin to work.
|
Note that on Unix systems this command requires write permissions to /usr/local/bin to work.
|
||||||
|
|
||||||
|
For GitHub Actions, the option -githubci needs to be specified.
|
Loading…
Reference in New Issue