Skip to content

Commit

Permalink
[Rgen] Establish transformer tool setup (#21784)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions Autoformatter <[email protected]>
  • Loading branch information
haritha-mohan and GitHub Actions Autoformatter authored Jan 6, 2025
1 parent 2149632 commit b472b63
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/rgen/Microsoft.Macios.Transformer/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using Microsoft.Macios.Transformer;


//TODO: logging infra
// add cli header stuff
var parser = new CommandLineBuilder (new TransformCommand ())
.UseDefaults ()
.Build ();

return await parser.InvokeAsync (args).ConfigureAwait (false);
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.Macios.Generator\Microsoft.Macios.Generator.csproj" PrivateAssets="all" />
<None Include="$(OutputPath)\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions src/rgen/Microsoft.Macios.Transformer/Program.cs

This file was deleted.

38 changes: 38 additions & 0 deletions src/rgen/Microsoft.Macios.Transformer/TransformCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.CommandLine;

namespace Microsoft.Macios.Transformer;

public class TransformCommand : Command {

public TransformCommand () : base ("rgen-transform", "command to convert outdated bindings to be rgen compatible")
{
var input = new Option<string> (["--input", "-i"], "input directory to search for bgen bindings") {
//single file support?
IsRequired = true
};
AddOption (input);

var output = new Option<string> (["--output", "-o"], "output directory to write rgen bindings") {
IsRequired = true
};
AddOption (output);

AddValidator (result => {
if (!Directory.Exists (result.GetValueForOption (input))) {
result.ErrorMessage = "Input directory does not exist";
}
if (!Directory.Exists (result.GetValueForOption (output))) {
Directory.CreateDirectory (result.GetValueForOption (output)!);
}
});
// this.AddOption (new Option<bool> (new string [] { "--verbose", "-v" }, "verbose output"));

this.SetHandler (Execute);
}

public async Task Execute ()
{
// placeholder for loading/parsing/transforming/writing components
await Task.CompletedTask;
}
}

10 comments on commit b472b63

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.