Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ All notable version changes will be recorded in this file.

***

### [v3.26.4] revision

**Improve**:
- `Project Diagnostics`: Add code action for stub func missed warning. (to auto fix gcc warning: "_xxx is not implemented and will always fail")
- `Toolchain Setup`: Goto eide tools folder by default when user start to select a location.

***

### [v3.26.3] revision

**New**:
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"homepage": "https://em-ide.com",
"license": "MIT",
"description": "A mcu development environment for 8051/AVR/STM8/Cortex-M/MIPS/RISC-V",
"version": "3.26.3",
"version": "3.26.4",
"preview": false,
"engines": {
"vscode": "^1.67.0"
Expand Down Expand Up @@ -538,6 +538,11 @@
}
],
"commands": [
{
"command": "eide.project.create_sys_stubs",
"category": "eide",
"title": "Create gcc system stubs for project"
},
{
"command": "eide.debug.start",
"category": "eide",
Expand Down
126 changes: 126 additions & 0 deletions res/data/gcc_posix_stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/times.h>

__attribute__((weak)) int _chown(const char *path, uid_t owner, gid_t group)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _execve(char *name, char **argv, char **env)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _fork(void)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _fstat(int fildes, struct stat *st)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _getpid(void)
{
errno = ENOSYS;
return -1;
}

struct timeval;

__attribute__((weak)) int _gettimeofday(struct timeval *ptimeval, void *ptimezone)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _isatty(int file)
{
errno = ENOSYS;
return 0;
}

__attribute__((weak)) int _kill(int pid, int sig)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _link(char *existing, char *new)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _lseek(int file, int ptr, int dir)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _open(char *file, int flags, int mode)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _close(int fildes)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _read(int file, char *ptr, int len)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _readlink(const char *path, char *buf, size_t bufsize)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _stat(const char *file, struct stat *st)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _symlink(const char *path1, const char *path2)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) clock_t _times(struct tms *buf)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _unlink(char *name)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _wait(int *status)
{
errno = ENOSYS;
return -1;
}

__attribute__((weak)) int _write(int file, char *ptr, int len)
{
errno = ENOSYS;
return -1;
}
3 changes: 3 additions & 0 deletions src/EIDEProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
return (<FileGroup[]>this.sourceRoots.getFileGroups()).concat(this.virtualSource.getFileGroups());
}

/**
* @note Not contains excluded source files. if you want to list all sources, please use getFileGroups
*/
getAllSources(): { path: string, virtualPath?: string; }[] {

const srcList: { path: string, virtualPath?: string; }[] = [];
Expand Down
128 changes: 124 additions & 4 deletions src/EIDEProjectExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ import {
txt_no,
remove_this_item,
view_str$prompt$filesOptionsComment,
view_str$virual_doc_provider_banner
view_str$virual_doc_provider_banner,
view_str$missed_stubs_added
} from './StringTable';
import { CodeBuilder, BuildOptions } from './CodeBuilder';
import { ExceptionToMessage, newMessage } from './Message';
Expand Down Expand Up @@ -128,7 +129,7 @@ import {
} from 'vscode-cpptools';
import * as eclipseParser from './EclipseProjectParser';
import { isArray } from 'util';
import { parseIarCompilerLog, CompilerDiagnostics, parseGccCompilerLog, parseArmccCompilerLog, parseKeilc51CompilerLog, parseSdccCompilerLog, parseCosmicStm8CompilerLog } from './ProblemMatcher';
import { parseIarCompilerLog, CompilerDiagnostics, parseGccCompilerLog, parseArmccCompilerLog, parseKeilc51CompilerLog, parseSdccCompilerLog, parseCosmicStm8CompilerLog, EideDiagnosticCode } from './ProblemMatcher';
import * as iarParser from './IarProjectParser';
import * as ArmCpuUtils from './ArmCpuUtils';
import { ShellFlasherIndexItem } from './WebInterface/WebInterface';
Expand Down Expand Up @@ -3488,6 +3489,16 @@ export class ProjectExplorer implements CustomConfigurationProvider {
this._event.emit(event, arg);
}

/**
*
* @param callbk return true to break foreach
*/
foreachProjects(callbk: (val: AbstractProject, index: number) => boolean | undefined) {
this.dataProvider.traverseProjects((prj, idx) => {
return callbk(prj, idx);
});
}

getProjectByTreeItem(prjItem?: ProjTreeItem): AbstractProject | undefined {
return prjItem instanceof ProjTreeItem ?
this.dataProvider.GetProjectByIndex(prjItem.val.projectIndex) :
Expand Down Expand Up @@ -3518,6 +3529,36 @@ export class ProjectExplorer implements CustomConfigurationProvider {

// -------

createSysStubs(prjuid: string | undefined) {

const prj = prjuid
? this.dataProvider.getProjectByUid(prjuid)
: this.dataProvider.getActiveProject();
if (!prj)
return; // no project

const tarFile = File.from(prj.getRootDir().path, 'sys_stubs.c');
for (const grp of prj.getFileGroups()) {
for (const e of grp.files) {
if (tarFile.path === e.file.path)
return; // it's existed, abort.
}
}

try {
const srcFile = File.from(ResManager.instance().getAppDataDir().path, 'gcc_posix_stubs.c');
tarFile.Write(srcFile.Read());
const vSrcManger = prj.getVirtualSourceManager();
vSrcManger.addFile(VirtualSource.rootName, tarFile.path);
// clear diags
const uri = vscode.Uri.file(File.from(prj.getOutputFolder().path, 'compiler.log').path);
this.compiler_diags.get(prj.getUid())?.delete(uri);
GlobalEvent.show_msgbox('Info', view_str$missed_stubs_added.replace('{}', tarFile.name));
} catch (error) {
GlobalEvent.show_msgbox('Error', error);
}
}

openLibsGeneratorConfig(prjItem?: ProjTreeItem) {

const proj = this.getProjectByTreeItem(prjItem);
Expand Down Expand Up @@ -3871,13 +3912,52 @@ export class ProjectExplorer implements CustomConfigurationProvider {
}
}

private parseLdLogs(file: File): {content: string, idx: number}[] {

const logLines: {content: string, idx: number}[] = [];

try {

const fileLines = file.Read().split(/\r\n|\n/);

let logStarted = false;
let logEnd = false;

fileLines.forEach((line, idx) => {

if (logEnd)
return;

if (!logStarted) {
if (line.startsWith('>>> ld')) {
logStarted = true;
}
} else {
if (line.startsWith('>>>')) {
logEnd = true;
} else {
logLines.push({
content: line,
idx
});
}
}
});

} catch (error) {
// nothing todo
}

return logLines;
}

private updateCompilerDiagsAfterBuild(prj: AbstractProject) {

let diag_res: CompilerDiagnostics | undefined;

try {
const logFile = File.from(prj.getOutputFolder().path, 'compiler.log');

const logFile = File.fromArray([prj.getOutputFolder().path, 'compiler.log']);
try {

switch (prj.getToolchain().name) {
case 'IAR_ARM':
Expand Down Expand Up @@ -3906,6 +3986,46 @@ export class ProjectExplorer implements CustomConfigurationProvider {
GlobalEvent.log_warn(error);
}

if (isGccFamilyToolchain(prj.toolchainName())) {
// examples:
// >>> ld
// ....
// warning: _getpid is not implemented and will always fail
const allStubs = [
'_chown', '_execve', '_fork', '_fstat', '_getpid',
'_gettimeofday', '_isatty', '_kill', '_link', '_lseek',
'_open', '_close', '_read', '_readlink', '_stat', '_symlink', '_times', '_unlink', '_wait', '_write',
];
const missedStubs: {name: string, lineIdx: number}[] = [];

this.parseLdLogs(logFile).forEach(line => {
const m = /warning: (\w+) is not implemented and will always fail/.exec(line.content);
if (m && m.length > 1) {
const name = m[1];
if (allStubs.includes(name))
missedStubs.push({ name, lineIdx: line.idx });
}
});

if (missedStubs.length > 0) {
if (diag_res == undefined)
diag_res = {};
const diags: vscode.Diagnostic[] = [];
for (const ele of missedStubs) {
const range = new vscode.Range(
new vscode.Position(ele.lineIdx, 0),
new vscode.Position(ele.lineIdx, 54));
const diag = new vscode.Diagnostic(range,
`warning: ${ele.name} is not implemented and will always fail`,
vscode.DiagnosticSeverity.Warning);
diag.source = "eide";
diag.code = EideDiagnosticCode.GCC_SYS_STUB_MISSED;
diags.push(diag);
}
diag_res[logFile.path] = diags;
}
}

if (diag_res) {

const uid = prj.getUid();
Expand Down
20 changes: 12 additions & 8 deletions src/OperationExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,28 +923,28 @@ export class OperationExplorer {
if (tool && !tool.no_binaries) { /* have online package */

const pickItems: vscode.QuickPickItem[] = [
{
label: 'Online',
description: 'Download from website and install',
detail: view_str$prompt$tool_install_mode_online
},
{
label: 'Local',
description: 'Use existed installation directory',
detail: view_str$prompt$tool_install_mode_local
},
{
label: 'Online',
description: 'Download from website and install',
detail: view_str$prompt$tool_install_mode_online
}
];

const onlineInstall = await vscode.window.showQuickPick(pickItems, {
const select = await vscode.window.showQuickPick(pickItems, {
canPickMany: false,
placeHolder: view_str$prompt$select_tool_install_mode
});

if (onlineInstall == undefined) {
if (select == undefined) {
return;
}

if (onlineInstall.label == 'Online') {
if (select.label == 'Online') {
await resInstaller.installTool(item.type);
return;
}
Expand Down Expand Up @@ -973,6 +973,10 @@ export class OperationExplorer {
};
}

if (item.type !== 'Keil_C51' && !item.label.includes('MDK') &&
item.type !== 'IAR_ARM' && item.type !== 'IAR_STM8')
dialogOption.defaultUri = vscode.Uri.file(ResManager.instance().getEideToolsInstallDir());

const path = await vscode.window.showOpenDialog(dialogOption);
if (path === undefined || path.length === 0) {
return;
Expand Down
Loading