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

Add Zig support #389

Open
wants to merge 3 commits into
base: stable
Choose a base branch
from

Conversation

MadLittleMods
Copy link

@MadLittleMods MadLittleMods commented Nov 2, 2023

Add Zig support, https://ziglang.org/documentation/0.11.0/#Comments

Fix #388

Tests pass and tested the extension in VSCode ✅

Dev notes

Setup

Using Node.js v18.16.0

Install depdencies

$ npm install

Make sure dotnet is installed (see section below for more details)

Testing

$ node .config/do.mjs test

Building

$ node .config/do.mjs package
Core build complete. Running tests:...
Passed: 473; Failed: 0; Errored: 0
Creating VSIX...
 WARNING  Using '*' activation is usually a bad idea as it impacts performance.
VSIX file created at .obj/Rewrap-VSCode.vsix

Install the extension in VSCode (this will just overwrite whatever version of Rewrap you already have installed):

$ code --install-extension .obj/Rewrap-VSCode.vsix
Installing extensions...
(node:310226) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `code --trace-deprecation ...` to show where the warning was created)
Extension 'Rewrap-VSCode.vsix' was successfully installed.

Other build commands for reference:

$ node .config/do.mjs build
$ node .config/do.mjs build vscode

Installing dotnet dependency

  1. Download and install the .NET Core SDK for your platform (tested with .NET 6). For me this looked like the following:
    $ cd ~/Downloads/
    $ wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
    $ chmod +x ./dotnet-install.sh
    $ ./dotnet-install.sh
    dotnet-install: Attempting to download using aka.ms link https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.415/dotnet-sdk-6.0.415-linux-x64.tar.gz
    dotnet-install: Remote file https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.415/dotnet-sdk-6.0.415-linux-x64.tar.gz size is 186298830 bytes.
    dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.415/dotnet-sdk-6.0.415-linux-x64.tar.gz
    dotnet-install: Downloaded file size is 186298830 bytes.
    dotnet-install: The remote and local file sizes are equal.
    dotnet-install: Installed version is 6.0.415
    dotnet-install: Adding to current process PATH: `/home/eric/.dotnet`. Note: This change will be visible only when sourcing script.
    dotnet-install: Note that the script does not resolve dependencies during installation.
    dotnet-install: To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
    dotnet-install: Installation finished successfully.
  2. Update your $PATH environment variable so you can access dotnet from the CLI:
    .bashrc
    # For .NET dotnet, C# (csharp)
    # https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#set-environment-variables-system-wide
    export DOTNET_ROOT=~/.dotnet
    # export MSBuildSDKsPath=$DOTNET_ROOT/sdk/$(${DOTNET_ROOT}/dotnet --version)/Sdks
    export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

Before this change:
```sh
$ node .config/do.mjs test
Error: ENOENT: no such file or directory, open './docs/specs/readme.md'
```

Tested on Linux (Manjaro, arch-based)
Comment on lines +231 to +232
// Also allow text paragraphs to be wrapped. Though wrapping the whole
// file at once will mess it up.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why adding the Zig entry below causes this error but I was running into this error:

./core/Parsing.Documents.fs(231,9): (232,42) info FSHARP: XML comment is not placed on a valid language element. (code 3520)

@@ -271,7 +271,7 @@ type Results = {passes:int; failures:int; errors:int}

[<EntryPoint>]
let main argv =
let norm (s: String) = s.ToLower().Replace('\\', '/')
let norm (s: String) = s.Replace('\\', '/')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the tests trying to read differing cased files.

Before this change:

$ node .config/do.mjs test
Error: ENOENT: no such file or directory, open './docs/specs/readme.md'

The actual file name is docs/specs/README.md

Tested on Linux (Manjaro, arch-based)

@@ -10,7 +10,7 @@
"@typescript-eslint/parser": "^5.12.0",
"eslint": "^8.9.0",
"log-update": "^5.0.0",
"parcel": "^2.3.2",
"parcel": "^2.10.2",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated parcel to fix the errors when trying to package things with Node.js 18

See parcel-bundler/parcel#8005

Before this change:

$ node .config/do.mjs package
Bundling Core tests with Parcel...
@parcel/optimizer-terser: You must provide the URL of lib/mappings.wasm by
calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
SourceMapConsumer
  Error: You must provide the URL of lib/mappings.wasm by calling
  SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
  SourceMapConsumer
  at readWasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/read-wasm.js:8:13)
  at wasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/wasm.js:25:16)
  at
  /home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/source-map-consumer.js:264:14
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async SourceMap
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:19362:20)
  at async minify
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:27714:41)
  at async Object.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/optimizer-terser/lib/TerserOptimizer.js:131:16)
  at async PackagerRunner.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:364:20)
  at async PackagerRunner.getBundleResult
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:255:15)
  at async PackagerRunner.getBundleInfo
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:239:9)
Error running: npx --silent parcel build core/test --cache-dir .obj/parcel
@parcel/optimizer-terser: You must provide the URL of lib/mappings.wasm by
calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
SourceMapConsumer
  Error: You must provide the URL of lib/mappings.wasm by calling
  SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
  SourceMapConsumer
  at readWasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/read-wasm.js:8:13)
  at wasm
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/wasm.js:25:16)
  at
  /home/eric/Documents/github/vscode-rewrap/node_modules/terser/node_modules/source-map/lib/source-map-consumer.js:264:14
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async SourceMap
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:19362:20)
  at async minify
  (/home/eric/Documents/github/vscode-rewrap/node_modules/terser/dist/bundle.min.js:27714:41)
  at async Object.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/optimizer-terser/lib/TerserOptimizer.js:131:16)
  at async PackagerRunner.optimize
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:364:20)
  at async PackagerRunner.getBundleResult
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:255:15)
  at async PackagerRunner.getBundleInfo
  (/home/eric/Documents/github/vscode-rewrap/node_modules/@parcel/core/lib/PackagerRunner.js:239:9)

Packaging & Optimizing...
🚨 Build failed.

MadLittleMods added a commit to MadLittleMods/zig-neural-networks that referenced this pull request Nov 3, 2023
I fixed the VSCode Rewrap plugin fixed for Zig in
stkb/Rewrap#389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zig doc comments /// are mangled
1 participant