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
11 changes: 6 additions & 5 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
workflow_call:
inputs:
os_target:
description: "target architecture" # linux-x64, darwin-arm64
description: "target architecture" # linux-x64, darwin-arm64, win32-x64
required: true
type: string
os_name:
description: "operating system" # ubuntu-latest, macos-latest
description: "operating system" # ubuntu-latest, macos-latest, windows-latest
required: true
type: string
secrets:
Expand All @@ -29,10 +29,10 @@ jobs:
node-version: 20.x
cache: "npm"

- name: Download fastedge-cli Artifact
- name: Download fastedge-run Artifact
uses: actions/download-artifact@v4
with:
name: fastedge-cli-${{ inputs.os_name }}-artifact
name: fastedge-run-${{ inputs.os_name }}-artifact
path: fastedge-cli

- name: Install dependencies
Expand Down Expand Up @@ -60,8 +60,9 @@ jobs:
npx vsce ls

- name: Ensure extension is exectuable
if: ${{ inputs.os_target != 'win32-x64' }}
run: |
chmod +x ./fastedge-cli/cli-${{ inputs.os_target }}
chmod +x ./fastedge-cli/fastedge-run-${{ inputs.os_target }}

- name: Package extension
run: |
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
echo "Creating new release tag: $TAG_VERSION""
git tag -a $TAG_VERSION" -m "Release $TAG_VERSION""
git push origin $TAG_VERSION"
echo "has_tag=false" >> $GITHUB_OUTPUT
echo "has_tag=true" >> $GITHUB_OUTPUT
else
TAG_VERSION=${GITHUB_REF#refs/tags/}
if [[ ! "$TAG_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$ ]]; then
Expand Down Expand Up @@ -74,3 +74,13 @@ jobs:
os_name: macos-latest
secrets:
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}

build_windows_extension:
uses: ./.github/workflows/build-extension.yml
needs: ["check_tags", "build_darwin_extension"]
if: ${{ needs.check_tags.outputs.has_release_tag == 'true' }}
with:
os_target: win32-x64
os_name: windows-latest
secrets:
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}
45 changes: 33 additions & 12 deletions .github/workflows/download-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ jobs:
include:
- target: linux-x64
os: ubuntu-latest
file_suffix: x86_64-unknown-linux-gnu
file_name: x86_64-unknown-linux-gnu
file_ext: tar.gz

- target: darwin-arm64
os: macos-latest
file_suffix: aarch64-apple-darwin
file_name: aarch64-apple-darwin
file_ext: tar.gz

- target: win32
os: windows-latest
file_name: x86_64-pc-windows-msvc
file_ext: zip

steps:
- name: Checkout this repository
Expand All @@ -53,29 +60,43 @@ jobs:
- name: Download FastEdge-lib assets
run: |
echo "Downloading version $VERSION for ${{ matrix.os }}"
curl -L -o cli-$VERSION-${{ matrix.file_suffix }}.tar.gz https://github.com/G-Core/FastEdge-lib/releases/download/$VERSION/cli-$VERSION-${{ matrix.file_suffix }}.tar.gz
curl -L -o cli-$VERSION-${{ matrix.file_suffix }}.tar.gz.sha256 https://github.com/G-Core/FastEdge-lib/releases/download/$VERSION/cli-$VERSION-${{ matrix.file_suffix }}.tar.gz.sha256
curl -L -o fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }} https://github.com/G-Core/FastEdge-lib/releases/download/$VERSION/fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}
curl -L -o fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}.sha256 https://github.com/G-Core/FastEdge-lib/releases/download/$VERSION/fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}.sha256

- name: Convert Windows SHA256 to Linux format
if: ${{ matrix.os == 'windows-latest' }}
run: |
HASH=$(grep -oP '^[0-9a-f]{64}' fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}.sha256)
echo "$HASH fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}" > fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}.sha256

- name: Verify checksum
run: |
sha256sum -c cli-$VERSION-${{ matrix.file_suffix }}.tar.gz.sha256
sha256sum -c fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}.sha256

- name: Extract fastedge-cli
- name: Extract fastedge-run
run: |
tar -xzf cli-$VERSION-${{ matrix.file_suffix }}.tar.gz
if [[ ${{ matrix.os }} == 'windows-latest' ]]; then
unzip fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}
else
tar -xzf fastedge-run-$VERSION-${{ matrix.file_name }}.${{ matrix.file_ext }}
fi

- name: Rename and copy fastedge-cli
- name: Rename and copy fastedge-run
run: |
cp cli-$VERSION-${{ matrix.file_suffix }}/cli ./fastedge-cli/cli-${{ matrix.target }}
if [[ ${{ matrix.os }} == 'windows-latest' ]]; then
cp fastedge-run-$VERSION-${{ matrix.file_name }}/fastedge-run.exe ./fastedge-cli/fastedge-run.exe
else
cp fastedge-run-$VERSION-${{ matrix.file_name }}/fastedge-run ./fastedge-cli/fastedge-run-${{ matrix.target }}
fi

- name: Create a RELEASE.json file
run: |
echo "{\"fastedge_cli_version\": \"$VERSION\"}" > fastedge-cli/METADATA.json
echo "{\"fastedge_run_version\": \"$VERSION\"}" > fastedge-cli/METADATA.json

- name: Upload fastedge-cli Artifact
- name: Upload fastedge-run Artifact
uses: actions/upload-artifact@v4
with:
name: fastedge-cli-${{ matrix.os }}-artifact
name: fastedge-run-${{ matrix.os }}-artifact
retention-days: 1
path: |
fastedge-cli/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In order for this extension to compile and run any code, you will need to have t

Examples:

- Rust: `rustup target add wasm32-wasi`
- Rust: `rustup target add wasm32-wasip1`
- Javascript: `npm install --save-dev @gcoredev/fastedge-sdk-js`

More detail can be found in the SDK documentation above. 👆
Expand Down
8 changes: 4 additions & 4 deletions exampleFolder/package-lock.json

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

5 changes: 3 additions & 2 deletions exampleFolder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"type": "module",
"author": "Gordon Farquharson",
"devDependencies": {
"@gcoredev/fastedge-sdk-js": "^1.1.1",
"@gcoredev/fastedge-sdk-js": "^1.1.2",
"typescript": "^5.4.5"
}
},
"dependencies": {}
}
17 changes: 17 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
"typescript": "^5.4.5"
},
"dependencies": {
"toml": "^3.0.0",
"tree-kill": "^1.2.2",
"vscode-debugadapter": "^1.51.0",
"vscode-debugprotocol": "^1.51.0"
}
Expand Down
17 changes: 8 additions & 9 deletions src/BinaryDebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,23 @@ export class BinaryDebugConfigurationProvider

private getLauncherPath(extensionPath: string): string {
switch (os.platform()) {
// todo: add support for windows
// case "win32":
// return vscode.Uri.joinPath(
// vscode.Uri.file(extensionPath),
// "fastedge-cli",
// "cli.exe"
// ).fsPath;
case "win32":
return vscode.Uri.joinPath(
vscode.Uri.file(extensionPath),
"fastedge-cli",
"fastedge-run.exe"
).fsPath;
case "darwin":
return vscode.Uri.joinPath(
vscode.Uri.file(extensionPath),
"fastedge-cli",
"cli-darwin-arm64"
"fastedge-run-darwin-arm64"
).fsPath;
case "linux":
return vscode.Uri.joinPath(
vscode.Uri.file(extensionPath),
"fastedge-cli",
"cli-linux-x64"
"fastedge-run-linux-x64"
).fsPath;
default:
throw new Error("Unsupported platform");
Expand Down
33 changes: 22 additions & 11 deletions src/FastEdgeDebugSession.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import * as os from "os";
import * as vscode from "vscode";
import * as cp from "child_process";
import treeKill from "tree-kill";
import { DebugProtocol } from "vscode-debugprotocol";
import {
DebugSession,
OutputEvent,
TerminatedEvent,
} from "vscode-debugadapter";
import { DebugProtocol } from "vscode-debugprotocol";
import { spawn, ChildProcess } from "child_process";

import { DebugConfig } from "./BinaryDebugConfigurationProvider";

import { compileActiveEditorsBinary } from "./compiler";

export class FastEdgeDebugSession extends DebugSession {
private childProcess: cp.ChildProcess | undefined;
private childProcess: ChildProcess | undefined;
private breakpoints: vscode.Breakpoint[] = [];
private disabledBreakpoints: vscode.Breakpoint[] = [];

Expand Down Expand Up @@ -84,7 +87,6 @@ export class FastEdgeDebugSession extends DebugSession {
_args: unknown
): Promise<void> {
const args: DebugConfig = _args as DebugConfig;

// Clear the debug console before starting a new session
this.clearDebugConsole();

Expand Down Expand Up @@ -168,22 +170,27 @@ export class FastEdgeDebugSession extends DebugSession {
execArgs.push(...this.injectVariables("env", args.env));
}

this.childProcess = cp.spawn(cli, execArgs, {
const isWindows = os.platform() === "win32";
const shell = isWindows ? "cmd.exe" : "sh";

this.childProcess = spawn(cli, execArgs, {
shell,
stdio: ["ignore", "pipe", "pipe"],
env: {
RUST_LOG: loggingLevel,
...process.env, // Preserve existing environment variables
},
});

this.childProcess?.stdout?.on("data", (data) => {
this.childProcess?.stdout?.on("data", (data: Buffer) => {
this.logDebugConsole(data.toString(), "stdout");
});

this.childProcess?.stderr?.on("data", (data) => {
this.childProcess?.stderr?.on("data", (data: Buffer) => {
this.logDebugConsole(data.toString(), "stderr");
});

this.childProcess?.on("close", (code) => {
this.childProcess?.on("close", (code: number) => {
this.sendEvent(new TerminatedEvent());
});

Expand All @@ -209,7 +216,7 @@ export class FastEdgeDebugSession extends DebugSession {
for (const key in vars) {
result.push(
type === "env" ? "--env" : "--headers",
`${key}=${vars[key]}`
`"${key}=${vars[key]}"`
);
}
return result;
Expand All @@ -220,15 +227,19 @@ export class FastEdgeDebugSession extends DebugSession {
args: DebugProtocol.DisconnectArguments
): void {
if (this.childProcess) {
this.childProcess.kill();
if (this.childProcess?.pid) {
treeKill(this.childProcess.pid);
} else {
this.childProcess.kill();
}
this.childProcess = undefined;
}
// Remove all disabled breakpoints
vscode.debug.removeBreakpoints(this.disabledBreakpoints);
// Add original breakpoints
vscode.debug.addBreakpoints(this.breakpoints);

this.logDebugConsole("FastEdge App stopping...");
this.logDebugConsole("FastEdge App stopping...\n");
this.sendResponse(response);
}
}
12 changes: 10 additions & 2 deletions src/compiler/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from "vscode";
import path from "node:path";

import { compileJavascriptBinary } from "./jsBuild";
import { compileRustAndFindBinary } from "./rustBuild";
Expand Down Expand Up @@ -45,11 +46,18 @@ async function compileActiveEditorsBinary(

if (activeFileLanguage === "javascript") {
return {
path: await compileJavascriptBinary(activeFile, debugContext),
path: await compileJavascriptBinary(
activeFile,
debugContext,
logDebugConsole
),
lang: activeFileLanguage,
};
} else if (activeFileLanguage === "rust") {
const activeFilePath = activeFile?.slice(0, activeFile?.lastIndexOf("/"));
const activeFilePath = activeFile?.slice(
0,
activeFile?.lastIndexOf(path.sep)
);
return {
path: await compileRustAndFindBinary(activeFilePath, logDebugConsole),
lang: activeFileLanguage,
Expand Down
Loading