diff --git a/cli/src/new/cargo-config.ts b/cli/src/new/cargo-config.ts new file mode 100644 index 00000000..55427207 --- /dev/null +++ b/cli/src/new/cargo-config.ts @@ -0,0 +1,18 @@ +export const createCargoConfig = ( + enableLinuxArm7: boolean, + enableLinuxArm8: boolean, +) => { + let result = '' + if (enableLinuxArm7) { + result = `[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc"` + } + if (enableLinuxArm8) { + result = `${result} + +[target.armv7-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" +` + } + return result +} diff --git a/cli/src/new/index.ts b/cli/src/new/index.ts index 8f6e61bc..618d9f23 100644 --- a/cli/src/new/index.ts +++ b/cli/src/new/index.ts @@ -11,6 +11,7 @@ import { DefaultPlatforms } from '../parse-triple' import { spawn } from '../spawn' import { createCargoContent } from './cargo' +import { createCargoConfig } from './cargo-config' import { createGithubActionsCIYml } from './ci-yml' import { createIndexJs } from './indexjs' import { LibRs } from './lib-rs' @@ -153,6 +154,19 @@ export class NewProjectCommand extends Command { join(process.cwd(), this.dirname!), join(process.cwd(), this.dirname!), ) + + const enableLinuxArm8 = this.targets!.includes('aarch64-unknown-linux-gnu') + const enableLinuxArm7 = this.targets!.includes( + 'armv7-unknown-linux-gnueabihf', + ) + const cargoConfig = createCargoConfig(enableLinuxArm7, enableLinuxArm8) + if (cargoConfig.length) { + const configDir = join(process.cwd(), this.dirname!, '.config') + if (!this.dryRun) { + mkdirSync(configDir) + this.writeFile(join('.config', 'config.toml'), cargoConfig) + } + } } private writeFile(path: string, content: string) {