Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bebop-tools wasi (node) #292

Merged
merged 1 commit into from
Jan 19, 2024
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: 4 additions & 4 deletions .github/workflows/build-bebopc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-quality: 'preview'
dotnet-quality: "preview"
- name: Restore Solution
run: dotnet restore

Expand Down Expand Up @@ -112,8 +112,8 @@ jobs:
path: ${{env.BUILD_ZIP_ARTIFACT_ARM64}}

- if: matrix.os == 'ubuntu-22.04' && matrix.BUILD_WASI
name: Upload WASI Build
name: Upload WASI_WASM Build
uses: actions/upload-artifact@v4
with:
name: wasm-wasi
path: ${{env.BUILD_ARTIFACT_WASI}}
name: wasi-wasm
path: ${{env.BUILD_ARTIFACT_WASI}}
36 changes: 33 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ jobs:
- os: ubuntu-22.04
IDENTIFIER: linux
ARTIFACT: bebopc
BUILD_WASI: true
env:
CONFIGURATION: Release
BUILD_ARTIFACT_X86_64: ./bin/compiler/Release/publish/${{matrix.IDENTIFIER}}-x64/${{matrix.ARTIFACT}}
BUILD_ARTIFACT_ARM64: ./bin/compiler/Release/publish/${{matrix.IDENTIFIER}}-arm64/${{matrix.ARTIFACT}}
BUILD_ZIP_ARTIFACT_X86_64: ./bin/compiler/Release/publish/${{matrix.ARTIFACT}}-${{matrix.IDENTIFIER}}-x64.zip
BUILD_ZIP_ARTIFACT_ARM64: ./bin/compiler/Release/publish/${{matrix.ARTIFACT}}-${{matrix.IDENTIFIER}}-arm64.zip
BUILD_ARTIFACT_WASI: ./bin/compiler/Release/publish/wasi-wasm/AppBundle/${{matrix.ARTIFACT}}.wasm
steps:
- uses: actions/checkout@v4

Expand All @@ -51,11 +53,16 @@ jobs:
sudo apt-get update
sudo apt-get install clang zlib1g-dev libkrb5-dev libtinfo5

- if: matrix.os == 'ubuntu-22.04' && matrix.BUILD_WASI
name: Install WASI Dependencies
run: ./install-wasi.sh
working-directory: ./scripts/

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-quality: 'preview'
dotnet-quality: "preview"

- name: Build bebopc
run: |
Expand All @@ -64,6 +71,11 @@ jobs:
dotnet publish -c ${{env.CONFIGURATION}} -r ${{matrix.IDENTIFIER}}-arm64 -p:ReleaseVersion=${{ steps.dotenv.outputs.version }} -p:PublishTrimmed=false -p:PublishSingleFile=true --self-contained
working-directory: ./Compiler/

- if: matrix.os == 'ubuntu-22.04' && matrix.BUILD_WASI
name: Build bebopc for WASI
run: ./build-wasi.sh
working-directory: ./scripts/

- if: matrix.os == 'macos-latest'
name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
Expand Down Expand Up @@ -120,6 +132,13 @@ jobs:
name: ${{matrix.IDENTIFIER}}-arm64
path: ${{env.BUILD_ZIP_ARTIFACT_ARM64}}

- if: matrix.os == 'ubuntu-22.04' && matrix.BUILD_WASI
name: Upload WASI_WASM Build
uses: actions/upload-artifact@v4
with:
name: wasi-wasm
path: ${{env.BUILD_ARTIFACT_WASI}}

build-runtimes:
env:
NET_TEST_ROOT: ${{github.workspace}}/Laboratory/C#/Test
Expand All @@ -144,7 +163,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
dotnet-quality: 'preview'
dotnet-quality: "preview"

- name: Test .NET Runtime
run: |
Expand Down Expand Up @@ -275,6 +294,7 @@ jobs:
unzip -j -o ./osx-arm64/bebopc-osx-arm64.zip -d ${{env.BEBOPC_PATH}}/macos/arm64
unzip -j -o ./linux-x64/bebopc-linux-x64.zip -d ${{env.BEBOPC_PATH}}/linux/x64
unzip -j -o ./linux-arm64/bebopc-linux-arm64.zip -d ${{env.BEBOPC_PATH}}/linux/arm64
cp ./wasi-wasm/bebopc.wasm ${{env.BEBOPC_PATH}}/wasi/wasm

- name: Build NuGet Package
run: bash build.sh ${{ steps.dotenv.outputs.version }}
Expand Down Expand Up @@ -402,7 +422,7 @@ jobs:
run: |
npm install --global @vscode/vsce
vsce publish --packagePath ./vscode-bebop/bebop-lang-${{ steps.dotenv.outputs.version }}.vsix -p ${{ secrets.VSCE_TOKEN }}

- name: Publish Open VSX Extension
run: |
npm i -g ovsx
Expand Down Expand Up @@ -478,3 +498,13 @@ jobs:
asset_path: ./linux-arm64/bebopc-linux-arm64.zip
asset_name: bebopc-linux-arm64.zip
asset_content_type: application/zip

- name: Upload Compiler for WASM
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./wasi-wasm/bebopc.wasm
asset_name: bebopc.wasm
asset_content_type: application/wasm
28 changes: 23 additions & 5 deletions Compiler/Commands/RootCommand.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.CommandLine;
using System.IO;
using Core.Logging;
using Core.Meta;
using Spectre.Console;
using Spectre.Console.Json;

namespace Compiler.Commands;

Expand Down Expand Up @@ -33,7 +36,12 @@ public static int HandleCommand(ParseResult result)
/// <returns>An integer representing the status of the operation.</returns>
private static int ShowConfig(BebopConfig config)
{
DiagnosticLogger.Instance.WriteLine(config.ToJson());
var json = new JsonText(config.ToJson());

DiagnosticLogger.Instance.Out.Write(new Panel(json)
.Collapse()
.RoundedBorder()
.BorderColor(Color.Yellow));
return 0;
}

Expand All @@ -58,13 +66,23 @@ private static int ListSchemas(BebopConfig config)
/// <returns>An integer representing the status of the operation.</returns>
private static int InitProject()
{
var workingDirectory = Directory.GetCurrentDirectory();
var configPath = Path.GetFullPath(Path.Combine(workingDirectory, BebopConfig.ConfigFileName));
if (File.Exists(configPath))
try
{
var workingDirectory = Directory.GetCurrentDirectory();
var configPath = Path.GetFullPath(Path.Combine(workingDirectory, BebopConfig.ConfigFileName));
if (File.Exists(configPath))
{
DiagnosticLogger.Instance.Error.MarkupLine($"[maroon]{BebopConfig.ConfigFileName} already exists in the current directory.[/]");
return 1;
}
File.WriteAllText(configPath, BebopConfig.Default.ToJson());
}
catch (Exception ex)
{
DiagnosticLogger.Instance.Error.WriteException(ex);
return 1;
}
File.WriteAllText(configPath, BebopConfig.Default.ToJson());

return 0;
}
}
1 change: 1 addition & 0 deletions Compiler/Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.5" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="Spectre.Console.Json" Version="0.48.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.23407.1" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions Compiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@

var results = rootCommand.Parse(args);



results.Configuration.EnableDefaultExceptionHandler = false;
results.Configuration.ProcessTerminationTimeout = null;
if (results.GetValue<bool>(CliStrings.TraceFlag))
Expand Down
8 changes: 4 additions & 4 deletions Core/Logging/DiagnosticLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
private static DiagnosticLogger? _instance;
private LogFormatter _formatter;
private bool _traceEnabled;
private bool _diagnosticsSupressed;

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / test-dart

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / test-csharp

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / test-rust

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / build-compiler (ubuntu-22.04)

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / build-compiler (ubuntu-22.04)

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / build-compiler (macos-latest)

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used

Check warning on line 17 in Core/Logging/DiagnosticLogger.cs

View workflow job for this annotation

GitHub Actions / build-compiler (windows-latest)

The field 'DiagnosticLogger._diagnosticsSupressed' is assigned but its value is never used
private readonly IAnsiConsole _out;
private readonly IAnsiConsole _err;
public IAnsiConsole Out => _out;
Expand Down Expand Up @@ -94,16 +94,16 @@
{
case SpanException span:
WriteSpanDiagonstics(new List<SpanException>() { span });
return span.ErrorCode;
return 74;
case FileNotFoundException file:
WriteFileNotFoundDiagonstic(file);
return FileNotFound;
return 66;
case CompilerException compiler:
WriteCompilerDiagonstic(compiler);
return compiler.ErrorCode;
return 1;
default:
WriteBaseDiagonstic(exception);
return Unknown;
return 1;
}
}

Expand Down
1 change: 1 addition & 0 deletions Core/Logging/DiagonsticLogger.Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Core.Logging;

public partial class DiagnosticLogger
{

internal const int FileNotFound = 404;
internal const int Unknown = 1000;
public record Diagnostic(Severity Severity, string Message, int ErrorCode, Span? Span) { }
Expand Down
Empty file added Tools/bebopc/wasi/.keep
Empty file.
Empty file added Tools/bebopc/wasi/wasm/.keep
Empty file.
16 changes: 0 additions & 16 deletions Tools/node/bebopc.js

This file was deleted.

Loading
Loading