MCPcopy Create free account
hub / github.com/cargo-lambda/cargo-lambda-cdk / constructor

Method constructor

src/bundling.ts:88–166  ·  view source on GitHub ↗
(readonly projectRoot: string, private readonly props: BundlingProps)

Source from the content-addressed store, hash-verified

86 public readonly local?: cdk.ILocalBundling;
87
88 constructor(readonly projectRoot: string, private readonly props: BundlingProps) {
89 Bundling.runsLocally = Bundling.runsLocally
90 ?? cargoLambdaVersion()
91 ?? false;
92
93 // Docker bundling
94 const shouldBuildImage = props.forcedDockerBundling || !Bundling.runsLocally;
95
96 this.image = shouldBuildImage
97 ? props.dockerImage ?? cdk.DockerImage.fromRegistry('ghcr.io/cargo-lambda/cargo-lambda')
98 : cdk.DockerImage.fromRegistry('dummy'); // Do not build if we don't need to
99
100 const manifest = getManifest(props.manifestPath);
101
102 const cargoLambdaFlags = props.cargoLambdaFlags ?? [];
103 const profile = props.profile ?? 'release';
104
105 const osPlatform = platform();
106 const bundlingCommand = this.createBundlingCommand({
107 osPlatform,
108 manifest,
109 cargoLambdaFlags,
110 profile,
111 outputDir: cdk.AssetStaging.BUNDLING_OUTPUT_DIR,
112 inputDir: cdk.AssetStaging.BUNDLING_INPUT_DIR,
113 binaryName: props.binaryName,
114 architecture: props.architecture,
115 lambdaExtension: props.lambdaExtension,
116 });
117
118 this.command = ['bash', '-c', bundlingCommand];
119 this.environment = props.environment;
120
121 //Local bundling
122 if (!props.forcedDockerBundling) { // only if Docker is not forced
123 const createLocalCommand = (outputDir: string) => {
124 return this.createBundlingCommand({
125 osPlatform,
126 manifest,
127 outputDir,
128 cargoLambdaFlags,
129 profile,
130 inputDir: projectRoot,
131 binaryName: props.binaryName,
132 architecture: props.architecture,
133 lambdaExtension: props.lambdaExtension,
134 });
135 };
136
137 this.local = {
138 tryBundle(outputDir: string) {
139 if (Bundling.runsLocally == false) {
140 process.stderr.write('Rust build cannot run locally. Switching to Docker bundling.\n');
141 return false;
142 }
143
144 const localCommand = createLocalCommand(outputDir);
145 exec(

Callers

nothing calls this directly

Calls 3

createBundlingCommandMethod · 0.95
getManifestFunction · 0.90
cargoLambdaVersionFunction · 0.85

Tested by

no test coverage detected