diff --git a/.github/workflows/update-version-number.yaml b/.github/workflows/update-version-number.yaml index a6885b98..56d3076e 100644 --- a/.github/workflows/update-version-number.yaml +++ b/.github/workflows/update-version-number.yaml @@ -75,8 +75,8 @@ jobs: - name: Update README.md ${{ steps.configure.outputs.git-tag }} run: | - ruby -i -pe 'gsub(%r{(https://github.com/hadashiA/VitalRouter.git\?path=/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity#)[\d\.]+}, %q{\1${{ steps.configure.outputs.git-tag }}})' README.md - ruby -i -pe 'gsub(%r{(https://github.com/hadashiA/VitalRouter.git\?path=/src/MRubyCS.Unity/Assets/MRubyCS.Serializer.Unity#)[\d\.]+}, %q{\1${{ steps.configure.outputs.git-tag }}})' README.md + ruby -i -pe 'gsub(%r{(https://github.com/hadashiA/MRubyCS.git\?path=src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity#)[\d\.]+}, %q{\1${{ steps.configure.outputs.git-tag }}})' README.md + ruby -i -pe 'gsub(%r{(https://github.com/hadashiA/MRubyCS.git\?path=src/MRubyCS.Unity/Assets/MRubyCS.Serializer.Unity#)[\d\.]+}, %q{\1${{ steps.configure.outputs.git-tag }}})' README.md - name: Update package.json ${{ steps.configure.outputs.git-tag }} run: | ruby -i -pe 'gsub(/"version"\s*:\s*"([\w\.-]+)"/, %q{"version": "${{ steps.configure.outputs.git-tag }}"})' src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/package.json diff --git a/README.md b/README.md index 0ef2c342..4712a477 100644 --- a/README.md +++ b/README.md @@ -128,12 +128,35 @@ Please refer to the following for the [benchmark code](https://github.com/hadash > [!NOTE] > Requirements: Unity 2021.3 or later. -1. Install [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity). -2. Install following packages via NugetForUnity +1. Install [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity) (v4.3.0 or later — required for native plugin support). +2. Install following packages via NuGetForUnity - Utf8StringInterpolation - MRubyCS + - (Optional) MRubyCS.Compiler — runtime Ruby compiler. Native binaries (macOS / Linux / Windows) ship inside the NuGet package. - (Optional) MRubyCS.Serializer -3. (Optional) To install utilities for generating mrb bytecode, refer to the [Compiling and Executing Ruby Code](#compiling-and-executing-ruby-code) section. +3. (Optional) For an Editor extension that auto-imports `.rb` / `.mrb` files as `TextAsset` subassets, install `MRubyCS.Compiler` Unity package as well — see [Unity AssetImporter](#unity-assetimporter). + +> [!IMPORTANT] +> **macOS Editor users** — NuGetForUnity v4.3.0's default `NativeRuntimeSettings` ships broken Editor settings for the `osx-arm64` / `osx-x64` runtimes (the Apple Silicon variant has no Editor target, and the Intel variant defaults to "Any CPU"), so `libmruby.dylib` may fail to load in the Editor. +> +> A fix has been submitted upstream — [NuGetForUnity#755](https://github.com/GlitchEnzo/NuGetForUnity/pull/755). Once that is merged and released, this workaround will no longer be needed. In the meantime, open `ProjectSettings/Packages/com.github-glitchenzo.nugetforunity/NativeRuntimeSettings.json` and make sure the two `osx-*` entries look like this, then reimport the dylibs under `Assets/Packages/MRubyCS.Compiler.*/runtimes/osx-*/native/`: +> +> ```json +> { +> "cpuArchitecture": "x86_64", +> "editorCpuArchitecture": "x86_64", +> "editorOperatingSystem": "OSX", +> "runtime": "osx-x64", +> "supportedPlatformTargets": ["StandaloneOSX"] +> }, +> { +> "cpuArchitecture": "ARM64", +> "editorCpuArchitecture": "ARM64", +> "editorOperatingSystem": "OSX", +> "runtime": "osx-arm64", +> "supportedPlatformTargets": ["StandaloneOSX"] +> } +> ``` ## Basic Usage @@ -313,12 +336,16 @@ NOTE: This is a wrapper for native compilers. Currently, only the following plat dotnet add package MRubyCS.Compiler ``` -**Unity**: Open the Package Manager window by selecting Window > Package Manager, then click on [+] > Add package from git URL and enter the following URL: +**Unity**: install `MRubyCS.Compiler` via [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity) (v4.3.0 or later). The native compiler binaries (`libmruby.dylib` / `.so` / `.dll`) are bundled in the NuGet package and resolved automatically. + +If you also want the Editor extension that auto-imports `.rb` / `.mrb` files as `TextAsset` subassets, additionally install the Unity package. Open Window > Package Manager, click [+] > Add package from git URL, and enter: ``` -https://github.com/hadashiA/MRubyCS.git?path=src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity#0.50.3 +https://github.com/hadashiA/MRubyCS.git?path=src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity#0.106.0 ``` +See [Unity AssetImporter](#unity-assetimporter) for details. + ```cs using MRubyCS.Compiler; @@ -1439,7 +1466,7 @@ By introducing the following packages, serialization of Unity-specific types wil Open the Package Manager window by selecting Window > Package Manager, then click on [+] > Add package from git URL and enter the following URL: ``` -https://github.com/hadashiA/MRubyCS.git?path=src/MRubyCS.Unity/Assets/MRubyCS.Serializer.Unity#0.18.1 +https://github.com/hadashiA/MRubyCS.git?path=src/MRubyCS.Unity/Assets/MRubyCS.Serializer.Unity#0.106.0 ``` | mruby | C# | diff --git a/src/MRubyCS.Compiler/MRubyCS.Compiler.csproj b/src/MRubyCS.Compiler/MRubyCS.Compiler.csproj index eca7f7d8..a4443378 100644 --- a/src/MRubyCS.Compiler/MRubyCS.Compiler.csproj +++ b/src/MRubyCS.Compiler/MRubyCS.Compiler.csproj @@ -1,11 +1,11 @@  - net8.0;net9.0;net10.0 + net8.0;net9.0;net10.0;netstandard2.1 enable true osx-arm64 - 9 + 13 Native binding for the mruby compiler for use from C# and MRubyCS @@ -17,37 +17,30 @@ - - - - - - - true - true - PreserveNewest - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + + + true + %(Identity) + + + - $(MSBuildProjectDirectory)\..\MRubyCS.Unity\Assets\MRubyCS.Compiler.Unity\Runtime + <_MRubyCompilerHostRid Condition="'$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier) + <_MRubyCompilerHostRid Condition="'$(_MRubyCompilerHostRid)' == ''">$(NETCoreSdkRuntimeIdentifier) - - - - - - + + + %(Filename)%(Extension) + PreserveNewest + false + - - - - - diff --git a/src/MRubyCS.Compiler/NativeMethods.cs b/src/MRubyCS.Compiler/NativeMethods.cs index 5633c2e6..be7008dc 100644 --- a/src/MRubyCS.Compiler/NativeMethods.cs +++ b/src/MRubyCS.Compiler/NativeMethods.cs @@ -56,54 +56,6 @@ unsafe class NativeMethods public const int Ok = 0; public const int Failed = 11; -#if !UNITY_2021_3_OR_NEWER - static NativeMethods() - { - NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly, DllImportResolver); - } - - static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) - { - if (libraryName == DllName) - { - var path = "runtimes"; - string extname; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - path = Path.Join(path, "win"); - extname = ".dll"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - path = Path.Join(path, "osx"); - extname = ".dylib"; - } - else - { - path = Path.Join(path, "linux"); - extname = ".so"; - } - - switch (RuntimeInformation.ProcessArchitecture) - { - case Architecture.X86: - path += "-x86"; - break; - case Architecture.X64: - path += "-x64"; - break; - case Architecture.Arm64: - path += "-arm64"; - break; - } - - path = Path.Join(path, "native", $"{DllName}{extname}"); - return NativeLibrary.Load(Path.Combine(AppContext.BaseDirectory, path), assembly, searchPath); - } - return IntPtr.Zero; - } -#endif [DllImport(DllName, EntryPoint = "mrb_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern MrbState* MrbOpen(); diff --git a/src/MRubyCS.Serializer/MRubyCS.Serializer.csproj b/src/MRubyCS.Serializer/MRubyCS.Serializer.csproj index 17feb3b2..a2a5c327 100644 --- a/src/MRubyCS.Serializer/MRubyCS.Serializer.csproj +++ b/src/MRubyCS.Serializer/MRubyCS.Serializer.csproj @@ -13,6 +13,10 @@ + + Analyzer + false + diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Editor/MRubyCS.Compiler.Editor.asmdef b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Editor/MRubyCS.Compiler.Editor.asmdef new file mode 100644 index 00000000..7c681711 --- /dev/null +++ b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Editor/MRubyCS.Compiler.Editor.asmdef @@ -0,0 +1,19 @@ +{ + "name": "MRubyCS.Compiler.Editor", + "rootNamespace": "", + "references": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "MRubyCS.dll", + "MRubyCS.Compiler.dll" + ], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Editor/MRubyCS.Compiler.Editor.asmdef.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Editor/MRubyCS.Compiler.Editor.asmdef.meta new file mode 100644 index 00000000..4d1d9439 --- /dev/null +++ b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Editor/MRubyCS.Compiler.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 460612ef6c4ffc621d4e8930517fd1cb +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime.meta deleted file mode 100644 index 1889efac..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f8ebbbd3d62634384ae84d758de62a57 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/BomHelper.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/BomHelper.cs deleted file mode 100644 index 08d882d0..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/BomHelper.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Text; - -namespace MRubyCS.Compiler -{ -static class BomHelper -{ - static readonly Encoding[] encodings = - { - Encoding.UTF8, - Encoding.Unicode, - Encoding.BigEndianUnicode, - Encoding.UTF32 - }; - - public static bool TryDetectEncoding(ReadOnlySpan source, out Encoding bomEncoding) - { - foreach (var encoding in encodings) - { - if (source.StartsWith(encoding.Preamble)) - { - bomEncoding = encoding; - return true; - } - } - bomEncoding = default!; - return false; - } -} -} diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/BomHelper.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/BomHelper.cs.meta deleted file mode 100644 index 5dd06c87..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/BomHelper.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 9d6a0c5f5db4d401a9b0986257be2230 \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/CompilationResult.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/CompilationResult.cs deleted file mode 100644 index b611e39e..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/CompilationResult.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MRubyCS.Compiler -{ -public class CompilationResult : IDisposable -{ - public IReadOnlyList Diagnostics { get; } - - public bool HasError => contextHandle.HasError; - - readonly MRubyState mrb; - readonly MrbStateHandle stateHandle; - readonly MrcCContextHandle contextHandle; - readonly IntPtr bytecodeDataPtr; - readonly int bytecodeLength; - bool disposed; - - internal CompilationResult( - MRubyState mrb, - MrbStateHandle stateHandle, - MrcCContextHandle contextHandle, - IntPtr bytecodeDataPtr, - int bytecodeLength) - { - this.mrb = mrb; - this.stateHandle = stateHandle; - this.contextHandle = contextHandle; - this.bytecodeDataPtr = bytecodeDataPtr; - this.bytecodeLength = bytecodeLength; - Diagnostics = contextHandle.GetDiagnostics(); - } - - internal CompilationResult( - MRubyState mrb, - MrbStateHandle stateHandle, - MrcCContextHandle contextHandle) - { - this.mrb = mrb; - this.stateHandle = stateHandle; - this.contextHandle = contextHandle; - Diagnostics = contextHandle.GetDiagnostics(); - } - - ~CompilationResult() - { - Dispose(disposing: false); - } - - public unsafe ReadOnlySpan AsBytecode() - { - return new ReadOnlySpan((byte*)bytecodeDataPtr, bytecodeLength); - } - - public ReadOnlySpan AsSpan() => AsBytecode(); - - public Irep ToIrep() - { - return mrb.RiteParser.Parse(AsBytecode()); - } - - public void Dispose() - { - Dispose(disposing: true); - GC.SuppressFinalize(this); // ファイナライザの呼び出しを抑制 - } - - unsafe void Dispose(bool disposing) - { - if (disposed) return; - - if (bytecodeDataPtr != IntPtr.Zero) - { - // NativeMethods.MrcFree(stateHandle.DangerousGetPtr(), bytecodeDataPtr.ToPointer()); - NativeMethods.MrcFree(bytecodeDataPtr.ToPointer()); - } - - contextHandle.Dispose(); - disposed = true; - } -} -} diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/CompilationResult.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/CompilationResult.cs.meta deleted file mode 100644 index 4bea8b3f..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/CompilationResult.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: df5c578544bc44c28808c83c63b47764 \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Diagnostics.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Diagnostics.cs deleted file mode 100644 index 621da0db..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Diagnostics.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace MRubyCS.Compiler -{ -public enum DiagnosticSeverity -{ - Warning, - Error, - GeneratorWarning, - GeneratorError, -} - -public class DiagnosticsDescriptor -{ - public DiagnosticSeverity Severity { get; } - public int Line { get; } - public int Column { get; } - public string? Message { get; } - - public DiagnosticsDescriptor(DiagnosticSeverity severity, int line, int column, string? message) - { - Severity = severity; - Line = line; - Column = column; - Message = message; - } - - public override string ToString() => $"{Severity}: {Message} ({Line}:{Column})"; - } -} diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Diagnostics.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Diagnostics.cs.meta deleted file mode 100644 index f076c217..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Diagnostics.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: f377a6e5764b745869e971cf9a71114a \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCS.Compiler.asmdef b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCS.Compiler.asmdef deleted file mode 100644 index 88864afc..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCS.Compiler.asmdef +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "MRubyCS.Compiler", - "rootNamespace": "", - "references": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": true, - "precompiledReferences": [ - "MRubyCS.dll" - ], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": true -} \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCS.Compiler.asmdef.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCS.Compiler.asmdef.meta deleted file mode 100644 index e9745d81..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCS.Compiler.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 77dda16c7de614694b76d018f1e29170 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCompiler.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCompiler.cs deleted file mode 100644 index 24dcc0af..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCompiler.cs +++ /dev/null @@ -1,196 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace MRubyCS.Compiler -{ - public class MRubyCompileException : Exception - { - public MRubyCompileException(string message) : base(message) - { - } - } - - public record MRubyCompileOptions - { - public static MRubyCompileOptions Default { get; set; } = new(); - } - - public class MRubyCompiler : IDisposable - { - public static MRubyCompiler Create(MRubyState mrb, MRubyCompileOptions? options = null) - { - var compilerStateHandle = MrbStateHandle.Create(); - return new MRubyCompiler(mrb, compilerStateHandle, options); - } - - readonly MRubyState mruby; - readonly MrbStateHandle compileStateHandle; - readonly MRubyCompileOptions options; - bool disposed; - - MRubyCompiler( - MRubyState mruby, - MrbStateHandle compileStateHandle, - MRubyCompileOptions? options = null) - { - this.mruby = mruby; - this.compileStateHandle = compileStateHandle; - this.options = options ?? MRubyCompileOptions.Default; - } - - ~MRubyCompiler() - { - Dispose(false); - } - - public MRubyValue LoadSourceCodeFile(string path) - { - using var compilation = CompileFile(path); - return mruby.LoadBytecode(compilation.AsBytecode()); - } - - public async Task LoadSourceCodeFileAsync(string path, CancellationToken cancellationToken = default) - { - using var compilation = await CompileFileAsync(path, cancellationToken); - return mruby.LoadBytecode(compilation.AsBytecode()); - } - - public MRubyValue LoadSourceCode(ReadOnlySpan utf8Source) - { - using var compilation = Compile(utf8Source); - return mruby.LoadBytecode(compilation.AsBytecode()); - } - - public MRubyValue LoadSourceCode(string source) - { - var utf8Source = Encoding.UTF8.GetBytes(source); - return LoadSourceCode(utf8Source); - } - - public RFiber LoadSourceCodeAsFiber(ReadOnlySpan utf8Source) - { - using var compilation = Compile(utf8Source); - var proc = mruby.CreateProc(compilation.ToIrep()); - return mruby.CreateFiber(proc); - } - - public RFiber LoadSourceCodeAsFiber(string source) - { - var utf8Source = Encoding.UTF8.GetBytes(source); - return LoadSourceCodeAsFiber(utf8Source); - } - - public CompilationResult CompileFile(string filePath, bool debugInfo = true) - { - var bytes = File.ReadAllBytes(filePath); - - return Compile(bytes, - filename: Path.GetFullPath(filePath), - debugInfo: debugInfo); - } - - public async Task CompileFileAsync(string filePath, CancellationToken cancellationToken = default, bool debugInfo = true) - { - var bytes = await File.ReadAllBytesAsync(filePath, cancellationToken); - return Compile(bytes, - filename: Path.GetFullPath(filePath), - debugInfo: debugInfo); - } - - public CompilationResult Compile(string sourceCode, string? filename = null, bool debugInfo = true) => - Compile(Encoding.UTF8.GetBytes(sourceCode), filename, debugInfo); - - /// - /// Compile Ruby source to .mrb bytecode. - /// - /// UTF-8 encoded source bytes. - /// - /// Optional source file name to record in the bytecode's DBG section. When non-null - /// (and is true), tools like the debugger / Backtrace - /// resolve pc back to filename:line. - /// - /// - /// When true (default), the bytecode includes a DBG section with line numbers. Set - /// to false to produce smaller bytecode for production distribution. - /// - public unsafe CompilationResult Compile( - ReadOnlySpan utf8Source, - string? filename = null, - bool debugInfo = true) - { - // Workaround for the crash that occurs when passing a blank to mrc - if (utf8Source.IsEmpty) - { - Span fallback = stackalloc byte[1]; - fallback[0] = (byte)' '; - return Compile(fallback, filename, debugInfo); - } - - if (BomHelper.TryDetectEncoding(utf8Source, out var encoding)) - { - if (encoding.Equals(Encoding.UTF8)) - { - utf8Source = utf8Source[encoding.Preamble.Length..]; - } - else - { - throw new MRubyCompileException("Only UTF-8 is supported"); - } - } - - var context = MrcCContextHandle.Create(compileStateHandle); - byte* bin = null; - nint binLength = 0; - - // Set the source filename on the compile context BEFORE parsing so the resulting - // mrc_irep has its debug_info populated with a real filename (not "(string)"). - // mrc allocates its own copy of the string, so the marshalled buffer can be freed - // immediately after the call. - if (!string.IsNullOrEmpty(filename)) - { - var byteCount = Encoding.UTF8.GetByteCount(filename) + 1; - var heap = new byte[byteCount]; - Encoding.UTF8.GetBytes(filename, heap.AsSpan(0, byteCount - 1)); - heap[byteCount - 1] = 0; - fixed (byte* heapPtr = heap) - { - NativeMethods.MrcCContextFilename(context.DangerousGetPtr(), heapPtr); - } - } - - // MRB_DUMP_DEBUG_INFO == 1; include the DBG section in the serialized .mrb so - // the C# RiteParser can recover (file, line) info for each pc. - var dumpFlags = (byte)(debugInfo ? 1 : 0); - - fixed (byte* sourcePtr = utf8Source) - { - var irepPtr = NativeMethods.MrcLoadStringCxt(context.DangerousGetPtr(), &sourcePtr, utf8Source.Length); - if (irepPtr == null || context.HasError) - { - // error - return new CompilationResult(mruby, compileStateHandle, context); - } - NativeMethods.MrcDumpIrep(context.DangerousGetPtr(), irepPtr, dumpFlags, &bin, &binLength); - NativeMethods.MrcIrepFree(context.DangerousGetPtr(), irepPtr); - return new CompilationResult(mruby, compileStateHandle, context, (IntPtr)bin, (int)binLength); - } - } - - public void Dispose(bool disposing) - { - if (disposed) return; - disposed = true; - compileStateHandle.Dispose(); - disposed = true; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - } -} \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCompiler.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCompiler.cs.meta deleted file mode 100644 index b0ddfa03..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MRubyCompiler.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: a87e0c66c0fe14121a546f7f5f111e97 \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbNativeBytesHandle.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbNativeBytesHandle.cs deleted file mode 100644 index b1cbd2dc..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbNativeBytesHandle.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace MRubyCS.Compiler -{ -public class MrbNativeBytesHandle : SafeHandle -{ - readonly MrbStateHandle stateHandle1; - - internal MrbNativeBytesHandle( - MrbStateHandle stateHandle, - IntPtr ptr, - int length) : base(ptr, true) - { - stateHandle1 = stateHandle; - Length = length; - } - - public override bool IsInvalid => handle == IntPtr.Zero; - public int Length { get; } - - public unsafe ReadOnlySpan AsSpan() - { - return new ReadOnlySpan(DangerousGetHandle().ToPointer(), Length); - } - - protected override unsafe bool ReleaseHandle() - { - if (IsClosed) return false; - // NativeMethods.MrbFree(stateHandle1.DangerousGetPtr(), DangerousGetHandle().ToPointer()); - NativeMethods.MrcFree(DangerousGetHandle().ToPointer()); - return true; - } -} -} diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbNativeBytesHandle.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbNativeBytesHandle.cs.meta deleted file mode 100644 index 2fb025cd..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbNativeBytesHandle.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 9a460b95aa4ba4b229a9eb70a364663c \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbStateHandle.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbStateHandle.cs deleted file mode 100644 index 0be6e0a8..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbStateHandle.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace MRubyCS.Compiler -{ -class MrbStateHandle : SafeHandle -{ - public MrbStateHandle(IntPtr invalidHandleValue) : base(invalidHandleValue, true) - { - } - - public static unsafe MrbStateHandle Create() - { - var ptr = NativeMethods.MrbOpen(); - return new MrbStateHandle((IntPtr)ptr); - } - - public override bool IsInvalid => handle == IntPtr.Zero; - - public unsafe MrbState* DangerousGetPtr() => (MrbState*)DangerousGetHandle(); - - protected override unsafe bool ReleaseHandle() - { - if (IsClosed) return false; - NativeMethods.MrbClose(DangerousGetPtr()); - return true; - } -} -} diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbStateHandle.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbStateHandle.cs.meta deleted file mode 100644 index 94eb431c..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrbStateHandle.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 98a207fec321547899b5f952e1455e9a \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrcCContextHandle.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrcCContextHandle.cs deleted file mode 100644 index d6b99f05..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrcCContextHandle.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace MRubyCS.Compiler -{ - class MrcCContextHandle : SafeHandle - { - public static unsafe MrcCContextHandle Create(MrbStateHandle mrbStateHandle) - { - var ptr = NativeMethods.MrcCContextNew(mrbStateHandle.DangerousGetPtr()); - return new MrcCContextHandle((IntPtr)ptr); - } - - public override bool IsInvalid => handle == IntPtr.Zero; - - public unsafe bool HasError => (DangerousGetPtr()->Flags & 0x01) != 0; - - public MrcCContextHandle(IntPtr invalidHandleValue) : base(invalidHandleValue, true) - { - } - - public unsafe MrcCContext* DangerousGetPtr() => (MrcCContext*)DangerousGetHandle(); - - protected override unsafe bool ReleaseHandle() - { - if (IsClosed) return false; - NativeMethods.MrcCContextFree(DangerousGetPtr()); - return true; - } - - public unsafe IReadOnlyList GetDiagnostics() - { - var list = new List(); - var nodePtr = DangerousGetPtr()->DiagnosticList; - while (nodePtr != null) - { - var severity = nodePtr->DiagnosticCode switch - { - MrcDiagnosticCode.Warning => DiagnosticSeverity.Warning, - MrcDiagnosticCode.Error => DiagnosticSeverity.Error, - MrcDiagnosticCode.GeneratorWarning => DiagnosticSeverity.GeneratorWarning, - MrcDiagnosticCode.GeneratorError => DiagnosticSeverity.GeneratorError, - _ => throw new ArgumentOutOfRangeException() - }; - var message = Marshal.PtrToStringUTF8((IntPtr)nodePtr->Message); - var descriptor = new DiagnosticsDescriptor(severity, nodePtr->Line, nodePtr->Column, message); - list.Add(descriptor); - nodePtr = nodePtr->Next; - } - return list; - } - } -} \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrcCContextHandle.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrcCContextHandle.cs.meta deleted file mode 100644 index db9c957d..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/MrcCContextHandle.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 256cff97da1c549a5b01889b054df863 \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/NativeMethods.cs b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/NativeMethods.cs deleted file mode 100644 index 5633c2e6..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/NativeMethods.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace MRubyCS.Compiler -{ -[StructLayout(LayoutKind.Explicit)] -struct MrbState { } - -[StructLayout(LayoutKind.Explicit)] -struct MrcIrep { } - -[StructLayout(LayoutKind.Sequential)] -unsafe struct MrcCContext -{ - public MrbState* Mrb; - public void* Jmp; - public void* P; - public void* Options; - public int SLen; - public byte* Filename; - public ushort LineNo; - public void* TargetClass; - // Six C bit-fields (capture_errors..no_ext_ops) packed into one byte. - // bit 0 = capture_errors, bit 1 = dump_result, bit 2 = no_exec, - // bit 3 = keep_lv, bit 4 = no_optimize, bit 5 = no_ext_ops - public byte Flags; - public void* Upper; - public MrcDiagnosticList* DiagnosticList; -} - -enum MrcDiagnosticCode -{ - Warning = 0, - Error = 1, - GeneratorWarning = 2, - GeneratorError = 3, -} - -[StructLayout(LayoutKind.Sequential)] -unsafe struct MrcDiagnosticList -{ - public MrcDiagnosticCode DiagnosticCode; - public byte* Message; - public byte* Filename; - public int Line; - public int Column; - public MrcDiagnosticList* Next; -} - -unsafe class NativeMethods -{ - const string DllName = "libmruby"; - - public const int Ok = 0; - public const int Failed = 11; - -#if !UNITY_2021_3_OR_NEWER - static NativeMethods() - { - NativeLibrary.SetDllImportResolver(typeof(NativeMethods).Assembly, DllImportResolver); - } - - static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) - { - if (libraryName == DllName) - { - var path = "runtimes"; - string extname; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - path = Path.Join(path, "win"); - extname = ".dll"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - path = Path.Join(path, "osx"); - extname = ".dylib"; - } - else - { - path = Path.Join(path, "linux"); - extname = ".so"; - } - - switch (RuntimeInformation.ProcessArchitecture) - { - case Architecture.X86: - path += "-x86"; - break; - case Architecture.X64: - path += "-x64"; - break; - case Architecture.Arm64: - path += "-arm64"; - break; - } - - path = Path.Join(path, "native", $"{DllName}{extname}"); - return NativeLibrary.Load(Path.Combine(AppContext.BaseDirectory, path), assembly, searchPath); - } - return IntPtr.Zero; - } -#endif - [DllImport(DllName, EntryPoint = "mrb_open", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern MrbState* MrbOpen(); - - [DllImport(DllName, EntryPoint = "mrb_close", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MrbClose(MrbState* mrb); - - [DllImport(DllName, EntryPoint = "mrubycs_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MrcFree(void* ptr); - - [DllImport(DllName, EntryPoint = "mrc_ccontext_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern MrcCContext* MrcCContextNew(MrbState* mrb); - - [DllImport(DllName, EntryPoint = "mrc_ccontext_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern MrcCContext* MrcCContextFree(MrcCContext* c); - - // const char *mrc_ccontext_filename(mrc_ccontext *c, const char *s); - // Sets the source filename used to populate the DBG section. mrc owns the resulting - // copy; the returned char* points into mrc-managed memory. - [DllImport(DllName, EntryPoint = "mrc_ccontext_filename", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern byte* MrcCContextFilename(MrcCContext* c, byte* filename); - - [DllImport(DllName, EntryPoint = "mrc_load_string_cxt", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern MrcIrep* MrcLoadStringCxt( - MrcCContext* c, - byte** source, - nint sourceLength); - - // int mrc_dump_irep(mrc_ccontext *c, const mrc_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size); - [DllImport(DllName, EntryPoint = "mrc_dump_irep", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MrcDumpIrep( - MrcCContext* c, - MrcIrep* irep, - byte flags, - byte** bin, - nint* binSize); - - [DllImport(DllName, EntryPoint = "mrc_irep_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MrcIrepFree(MrcCContext* c, MrcIrep* irep); - - [DllImport(DllName, EntryPoint = "mrc_diagnostic_list_free", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MrcDiagnosticListFree(MrcCContext* c); - -} -} diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/NativeMethods.cs.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/NativeMethods.cs.meta deleted file mode 100644 index b059afbd..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/NativeMethods.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 0014cf52f053a4ff5926b1db8dce9e79 \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins.meta deleted file mode 100644 index 2320edd4..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a6cc262ff839a474ba2911772f31806a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64.meta deleted file mode 100644 index 1759ae41..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c8b10d26c49a14b83bbc1393ef144069 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native.meta deleted file mode 100644 index 3434661d..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3c73516fe38e848ba99509a5f792dee5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native/libmruby.so b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native/libmruby.so deleted file mode 100755 index 3979fc9f..00000000 Binary files a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native/libmruby.so and /dev/null differ diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native/libmruby.so.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native/libmruby.so.meta deleted file mode 100644 index bdfa5e4f..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-arm64/native/libmruby.so.meta +++ /dev/null @@ -1,50 +0,0 @@ -fileFormatVersion: 2 -guid: b4ed4d99bd2f147b1b752640dd7ac707 -PluginImporter: - externalObjects: {} - serializedVersion: 3 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - Android: - enabled: 0 - settings: - Is16KbAligned: true - Any: - enabled: 0 - settings: - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 1 - Exclude Win: 0 - Exclude Win64: 0 - Editor: - enabled: 1 - settings: - CPU: AnyCPU - DefaultValueInitialized: true - OS: Linux - Linux64: - enabled: 1 - settings: - CPU: None - OSXUniversal: - enabled: 0 - settings: - CPU: None - Win: - enabled: 1 - settings: - CPU: None - Win64: - enabled: 1 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64.meta deleted file mode 100644 index 81307c41..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c862a494c4219499aadbb04b9c5fe1cd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native.meta deleted file mode 100644 index b7ba7693..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: aae39ed956f24456cb4b0920f80fa863 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native/libmruby.so b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native/libmruby.so deleted file mode 100755 index f424d9cb..00000000 Binary files a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native/libmruby.so and /dev/null differ diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native/libmruby.so.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native/libmruby.so.meta deleted file mode 100644 index 79b92eaa..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/linux-x64/native/libmruby.so.meta +++ /dev/null @@ -1,50 +0,0 @@ -fileFormatVersion: 2 -guid: 922f1d5ec5fc14164ad302e6bd8ebf35 -PluginImporter: - externalObjects: {} - serializedVersion: 3 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - Android: - enabled: 0 - settings: - Is16KbAligned: false - Any: - enabled: 0 - settings: - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 1 - Exclude Win: 0 - Exclude Win64: 0 - Editor: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: Linux - Linux64: - enabled: 1 - settings: - CPU: x86_64 - OSXUniversal: - enabled: 0 - settings: - CPU: None - Win: - enabled: 1 - settings: - CPU: None - Win64: - enabled: 1 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64.meta deleted file mode 100644 index 7afbe187..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b0457d023f3b34ecd865944b26b5295b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native.meta deleted file mode 100644 index 08511f46..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b6ade2d4978514415a1e0a253d289c22 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native/libmruby.dylib b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native/libmruby.dylib deleted file mode 100755 index e6cbf8d4..00000000 Binary files a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native/libmruby.dylib and /dev/null differ diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native/libmruby.dylib.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native/libmruby.dylib.meta deleted file mode 100644 index c498be1d..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-arm64/native/libmruby.dylib.meta +++ /dev/null @@ -1,46 +0,0 @@ -fileFormatVersion: 2 -guid: ff554734fe9994eed857984ec552c087 -PluginImporter: - externalObjects: {} - serializedVersion: 3 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - Any: - enabled: 0 - settings: - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - Editor: - enabled: 1 - settings: - CPU: ARM64 - DefaultValueInitialized: true - OS: OSX - Linux64: - enabled: 1 - settings: - CPU: None - OSXUniversal: - enabled: 1 - settings: - CPU: ARM64 - Win: - enabled: 1 - settings: - CPU: None - Win64: - enabled: 1 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64.meta deleted file mode 100644 index 811315bd..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b57f0b3cff667486daf4596cd806f1cd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native.meta deleted file mode 100644 index b2ca820e..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e937143e8e2ab44d7bd33d584a7546ba -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native/libmruby.dylib b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native/libmruby.dylib deleted file mode 100755 index e687a989..00000000 Binary files a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native/libmruby.dylib and /dev/null differ diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native/libmruby.dylib.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native/libmruby.dylib.meta deleted file mode 100644 index 82b714f0..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/osx-x64/native/libmruby.dylib.meta +++ /dev/null @@ -1,46 +0,0 @@ -fileFormatVersion: 2 -guid: ee68ae48eec7d4564977eefe8af9e28d -PluginImporter: - externalObjects: {} - serializedVersion: 3 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - Any: - enabled: 0 - settings: - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - Editor: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: OSX - Linux64: - enabled: 1 - settings: - CPU: None - OSXUniversal: - enabled: 1 - settings: - CPU: x86_64 - Win: - enabled: 1 - settings: - CPU: None - Win64: - enabled: 1 - settings: - CPU: None - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64.meta deleted file mode 100644 index 104e0085..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d17126bb68dca4ef681cd6c95f7d9a2f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native.meta deleted file mode 100644 index 2a6a354e..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: de3bc3441a78e4b158c90ee2654b5e02 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native/libmruby.dll b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native/libmruby.dll deleted file mode 100644 index d18e2c42..00000000 Binary files a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native/libmruby.dll and /dev/null differ diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native/libmruby.dll.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native/libmruby.dll.meta deleted file mode 100644 index ebabcd2d..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/Plugins/win-x64/native/libmruby.dll.meta +++ /dev/null @@ -1,50 +0,0 @@ -fileFormatVersion: 2 -guid: 9999f1a950d7243b59a6d96a5052abd8 -PluginImporter: - externalObjects: {} - serializedVersion: 3 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - Any: - enabled: 0 - settings: - Exclude Editor: 0 - Exclude Linux64: 0 - Exclude OSXUniversal: 0 - Exclude Win: 0 - Exclude Win64: 0 - Editor: - enabled: 1 - settings: - CPU: x86_64 - DefaultValueInitialized: true - OS: AnyOS - Linux64: - enabled: 1 - settings: - CPU: None - OSXUniversal: - enabled: 1 - settings: - CPU: None - Win: - enabled: 1 - settings: - CPU: None - Win64: - enabled: 1 - settings: - CPU: x86_64 - WindowsStoreApps: - enabled: 0 - settings: - CPU: x64 - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/csc.rsp b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/csc.rsp deleted file mode 100644 index 5e5b2d4e..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/csc.rsp +++ /dev/null @@ -1 +0,0 @@ --langVersion:preview -nullable \ No newline at end of file diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/csc.rsp.meta b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/csc.rsp.meta deleted file mode 100644 index c8d4d52f..00000000 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/Runtime/csc.rsp.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a5cbaac202ce6438fa0dd1a8d5a029c0 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/package.json b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/package.json index 7226bf87..77ba121b 100644 --- a/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/package.json +++ b/src/MRubyCS.Unity/Assets/MRubyCS.Compiler.Unity/package.json @@ -3,7 +3,7 @@ "displayName": "MRubyCS.Compiler", "version": "0.106.0", "unity": "2021.3", - "description": "mruby compiler wrappter for MRubyCS", + "description": "Unity Editor extension for MRubyCS.Compiler (ScriptedImporter for .rb / .mrb). Requires the MRubyCS.Compiler NuGet package installed via NuGetForUnity.", "keywords": ["mruby", "ruby"], "license": "MIT", "documentationUrl": "https://github.com/hadashiA/MRubyCS", diff --git a/src/MRubyCS.Unity/Assets/NuGet.config b/src/MRubyCS.Unity/Assets/NuGet.config index d267a780..04a4404e 100644 --- a/src/MRubyCS.Unity/Assets/NuGet.config +++ b/src/MRubyCS.Unity/Assets/NuGet.config @@ -1,10 +1,11 @@ - + - - + + + diff --git a/src/MRubyCS.Unity/Assets/packages.config b/src/MRubyCS.Unity/Assets/packages.config index 7909f9b2..240f851c 100644 --- a/src/MRubyCS.Unity/Assets/packages.config +++ b/src/MRubyCS.Unity/Assets/packages.config @@ -1,6 +1,8 @@ - +?xml version="1.0" encoding="utf-8"?> - + + + - \ No newline at end of file + diff --git a/src/MRubyCS.Unity/Packages/manifest.json b/src/MRubyCS.Unity/Packages/manifest.json index ee999ef8..9c8f66f4 100644 --- a/src/MRubyCS.Unity/Packages/manifest.json +++ b/src/MRubyCS.Unity/Packages/manifest.json @@ -1,6 +1,6 @@ { "dependencies": { - "com.github-glitchenzo.nugetforunity": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity#v4.3.0", + "com.github-glitchenzo.nugetforunity": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity#v4.5.0", "com.unity.ide.rider": "3.0.38", "com.unity.ide.visualstudio": "2.0.25", "com.unity.inputsystem": "1.14.2", @@ -8,7 +8,6 @@ "com.unity.test-framework": "1.6.0", "com.unity.toolchain.macos-arm64-linux-x86_64": "2.0.5", "com.unity.ugui": "2.0.0", - "jp.hadashikick.mrubycs.internal": "file:../../MRubyCS/bin/Debug/netstandard2.1", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", diff --git a/src/MRubyCS.Unity/Packages/packages-lock.json b/src/MRubyCS.Unity/Packages/packages-lock.json index a6d6ea9e..2ec7c660 100644 --- a/src/MRubyCS.Unity/Packages/packages-lock.json +++ b/src/MRubyCS.Unity/Packages/packages-lock.json @@ -1,11 +1,11 @@ { "dependencies": { "com.github-glitchenzo.nugetforunity": { - "version": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity#v4.3.0", + "version": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity#v4.5.0", "depth": 0, "source": "git", "dependencies": {}, - "hash": "36d3260fdca03bf6feb105c67022d1fd7629dd2f" + "hash": "a7c6b49a0141a5bff9b1983e38137522ef61977d" }, "com.unity.burst": { "version": "1.8.25", @@ -191,12 +191,6 @@ "com.unity.modules.imgui": "1.0.0" } }, - "jp.hadashikick.mrubycs.internal": { - "version": "file:../../MRubyCS/bin/Debug/netstandard2.1", - "depth": 0, - "source": "local", - "dependencies": {} - }, "com.unity.modules.assetbundle": { "version": "1.0.0", "depth": 0, diff --git a/src/MRubyCS.Unity/ProjectSettings/Packages/com.github-glitchenzo.nugetforunity/NativeRuntimeSettings.json b/src/MRubyCS.Unity/ProjectSettings/Packages/com.github-glitchenzo.nugetforunity/NativeRuntimeSettings.json new file mode 100644 index 00000000..33933c6e --- /dev/null +++ b/src/MRubyCS.Unity/ProjectSettings/Packages/com.github-glitchenzo.nugetforunity/NativeRuntimeSettings.json @@ -0,0 +1,121 @@ +{ + "configurations": [ + { + "cpuArchitecture": "x86_64", + "editorCpuArchitecture": "", + "editorOperatingSystem": "Windows", + "runtime": "win10-x64", + "supportedPlatformTargets": [ + "StandaloneWindows64" + ] + }, + { + "cpuArchitecture": "AnyCPU", + "editorCpuArchitecture": "", + "editorOperatingSystem": "Windows", + "runtime": "win10-x86", + "supportedPlatformTargets": [ + "StandaloneWindows" + ] + }, + { + "cpuArchitecture": "x86_64", + "editorCpuArchitecture": "", + "editorOperatingSystem": "Windows", + "runtime": "win7-x64", + "supportedPlatformTargets": [ + "StandaloneWindows64" + ] + }, + { + "cpuArchitecture": "AnyCPU", + "editorCpuArchitecture": "", + "editorOperatingSystem": "Windows", + "runtime": "win7-x86", + "supportedPlatformTargets": [ + "StandaloneWindows" + ] + }, + { + "cpuArchitecture": "x86_64", + "editorCpuArchitecture": "", + "editorOperatingSystem": "Windows", + "runtime": "win-x64", + "supportedPlatformTargets": [ + "StandaloneWindows64" + ] + }, + { + "cpuArchitecture": "AnyCPU", + "editorCpuArchitecture": "", + "editorOperatingSystem": "Windows", + "runtime": "win-x86", + "supportedPlatformTargets": [ + "StandaloneWindows" + ] + }, + { + "cpuArchitecture": "x86_64", + "editorCpuArchitecture": "x86_64", + "editorOperatingSystem": "Linux", + "runtime": "linux-x64", + "supportedPlatformTargets": [ + "StandaloneLinux64" + ] + }, + { + "cpuArchitecture": "", + "editorCpuArchitecture": "", + "editorOperatingSystem": "", + "runtime": "android", + "supportedPlatformTargets": [ + "Android" + ] + }, + { + "cpuArchitecture": "ARM64", + "editorCpuArchitecture": "", + "editorOperatingSystem": "", + "runtime": "android-arm64", + "supportedPlatformTargets": [ + "Android" + ] + }, + { + "cpuArchitecture": "", + "editorCpuArchitecture": "", + "editorOperatingSystem": "", + "runtime": "ios", + "supportedPlatformTargets": [ + "iOS" + ] + }, + { + "cpuArchitecture": "ARM64", + "editorCpuArchitecture": "", + "editorOperatingSystem": "", + "runtime": "ios-arm64", + "supportedPlatformTargets": [ + "iOS" + ] + }, + { + "cpuArchitecture": "x86_64", + "editorCpuArchitecture": "x86_64", + "editorOperatingSystem": "OSX", + "runtime": "osx-x64", + "supportedPlatformTargets": [ + "StandaloneOSX" + ] + }, + { + "cpuArchitecture": "ARM64", + "editorCpuArchitecture": "ARM64", + "editorOperatingSystem": "OSX", + "runtime": "osx-arm64", + "supportedPlatformTargets": [ + "StandaloneOSX" + ] + } + ] +} \ No newline at end of file