feat(cli): create .cargo/config if needed
This commit is contained in:
parent
cbd4e4d1fc
commit
84a6a8613b
2 changed files with 32 additions and 0 deletions
18
cli/src/new/cargo-config.ts
Normal file
18
cli/src/new/cargo-config.ts
Normal file
|
@ -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
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue