Merge pull request #1 from dellis1972/macos

Added .travis.yml to Build MacOS
pull/282/head
Tom Spilman 6 years ago committed by GitHub
commit a88aaa4f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,11 @@
language: csharp
os:
- osx
compiler:
- clang
- gcc
script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd build ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" -DNVTT_SHARED="TRUE" .. ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make ; fi

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Nvidia.TextureTools.UnitTests</RootNamespace>
<AssemblyName>Nvidia.TextureTools.UnitTests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Test.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nvidia.TextureTools\Nvidia.TextureTools.csproj">
<Project>{CAB55C39-8FA9-4912-98D9-E52669C8911D}</Project>
<Name>Nvidia.TextureTools</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,66 @@
using NUnit.Framework;
using System;
using Nvidia.TextureTools;
using System.Runtime.InteropServices;
namespace Nvidia.TextureTools.UnitTests {
[TestFixture ()]
public class Test {
[Test ()]
public void TestCase ()
{
var inputOptions = new InputOptions ();
var outputOptions = new OutputOptions ();
var compressionOptions = new CompressionOptions ();
var compressor = new Compressor ();
inputOptions.SetAlphaMode (AlphaMode.Premultiplied);
inputOptions.SetTextureLayout (TextureType.Texture2D, 128, 128, 1);
byte [] sourceData = new byte [128*128*4];
var dataHandle = GCHandle.Alloc (sourceData, GCHandleType.Pinned);
var BeginImage = new OutputOptions.BeginImageHandler (BeginImageInternal);
var WriteData = new OutputOptions.OutputHandler (WriteDataInternal);
var EndImage = new OutputOptions.EndImageHandler (EndImageInternal);
var a = GCHandle.Alloc (BeginImage);
var b = GCHandle.Alloc (WriteData);
var c = GCHandle.Alloc (EndImage);
try {
var dataPtr = dataHandle.AddrOfPinnedObject ();
inputOptions.SetMipmapData (dataPtr, 128, 128, 1, 0, 0);
inputOptions.SetMipmapGeneration (false);
inputOptions.SetGamma (1.0f, 1.0f);
compressionOptions.SetFormat (Format.RGBA);
outputOptions.SetOutputHeader (false);
outputOptions.SetOutputOptionsOutputHandler (BeginImage, WriteData, EndImage);
var estsize = compressor.EstimateSize (inputOptions, compressionOptions);
Assert.True (compressor.Compress (inputOptions, compressionOptions, outputOptions));
Assert.AreEqual (estsize, buffer.Length);
}finally {
a.Free ();
b.Free ();
c.Free ();
dataHandle.Free ();
}
}
byte [] buffer;
int offset;
void BeginImageInternal (int size, int width, int height, int depth, int face, int miplevel)
{
buffer = new byte [size];
offset = 0;
}
bool WriteDataInternal (IntPtr data, int length)
{
Marshal.Copy (data, buffer, offset, length);
offset += length;
return true;
}
void EndImageInternal ()
{
// add done write the buffer.
}
}
}

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.9.0" targetFramework="net461" />
</packages>

@ -44,6 +44,11 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextureTools.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Nvidia.TextureTools.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

@ -0,0 +1,4 @@
<configuration>
<dllmap os="macos" dll="nvtt.dll" target="libnvtt.dylib"/>
<dllmap os="linux" dll="nvtt.dll" target="libnvtt.so"/>
</configuration>

@ -422,8 +422,9 @@ namespace Nvidia.TextureTools
{
#region Delegates
public delegate void ErrorHandler(Error error);
private delegate void WriteDataDelegate(IntPtr data, int size);
private delegate void ImageDelegate(int size, int width, int height, int depth, int face, int miplevel);
public delegate bool OutputHandler(IntPtr data, int size);
public delegate void EndImageHandler();
public delegate void BeginImageHandler (int size, int width, int height, int depth, int face, int miplevel);
#endregion
#region Bindings
@ -447,8 +448,8 @@ namespace Nvidia.TextureTools
[DllImport("nvtt"), SuppressUnmanagedCodeSecurity]
private extern static void nvttSetOutputOptionsOutputHeader(IntPtr outputOptions, bool b);
//[DllImport("nvtt"), SuppressUnmanagedCodeSecurity]
//private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, WriteDataDelegate writeData, ImageDelegate image);
[DllImport("nvtt"), SuppressUnmanagedCodeSecurity]
private extern static void nvttSetOutputOptionsOutputHandler(IntPtr outputOptions, IntPtr beginImageHandler, IntPtr outputHandler, IntPtr endImageHandler);
#endregion
@ -477,6 +478,18 @@ namespace Nvidia.TextureTools
}
// @@ Add OutputHandler interface.
public void SetOutputOptionsOutputHandler (BeginImageHandler beginImageHandler, OutputHandler outputHandler, EndImageHandler endImageHandler)
{
IntPtr writeData = IntPtr.Zero;
IntPtr beginImage = IntPtr.Zero;
IntPtr endImage = IntPtr.Zero;
if (beginImageHandler != null || outputHandler != null || endImageHandler != null) {
writeData = Marshal.GetFunctionPointerForDelegate (outputHandler);
beginImage = Marshal.GetFunctionPointerForDelegate (beginImageHandler);
endImage = Marshal.GetFunctionPointerForDelegate (endImageHandler);
}
nvttSetOutputOptionsOutputHandler (this.options, beginImage, writeData, endImage);
}
}
#endregion

@ -47,6 +47,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nvthread", "nvthread\nvthre
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bc7", "bc7\bc7.vcxproj", "{F974F34B-AF02-4C88-8E1E-85475094EA78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nvidia.TextureTools.UnitTests", "Nvidia.TextureTools.UnitTests\Nvidia.TextureTools.UnitTests.csproj", "{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -219,6 +221,22 @@ Global
{F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|Win32.Build.0 = Release|Win32
{F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.ActiveCfg = Release|x64
{F974F34B-AF02-4C88-8E1E-85475094EA78}.Release-CUDA|x64.Build.0 = Release|x64
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug|Win32.ActiveCfg = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug|Win32.Build.0 = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug|x64.ActiveCfg = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug|x64.Build.0 = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|Win32.ActiveCfg = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|Win32.Build.0 = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|x64.ActiveCfg = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Debug-CUDA|x64.Build.0 = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|Win32.ActiveCfg = Release|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|Win32.Build.0 = Release|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|x64.ActiveCfg = Release|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release|x64.Build.0 = Release|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release-CUDA|Win32.ActiveCfg = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release-CUDA|Win32.Build.0 = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release-CUDA|x64.ActiveCfg = Debug|Any CPU
{553ABAEE-C4B8-4196-BC4A-EFF71D47CEAA}.Release-CUDA|x64.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save