Skip to content

Commit

Permalink
Merge pull request #30 from runtimeverification/raoul/build-on-demand
Browse files Browse the repository at this point in the history
Auto build when files change.
  • Loading branch information
RaoulSchaffranek authored Jan 13, 2025
2 parents 574345a + 1753732 commit 4f8b102
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 72 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the "Simbolik VSCode" extension will be documented in this file.

## [5.0.0] - 2025-01-13

- Simbolik only recompiles the contracts if the source code has changed

## [4.1.0] - 2024-12-19

- The web version now offers experimental support for debugging transactions from BuildBear sandboxes.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Visit our Documentation: https://docs.runtimeverification.com/simbolik
Join our Discord: https://discord.gg/jnvEeDxW
Join our TG group: https://t.me/rv_simbolik

<img src="https://github.com/runtimeverification/simbolik-vscode/raw/master/images/simbolik-screenshot-1.png?raw=true" width="800" />

## Features

- **Step-by-step debugging**: Debug your Solidity smart contracts line by line.
Expand Down
Binary file added images/simbolik-screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 59 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 10 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"publisher": "runtimeverification",
"description": "Advanced Solidity and EVM Debugger",
"version": "4.1.0",
"version": "5.0.0",
"engines": {
"vscode": "^1.79.0"
},
Expand Down Expand Up @@ -63,29 +63,23 @@
"order": 2
},
"simbolik.autobuild": {
"type": "boolean",
"default": true,
"description": "If set to true, the debugger will automatically build the project before starting the debugger.",
"type": "string",
"enum": ["never", "on-change", "always"],
"default": "on-change",
"markdownEnumDescriptions": [
"Never build the project automatically. This is useful when you're using `forge build --watch` to build the project.",
"Build the project when the source code changes.",
"Always build the project before every debugging session."
],
"description": "Chose when Simbolik should build the project.",
"order": 3
},
"simbolik.incremental-build": {
"type": "boolean",
"default": false,
"description": "If autobuild is enabled and incremental-build is set to true, the debugger will use incremental builds. Notice, that the support for incremental builds is experimental and sometimes leads to unexpected behavior.",
"order": 4
},
"simbolik.stop-at-first-opcode": {
"type": "boolean",
"description": "If set to true, the debugger will stop at the first opcode. Otherwise it will stop at the function entry. Disabling this option is experimental and may lead to unexpected behavior.",
"default": true,
"order": 5
},
"simbolik.enable-parameters": {
"type": "boolean",
"default": false,
"description": "If set to true, the debugger will show a debug button above functions with parameters. Notice, that this requires a backend that supports parameter debugging. The default Foundry backend does not support parameter debugging.",
"order": 6
},
"simbolik.show-sourcemaps": {
"type": "boolean",
"default": false,
Expand Down
5 changes: 2 additions & 3 deletions src/CodelensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export class CodelensProvider implements vscode.CodeLensProvider {
}

private getFunctions(ast: any): [ContractDefinition, FunctionDefinition][] {
const enableParameters = getConfigValue('enable-parameters', false);
const results: [ContractDefinition, FunctionDefinition][] = [];
parser.visit(ast, {
ContractDefinition: contract => {
Expand All @@ -73,12 +72,12 @@ export class CodelensProvider implements vscode.CodeLensProvider {
}
},
});
if (enableParameters || !hasConstructorArgs) {
if (!hasConstructorArgs) {
parser.visit(contract, {
FunctionDefinition: fn => {
if (
this.isExecutable(fn) &&
(enableParameters || fn.parameters.length === 0)
fn.parameters.length === 0
) {
results.push([contract, fn]);
}
Expand Down
34 changes: 34 additions & 0 deletions src/WorkspaceWatcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as vscode from 'vscode';

/**
* Watches for changes to Solidity files in the workspace.
* This is used to determine when a project needs to be recompiled.
*/
export
class WorkspaceWatcher {
constructor(
private _hasChanges : boolean = false
) {
vscode.workspace.onDidSaveTextDocument(document => {
if (document.languageId === 'solidity') {
this._hasChanges = true;
}
});
vscode.workspace.onDidCreateFiles(event => {
if (event.files.some(uri => uri.fsPath.endsWith('.sol'))) {
this._hasChanges = true;
}
});
vscode.workspace.onDidRenameFiles(event => {
if (event.files.some(uri => uri.newUri.fsPath.endsWith('.sol'))) {
this._hasChanges = true;
}
});
}
hasChanges() : boolean {
return this._hasChanges;
}
reset() {
this._hasChanges = false;
}
}
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {SolidityDebugAdapterDescriptorFactory} from './DebugAdapter';
import {startDebugging} from './startDebugging';
import {KastProvider, viewKast} from './KastProvider';
import {getConfigValue} from './utils';
import { WorkspaceWatcher } from './WorkspaceWatcher';

const outputChannel = vscode.window.createOutputChannel(
'Simbolik Solidity Debugger',
Expand Down Expand Up @@ -35,9 +36,11 @@ export function activate(context: vscode.ExtensionContext) {
);
context.subscriptions.push(disposable);

const workspaceWatcher = new WorkspaceWatcher();

disposable = vscode.commands.registerCommand(
'simbolik.startDebugging',
(contract, method) => startDebugging(contract, method),
(contract, method) => startDebugging(contract, method, workspaceWatcher),
);
context.subscriptions.push(disposable);

Expand Down
3 changes: 1 addition & 2 deletions src/foundry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {parse as parseToml} from 'smol-toml';

export
function forgeBuildTask(file: vscode.Uri) {
const incrementalBuild = getConfigValue('incremental-build', false);
const forgePath = getConfigValue('forge-path', 'forge');
const cwd = file.with({path: file.path.split('/').slice(0, -1).join('/')}).fsPath;
const task = new vscode.Task(
Expand All @@ -23,7 +22,7 @@ function forgeBuildTask(file: vscode.Uri) {
'FOUNDRY_EXTRA_OUTPUT': '["storageLayout", "evm.bytecode.generatedSources", "evm.legacyAssembly", "evm.deployedBytecode.immutableReferences"]',
'FOUNDRY_BYTECODE_HASH': 'ipfs',
'FOUNDRY_CBOR_METADATA': 'true',
'FOUNDRY_FORCE': incrementalBuild ? 'false' : 'true',
'FOUNDRY_FORCE': 'true',
}
})
);
Expand Down
Loading

0 comments on commit 4f8b102

Please sign in to comment.