Enable more hw intrinsics for AOT (#17160)
[mono-project.git] / eng / common / pipeline-logging-functions.sh
blob1c560a506132557eb07e8c37f79c8a644335ea36
1 #!/usr/bin/env bash
3 function Write-PipelineTelemetryError {
4 local telemetry_category=''
5 local function_args=()
6 local message=''
7 while [[ $# -gt 0 ]]; do
8 opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
9 case "$opt" in
10 -category|-c)
11 telemetry_category=$2
12 shift
14 -*)
15 function_args+=("$1 $2")
16 shift
19 message=$*
21 esac
22 shift
23 done
25 if [[ "$ci" != true ]]; then
26 echo "$message" >&2
27 return
30 message="(NETCORE_ENGINEERING_TELEMETRY=$telemetry_category) $message"
31 function_args+=("$message")
33 Write-PipelineTaskError $function_args
36 function Write-PipelineTaskError {
37 if [[ "$ci" != true ]]; then
38 echo "$@" >&2
39 return
42 local message_type="error"
43 local sourcepath=''
44 local linenumber=''
45 local columnnumber=''
46 local error_code=''
48 while [[ $# -gt 0 ]]; do
49 opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
50 case "$opt" in
51 -type|-t)
52 message_type=$2
53 shift
55 -sourcepath|-s)
56 sourcepath=$2
57 shift
59 -linenumber|-ln)
60 linenumber=$2
61 shift
63 -columnnumber|-cn)
64 columnnumber=$2
65 shift
67 -errcode|-e)
68 error_code=$2
69 shift
72 break
74 esac
76 shift
77 done
79 local message="##vso[task.logissue"
81 message="$message type=$message_type"
83 if [ -n "$sourcepath" ]; then
84 message="$message;sourcepath=$sourcepath"
87 if [ -n "$linenumber" ]; then
88 message="$message;linenumber=$linenumber"
91 if [ -n "$columnnumber" ]; then
92 message="$message;columnnumber=$columnnumber"
95 if [ -n "$error_code" ]; then
96 message="$message;code=$error_code"
99 message="$message]$*"
100 echo "$message"
103 function Write-PipelineSetVariable {
104 if [[ "$ci" != true ]]; then
105 return
108 local name=''
109 local value=''
110 local secret=false
111 local as_output=false
112 local is_multi_job_variable=true
114 while [[ $# -gt 0 ]]; do
115 opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
116 case "$opt" in
117 -name|-n)
118 name=$2
119 shift
121 -value|-v)
122 value=$2
123 shift
125 -secret|-s)
126 secret=true
128 -as_output|-a)
129 as_output=true
131 -is_multi_job_variable|-i)
132 is_multi_job_variable=$2
133 shift
135 esac
136 shift
137 done
139 value=${value/;/%3B}
140 value=${value/\\r/%0D}
141 value=${value/\\n/%0A}
142 value=${value/]/%5D}
144 local message="##vso[task.setvariable variable=$name;isSecret=$secret;isOutput=$is_multi_job_variable]$value"
146 if [[ "$as_output" == true ]]; then
147 $message
148 else
149 echo "$message"
153 function Write-PipelinePrependPath {
154 local prepend_path=''
156 while [[ $# -gt 0 ]]; do
157 opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
158 case "$opt" in
159 -path|-p)
160 prepend_path=$2
161 shift
163 esac
164 shift
165 done
167 export PATH="$prepend_path:$PATH"
169 if [[ "$ci" == true ]]; then
170 echo "##vso[task.prependpath]$prepend_path"