Skip to content

Commit

Permalink
remove csbindgen and native methods generation
Browse files Browse the repository at this point in the history
  • Loading branch information
vobradovich committed Nov 12, 2024
1 parent f2012cc commit 0c29bdb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 69 deletions.
11 changes: 0 additions & 11 deletions net/rs/Cargo.lock

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

1 change: 0 additions & 1 deletion net/rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ sails-idl-parser = "=0.6.3"
# others
anyhow = "1"
convert-case = { package = "convert_case", version = "0.6" }
csbindgen = "1.9"
genco = "0.17"
insta = "1.41"
itertools = "0.13"
Expand Down
3 changes: 0 additions & 3 deletions net/rs/client-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ repository.workspace = true
[lib]
crate-type = ["cdylib", "rlib"]

[build-dependencies]
csbindgen.workspace = true

[dependencies]
anyhow.workspace = true
convert-case.workspace = true
Expand Down
8 changes: 0 additions & 8 deletions net/rs/client-gen/build.rs

This file was deleted.

6 changes: 3 additions & 3 deletions net/src/Sails.ClientGenerator/NativeMethods.Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ internal static unsafe partial class NativeMethods
internal static IntPtr LoadNativeLibrary()
{
// Determine where to extract the DLL
var tempDirectory = Path.Combine(Path.GetTempPath(), __DllName);
var tempDirectory = Path.Combine(Path.GetTempPath(), DllName);
Directory.CreateDirectory(tempDirectory);

var (platform, extension) = GetResourcePlatform();
var nativeLibraryPath = Path.Combine(tempDirectory, __DllName + extension);
var nativeLibraryPath = Path.Combine(tempDirectory, DllName + extension);
// Extract the DLL only if it doesn't already exist
if (!File.Exists(nativeLibraryPath))
{
ExtractResourceToFile($"{platform}.{__DllName}{extension}", nativeLibraryPath);
ExtractResourceToFile($"{platform}.{DllName}{extension}", nativeLibraryPath);
}
var ret = LibraryLoader.GetPlatformDefaultLoader().LoadNativeLibraryByPath(nativeLibraryPath);
if (ret == IntPtr.Zero)
Expand Down
24 changes: 24 additions & 0 deletions net/src/Sails.ClientGenerator/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Runtime.InteropServices;

namespace Sails.ClientGenerator;

internal static unsafe partial class NativeMethods
{
private const string DllName = "sails_net_client_gen";

/// <summary>
/// # Safety
///
/// Function [`free_c_string`] should be called after this function
/// </summary>
[DllImport(DllName, EntryPoint = "generate_dotnet_client", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern byte* generate_dotnet_client(byte* program_utf8, int program_len, byte* config_utf8, int config_len);

/// <summary>
/// # Safety
///
/// This function should not be called before the [`generate_dotnet_client`]
/// </summary>
[DllImport(DllName, EntryPoint = "free_c_string", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
internal static extern void free_c_string(byte* str);
}
40 changes: 0 additions & 40 deletions net/src/Sails.ClientGenerator/NativeMethods.g.cs

This file was deleted.

4 changes: 1 addition & 3 deletions net/src/Sails.ClientGenerator/SailsClientGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#pragma warning disable RS1035 // Do not use APIs banned for analyzers

using System.Collections.Immutable;
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down

0 comments on commit 0c29bdb

Please sign in to comment.