setup-cpp/dist/legacy/setup-cpp.js

42 lines
250 KiB
JavaScript
Raw Normal View History

2023-07-16 06:41:58 +08:00
#!/usr/bin/env node
let e,t,r,n,i,o,s,a;var l,c,u,p,d,f=require("os"),h=require("path"),m=require("fs"),v=require("crypto"),g=require("http"),E=require("https");require("net");var y=require("tls"),w=require("events"),x=require("assert"),b=require("util"),S=require("fs"),O=require("child_process"),I=require("string_decoder"),R=require("timers"),$=require("buffer"),T=require("stream"),C=require("process"),A=require("buffer"),_=require("path"),P=require("child_process"),N=require("process"),L=require("url"),D=require("os"),k=require("util"),U=require("url"),j=require("console");function F(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0});}function M(e){return e&&e.__esModule?e.default:e;}var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},B={},H={},q=G.parcelRequire810d;null==q&&((q=function(e){if(e in B)return B[e].exports;if(e in H){var t=H[e];delete H[e];var r={id:e,exports:{}};return B[e]=r,t.call(r.exports,r,r.exports),r.exports;}var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n;}).register=function(e,t){H[e]=t;},G.parcelRequire810d=q),q.register("cLprm",function(e,t){var r=q("iQYeD");let n=process.env;function i(e){return"string"==typeof e?!!n[e]:"env"in e?n[e.env]&&n[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!n[e];}):Object.keys(e).every(function(t){return n[t]===e[t];});}Object.defineProperty(e.exports,"_vendors",{value:r.map(function(e){return e.constant;})}),e.exports.name=null,e.exports.isPR=null,r.forEach(function(t){let r=Array.isArray(t.env)?t.env:[t.env],o=r.every(function(e){return i(e);});if(e.exports[t.constant]=o,o)switch(e.exports.name=t.name,typeof t.pr){case"string":e.exports.isPR=!!n[t.pr];break;case"object":"env"in t.pr?e.exports.isPR=t.pr.env in n&&n[t.pr.env]!==t.pr.ne:"any"in t.pr?e.exports.isPR=t.pr.any.some(function(e){return!!n[e];}):e.exports.isPR=i(t.pr);break;default:e.exports.isPR=null;}}),e.exports.isCI=!!("false"!==n.CI&&(n.BUILD_ID||n.BUILD_NUMBER||n.CI||n.CI_APP_ID||n.CI_BUILD_ID||n.CI_BUILD_NUMBER||n.CI_NAME||n.CONTINUOUS_INTEGRATION||n.RUN_ID||e.exports.name));}),q.register("iQYeD",function(e,t){e.exports=JSON.parse('[{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE"},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN"},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"SYSTEM_TEAMFOUNDATIONCOLLECTIONURI","pr":"SYSTEM_PULLREQUEST_PULLREQUESTID"},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);},e.exports.setOutput=function(e,t){let r=process.env.GITHUB_OUTPUT||"";if(r)return c.issueFileCommand("OUTPUT",c.prepareKeyValueMessage(e,t));process.stdout.write(p.EOL),l.issueCommand("set-output",{name:e},u.toCommandValue(t));},e.exports.setCommandEcho=function(e){l.issue("echo",e?"on":"off");},e.exports.setFailed=function(e){process.exitCode=n.Failure,g(e);},e.exports.isDebug=function(){return"1"===process.env.RUNNER_DEBUG;},e.exports.debug=function(e){l.issueCommand("debug",{},e);},e.exports.error=g,e.exports.warning=function(e,t={}){l.issueCommand("warning",u.toCommandProperties(t),e instanceof Error?e.toString():e);},e.exports.notice=function(e,t={}){l.issueCommand("notice",u.toCommandProperties(t),e instanceof Error?e.toString():e);},e.exports.info=function(e){process.stdout.write(e+p.EOL);},e.exports.startGroup=E,e.exports.endGroup=y,e.exports.group=function(e,t){return a(this,void 0,void 0,function*(){let r;E(e);try{r=yield t();}finally{y();}return r;});},e.exports.saveState=function(e,t){let r=process.env.GITHUB_STATE||"";if(r)return c.issueFileCommand("STATE",c.prepareKeyValueMessage(e,t));l.issueCommand("save-state",{name:e},u.toCommandValue(t));},e.exports.getState=function(e){return process.env[`STATE_${e}`]||"";},e.exports.getIDToken=function(e){return a(this,void 0,void 0,function*(){return yield m.OidcClient.getIDToken(e);});};var w=q("a9gnA");Object.defineProperty(e.exports,"summary",{enumerable:!0,get:function(){return w.summary;}});var w=q("a9gnA");Object.defineProperty(e.exports,"markdownSummary",{enumerable:!0,get:function(){return w.markdownSummary;}});var x=q("3zXsD");Object.defineProperty(e.exports,"toPosixPath",{enumerable:!0,get:function(){return x.toPosixPath;}}),Object.defineProperty(e.exports,"toWin32Path",{enumerable:!0,get:function(){return x.toWin32Path;}}),Object.defineProperty(e.exports,"toPlatformPath",{enumerable:!0,get:function(){return x.toPlatformPath;}});}),q.register("lxvYw",function(e,t){var r=e.exports&&e.exports.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r];}});}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r];}),n=e.exports&&e.exports.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t});}:function(e,t){e.default=t;}),i=e.exports&&e.exports.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t;};Object.defineProperty(e.exports,"__esModule",{value:!0}),e.exports.issue=e.exports.issueCommand=void 0;let o=i(f);var s=q("3GPt4");function a(e,t,r){let n=new l(e,t,r);process.stdout.write(n.toString()+o.EOL);}e.exports.issueCommand=a,e.exports.issue=function(e,t=""){a(e,{},t);};class l{constructor(e,t,r){e||(e="missing.command"),this.command=e,this.properties=t,this.message=r;}toString(){var e;let t="::"+this.command;if(this.properties&&Object.keys(this.properties).length>0){t+=" ";let e=!0;for(let r in this.properties)if(this.properties.hasOwnProperty(r)){let n=this.properties[r];n&&(e?e=!1:t+=",",t+=`${r}=${s.toCommandValue(n).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}`);}}return t+`::${(e=this.message,s.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A"))}`;}}}),q.register("3GPt4",function(e,t){Object.defineProperty(e.exports,"__esModule",{value:!0}),e.exports.toCommandProperties=e.exports.toCommandValue=void 0,e.exports.toCommandValue=function(e){return null==e?"":"string"==typeof e||e instanceof String?e:JSON.stringify(e);},e.exports.toCommandProperties=function(e){return Object.keys(e).length?{title:e.title,file:e.file,line:e.startLine,endLine:e.endLine,col:e.startColumn,endColumn:e.endColumn}:{};};}),q.register("izMKk",function(e,t){var r=e.exports&&e.exports.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,g
2023-07-16 06:41:58 +08:00
Error Code : ${e.statusCode}
Error Message: ${e.result.message}`);}),i=null===(t=n.result)||void 0===t?void 0:t.value;if(!i)throw Error("Response json body do not have ID Token field");return i;});}static getIDToken(e){return r(this,void 0,void 0,function*(){try{let t=s.getIDTokenUrl();if(e){let r=encodeURIComponent(e);t=`${t}&audience=${r}`;}o.debug(`ID token url is ${t}`);let r=yield s.getCall(t);return o.setSecret(r),r;}catch(e){throw Error(`Error message: ${e.message}`);}});}}e.exports.OidcClient=s;}),q.register("aPbbM",function(e,t){var r,n,i,o,s,a=e.exports&&e.exports.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r];}});}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r];}),l=e.exports&&e.exports.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t});}:function(e,t){e.default=t;}),c=e.exports&&e.exports.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&a(t,e,r);return l(t,e),t;},u=e.exports&&e.exports.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function s(e){try{l(n.next(e));}catch(e){o(e);}}function a(e){try{l(n.throw(e));}catch(e){o(e);}}function l(e){var t;e.done?i(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t);})).then(s,a);}l((n=n.apply(e,t||[])).next());});};Object.defineProperty(e.exports,"__esModule",{value:!0}),e.exports.HttpClient=e.exports.isHttps=e.exports.HttpClientResponse=e.exports.HttpClientError=e.exports.getProxyUrl=e.exports.MediaTypes=e.exports.Headers=e.exports.HttpCodes=void 0;let p=c(g),d=c(E),f=c(q("dG8Uc")),h=c(q("j6C2A"));(r=i=e.exports.HttpCodes||(e.exports.HttpCodes={}))[r.OK=200]="OK",r[r.MultipleChoices=300]="MultipleChoices",r[r.MovedPermanently=301]="MovedPermanently",r[r.ResourceMoved=302]="ResourceMoved",r[r.SeeOther=303]="SeeOther",r[r.NotModified=304]="NotModified",r[r.UseProxy=305]="UseProxy",r[r.SwitchProxy=306]="SwitchProxy",r[r.TemporaryRedirect=307]="TemporaryRedirect",r[r.PermanentRedirect=308]="PermanentRedirect",r[r.BadRequest=400]="BadRequest",r[r.Unauthorized=401]="Unauthorized",r[r.PaymentRequired=402]="PaymentRequired",r[r.Forbidden=403]="Forbidden",r[r.NotFound=404]="NotFound",r[r.MethodNotAllowed=405]="MethodNotAllowed",r[r.NotAcceptable=406]="NotAcceptable",r[r.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",r[r.RequestTimeout=408]="RequestTimeout",r[r.Conflict=409]="Conflict",r[r.Gone=410]="Gone",r[r.TooManyRequests=429]="TooManyRequests",r[r.InternalServerError=500]="InternalServerError",r[r.NotImplemented=501]="NotImplemented",r[r.BadGateway=502]="BadGateway",r[r.ServiceUnavailable=503]="ServiceUnavailable",r[r.GatewayTimeout=504]="GatewayTimeout",(n=o=e.exports.Headers||(e.exports.Headers={})).Accept="accept",n.ContentType="content-type",(s=e.exports.MediaTypes||(e.exports.MediaTypes={})).ApplicationJson="application/json",e.exports.getProxyUrl=function(e){let t=f.getProxyUrl(new URL(e));return t?t.href:"";};let m=[i.MovedPermanently,i.ResourceMoved,i.SeeOther,i.TemporaryRedirect,i.PermanentRedirect],v=[i.BadGateway,i.ServiceUnavailable,i.GatewayTimeout],y=["OPTIONS","GET","DELETE","HEAD"];class w extends Error{constructor(e,t){super(e),this.name="HttpClientError",this.statusCode=t,Object.setPrototypeOf(this,w.prototype);}}e.exports.HttpClientError=w;class x{constructor(e){this.message=e;}readBody(){return u(this,void 0,void 0,function*(){return new Promise(e=>u(this,void 0,void 0,function*(){let t=Buffer.alloc(0);this.message.on("data",e=>{t=Buffer.concat([t,e]);}),this.message.on("end",()=>{e(t.toString());});}));});}}e.exports.HttpClientResponse=x,e.exports.isHttps=function(e){let t=new URL(e);return"https:"===t.protocol;},e.exports.HttpClient=class{constructor(e,t,r){this._ignoreSslError=!1,this._allowRedirects=!0,this._allowRedirectDowngrade=!1,this._maxRedirects=50,this._allowRetries=!1,this._maxRetries=1,this._keepAlive=!1,this._disposed=!1,this.userAgent=e,this.handlers=t||[],this.requestOptions=r,r&&(
${n.message}`:m,E=[g,t,e].filter(Boolean).join("\n");return v?(n.originalMessage=n.message,n.message=E):n=Error(E),n.shortMessage=g,n.command=s,n.escapedCommand=a,n.exitCode=o,n.signal=i,n.signalDescription=d,n.stdout=e,n.stderr=t,void 0!==r&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!l,n.isCanceled=c,n.killed=u&&!l,n;};var eY={};const eQ=["stdin","stdout","stderr"],eJ=e=>eQ.some(t=>void 0!==e[t]),eZ=e=>{if(!e)return;let{stdio:t}=e;if(void 0===t)return eQ.map(t=>e[t]);if(eJ(e))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${eQ.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof t)return t;if(!Array.isArray(t))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let r=Math.max(t.length,eQ.length);return Array.from({length:r},(e,r)=>t[r]);};(eY=eZ).node=e=>{let t=eZ(e);return"ipc"===t?"ipc":void 0===t||"string"==typeof t?[t,t,t,"ipc"]:t.includes("ipc")?t:[...t,"ipc"];};var e0={},e1={},e2=G.process;const e3=function(e){return e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on;};if(e3(e2)){var e4,e6,e8=q("2dWxz"),e5=/^win/i.test(e2.platform),e9=w;"function"!=typeof e9&&(e9=e9.EventEmitter),e2.__signal_exit_emitter__?e6=e2.__signal_exit_emitter__:((e6=e2.__signal_exit_emitter__=new e9()).count=0,e6.emitted={}),e6.infinite||(e6.setMaxListeners(1/0),e6.infinite=!0);var e7=function(){tr&&e3(G.process)&&(tr=!1,e8.forEach(function(e){try{e2.removeListener(e,tt[e]);}catch(e){}}),e2.emit=ts,e2.reallyExit=ti,e6.count-=1);};(e1=function(e,t){if(!e3(G.process))return function(){};x.equal(typeof e,"function","a callback must be provided for exit handler"),!1===tr&&tn();var r="exit";return t&&t.alwaysLast&&(r="afterexit"),e6.on(r,e),function(){e6.removeListener(r,e),0===e6.listeners("exit").length&&0===e6.listeners("afterexit").length&&e7();};}).unload=e7;var te=function(e,t,r){e6.emitted[e]||(e6.emitted[e]=!0,e6.emit(e,t,r));},tt={};e8.forEach(function(e){tt[e]=function(){e3(G.process)&&e2.listeners(e).length===e6.count&&(e7(),te("exit",null,e),te("afterexit",null,e),e5&&"SIGHUP"===e&&(e="SIGINT"),e2.kill(e2.pid,e));};}),e1.signals=function(){return e8;};var tr=!1,tn=function(){!tr&&e3(G.process)&&(tr=!0,e6.count+=1,e8=e8.filter(function(e){try{return e2.on(e,tt[e]),!0;}catch(e){return!1;}}),e2.emit=ta,e2.reallyExit=to);};e1.load=tn;var ti=e2.reallyExit,to=function(e){e3(G.process)&&(e2.exitCode=e||0,te("exit",e2.exitCode,null),te("afterexit",e2.exitCode,null),ti.call(e2,e2.exitCode));},ts=e2.emit,ta=function(e,t){if(!("exit"===e&&e3(G.process)))return ts.apply(this,arguments);void 0!==t&&(e2.exitCode=t);var r=ts.apply(this,arguments);return te("exit",e2.exitCode,null),te("afterexit",e2.exitCode,null),r;};}else e1=function(){return function(){};};const tl=(e,t,r,n)=>{if(!tc(t,r,n))return;let i=tp(r),o=setTimeout(()=>{e("SIGKILL");},i);o.unref&&o.unref();},tc=(e,{forceKillAfterTimeout:t},r)=>tu(e)&&!1!==t&&r,tu=e=>e===f.constants.signals.SIGTERM||"string"==typeof e&&"SIGTERM"===e.toUpperCase(),tp=({forceKillAfterTimeout:e=!0})=>{if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e;},td=(e,t,r)=>{e.kill(t),r(Object.assign(Error("Timed out"),{timedOut:!0,signal:t}));},tf=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;let i=e1(()=>{e.kill();});return n.finally(()=>{i();});};var th=(e0={spawnedKill:(e,t="SIGTERM",r={})=>{let n=e(t);return tl(e,t,r,n),n;},spawnedCancel:(e,t)=>{let r=e.kill();r&&(t.isCanceled=!0);},setupTimeout:(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{let i;if(0===t||void 0===t)return n;let o=new Promise((n,o)=>{i=setTimeout(()=>{td(e,r,o);},t);}),s=n.finally(()=>{clearTimeout(i);});return Promise.race([o,s]);},validateTimeout:({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw TypeError(`Expected
${t}`,rR=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),r$=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),rT=(e,t,r)=>{let n=""===r?"":`with ${r.trim()}() `,i=rI.bind(null,n,t.toString());Object.defineProperty(i,"name",r$),Object.defineProperty(e,"toString",{...rR,value:i});},rC=new WeakMap(),rA=(e,t={})=>{let r;if("function"!=typeof e)throw TypeError("Expected a function");let n=0,i=e.displayName||e.name||"<anonymous>",o=function(...s){if(rC.set(o,++n),1===n)r=e.apply(this,s),e=null;else if(!0===t.throw)throw Error(`Function \`${i}\` can only be called once`);return r;};return!function(e,t,{ignoreNonConfigurable:r=!1}={}){let{name:n}=e;for(let n of Reflect.ownKeys(t))rb(e,t,n,r);rO(e,t),rT(e,t,n);}(o,e),rC.set(o,n),o;};rA.callCount=e=>{if(!rC.has(e))throw Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return rC.get(e);};const r_=()=>Array.from({length:rL-rN+1},rP),rP=(e,t)=>({name:`SIGRT${t+1}`,number:rN+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),rN=34,rL=64,rD=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"termina
${n.message}`:m,E=[g,t,e].filter(Boolean).join("\n");return v?(n.originalMessage=n.message,n.message=E):n=Error(E),n.shortMessage=g,n.command=s,n.escapedCommand=a,n.exitCode=o,n.signal=i,n.signalDescription=d,n.stdout=e,n.stderr=t,void 0!==r&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!l,n.isCanceled=c,n.killed=u&&!l,n;},rq=["stdin","stdout","stderr"],rV=e=>rq.some(t=>void 0!==e[t]),rX=e=>{if(!e)return;let{stdio:t}=e;if(void 0===t)return rq.map(t=>e[t]);if(rV(e))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${rq.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof t)return t;if(!Array.isArray(t))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let r=Math.max(t.length,rq.length);return Array.from({length:r},(e,r)=>t[r]);},rz=(e,t="SIGTERM",r={})=>{let n=e(t);return rW(e,t,r,n),n;},rW=(e,t,r,n)=>{if(!rK(t,r,n))return;let i=rQ(r),o=setTimeout(()=>{e("SIGKILL");},i);o.unref&&o.unref();},rK=(e,{forceKillAfterTimeout:t},r)=>rY(e)&&!1!==t&&r,rY=e=>e===M(D).constants.signals.SIGTERM||"string"==typeof e&&"SIGTERM"===e.toUpperCase(),rQ=({forceKillAfterTimeout:e=!0})=>{if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e;},rJ=(e,t)=>{let r=e.kill();r&&(t.isCanceled=!0);},rZ=(e,t,r)=>{e.kill(t),r(Object.assign(Error("Timed out"),{timedOut:!0,signal:t}));},r0=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{let i;if(0===t||void 0===t)return n;let o=new Promise((n,o)=>{i=setTimeout(()=>{rZ(e,r,o);},t);}),s=n.finally(()=>{clearTimeout(i);});return Promise.race([o,s]);},r1=({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);},r2=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;let i=M(e1)(()=>{e.kill();});return n.finally(()=>{i();});};function r3(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe;}function r4(e){return r3(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState;}const r6=e=>e instanceof P.ChildProcess&&"function"==typeof e.then,r8=(e,t,r)=>{if("string"==typeof r)return e[t].pipe((0,S.createWriteStream)(r)),e;if(r4(r))return e[t].pipe(r),e;if(!r6(r))throw TypeError("The second argument must be a string, a stream or an Execa child process.");if(!r4(r.stdin))throw TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r;},r5=e=>{null!==e.stdout&&(e.pipeStdout=r8.bind(void 0,e,"stdout")),null!==e.stderr&&(e.pipeStderr=r8.bind(void 0,e,"stderr")),void 0!==e.all&&(e.pipeAll=r8.bind(void 0,e,"all"));},r9=e=>{if(void 0!==e)throw TypeError("The `input` and `inputFile` options cannot be both set.");},r7=({input:e,inputFile:t})=>"string"!=typeof t?e:(r9(e),(0,S.readFileSync)(t)),ne=e=>{let t=r7(e);if(r3(t))throw TypeError("The `input` option cannot be a stream in sync mode");return t;},nt=({input:e,inputFile:t})=>"string"!=typeof t?e:(r9(e),(0,S.createReadStream)(t)),nr=(e,t)=>{let r=nt(t);void 0!==r&&(r3(r)?r.pipe(e.stdin):e.stdin.end(r));},nn=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;let r=M(tA)();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r;},ni=async(e,t)=>{if(e&&void 0!==t){e.destroy();try{return await t;}catch(e){return e.bufferedData;}}},no=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(e&&r)return t?M(tb)(e,{encoding:t,maxBuffer:n}):M(tb).buffer(e,{maxBuffer:n});},ns=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:i,maxBuffer:o},s)=>{let a=no(e,{encoding:n,buffer:i,maxBuffer:o}),l=no(t,{encoding:n,buffer:i,maxBuffer:o}),c=no(r,{encoding:n,buffer:i,maxBuffer:2*o});try{return await Promise.all([s,a,l,c]);}catch(n){return Promise.all([{error:n,signal:n.signal,timedOut:n.timedOut},ni(e,a),ni(t,l),ni(r,c)]);}},na=(async()=>{})().constructor.prototype,nl=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(na,e)]),nc=(e,t)=>{for(let[r,n]of nl){let i="function"==typ
`);},nR=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:i})=>{let o=t?{...M(N).env,...e}:e;return r?rx({env:o,cwd:n,execPath:i}):o;},n$=(e,t,r={})=>{let n=M(el)._parse(e,t,r);return e=n.command,t=n.args,(r={maxBuffer:1e8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:(r=n.options).cwd||M(N).cwd(),execPath:M(N).execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:nb,...r}).env=nR(r),r.stdio=rX(r),"win32"===M(N).platform&&"cmd"===M(_).basename(e,".exe")&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n};},nT=(e,t,r)=>"string"==typeof t||(0,A.Buffer).isBuffer(t)?e.stripFinalNewline?ry(t):t:void 0===r?void 0:"";function nC(e,t,r){let n;let i=n$(e,t,r),o=nm(e,t),s=nv(e,t);nI(s,i.options),r1(i.options);try{n=M(P).spawn(i.file,i.args,i.options);}catch(r){let e=new(M(P).ChildProcess)(),t=Promise.reject(rH({error:r,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:i,timedOut:!1,isCanceled:!1,killed:!1}));return nc(e,t),e;}let a=nu(n),l=r0(n,i.options,a),c=r2(n,i.options,l),u={isCanceled:!1};n.kill=rz.bind(null,n.kill.bind(n)),n.cancel=rJ.bind(null,n,u);let p=async()=>{let[{error:e,exitCode:t,signal:r,timedOut:a},l,p,d]=await ns(n,i.options,c),f=nT(i.options,l),h=nT(i.options,p),m=nT(i.options,d);if(e||0!==t||null!==r){let l=rH({error:e,exitCode:t,signal:r,stdout:f,stderr:h,all:m,command:o,escapedCommand:s,parsed:i,timedOut:a,isCanceled:u.isCanceled||!!i.options.signal&&i.options.signal.aborted,killed:n.killed});if(!i.options.reject)return l;throw l;}return{command:o,escapedCommand:s,exitCode:0,stdout:f,stderr:h,all:m,failed:!1,timedOut:!1,isCanceled:!1,killed:!1};},d=rA(p);return nr(n,i.options),n.all=nn(n,i.options),r5(n),nc(n,d),n;}const nA=({input:e,inputFile:t,stdio:r})=>void 0===e&&void 0===t&&void 0===r?{stdin:"inherit"}:{},n_=(e={})=>({preferLocal:!0,...nA(e),...e});function nP(t,r=["-NoProfile","-NoLogo","-NonInteractive"],n={stdio:"inherit"}){return nC(function(){if(void 0===e){let t=M(Z).sync("pwsh",{nothrow:!0});null!==t&&(e=t);let r=M(Z).sync("powershell",{nothrow:!0});null!==r&&(e=r);}if(void 0===e)throw Error("Could not find powershell");return e;}(),[...r,"-c",t],n);}!function e(t){function r(n,...i){if(!Array.isArray(n))return e({...t,...n});let[o,...s]=nx(n,i);return nC(o,s,n_(t));}return r.sync=(e,...r)=>{if(!Array.isArray(e))throw TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[n,...i]=nx(e,r);return function(e,t,r){let n;let i=n$(e,t,r),o=nm(e,t),s=nv(e,t);nI(s,i.options);let a=ne(i.options);try{n=M(P).spawnSync(i.file,i.args,{...i.options,input:a});}catch(e){throw rH({error:e,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:i,timedOut:!1,isCanceled:!1,killed:!1});}let l=nT(i.options,n.stdout,n.error),c=nT(i.options,n.stderr,n.error);if(n.error||0!==n.status||null!==n.signal){let e=rH({stdout:l,stderr:c,error:n.error,signal:n.signal,exitCode:n.status,command:o,escapedCommand:s,parsed:i,timedOut:n.error&&"ETIMEDOUT"===n.error.code,isCanceled:!1,killed:null!==n.signal});if(!i.options.reject)return e;throw e;}return{command:o,escapedCommand:s,exitCode:0,stdout:l,stderr:c,failed:!1,timedOut:!1,isCanceled:!1,killed:!1};}(n,i,n_(t));},r;}();var nN={};const nL="win32"!==f.platform(),nD=f.release(),nk=/(\d+\.\d+)\.(\d+)/,nU=(e="",t="")=>/1\d+\.\d+/.test(e)&&Number(t)>=17134.1184;function nj(e){if(("linux"===process.platform||"darwin"===process.platform)&&t3()&&void 0!==process.env.SUDO_USER){let t=(0,m.statSync)(e).isDirectory();t4("chown",[...(t?["-R"]:[]),process.env.SUDO_USER,e],{cwd:e,stdio:"inherit",shell:!0});}}nN=function(e){return nL?e.replace(/(\s+)/g,"\\$1"):nU(...nk.exec(nD).splice(1))?e:e.replace(/(\s+)/g,"%20");};var nF={};(function(){var e,t;e=q("eaZtc"),t=function(e){return e.split("").reverse().join("");},nF=function(r,n,i){var o;return(null==n&&(n="'"),null==i&&(i="\\"),"string"!=typeof r)?r:(o=RegExp("(["+e(n)+"])(?!"+e(i)+")","g"),t(t(r).replace(o,"$1"+i)));};}).call(nF);var nM=q("3WkGD");const nG={shouldEscapeSpace:!1,shouldAddOnlyIfNotDefined:!1};async function nB(e,t,r=nG){let n=fu
2023-07-16 06:41:58 +08:00
if [ -z "\${${e}}" ]; then export ${e}="${n}"; fi
`),(0,rg.info)(`if not defined ${e} then ${e}="${n}" was added to "${nV}`)):((0,m.appendFileSync)(nV,`
2023-07-16 06:41:58 +08:00
export ${e}="${n}"
`),(0,rg.info)(`${e}="${n}" was added to "${nV}`));return;}process.env[e]=n;}async function nz(e){switch(process.platform){case"win32":await nP(`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${e};$USER_PATH", "User")`),(0,rg.info)(`"${e}" was added to the PATH.`);return;case"linux":case"darwin":await nK(),(0,m.appendFileSync)(nV,`
2023-07-16 06:41:58 +08:00
export PATH="${e}:$PATH"
`),(0,rg.info)(`"${e}" was added to "${nV}"`);return;default:return;}}let nW=!1;async function nK(){if(nW)return;let e="# Automatically Generated by setup-cpp\nexport SOURCE_CPPRC=0";if(await(0,nM.pathExists)(nV)){let t=(0,m.readFileSync)(nV,"utf8");if(t.includes(e))return;}(0,m.appendFileSync)(nV,`
2023-07-16 06:41:58 +08:00
${e}
`),(0,rg.info)(`Added ${e} to ${nV}`);let t=`
2023-07-16 06:41:58 +08:00
# source .cpprc if SOURCE_CPPRC is not set to 0
if [[ "$SOURCE_CPPRC" != 0 && -f "${nV}" ]]; then source "${nV}"; fi
`;try{let e=t8(".profile");(0,m.appendFileSync)(e,t),(0,rg.info)(`${t} was added to ${e}`);let r=t8(".bashrc");(0,m.appendFileSync)(r,t),(0,rg.info)(`${t} was added to ${r}`);}catch(e){(0,X.warning)(`Failed to add ${t} to .profile or .bashrc. You should add it manually: ${e}`);}nW=!0;}async function nY(){if(await(0,nM.pathExists)(nV)){let e=(0,m.readFileSync)(nV,"utf-8").split("\n"),t=[...new Set(e.reverse())].reverse();(0,m.writeFileSync)(nV,t.join("\n"));try{nj(nV);}catch{}}}var nM=q("3WkGD");const nQ=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:i,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":void 0!==r?`failed with ${r}`:void 0!==n?`was killed with ${n} (${i})`:void 0!==o?`failed with exit code ${o}`:"failed",nJ=({stdout:e,stderr:t,all:r,error:n,signal:i,exitCode:o,command:s,escapedCommand:a,timedOut:l,isCanceled:c,killed:u,parsed:{options:{timeout:p,cwd:d=M(N).cwd()}}})=>{o=null===o?void 0:o,i=null===i?void 0:i;let f=void 0===i?void 0:rF[i].description,h=n&&n.code,m=nQ({timedOut:l,timeout:p,errorCode:h,signal:i,signalDescription:f,exitCode:o,isCanceled:c}),v=`Command ${m}: ${s}`,g="[object Error]"===Object.prototype.toString.call(n),E=g?`${v}
${n.message}`:v,y=[E,t,e].filter(Boolean).join("\n");return g?(n.originalMessage=n.message,n.message=y):n=Error(y),n.shortMessage=E,n.command=s,n.escapedCommand=a,n.exitCode=o,n.signal=i,n.signalDescription=f,n.stdout=e,n.stderr=t,n.cwd=d,void 0!==r&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!l,n.isCanceled=c,n.killed=u&&!l,n;},nZ=["stdin","stdout","stderr"],n0=e=>nZ.some(t=>void 0!==e[t]),n1=e=>{if(!e)return;let{stdio:t}=e;if(void 0===t)return nZ.map(t=>e[t]);if(n0(e))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${nZ.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof t)return t;if(!Array.isArray(t))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let r=Math.max(t.length,nZ.length);return Array.from({length:r},(e,r)=>t[r]);},n2=(e,t="SIGTERM",r={})=>{let n=e(t);return n3(e,t,r,n),n;},n3=(e,t,r,n)=>{if(!n4(t,r,n))return;let i=n8(r),o=setTimeout(()=>{e("SIGKILL");},i);o.unref&&o.unref();},n4=(e,{forceKillAfterTimeout:t},r)=>n6(e)&&!1!==t&&r,n6=e=>e===M(D).constants.signals.SIGTERM||"string"==typeof e&&"SIGTERM"===e.toUpperCase(),n8=({forceKillAfterTimeout:e=!0})=>{if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e;},n5=(e,t)=>{let r=e.kill();r&&(t.isCanceled=!0);},n9=(e,t,r)=>{e.kill(t),r(Object.assign(Error("Timed out"),{timedOut:!0,signal:t}));},n7=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{let i;if(0===t||void 0===t)return n;let o=new Promise((n,o)=>{i=setTimeout(()=>{n9(e,r,o);},t);}),s=n.finally(()=>{clearTimeout(i);});return Promise.race([o,s]);},ie=({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);},it=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;let i=M(e1)(()=>{e.kill();});return n.finally(()=>{i();});},ir=e=>e instanceof P.ChildProcess&&"function"==typeof e.then,ii=(e,t,r)=>{if("string"==typeof r)return e[t].pipe((0,S.createWriteStream)(r)),e;if(r4(r))return e[t].pipe(r),e;if(!ir(r))throw TypeError("The second argument must be a string, a stream or an Execa child process.");if(!r4(r.stdin))throw TypeError("The target child process's stdin must be available.");return e[t].pipe(r.stdin),r;},io=e=>{null!==e.stdout&&(e.pipeStdout=ii.bind(void 0,e,"stdout")),null!==e.stderr&&(e.pipeStderr=ii.bind(void 0,e,"stderr")),void 0!==e.all&&(e.pipeAll=ii.bind(void 0,e,"all"));},is=e=>{if(void 0!==e)throw TypeError("The `input` and `inputFile` options cannot be both set.");},ia=({input:e,inputFile:t})=>"string"!=typeof t?e:(is(e),(0,S.readFileSync)(t)),il=e=>{let t=ia(e);if(r3(t))throw TypeError("The `input` option cannot be a stream in sync mode");return t;},ic=({input:e,inputFile:t})=>"string"!=typeof t?e:(is(e),(0,S.createReadStream)(t)),iu=(e,t)=>{let r=ic(t);void 0!==r&&(r3(r)?r.pipe(e.stdin):e.stdin.end(r));},ip=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;let r=M(tA)();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r;},id=async(e,t)=>{if(e&&void 0!==t){e.destroy();try{return await t;}catch(e){return e.bufferedData;}}},ih=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(e&&r)return t?M(tb)(e,{encoding:t,maxBuffer:n}):M(tb).buffer(e,{maxBuffer:n});},im=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:i,maxBuffer:o},s)=>{let a=ih(e,{encoding:n,buffer:i,maxBuffer:o}),l=ih(t,{encoding:n,buffer:i,maxBuffer:o}),c=ih(r,{encoding:n,buffer:i,maxBuffer:2*o});try{return await Promise.all([s,a,l,c]);}catch(n){return Promise.all([{error:n,signal:n.signal,timedOut:n.timedOut},id(e,a),id(t,l),id(r,c)]);}},iv=(async()=>{})().constructor.prototype,ig=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(iv,e)]),iE=(e,t)=>{for(let[r,n]of ig){let i="function"==typeof t?(...e)=>Reflect.apply(n.value,t(),e):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:i});}},iy=e=>new Promise((t,r)=>{e.on("exit",(e,r)=>{t({exitCode:e,signal:r});}),e.on("er
`);},iD=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:i})=>{let o=t?{...M(N).env,...e}:e;return r?rx({env:o,cwd:n,execPath:i}):o;},ik=(e,t,r={})=>{let n=M(el)._parse(e,t,r);return e=n.command,t=n.args,(r={maxBuffer:1e8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:(r=n.options).cwd||M(N).cwd(),execPath:M(N).execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:i_,...r}).env=iD(r),r.stdio=n1(r),"win32"===M(N).platform&&"cmd"===M(_).basename(e,".exe")&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n};},iU=(e,t,r)=>"string"==typeof t||(0,A.Buffer).isBuffer(t)?e.stripFinalNewline?ry(t):t:void 0===r?void 0:"";function ij(e,t,r){let n;let i=ik(e,t,r),o=iO(e,t),s=iI(e,t);iL(s,i.options),ie(i.options);try{n=M(P).spawn(i.file,i.args,i.options);}catch(r){let e=new(M(P).ChildProcess)(),t=Promise.reject(nJ({error:r,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:i,timedOut:!1,isCanceled:!1,killed:!1}));return iE(e,t),e;}let a=iy(n),l=n7(n,i.options,a),c=it(n,i.options,l),u={isCanceled:!1};n.kill=n2.bind(null,n.kill.bind(n)),n.cancel=n5.bind(null,n,u);let p=async()=>{let[{error:e,exitCode:t,signal:r,timedOut:a},l,p,d]=await im(n,i.options,c),f=iU(i.options,l),h=iU(i.options,p),m=iU(i.options,d);if(e||0!==t||null!==r){let l=nJ({error:e,exitCode:t,signal:r,stdout:f,stderr:h,all:m,command:o,escapedCommand:s,parsed:i,timedOut:a,isCanceled:u.isCanceled||!!i.options.signal&&i.options.signal.aborted,killed:n.killed});if(!i.options.reject)return l;throw l;}return{command:o,escapedCommand:s,exitCode:0,stdout:f,stderr:h,all:m,failed:!1,timedOut:!1,isCanceled:!1,killed:!1};},d=rA(p);return iu(n,i.options),n.all=ip(n,i.options),io(n),iE(n,d),n;}function iF(e,t,r){let n;let i=ik(e,t,r),o=iO(e,t),s=iI(e,t);iL(s,i.options);let a=il(i.options);try{n=M(P).spawnSync(i.file,i.args,{...i.options,input:a});}catch(e){throw nJ({error:e,stdout:"",stderr:"",all:"",command:o,escapedCommand:s,parsed:i,timedOut:!1,isCanceled:!1,killed:!1});}let l=iU(i.options,n.stdout,n.error),c=iU(i.options,n.stderr,n.error);if(n.error||0!==n.status||null!==n.signal){let e=nJ({stdout:l,stderr:c,error:n.error,signal:n.signal,exitCode:n.status,command:o,escapedCommand:s,parsed:i,timedOut:n.error&&"ETIMEDOUT"===n.error.code,isCanceled:!1,killed:null!==n.signal});if(!i.options.reject)return e;throw e;}return{command:o,escapedCommand:s,exitCode:0,stdout:l,stderr:c,failed:!1,timedOut:!1,isCanceled:!1,killed:!1};}const iM=({input:e,inputFile:t,stdio:r})=>void 0===e&&void 0===t&&void 0===r?{stdin:"inherit"}:{},iG=(e={})=>({preferLocal:!0,...iM(e),...e});!function e(t){function r(n,...i){if(!Array.isArray(n))return e({...t,...n});let[o,...s]=iA(n,i);return ij(o,s,iG(t));}return r.sync=(e,...r)=>{if(!Array.isArray(e))throw TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");let[n,...i]=iA(e,r);return iF(n,i,iG(t));},r;}();var iB=q("9O4vc"),X=q("hHq4F"),iH={},iq=h.join,iV=h.delimiter,iX=h.sep,iz=h.posix;const iW="win32"===process.platform,iK=new RegExp(`[${iz.sep}${iX===iz.sep?"":iX}]`.replace(/(\\)/g,"\\$1")),iY=RegExp(`^\\.${iK.source}`),iQ=e=>Object.assign(Error(`not found: ${e}`),{code:"ENOENT"}),iJ=(e,{path:t=process.env.PATH,pathExt:r=process.env.PATHEXT,delimiter:n=iV})=>{let i=e.match(iK)?[""]:[...(iW?[process.cwd()]:[]),...(t||"").split(n)];if(iW){let t=r||[".EXE",".CMD",".BAT",".COM"].join(n),o=t.split(n).reduce((e,t)=>(e.push(t),e.push(t.toLowerCase()),e),[]);return e.includes(".")&&""!==o[0]&&o.unshift(""),{pathEnv:i,pathExt:o,pathExtExe:t};}return{pathEnv:i,pathExt:[""]};},iZ=(e,t)=>{let r=/^".*"$/.test(e)?e.slice(1,-1):e,n=!r&&iY.test(t)?t.slice(0,2):"";return n+iq(r,t);},i0=async(e,t={})=>{let{pathEnv:r,pathExt:n,pathExtExe:i}=iJ(e,t),o=[];for(let s of r){let r=iZ(s,e);for(let e of n){let n=r+e,s=await er(n,{pathExt:i,ignoreErrors:!0});if(s){if(!t.all)return n;o.push(n);}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw iQ(e);};iH=i0,i0.sync=(e,t={})=>{let{pathEnv:r,pathExt:n,pathExtExe:i}=iJ(e,t),o=[];for(let s of r){let r=iZ(s,e);for(let e of n){let n=r+e,s=er
2023-07-16 06:41:58 +08:00
if [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${e} ${e} ${t} 40; fi
2023-09-01 18:46:12 +08:00
`));}async function oo(e){try{let{stdout:t}=await ij("dpkg",["-l",e]),r=t.split("\n");return r.some(e=>e.startsWith("ii"));}catch{return!1;}}(l=u||(u={}))[l.NameDashVersion=0]="NameDashVersion",l[l.NameEqualsVersion=1]="NameEqualsVersion",l[l.Name=2]="Name",l[l.None=3]="None";var rg=q("2heqc"),os=(q("A8hFE"),q("A8hFE")),oa=q("kSdX3");async function ol(e,r,n){if(!["darwin","linux"].includes(process.platform))return;if("string"==typeof t)return{binDir:t};let i=M(iH).sync("brew",{nothrow:!0});if(null!==i)return{binDir:t=(0,os.dirname)(i)};let o=M(h).join((0,f.tmpdir)(),"setup-cpp","brew");await(0,oa.mkdirP)(o),iF("curl",["-LJO","https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"],{cwd:o});let s=(0,h.join)(o,"install.sh");if("linux"===process.platform){let e=(0,m.readFileSync)(s,"utf-8");e.replace("#!/bin/bash","");}return iF("/bin/bash",[s],{stdio:"inherit",env:{NONINTERACTIVE:"1"}}),t=oc(),await nq(t),{binDir:t};}function oc(){return"linux"===process.platform?"/home/linuxbrew/.linuxbrew/bin/":"/usr/local/bin/";}let ou=!1;async function op(e,t,r=[]){(0,rg.info)(`Installing ${e} ${null!=t?t:""} via brew`),ou&&null!==M(iH).sync("brew",{nothrow:!0})||(await ol("","",process.arch),ou=!0);let n=oc();return iF((0,os.join)(n,"brew"),["install",void 0!==t&&""!==t?`${e}@${t}`:e,...r],{stdio:"inherit"}),{binDir:n};}var nM=q("3WkGD"),os=q("A8hFE");async function od(e,t,n){var i;if("win32"!==process.platform)return;if("string"==typeof r)return{binDir:r};let o=M(iH).sync("choco",{nothrow:!0});if(null!==o)return{binDir:r=(0,os.dirname)(o)};let s="powershell.exe",a=M(iH).sync(`${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,{nothrow:!0});null!==a&&(s=a),iF(s,["-NoProfile","-InputFormat","None","-ExecutionPolicy","Bypass","-Command","[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))"],{stdio:"inherit"});let l=`${process.env.ALLUSERSPROFILE}\\chocolatey\\bin`;await nq(l);let c=M(iH).sync("choco",{nothrow:!0});if(r=null!==c?(0,os.dirname)(c):`${null!==(i=process.env.ChocolateyInstall)&&void 0!==i?i:"C:/ProgramData/chocolatey"}/bin`,await(0,nM.pathExists)(r))return{binDir:r};}var rg=q("2heqc"),X=q("hHq4F");let of=!1;async function oh(e,t,r=[]){var n;(0,rg.info)(`Installing ${e} ${null!=t?t:""} via chocolatey`),of&&null!==M(iH).sync("choco",{nothrow:!0})||(await od("","",process.arch),of=!0);let i=process.env.PATH,o={...process.env};if(delete o.TMP,delete o.TEMP,delete o.Path,o.PATH=i,void 0!==t&&""!==t)iF("choco",["install","-y",e,`--version=${t}`,...r],{env:o,extendEnv:!1,stdio:"inherit"});else try{iF("choco",["install","-y",e,...r],{env:o,extendEnv:!1,stdio:"inherit"});}catch(t){if(t.message.includes("exit code 3010"))(0,X.notice)(`${e} might require a reboot for the completion of the installation.`);else throw t;}let s=`${null!==(n=process.env.ChocolateyInstall)&&void 0!==n?n:"C:/ProgramData/chocolatey"}/bin`;return await nq(s),{binDir:s};}function om(){return"linux"===process.platform&&(void 0===o&&(o=null!==M(iH).sync("pacman",{nothrow:!0})),o);}function ov(){return"linux"===process.platform&&(void 0===s&&(s=null!==M(iH).sync("dnf",{nothrow:!0})),s);}async function og(e){for(let{name:t,version:r}of e)(0,X.info)(`Installing ${t} ${null!=r?r:""} via dnf`);let t=await Promise.all(e.map(e=>oE(e.name,e.version)));return t4("dnf",["-y","install",...t]),{binDir:"/usr/bin/"};}async function oE(e,t){if(void 0!==t&&""!==t){let{stdout:r}=await ij("dnf",["search","-q",`${e}-${t}`]);if(""!==r.trim())return`${e}-${t}`;{let{stdout:r}=await ij("dnf",["search","-q",`${e}${t}`]);if(""!==r.trim())return`${e}${t}`;(0,X.warning)(`Failed to install ${e} ${t} via dnf, trying without version`);}}return e;}function oy(){return"linux"===process.platform&&(void 0===a&&(a=null!==M(iH).sync("apt-get",{nothrow:!0})),a);}async function ow(e,t,r){switch(process.platform){case"win32":return oh("bazelisk",e);case"darwin":return op("bazelisk",e);case"linux":if(om())throw Error("installing bazel on Arch linux is not
2023-07-16 06:41:58 +08:00
- The installation directory is ${t.installDir}`),""!==t.binDir&&(r+=`
- The binary directory is ${t.binDir}`)),r;}var rg=q("2heqc"),X=q("hHq4F"),sI=q("eO4vc");async function lU(e,t,r,n,i,o,s){try{let{compiler:a,version:l}=function(e){let t=e.split("-"),r=t[0];if(1 in t){let e=t[1];return null!==M(sI)(e)||(0,X.info)(`Invalid semver version ${e} used for the compiler.`),{compiler:r,version:e};}return{compiler:r,version:void 0};}(e);switch((0,rg.startGroup)(`Installing ${a} ${null!=l?l:""}`),a){case"llvm":case"clang":case"clang++":{let e=await lp(sK("llvm",l,t),(0,h.join)(r,"llvm"),n);await nB("GCOV","llvm-cov gcov"),i.push(lk("llvm",e));break;}case"gcc":case"mingw":case"cygwin":case"msys":{let e="mingw"===a?sK("mingw",l,t):sK("gcc",l,t),s="mingw"===a?await ad(e,(0,h.join)(r,"gcc"),n):await ap(e,(0,h.join)(r,"gcc"),n);o&&(await nB("CPPFLAGS","")),await function(e){let t=M(sI)(e),r=null!==t?M(as)(t):e,n=""!==r?`gcov-${r}`:"gcov";return nB("GCOV",n);}(e),i.push(lk("gcc",s));break;}case"cl":case"msvc":case"msbuild":case"vs":case"visualstudio":case"visualcpp":case"visualc++":{let e=await lO(sK("msvc",l,t),(0,h.join)(r,"msvc"),n);o&&(await nB("CPPFLAGS","")),i.push(lk("msvc",e));break;}case"appleclang":case"applellvm":(0,rg.notice)("Assuming apple-clang is already installed"),await Promise.all([nB("CC","clang"),nB("CXX","clang++")]),i.push(lk("apple-clang",void 0));break;default:s.push(`Unsupported compiler ${a}`);}}catch(t){(0,X.error)(t),s.push(`Failed to install the ${e}`);}(0,rg.endGroup)();}(async function(e){var t,r,n;let i,o,s=Promise.resolve();V.GITHUB_ACTIONS||(s=rv(),process.env.ACTIONS_ALLOW_UNSECURE_COMMANDS="true");let a=function(e,t){t=t||{};var r,n,i,o,s,a={_:[]},l=0,c=0,u=0,p=(e=e||[]).length;let d=void 0!==t.alias,f=void 0!==t.unknown,h=void 0!==t.default;if(t.alias=t.alias||{},t.string=rE(t.string),t.boolean=rE(t.boolean),d)for(r in t.alias)for(l=0,n=t.alias[r]=rE(t.alias[r]);l<n.length;l++)(t.alias[n[l]]=n.concat(r)).splice(l,1);for(l=t.boolean.length;l-->0;)for(c=(n=t.alias[t.boolean[l]]||[]).length;c-->0;)t.boolean.push(n[c]);for(l=t.string.length;l-->0;)for(c=(n=t.alias[t.string[l]]||[]).length;c-->0;)t.string.push(n[c]);if(h){for(r in t.default)if(o=typeof t.default[r],n=t.alias[r]=t.alias[r]||[],void 0!==t[o])for(t[o].push(r),l=0;l<n.length;l++)t[o].push(n[l]);}let m=f?Object.keys(t.alias):[];for(l=0;l<p;l++){if("--"===(i=e[l])){a._=a._.concat(e.slice(++l));break;}for(c=0;c<i.length&&45===i.charCodeAt(c);c++);if(0===c)a._.push(i);else if("no-"===i.substring(c,c+3)){if(o=i.substring(c+3),f&&!~m.indexOf(o))return t.unknown(i);a[o]=!1;}else{for(u=c+1;u<i.length&&61!==i.charCodeAt(u);u++);for(o=i.substring(c,u),s=i.substring(++u)||l+1===p||45===(""+e[l+1]).charCodeAt(0)||e[++l],n=2===c?[o]:o,u=0;u<n.length;u++){if(o=n[u],f&&!~m.indexOf(o))return t.unknown("-".repeat(c)+o);!function(e,t,r,n){var i,o=e[t],s=~n.string.indexOf(t)?null==r||!0===r?"":String(r):"boolean"==typeof r?r:~n.boolean.indexOf(t)?"false"!==r&&("true"===r||(e._.push(0*(i=+r)==0?i:r),!!r)):0*(i=+r)==0?i:r;e[t]=null==o?s:Array.isArray(o)?o.concat(s):[o,s];}(a,o,u+1<n.length||s,t);}}}if(h)for(r in t.default)void 0===a[r]&&(a[r]=t.default[r]);if(d)for(r in a)for(n=t.alias[r]||[];n.length>0;)a[n.shift()]=a[r];return a;}(e,{string:[...lD,"timeout"],default:Object.fromEntries(lD.map(e=>[e,function(e){let t=(0,rg.getInput)(e.toLowerCase());if("false"!==t&&""!==t)return t;}(e)])),alias:{h:"help"},boolean:"help"});a.help&&((0,X.info)(`
2023-07-16 06:41:58 +08:00
setup-cpp [options]
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Install all the tools required for building and testing C++/C projects.
--architecture the cpu architecture to install the tools for. By default it uses the current CPU architecture.
--timeout the timeout for the installation of each tool in minutes. By default it is 10 minutes.
2023-07-16 06:41:58 +08:00
--compiler the <compiler> to install.
You can specify the version instead of specifying just the name e.g: --compiler 'llvm-13.0.0'
--$tool_name pass "true" or pass the <version> you would like to install for this tool. e.g. --conan true or --conan "1.42.1"
All the available tools:
`),console.table({"compiler and analyzer":{tools:"--llvm, --gcc, --msvc, --vcvarsall, --cppcheck, --clangtidy, --clangformat"},"build system":{tools:"--cmake, --ninja, --meson, --make, --task, --bazel"},"package manager":{tools:"--vcpkg, --conan, --choco, --brew, --nala"},cache:{tools:"--cppcache, --sccache"},documentation:{tools:"--doxygen, --graphviz"},coverage:{tools:"--gcovr, --opencppcoverage, --kcov"},other:{tools:"--python, --powershell, --sevenzip"}},["tools"]));let l=null!==(t=a.architecture)&&void 0!==t?t:process.arch,c=null!==(r=process.env.SETUP_CPP_DIR)&&void 0!==r?r:t8(""),u=[],p=[],d=K.create({autoloadLocales:!0});K.addLocale(M(Y)),z.addLocale(M(W));let f=await s0();if(!function(e,t){let r=t.filter(t=>void 0!==e[t]),n=r.filter(t=>!sY(e[t])),i=n.length>=1?e[n[0]]:"true";return!n.some(t=>e[t]!==i)&&(r.forEach(t=>{e[t]=i;}),!0);}(a,["llvm","clangtidy","clangformat"]))return(0,X.error)("The same version must be used for llvm, clangformat and clangtidy"),1;om()&&"string"==typeof a.cppcheck&&"string"==typeof a.gcovr&&((0,X.info)("installing python-pygments to avoid conflicts with cppcheck and gcovr on Arch linux"),await oS("python-pygments"));let h=!1,m=!1;for(let e of lL){if(V.isCI&&0!==p.length){m=!0;break;}let t=a[e];void 0!==t&&(i=Date.now(),h=await a1(e,t,f,l,c,u,p,6e4*parseFloat(null!==(n=a.timeout)&&void 0!==n?n:"20")),o=Date.now(),(0,X.info)(`took ${d.format(i,o)||"0 seconds"}`));}if(!m){let e=a.compiler;if(void 0!==e){let t=Date.now();await lU(e,f,c,l,u,h,p);let r=Date.now();(0,X.info)(`took ${d.format(t,r)||"0 seconds"}`);}}if(await nY(),0===u.length&&0===p.length)return(0,X.warning)("setup-cpp was called without any arguments. Nothing to do."),0;if(u.forEach(e=>(0,X.success)(e)),p.forEach(e=>(0,X.error)(e)),(0,X.info)("setup-cpp finished"),!V.GITHUB_ACTIONS)switch(process.platform){case"win32":(0,X.warning)("Run `RefreshEnv.cmd` or restart your shell to update the environment.");break;case"linux":case"darwin":(0,X.warning)("Run `source ~/.cpprc` or restart your shell to update the environment.");}return await s,0===p.length?0:1;})(process.argv).then(e=>{process.exitCode=e;}).catch(e=>{(0,X.error)("main() panicked!"),(0,X.error)(e),process.exitCode=1;});
2023-07-16 06:41:58 +08:00
//# sourceMappingURL=setup-cpp.js.map