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,UAAW,IAAI,UAAU,CAAE,KAAM,IAAO,OAAQ,KAEjD,QAAS,YACT,QAAS,aAIX,CACA,OAAO,QAAU,CAChB,QAtEe,EAuEf","file":"/npm/@genhub/vercel-rust@0.0.35/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@genhub/vercel-rust@0.0.35/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const fs = require(\"fs\");\nconst path = require(\"path\");\nconst execa = require(\"execa\");\nconst toml = require(\"toml\");\nconst {\n\tglob,\n\tcreateLambda,\n\tdebug,\n\tdownload,\n\tFileFsRef\n} = require(\"@now/build-utils\");\nconst { installRustAndFriends } = require(\"./install-rust\");\nconst version = 3;\n\nconst codegenFlags = [\n\t\"-C\",\n\t\"target-cpu=ivybridge\",\n\t\"-C\",\n\t\"target-feature=-aes,-avx,+fxsr,-popcnt,+sse,+sse2,-sse3,-sse4.1,-sse4.2,-ssse3,-xsave,-xsaveopt\"\n];\n\nfunction getBinName(cargo, entrypoint) {\n\tlet res = cargo.bin.find(item => item.path === entrypoint);\n\tif (!res) {\n\t\tthrow Error(`Entry point '${entrypoint}' is not a binary.`);\n\t}\n\n\treturn res.name;\n}\n\nasync function build({\n\tfiles,\n\tentrypoint,\n\tworkPath,\n\tmeta\n}) {\n\tlet { isDev } = meta;\n\tawait installRustAndFriends();\n\tawait download(files, workPath, meta);\n\tconst cargoPath = `${workPath}/Cargo.toml`;\n\tif (!fs.existsSync(cargoPath)) {\n\t\tthrow Error(\"Cargo.toml not found in root dir.\");\n\t}\n\tlet cargo = toml.parse(fs.readFileSync(cargoPath));\n\tlet binName = getBinName(cargo, entrypoint);\n\tconst staticPath = `${workPath}/static`;\n\tlet staticStats = fs.lstatSync(staticPath);\n\n\tif (!staticStats.isDirectory()) {\n\t\tthrow Error(\"'static' exists but it is not a directory.\");\n\t}\n\n\tconst extraFiles = await glob(\"static/**\", workPath);\n\tdebug(`building binary '${binName}'...`);\n\tconst { PATH, HOME, RUSTFLAGS } = process.env;\n\tconst rustEnv = {\n\t\t...process.env,\n\t\tPATH: `${path.join(HOME, \".cargo/bin\")}:${PATH}`,\n\t\tRUSTFLAGS: [RUSTFLAGS, ...codegenFlags]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\" \")\n\t};\n\tlet res = await execa.command(`cargo build --bin ${binName} ${isDev ? \"--verbose\" : \"--release\"}`, {\n\t\tenv: rustEnv,\n\t\tcwd: workPath,\n\t\tstdio: \"inherit\"\n\t});\n\tdebug(`done building '${res}'`);\n\n\tlet bin = `${workPath}/target/${isDev ? \"debug\" : \"release\"}/${binName}`;\n\tconst lambda = await createLambda({\n\t\tfiles: {\n\t\t\t...extraFiles,\n\t\t\tbootstrap: new FileFsRef({ mode: 0o755, fsPath: bin })\n\t\t},\n\t\thandler: \"bootstrap\",\n\t\truntime: \"provided\"\n\t});\n\n\treturn { output: lambda };\n}\nmodule.exports = {\n\tversion,\n\tbuild,\n};"]}