(props: CommandOptions)
| 166 | } |
| 167 | |
| 168 | public createBundlingCommand(props: CommandOptions): string { |
| 169 | const buildBinary: string[] = [ |
| 170 | 'cargo', |
| 171 | 'lambda', |
| 172 | 'build', |
| 173 | '--lambda-dir', |
| 174 | props.outputDir, |
| 175 | ]; |
| 176 | |
| 177 | if (!props.cargoLambdaFlags.includes('--profile') |
| 178 | && !props.cargoLambdaFlags.includes('--release')) { |
| 179 | if (props.profile === 'release') { |
| 180 | buildBinary.push('--release'); |
| 181 | } else { |
| 182 | buildBinary.push('--profile'); |
| 183 | buildBinary.push(props.profile); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (props.lambdaExtension) { |
| 188 | buildBinary.push('--extension'); |
| 189 | } |
| 190 | |
| 191 | if (props.architecture && !props.cargoLambdaFlags.includes('--target')) { |
| 192 | const targetFlag = props.architecture.name == Architecture.ARM_64.name ? '--arm64' : '--x86-64'; |
| 193 | buildBinary.push(targetFlag); |
| 194 | } |
| 195 | |
| 196 | let packageName; |
| 197 | if (props.binaryName) { |
| 198 | buildBinary.push('--bin'); |
| 199 | buildBinary.push(props.binaryName); |
| 200 | packageName = props.binaryName; |
| 201 | } else { |
| 202 | if (props.manifest.workspace) { |
| 203 | throw new Error('the Cargo manifest is a workspace, use the option `binaryName` to specify the binary to build'); |
| 204 | } |
| 205 | |
| 206 | packageName = props.manifest.package?.name; |
| 207 | if (props.manifest.bin) { |
| 208 | if (props.manifest.bin.length == 1) { |
| 209 | packageName = props.manifest.bin[0].name; |
| 210 | |
| 211 | buildBinary.push('--bin'); |
| 212 | buildBinary.push(packageName); |
| 213 | } else { |
| 214 | throw new Error('there are more than one binaries declared in this Cargo package, use the option `binaryName` to specify the binary to build'); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if (!packageName) { |
| 219 | throw new Error('the Cargo package is missing the package name or a [[bin]] section, use the option `binaryName` to specify the binary to build'); |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | if (!props.lambdaExtension && packageName) { |
| 224 | buildBinary.push('--flatten'); |
| 225 | buildBinary.push(packageName); |
no test coverage detected