Skip to content

Commit

Permalink
ATL-66: Added compiler warnings.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta authored and kittaakos committed Feb 25, 2021
1 parent 057904d commit 86be874
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 25 deletions.
15 changes: 8 additions & 7 deletions arduino-ide-extension/src/browser/arduino-preferences.ts
@@ -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',
Expand All @@ -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.',
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -80,14 +80,16 @@ 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,
fqbn,
optimizeForDebug: this.editorMode.compileForDebug,
verbose,
exportBinaries,
sourceOverride
sourceOverride,
compilerWarnings
});
this.messageService.info('Done compiling.', { timeout: 1000 });
} catch (e) {
Expand Down
25 changes: 24 additions & 1 deletion arduino-ide-extension/src/browser/settings.tsx
Expand Up @@ -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`
Expand All @@ -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`
Expand Down Expand Up @@ -87,6 +88,7 @@ export class SettingsService {
interfaceScale,
// checkForUpdates,
verboseOnCompile,
compilerWarnings,
verboseOnUpload,
verifyAfterUpload,
enableLsLogs,
Expand All @@ -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),
Expand All @@ -114,6 +117,7 @@ export class SettingsService {
interfaceScale,
// checkForUpdates,
verboseOnCompile,
compilerWarnings,
verboseOnUpload,
verifyAfterUpload,
enableLsLogs,
Expand Down Expand Up @@ -175,6 +179,7 @@ export class SettingsService {
interfaceScale,
// checkForUpdates,
verboseOnCompile,
compilerWarnings,
verboseOnUpload,
verifyAfterUpload,
enableLsLogs,
Expand All @@ -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),
Expand Down Expand Up @@ -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'>
Expand Down Expand Up @@ -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'>
Expand Down Expand Up @@ -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 });
};
Expand Down
Expand Up @@ -4,7 +4,7 @@

.arduino-settings-dialog .content {
padding: 5px;
height: 250px;
height: 270px;
}

.arduino-settings-dialog .flex-line {
Expand Down
5 changes: 4 additions & 1 deletion arduino-ide-extension/src/common/protocol/core-service.ts
@@ -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>;
Expand Down
31 changes: 17 additions & 14 deletions arduino-ide-extension/src/node/core-service-impl.ts
Expand Up @@ -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';
Expand All @@ -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) => {
Expand Down

0 comments on commit 86be874

Please sign in to comment.