-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Created flow from cubeIde import to a STM32 config yaml file
- Loading branch information
Showing
5 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
import _ = require('lodash'); | ||
import MakeInfo from '../types/MakeInfo'; | ||
|
||
const defaults: Partial<MakeInfo> = { | ||
libs: ['c', 'm', 'nosys'], | ||
assemblyFlags: ['-specs=nosys.specs'], | ||
cxxFlags: ['-feliminate-unused-debug-types'] | ||
}; | ||
|
||
/** | ||
* Adds default library and flags to the MakeInfo. | ||
* @param info makeInfo to add default libs and flags to | ||
* @returns | ||
*/ | ||
export function addDefaultLibsAndFlagsInfo(info: MakeInfo): MakeInfo { | ||
if (info.libs === undefined) { | ||
info.libs = []; | ||
} | ||
if (defaults.libs === undefined) { | ||
defaults.libs = []; | ||
} | ||
if (info.assemblyFlags === undefined) { | ||
info.assemblyFlags = []; | ||
} | ||
if (defaults.assemblyFlags === undefined) { | ||
defaults.assemblyFlags = []; | ||
} | ||
if (defaults.cxxFlags === undefined) { | ||
defaults.cxxFlags = []; | ||
} | ||
|
||
|
||
info.libs = info.libs.concat(defaults.libs); | ||
info.assemblyFlags = info.assemblyFlags.concat(defaults.assemblyFlags); | ||
info.cxxFlags = info.cxxFlags.concat(defaults.cxxFlags); | ||
return info; | ||
} | ||
|
||
export default function addDefaults(info: MakeInfo): MakeInfo { | ||
return addDefaultLibsAndFlagsInfo(info); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import getCubeProjectInfo from './getInfo/STM32CubeIDE'; | ||
import setDefaults from './getInfo/defaultInfo'; | ||
import { ExtensionConfiguration } from './types'; | ||
import { writeConfigFile } from './configuration/stm32Config'; | ||
import * as vscode from 'vscode'; | ||
|
||
export default async function importAndSetupCubeIDEProject(): Promise<void> { | ||
try { | ||
const cubeProjectInfo = await getCubeProjectInfo(); | ||
const withDefaults = setDefaults(cubeProjectInfo); | ||
const configFile = new ExtensionConfiguration(); | ||
configFile.importRelevantInfoFromMakefile(withDefaults); | ||
console.log({ cubeProjectInfo, withDefaults, configFile }); | ||
|
||
await writeConfigFile(configFile); | ||
} catch (error) { | ||
vscode.window.showErrorMessage(`Something went wrong with importing the project. Error: ${error}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters