Skip to content

Add 'compile-slice' Script for Slice Compiler Definitions#4723

Closed
InsertCreativityHere wants to merge 9 commits into
icerpc:mainfrom
InsertCreativityHere:add-slice-compile-script
Closed

Add 'compile-slice' Script for Slice Compiler Definitions#4723
InsertCreativityHere wants to merge 9 commits into
icerpc:mainfrom
InsertCreativityHere:add-slice-compile-script

Conversation

@InsertCreativityHere
Copy link
Copy Markdown
Member

This PR adds a new build/compile-slice.py script which will automatically regenerate the C# code in src/ZeroC.Slice.Symbols/Compiler based on the existing compiler definitions, and the version of slicec downloaded in the repository.

The script should be runnable anywhere from within the repository. It will automatically figure out the pathing.

I also made sure to have it forward any errors, not that there should ever be any.


Normal output:

PS icerpc-csharp> python build/compile-slice.py
Found 'slicec' at: 'D:/Code/Workspace/icerpc-csharp\src\IceRpc.Slice.Tools\obj\tools\windows-x64\slicec.exe'
Found code-generator at: 'D:/Code/Workspace/icerpc-csharp\src\ZeroC.Slice.Generator\bin\Debug\net10.0\slicec-csharp-generator.bat'
Found output directory at: 'D:/Code/Workspace/icerpc-csharp\src\ZeroC.Slice.Symbols\Compiler'
Compiling the following files: [
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\CodeGenerator.slice
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\Diagnostics.slice
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\DocComment.slice
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\SyntaxElements.slice
]

Completed

Output if there were errors:

PS icerpc-csharp> python build/compile-slice.py
Found 'slicec' at: 'D:/Code/Workspace/icerpc-csharp\src\IceRpc.Slice.Tools\obj\tools\windows-x64\slicec.exe'
Found code-generator at: 'D:/Code/Workspace/icerpc-csharp\src\ZeroC.Slice.Generator\bin\Debug\net10.0\slicec-csharp-generator.bat'
Found output directory at: 'D:/Code/Workspace/icerpc-csharp\src\ZeroC.Slice.Symbols\Compiler'
Compiling the following files: [
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\CodeGenerator.slice
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\Diagnostics.slice
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\DocComment.slice
    D:/Code/Workspace/icerpc-csharp\slice\Compiler\SyntaxElements.slice
]

Errors encountered while trying to compile Slice files:

error [E033]: no element with identifier 'strin' exists
  Reported by: [slicec]
 --> D:/Code/Workspace/icerpc-csharp\slice\Compiler\CodeGenerator.slice:19:11
   |
19 |     path: strin
   |           -----
   |

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new repository-local helper script to regenerate the C# sources under src/ZeroC.Slice.Symbols/Compiler from the Slice compiler definition files using the slicec binary downloaded by the build.

Changes:

  • Add build/compile-slice.py to locate slicec, locate the ZeroC.Slice.Generator code generator script, and compile slice/Compiler/*.slice into src/ZeroC.Slice.Symbols/Compiler.
  • Update build/sync-slice.py’s docstring usage paths to reference build/ instead of tools/.
  • Remove a couple of VS Code workspace settings related to Rust Analyzer, and remove unused _SliceCExe properties from IceRpc.Slice.Tools.csproj.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/IceRpc.Slice.Tools/IceRpc.Slice.Tools.csproj Removes no-longer-used properties related to slicec executable naming.
build/sync-slice.py Docstring usage text updates to match the script’s actual location under build/.
build/compile-slice.py New script to regenerate compiler-symbol C# sources by invoking slicec + the C# generator.
.vscode/settings.json Removes Rust Analyzer-related VS Code settings (not mentioned in PR description).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build/compile-slice.py
Comment thread build/compile-slice.py Outdated
Comment thread build/compile-slice.py
Comment thread .vscode/settings.json
Comment thread build/compile-slice.py
Comment thread build/compile-slice.py
Comment thread build/compile-slice.py
Comment thread .vscode/settings.json Outdated
@@ -1,11 +1,5 @@
{
"dotnet.defaultSolution": "IceRpc.sln",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While looking for where we store slicec, I stumbled across this.
Leftover from the old slicec-cs tool. So these are no longer doing anything for us.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be slnx

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed!

<_IceRpcOSArch>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower())</_IceRpcOSArch>
<_SliceCExe Condition="'$(_IceRpcOSName)' == 'windows'">slicec.exe</_SliceCExe>
<_SliceCExe Condition="'$(_IceRpcOSName)' != 'windows'">slicec</_SliceCExe>
</PropertyGroup>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I couldn't find a single reference to this _SliceCExe property anywhere.
Is there something special I'm missing or is this just properly dead code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see any either.

Comment thread build/sync-slice.py
@@ -4,13 +4,13 @@
"""Synchronize vendored Slice files (*.ice, *.slice) based on slice.toml.

Usage:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This file was moved from tools to build some time ago.

Also there were some sentences that ended with 2 spaces instead of 1?
If this is intentional I can revert, but it seemed like just a typo to me.

@InsertCreativityHere
Copy link
Copy Markdown
Member Author

Replaced by #4725.

I still like my script, but it's easier to do this regeneration with a build task.
This way we can re-use the existing logic for finding slicec.
Because really, finding slicec and the generator is 80% of this script.

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.

3 participants