2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-06-30 19:03:42 -04:00

Project tidying

- Project now uses AnyCPU.
- Fixed assembly info and renamed Raylib-cs project to Generator.
- Removed resources folder and dlls.
- Improving current manual bindings.
This commit is contained in:
2018-08-04 21:04:02 +01:00
parent 9c09f1f030
commit 2995318a4e
129 changed files with 359 additions and 3446 deletions

6
Generator/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

69
Generator/Generator.cs Normal file
View File

@ -0,0 +1,69 @@
using CppSharp;
using CppSharp.AST;
using CppSharp.Generators;
using System;
using System.IO;
namespace Raylibcs
{
/// <summary>
/// Generates the bindings for raylib(WIP)
/// ConsoleDriver.Run(new SampleLibrary());
/// </summary>
public class SampleLibrary : ILibrary
{
void ILibrary.Setup(Driver driver)
{
var options = driver.Options;
options.GeneratorKind = GeneratorKind.CSharp;
options.OutputDir = Path.Combine(Environment.CurrentDirectory, "Raylib-cs");
options.Verbose = true;
// options.UseHeaderDirectories = true;
var module = options.AddModule("raylib");
module.IncludeDirs.Add("C:\\raylib\\raylib\\src");
module.Headers.Add("raylib.h");
// module.Headers.Add("rlgl.h");
// module.Headers.Add("raymath.h");
module.LibraryDirs.Add("C:\\raylib\\raylib\\projects\\VS2017\\x64\\Debug.DLL");
module.Libraries.Add("raylib.lib");
// module.OutputNamespace = "Raylib";
// module.internalNamespace = "rl";
}
void ILibrary.SetupPasses(Driver driver)
{
// driver.Context.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any);
// driver.AddTranslationUnitPass(new FunctionToInstanceMethodPass());
// driver.AddTranslationUnitPass(new CheckOperatorsOverloadsPass());
/*driver.Context.TranslationUnitPasses.RemovePrefix("FLAG_");
driver.Context.TranslationUnitPasses.RemovePrefix("KEY_");
driver.Context.TranslationUnitPasses.RemovePrefix("MOUSE_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_PS3_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_PS3_AXIS_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_XBOX_AXIS_");
driver.Context.TranslationUnitPasses.RemovePrefix("GAMEPAD_ANDORID_");*/
}
public void Preprocess(Driver driver, ASTContext ctx)
{
ctx.SetNameOfEnumWithMatchingItem("KEY_UNKOWN", "Key");
ctx.GenerateEnumFromMacros("Flag", "FLAG_(.*)");
ctx.GenerateEnumFromMacros("Key", "KEY_(.*)");
ctx.GenerateEnumFromMacros("Mouse", "MOUSE_(.*)");
ctx.GenerateEnumFromMacros("Gamepad", "GAMEPAD_(.*)");
ctx.GenerateEnumFromMacros("GamepadPS3", "GAMEPAD_PS3_(.*)");
ctx.GenerateEnumFromMacros("GamepadPS3Axis", "GAMEPAD_PS3_AXIS_(.*)");
ctx.GenerateEnumFromMacros("GamepadXbox", "GAMEPAD_XBOX_(.*)");
ctx.GenerateEnumFromMacros("GamepadXboxAxis", "GAMEPAD_XBOX_AXIS_(.*)");
ctx.GenerateEnumFromMacros("GamepadAndroid", "GAMEPAD_ANDROID_(.*)");
// TODO: MaxTouchPoints, MaxShaderLocations, MaxMateiralMaps
}
public void Postprocess(Driver driver, ASTContext ctx)
{
}
}
}

126
Generator/Generator.csproj Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3B25D9D6-17A6-4A32-B9D1-C637002BD554}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Raylibcs</RootNamespace>
<AssemblyName>Raylibcs</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.dll</HintPath>
</Reference>
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.AST.dll</HintPath>
</Reference>
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Generator.dll</HintPath>
</Reference>
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Parser.dll</HintPath>
</Reference>
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Parser.CLI.dll</HintPath>
</Reference>
<Reference Include="CppSharp.Parser.CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Parser.CSharp.dll</HintPath>
</Reference>
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\CppSharp.0.8.20\lib\CppSharp.Runtime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Compile Include="Generator.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets" Condition="Exists('packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Baseclass.Contrib.Nuget.Output.2.4.3\build\Baseclass.Contrib.Nuget.Output.targets'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

16
Generator/Program.cs Normal file
View File

@ -0,0 +1,16 @@
using System;
using CppSharp;
namespace Raylibcs
{
static class Program
{
static void Main(string[] args)
{
Console.WriteLine("Raylib-cs binding generator");
ConsoleDriver.Run(new SampleLibrary());
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Raylibcs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Raylibcs")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3b25d9d6-17a6-4a32-b9d1-c637002bd554")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Baseclass.Contrib.Nuget.Output" version="2.4.3" targetFramework="net461" />
<package id="CppSharp" version="0.8.20" targetFramework="net461" developmentDependency="true" />
</packages>