mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-27 05:06:42 +00:00
ATL-66: Added compiler warnings.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
057904d38d
commit
86be874bb0
@ -1,11 +1,6 @@
|
|||||||
import { interfaces } from 'inversify';
|
import { interfaces } from 'inversify';
|
||||||
import {
|
import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser/preferences';
|
||||||
createPreferenceProxy,
|
import { CompilerWarningLiterals, CompilerWarnings } from '../common/protocol';
|
||||||
PreferenceProxy,
|
|
||||||
PreferenceService,
|
|
||||||
PreferenceContribution,
|
|
||||||
PreferenceSchema
|
|
||||||
} from '@theia/core/lib/browser/preferences';
|
|
||||||
|
|
||||||
export const ArduinoConfigSchema: PreferenceSchema = {
|
export const ArduinoConfigSchema: PreferenceSchema = {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
@ -20,6 +15,11 @@ export const ArduinoConfigSchema: PreferenceSchema = {
|
|||||||
'description': 'True for verbose compile output. False by default',
|
'description': 'True for verbose compile output. False by default',
|
||||||
'default': false
|
'default': false
|
||||||
},
|
},
|
||||||
|
'arduino.compile.warnings': {
|
||||||
|
'enum': [...CompilerWarningLiterals],
|
||||||
|
'description': "Tells gcc which warning level to use. It's 'None' by default",
|
||||||
|
'default': 'None'
|
||||||
|
},
|
||||||
'arduino.upload.verbose': {
|
'arduino.upload.verbose': {
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'description': 'True for verbose upload output. False by default.',
|
'description': 'True for verbose upload output. False by default.',
|
||||||
@ -50,6 +50,7 @@ export const ArduinoConfigSchema: PreferenceSchema = {
|
|||||||
export interface ArduinoConfiguration {
|
export interface ArduinoConfiguration {
|
||||||
'arduino.language.log': boolean;
|
'arduino.language.log': boolean;
|
||||||
'arduino.compile.verbose': boolean;
|
'arduino.compile.verbose': boolean;
|
||||||
|
'arduino.compile.warnings': CompilerWarnings;
|
||||||
'arduino.upload.verbose': boolean;
|
'arduino.upload.verbose': boolean;
|
||||||
'arduino.upload.verify': boolean;
|
'arduino.upload.verify': boolean;
|
||||||
'arduino.window.autoScale': boolean;
|
'arduino.window.autoScale': boolean;
|
||||||
|
@ -80,6 +80,7 @@ export class VerifySketch extends SketchContribution {
|
|||||||
this.sourceOverride()
|
this.sourceOverride()
|
||||||
]);
|
]);
|
||||||
const verbose = this.preferences.get('arduino.compile.verbose');
|
const verbose = this.preferences.get('arduino.compile.verbose');
|
||||||
|
const compilerWarnings = this.preferences.get('arduino.compile.warnings');
|
||||||
this.outputChannelManager.getChannel('Arduino').clear();
|
this.outputChannelManager.getChannel('Arduino').clear();
|
||||||
await this.coreService.compile({
|
await this.coreService.compile({
|
||||||
sketchUri: sketch.uri,
|
sketchUri: sketch.uri,
|
||||||
@ -87,7 +88,8 @@ export class VerifySketch extends SketchContribution {
|
|||||||
optimizeForDebug: this.editorMode.compileForDebug,
|
optimizeForDebug: this.editorMode.compileForDebug,
|
||||||
verbose,
|
verbose,
|
||||||
exportBinaries,
|
exportBinaries,
|
||||||
sourceOverride
|
sourceOverride,
|
||||||
|
compilerWarnings
|
||||||
});
|
});
|
||||||
this.messageService.info('Done compiling.', { timeout: 1000 });
|
this.messageService.info('Done compiling.', { timeout: 1000 });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -18,7 +18,7 @@ import { DisposableCollection } from '@theia/core/lib/common/disposable';
|
|||||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||||
import { AbstractDialog, DialogProps, PreferenceService, PreferenceScope, DialogError, ReactWidget } from '@theia/core/lib/browser';
|
import { AbstractDialog, DialogProps, PreferenceService, PreferenceScope, DialogError, ReactWidget } from '@theia/core/lib/browser';
|
||||||
import { Index } from '../common/types';
|
import { Index } from '../common/types';
|
||||||
import { ConfigService, FileSystemExt, Network, ProxySettings } from '../common/protocol';
|
import { CompilerWarnings, CompilerWarningLiterals, ConfigService, FileSystemExt, Network, ProxySettings } from '../common/protocol';
|
||||||
|
|
||||||
export interface Settings extends Index {
|
export interface Settings extends Index {
|
||||||
editorFontSize: number; // `editor.fontSize`
|
editorFontSize: number; // `editor.fontSize`
|
||||||
@ -29,6 +29,7 @@ export interface Settings extends Index {
|
|||||||
interfaceScale: number; // `arduino.window.zoomLevel` https://github.com/eclipse-theia/theia/issues/8751
|
interfaceScale: number; // `arduino.window.zoomLevel` https://github.com/eclipse-theia/theia/issues/8751
|
||||||
checkForUpdates?: boolean; // `arduino.ide.autoUpdate`
|
checkForUpdates?: boolean; // `arduino.ide.autoUpdate`
|
||||||
verboseOnCompile: boolean; // `arduino.compile.verbose`
|
verboseOnCompile: boolean; // `arduino.compile.verbose`
|
||||||
|
compilerWarnings: CompilerWarnings; // `arduino.compile.warnings`
|
||||||
verboseOnUpload: boolean; // `arduino.upload.verbose`
|
verboseOnUpload: boolean; // `arduino.upload.verbose`
|
||||||
verifyAfterUpload: boolean; // `arduino.upload.verify`
|
verifyAfterUpload: boolean; // `arduino.upload.verify`
|
||||||
enableLsLogs: boolean; // `arduino.language.log`
|
enableLsLogs: boolean; // `arduino.language.log`
|
||||||
@ -87,6 +88,7 @@ export class SettingsService {
|
|||||||
interfaceScale,
|
interfaceScale,
|
||||||
// checkForUpdates,
|
// checkForUpdates,
|
||||||
verboseOnCompile,
|
verboseOnCompile,
|
||||||
|
compilerWarnings,
|
||||||
verboseOnUpload,
|
verboseOnUpload,
|
||||||
verifyAfterUpload,
|
verifyAfterUpload,
|
||||||
enableLsLogs,
|
enableLsLogs,
|
||||||
@ -99,6 +101,7 @@ export class SettingsService {
|
|||||||
this.preferenceService.get<number>('arduino.window.zoomLevel', 0),
|
this.preferenceService.get<number>('arduino.window.zoomLevel', 0),
|
||||||
// this.preferenceService.get<string>('arduino.ide.autoUpdate', true),
|
// this.preferenceService.get<string>('arduino.ide.autoUpdate', true),
|
||||||
this.preferenceService.get<boolean>('arduino.compile.verbose', true),
|
this.preferenceService.get<boolean>('arduino.compile.verbose', true),
|
||||||
|
this.preferenceService.get<any>('arduino.compile.warnings', 'None'),
|
||||||
this.preferenceService.get<boolean>('arduino.upload.verbose', true),
|
this.preferenceService.get<boolean>('arduino.upload.verbose', true),
|
||||||
this.preferenceService.get<boolean>('arduino.upload.verify', true),
|
this.preferenceService.get<boolean>('arduino.upload.verify', true),
|
||||||
this.preferenceService.get<boolean>('arduino.language.log', true),
|
this.preferenceService.get<boolean>('arduino.language.log', true),
|
||||||
@ -114,6 +117,7 @@ export class SettingsService {
|
|||||||
interfaceScale,
|
interfaceScale,
|
||||||
// checkForUpdates,
|
// checkForUpdates,
|
||||||
verboseOnCompile,
|
verboseOnCompile,
|
||||||
|
compilerWarnings,
|
||||||
verboseOnUpload,
|
verboseOnUpload,
|
||||||
verifyAfterUpload,
|
verifyAfterUpload,
|
||||||
enableLsLogs,
|
enableLsLogs,
|
||||||
@ -175,6 +179,7 @@ export class SettingsService {
|
|||||||
interfaceScale,
|
interfaceScale,
|
||||||
// checkForUpdates,
|
// checkForUpdates,
|
||||||
verboseOnCompile,
|
verboseOnCompile,
|
||||||
|
compilerWarnings,
|
||||||
verboseOnUpload,
|
verboseOnUpload,
|
||||||
verifyAfterUpload,
|
verifyAfterUpload,
|
||||||
enableLsLogs,
|
enableLsLogs,
|
||||||
@ -198,6 +203,7 @@ export class SettingsService {
|
|||||||
this.preferenceService.set('arduino.window.zoomLevel', interfaceScale, PreferenceScope.User),
|
this.preferenceService.set('arduino.window.zoomLevel', interfaceScale, PreferenceScope.User),
|
||||||
// this.preferenceService.set('arduino.ide.autoUpdate', checkForUpdates, PreferenceScope.User),
|
// this.preferenceService.set('arduino.ide.autoUpdate', checkForUpdates, PreferenceScope.User),
|
||||||
this.preferenceService.set('arduino.compile.verbose', verboseOnCompile, PreferenceScope.User),
|
this.preferenceService.set('arduino.compile.verbose', verboseOnCompile, PreferenceScope.User),
|
||||||
|
this.preferenceService.set('arduino.compile.warnings', compilerWarnings, PreferenceScope.User),
|
||||||
this.preferenceService.set('arduino.upload.verbose', verboseOnUpload, PreferenceScope.User),
|
this.preferenceService.set('arduino.upload.verbose', verboseOnUpload, PreferenceScope.User),
|
||||||
this.preferenceService.set('arduino.upload.verify', verifyAfterUpload, PreferenceScope.User),
|
this.preferenceService.set('arduino.upload.verify', verifyAfterUpload, PreferenceScope.User),
|
||||||
this.preferenceService.set('arduino.language.log', enableLsLogs, PreferenceScope.User),
|
this.preferenceService.set('arduino.language.log', enableLsLogs, PreferenceScope.User),
|
||||||
@ -267,6 +273,7 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
|
|||||||
<div className='flex-line'>Interface scale:</div>
|
<div className='flex-line'>Interface scale:</div>
|
||||||
<div className='flex-line'>Theme:</div>
|
<div className='flex-line'>Theme:</div>
|
||||||
<div className='flex-line'>Show verbose output during:</div>
|
<div className='flex-line'>Show verbose output during:</div>
|
||||||
|
<div className='flex-line'>Compiler warnings:</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='column'>
|
<div className='column'>
|
||||||
<div className='flex-line'>
|
<div className='flex-line'>
|
||||||
@ -321,6 +328,14 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
|
|||||||
upload
|
upload
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div className='flex-line'>
|
||||||
|
<select
|
||||||
|
className='theia-select'
|
||||||
|
value={this.state.compilerWarnings}
|
||||||
|
onChange={this.compilerWarningsDidChange}>
|
||||||
|
{CompilerWarningLiterals.map(value => <option key={value} value={value}>{value}</option>)}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<label className='flex-line'>
|
<label className='flex-line'>
|
||||||
@ -544,6 +559,14 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected compilerWarningsDidChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
|
const { selectedIndex } = event.target.options;
|
||||||
|
const compilerWarnings = CompilerWarningLiterals[selectedIndex];
|
||||||
|
if (compilerWarnings) {
|
||||||
|
this.setState({ compilerWarnings });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
protected verboseOnCompileDidChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
protected verboseOnCompileDidChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
this.setState({ verboseOnCompile: event.target.checked });
|
this.setState({ verboseOnCompile: event.target.checked });
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
.arduino-settings-dialog .content {
|
.arduino-settings-dialog .content {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
height: 250px;
|
height: 270px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.arduino-settings-dialog .flex-line {
|
.arduino-settings-dialog .flex-line {
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import { Programmer } from './boards-service';
|
import { Programmer } from './boards-service';
|
||||||
|
|
||||||
|
export const CompilerWarningLiterals = ['None', 'Default', 'More', 'All'] as const;
|
||||||
|
export type CompilerWarnings = typeof CompilerWarningLiterals[number];
|
||||||
|
|
||||||
export const CoreServicePath = '/services/core-service';
|
export const CoreServicePath = '/services/core-service';
|
||||||
export const CoreService = Symbol('CoreService');
|
export const CoreService = Symbol('CoreService');
|
||||||
export interface CoreService {
|
export interface CoreService {
|
||||||
compile(options: CoreService.Compile.Options & Readonly<{ exportBinaries?: boolean }>): Promise<void>;
|
compile(options: CoreService.Compile.Options & Readonly<{ exportBinaries?: boolean, compilerWarnings?: CompilerWarnings }>): Promise<void>;
|
||||||
upload(options: CoreService.Upload.Options): Promise<void>;
|
upload(options: CoreService.Upload.Options): Promise<void>;
|
||||||
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
|
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
|
||||||
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;
|
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;
|
||||||
|
@ -2,7 +2,7 @@ import { FileUri } from '@theia/core/lib/node/file-uri';
|
|||||||
import { inject, injectable } from 'inversify';
|
import { inject, injectable } from 'inversify';
|
||||||
import { relative } from 'path';
|
import { relative } from 'path';
|
||||||
import * as jspb from 'google-protobuf';
|
import * as jspb from 'google-protobuf';
|
||||||
import { CoreService } from '../common/protocol/core-service';
|
import { CompilerWarnings, CoreService } from '../common/protocol/core-service';
|
||||||
import { CompileReq, CompileResp } from './cli-protocol/commands/compile_pb';
|
import { CompileReq, CompileResp } from './cli-protocol/commands/compile_pb';
|
||||||
import { CoreClientAware } from './core-client-provider';
|
import { CoreClientAware } from './core-client-provider';
|
||||||
import { UploadReq, UploadResp, BurnBootloaderReq, BurnBootloaderResp, UploadUsingProgrammerReq, UploadUsingProgrammerResp } from './cli-protocol/commands/upload_pb';
|
import { UploadReq, UploadResp, BurnBootloaderReq, BurnBootloaderResp, UploadUsingProgrammerReq, UploadUsingProgrammerResp } from './cli-protocol/commands/upload_pb';
|
||||||
@ -22,31 +22,34 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
|
|||||||
@inject(NotificationServiceServer)
|
@inject(NotificationServiceServer)
|
||||||
protected readonly notificationService: NotificationServiceServer;
|
protected readonly notificationService: NotificationServiceServer;
|
||||||
|
|
||||||
async compile(options: CoreService.Compile.Options & { exportBinaries?: boolean }): Promise<void> {
|
async compile(options: CoreService.Compile.Options & { exportBinaries?: boolean, compilerWarnings?: CompilerWarnings }): Promise<void> {
|
||||||
const { sketchUri, fqbn } = options;
|
const { sketchUri, fqbn, compilerWarnings } = options;
|
||||||
const sketchPath = FileUri.fsPath(sketchUri);
|
const sketchPath = FileUri.fsPath(sketchUri);
|
||||||
|
|
||||||
const coreClient = await this.coreClient();
|
const coreClient = await this.coreClient();
|
||||||
const { client, instance } = coreClient;
|
const { client, instance } = coreClient;
|
||||||
|
|
||||||
const compilerReq = new CompileReq();
|
const compileReq = new CompileReq();
|
||||||
compilerReq.setInstance(instance);
|
compileReq.setInstance(instance);
|
||||||
compilerReq.setSketchpath(sketchPath);
|
compileReq.setSketchpath(sketchPath);
|
||||||
if (fqbn) {
|
if (fqbn) {
|
||||||
compilerReq.setFqbn(fqbn);
|
compileReq.setFqbn(fqbn);
|
||||||
}
|
}
|
||||||
compilerReq.setOptimizefordebug(options.optimizeForDebug);
|
if (compilerWarnings) {
|
||||||
compilerReq.setPreprocess(false);
|
compileReq.setWarnings(compilerWarnings.toLowerCase());
|
||||||
compilerReq.setVerbose(options.verbose);
|
}
|
||||||
compilerReq.setQuiet(false);
|
compileReq.setOptimizefordebug(options.optimizeForDebug);
|
||||||
|
compileReq.setPreprocess(false);
|
||||||
|
compileReq.setVerbose(options.verbose);
|
||||||
|
compileReq.setQuiet(false);
|
||||||
if (typeof options.exportBinaries === 'boolean') {
|
if (typeof options.exportBinaries === 'boolean') {
|
||||||
const exportBinaries = new BoolValue();
|
const exportBinaries = new BoolValue();
|
||||||
exportBinaries.setValue(options.exportBinaries);
|
exportBinaries.setValue(options.exportBinaries);
|
||||||
compilerReq.setExportBinaries(exportBinaries);
|
compileReq.setExportBinaries(exportBinaries);
|
||||||
}
|
}
|
||||||
this.mergeSourceOverrides(compilerReq, options);
|
this.mergeSourceOverrides(compileReq, options);
|
||||||
|
|
||||||
const result = client.compile(compilerReq);
|
const result = client.compile(compileReq);
|
||||||
try {
|
try {
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
result.on('data', (cr: CompileResp) => {
|
result.on('data', (cr: CompileResp) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user