-
Notifications
You must be signed in to change notification settings - Fork 0
/
cn.fish
123 lines (102 loc) · 2.92 KB
/
cn.fish
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
function _is_in_git_repository
if test (git rev-parse --is-inside-work-tree 2> /dev/null; or echo "false") = "true"
return 0
else
return 1
end
end
function cn
set -l arguments
set arguments $arguments (fish_opt -s p -l profile -r)
set arguments $arguments (fish_opt -s o -l options -r --multiple-vals)
set arguments $arguments (fish_opt -s r -l recipe_path -r --multiple-vals)
set arguments $arguments (fish_opt -s d -l deps -r --multiple-vals)
set arguments $arguments (fish_opt -s u -l update)
set arguments $arguments (fish_opt -s s -l settings -r --multiple-vals)
set arguments $arguments (fish_opt -s i -l install)
set arguments $arguments (fish_opt -s b -l build)
set arguments $arguments (fish_opt -s c -l configure)
set arguments $arguments (fish_opt -s t -l test)
set arguments $arguments (fish_opt -s n -l dry-run)
argparse $arguments -- $argv; or return 1
set -l dontconfigure
set -l profile
if set -q -l _flag_profile
set profile '--profile='{$_flag_profile}
end
set -l options
if set -q -l _flag_options
set options '--options='{$_flag_options}
set -e dontconfigure
end
set -l deps
if set -q -l _flag_deps
set deps '--build='{$_flag_deps}
set -e dontconfigure
end
set -l doupdate
if set -q -l _flag_update
set doupdate '--update'
set -e dontconfigure
end
set -l settings
if set -q -l _flag_settings
set settings '--settings='{$_flag_settings}
set -e dontconfigure
end
set -l install
if set -q -l _flag_install
set -e dontconfigure
set install '--install'
end
set -l configure
if set -q -l _flag_configure
set -e dontconfigure
set configure '--configure'
end
set -l dotest
if set -q -l _flag_test
set dotest '--test'
end
set -l build
if set -q -l _flag_build
set build '--build'
end
set -l recipe_path
if set -q -l _flag_recipe_path
set recipe_path $_flag_recipe_path
end
set -l worktree
if test -z $recipe_path
if not _is_in_git_repository
echo "not in a repository"
return 1
end
set -l git_root (command git rev-parse --show-cdup)
if test -z $git_root
set git_root .
end
set worktree (realpath $git_root)
else
set worktree (realpath $recipe_path)
if test -f $worktree
set worktree (command dirname $worktree)
end
end
set -l buildsuffix default
if set -q -l _flag_profile
set buildsuffix $_flag_profile
end
set -l builddir (string join - build {$buildsuffix})
set -l relbuilddir (string join / {$worktree} {$builddir})
if not test -d $relbuilddir
set -e dontconfigure
command mkdir -p $relbuilddir; or return 1
echo directory made
end
if not set -q -l dontconfigure
command conan install $worktree $profile $settings $doupdate $deps $options -if $relbuilddir; or return 1
end
command conan build $worktree -bf $relbuilddir $build $configure $dotest $install; or return 1
return 0
end