From 66c12f607dbdc11a9e07025a9af1f4ceb7cf2973 Mon Sep 17 00:00:00 2001 From: despiegk Date: Sat, 13 Jan 2024 14:42:27 +0300 Subject: [PATCH] v --- tools/git.nu | 6 ++---- tools/herotools.nu | 18 +++++++++++++++--- tools/runonce.nu | 10 ++++++---- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tools/git.nu b/tools/git.nu index 142dc89..cffeb97 100644 --- a/tools/git.nu +++ b/tools/git.nu @@ -25,16 +25,14 @@ export def git_configure [] { export def git_clone [ name: string url: string , --reset=false , --pull=false ] string { - print $"git clone '($url)'" git_configure - let $dest = $"($env.BASE)/code/($name)" if $reset { print $"remove git dir: ($dest)" rm -f $dest } - if ($dest | path exists) and ( ( ls $dest | length ) > 0 ) { + if ($dest | path exists) and ( ( ls $dest | length ) > 0 ) { mkdir $dest cd $dest if $pull == true { @@ -42,7 +40,7 @@ export def git_clone [ name: string url: string , --reset=false , --pull=false ] git pull } } else { - print $"git clone execute" + print $"git clone '($url)'" cd $"($env.BASE)/code" git clone --depth 1 --no-single-branch $url } diff --git a/tools/herotools.nu b/tools/herotools.nu index 235931e..df5f06e 100644 --- a/tools/herotools.nu +++ b/tools/herotools.nu @@ -1,5 +1,6 @@ use git.nu use download.nu +use runonce.nu def sshagent_loaded [ ] bool { return ( (ssh-add -l | lines -s | length) > 0 ) @@ -15,9 +16,13 @@ def url_crystal [] { } } -export def clone_crystal [ --reset=false , --pull=false ] string { +export def install_crystal [ --reset=false , --pull=false ] string { + let $vpath = install_v + rm -f $"($env.BASE)/bin/v" + ln -s $"($vpath)/v" $"($env.BASE)/bin/v" let $url = url_crystal let $r = git git_clone crystallib $url + # ln -s $"($r)/" return $r } @@ -35,8 +40,15 @@ export def clone_nuscripts [ --reset=false , --pull=false ] string { } } - - +export def install_v [ --reset=false , --pull=false ] string { + let $r = git git_clone v "https://github.com/vlang/v" + runonce run 'install_v' { + cd $r + print "will compile V, can take a long while." + ^make + } --reset $reset + return $r +} def url_mycelium [] string { let $os = $nu.os-info.name diff --git a/tools/runonce.nu b/tools/runonce.nu index 6926538..1517750 100644 --- a/tools/runonce.nu +++ b/tools/runonce.nu @@ -7,8 +7,10 @@ export def "run" [ --reset: bool = false #means we redo the command ] { - mkdir $"($env.HOME)/hero/done/)" - let state_file = [ $env.HOME 'hero' done ('nu_done_' + $name) ] | path join + + let $state_dir = $"($env.BASE/done)" + mkdir $state_dir + let $state_file = $"($state_dir)/nu_done_($name)" if ($reset or (not ($state_file | path exists ) ) ) { let start = date now # let result = do $task @@ -28,7 +30,7 @@ export def "run" [ export def "reset" [ prefix: string ] { - ls $"($env.HOME)/hero/done/nu_done*" | each { |it| rm $it.name} + ls $"($env.BASE)/done/nu_done*" | each { |it| rm $it.name} } @@ -43,7 +45,7 @@ export def "reset" [ # --reset: bool = false # #means we redo the command # ] { -# let state_file = [ $env.HOME 'hero' ('nu_done_' + $name) ] | path join +# let state_file = [ $env.BASE 'hero' ('nu_done_' + $name) ] | path join # if ($reset or (not ($state_file | path exists ) ) ) { # let start = date now # # let result = do $task