ATL-66: Added compiler warnings.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2021-02-24 11:52:29 +01:00 committed by Akos Kitta
parent 057904d38d
commit 86be874bb0
6 changed files with 57 additions and 25 deletions

View File

@ -1,11 +1,6 @@
import { interfaces } from 'inversify';
import {
createPreferenceProxy,
PreferenceProxy,
PreferenceService,
PreferenceContribution,
PreferenceSchema
} from '@theia/core/lib/browser/preferences';
import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser/preferences';
import { CompilerWarningLiterals, CompilerWarnings } from '../common/protocol';
export const ArduinoConfigSchema: PreferenceSchema = {
'type': 'object',
@ -20,6 +15,11 @@ export const ArduinoConfigSchema: PreferenceSchema = {
'description': 'True for verbose compile output. False by default',
'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': {
'type': 'boolean',
'description': 'True for verbose upload output. False by default.',
@ -50,6 +50,7 @@ export const ArduinoConfigSchema: PreferenceSchema = {
export interface ArduinoConfiguration {
'arduino.language.log': boolean;
'arduino.compile.verbose': boolean;
'arduino.compile.warnings': CompilerWarnings;
'arduino.upload.verbose': boolean;
'arduino.upload.verify': boolean;
'arduino.window.autoScale': boolean;

View File

@ -80,6 +80,7 @@ export class VerifySketch extends SketchContribution {
this.sourceOverride()
]);
const verbose = this.preferences.get('arduino.compile.verbose');
const compilerWarnings = this.preferences.get('arduino.compile.warnings');
this.outputChannelManager.getChannel('Arduino').clear();
await this.coreService.compile({
sketchUri: sketch.uri,
@ -87,7 +88,8 @@ export class VerifySketch extends SketchContribution {
optimizeForDebug: this.editorMode.compileForDebug,
verbose,
exportBinaries,
sourceOverride
sourceOverride,
compilerWarnings
});
this.messageService.info('Done compiling.', { timeout: 1000 });
} catch (e) {

View File

@ -18,7 +18,7 @@ import { DisposableCollection } from '@theia/core/lib/common/disposable';
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
import { AbstractDialog, DialogProps, PreferenceService, PreferenceScope, DialogError, ReactWidget } from '@theia/core/lib/browser';
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 {
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
checkForUpdates?: boolean; // `arduino.ide.autoUpdate`
verboseOnCompile: boolean; // `arduino.compile.verbose`
compilerWarnings: CompilerWarnings; // `arduino.compile.warnings`
verboseOnUpload: boolean; // `arduino.upload.verbose`
verifyAfterUpload: boolean; // `arduino.upload.verify`
enableLsLogs: boolean; // `arduino.language.log`
@ -87,6 +88,7 @@ export class SettingsService {
interfaceScale,
// checkForUpdates,
verboseOnCompile,
compilerWarnings,
verboseOnUpload,
verifyAfterUpload,
enableLsLogs,
@ -99,6 +101,7 @@ export class SettingsService {
this.preferenceService.get<number>('arduino.window.zoomLevel', 0),
// this.preferenceService.get<string>('arduino.ide.autoUpdate', 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.verify', true),
this.preferenceService.get<boolean>('arduino.language.log', true),
@ -114,6 +117,7 @@ export class SettingsService {
interfaceScale,
// checkForUpdates,
verboseOnCompile,
compilerWarnings,
verboseOnUpload,
verifyAfterUpload,
enableLsLogs,
@ -175,6 +179,7 @@ export class SettingsService {
interfaceScale,
// checkForUpdates,
verboseOnCompile,
compilerWarnings,
verboseOnUpload,
verifyAfterUpload,
enableLsLogs,
@ -198,6 +203,7 @@ export class SettingsService {
this.preferenceService.set('arduino.window.zoomLevel', interfaceScale, 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.warnings', compilerWarnings, PreferenceScope.User),
this.preferenceService.set('arduino.upload.verbose', verboseOnUpload, PreferenceScope.User),
this.preferenceService.set('arduino.upload.verify', verifyAfterUpload, 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'>Theme:</div>
<div className='flex-line'>Show verbose output during:</div>
<div className='flex-line'>Compiler warnings:</div>
</div>
<div className='column'>
<div className='flex-line'>
@ -321,6 +328,14 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
upload
</label>
</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>
<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>) => {
this.setState({ verboseOnCompile: event.target.checked });
};

View File

@ -4,7 +4,7 @@
.arduino-settings-dialog .content {
padding: 5px;
height: 250px;
height: 270px;
}
.arduino-settings-dialog .flex-line {

View File

@ -1,9 +1,12 @@
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 CoreService = Symbol('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>;
uploadUsingProgrammer(options: CoreService.Upload.Options): Promise<void>;
burnBootloader(options: CoreService.Bootloader.Options): Promise<void>;

View File

@ -2,7 +2,7 @@ import { FileUri } from '@theia/core/lib/node/file-uri';
import { inject, injectable } from 'inversify';
import { relative } from 'path';
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 { CoreClientAware } from './core-client-provider';
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)
protected readonly notificationService: NotificationServiceServer;
async compile(options: CoreService.Compile.Options & { exportBinaries?: boolean }): Promise<void> {
const { sketchUri, fqbn } = options;
async compile(options: CoreService.Compile.Options & { exportBinaries?: boolean, compilerWarnings?: CompilerWarnings }): Promise<void> {
const { sketchUri, fqbn, compilerWarnings } = options;
const sketchPath = FileUri.fsPath(sketchUri);
const coreClient = await this.coreClient();
const { client, instance } = coreClient;
const compilerReq = new CompileReq();
compilerReq.setInstance(instance);
compilerReq.setSketchpath(sketchPath);
const compileReq = new CompileReq();
compileReq.setInstance(instance);
compileReq.setSketchpath(sketchPath);
if (fqbn) {
compilerReq.setFqbn(fqbn);
compileReq.setFqbn(fqbn);
}
compilerReq.setOptimizefordebug(options.optimizeForDebug);
compilerReq.setPreprocess(false);
compilerReq.setVerbose(options.verbose);
compilerReq.setQuiet(false);
if (compilerWarnings) {
compileReq.setWarnings(compilerWarnings.toLowerCase());
}
compileReq.setOptimizefordebug(options.optimizeForDebug);
compileReq.setPreprocess(false);
compileReq.setVerbose(options.verbose);
compileReq.setQuiet(false);
if (typeof options.exportBinaries === 'boolean') {
const exportBinaries = new BoolValue();
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 {
await new Promise<void>((resolve, reject) => {
result.on('data', (cr: CompileResp) => {