Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Splamy committed Oct 22, 2016
2 parents bcf7ec8 + 977fc9b commit ae4f64a
Show file tree
Hide file tree
Showing 120 changed files with 18,435 additions and 3,078 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.userprefs
.buildvars.py
.sconsign.dblite
.vs/config/*

# Build results
[Dd]ebug/
Expand Down
98 changes: 48 additions & 50 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
sudo: false
language: csharp

compiler:
- clang

cache:
apt: true
directories:
- $HOME/FFmpegbin

addons:
apt:
sources:
# Try to add up to date compilers
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
packages:
- nasm
- build-essential
- cmake
- libcppunit-dev
- gcc-5
- g++-5
- clang-3.6
language: generic
# Build with docker to have an up-to-date version of ubuntu
sudo: required
services:
- docker

notifications:
email: false

branches:
only:
- master
- develop

git:
depth: 1

#cache:
# directories:
# - $HOME/docker

install:
- nuget restore TS3AudioBot.sln
- nuget install NUnit.Runners -OutputDirectory nunit

before_script:
- export THREADS=$((`nproc` + 1))
- echo "THREADS = $THREADS"
- cd "$HOME"
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then git clone --depth 1 --branch n3.0 https://github.com/FFmpeg/FFmpeg.git; fi
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then mkdir -p FFmpegbin; cd FFmpegbin; fi
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then $HOME/FFmpeg/configure --enable-shared; fi
- if [ ! -f "$HOME/FFmpegbin/libavcodec/libavcodec.so" ]; then make -j $THREADS; fi

solution: TS3AudioBot.sln
# Use the cached docker image if it is available
- mkdir -p "$HOME/docker"
- if [ -f "$HOME/docker/ts3audiobot.tar" ]; then
docker import "$HOME/docker/ts3audiobot.tar" ts3audiobot:latest;
else
docker build -t ts3audiobot -f Dockerfile .;
fi
# docker save -o "$HOME/docker/ts3audiobot.tar" ts3audiobot;
# fi

script:
# Building the AudioBob (C++ stuff)
- cd $TRAVIS_BUILD_DIR/TS3AudioBob
- mkdir bin
- cd bin
- cmake .. -DAVCODEC_INCLUDE_DIRS="$HOME/FFmpeg" -DAVCODEC_LIBRARIES="$HOME/FFmpegbin/libavcodec/libavcodec.so" -DAVFILTER_INCLUDE_DIRS="$HOME/FFmpeg" -DAVFILTER_LIBRARIES="$HOME/FFmpegbin/libavfilter/libavfilter.so" -DAVFORMAT_INCLUDE_DIRS="$HOME/FFmpeg" -DAVFORMAT_LIBRARIES="$HOME/FFmpegbin/libavformat/libavformat.so" -DAVUTIL_INCLUDE_DIRS="$HOME/FFmpegbin" -DAVUTIL_LIBRARIES="$HOME/FFmpegbin/libavutil/libavutil.so" -DSWSCALE_INCLUDE_DIRS="$HOME/FFmpeg" -DSWSCALE_LIBRARIES="$HOME/FFmpegbin/libswscale/libswscale.so" -DSWRESAMPLE_INCLUDE_DIRS="$HOME/FFmpeg" -DSWRESAMPLE_LIBRARIES="$HOME/FFmpegbin/libswresample/libswresample.so" -DSWSCALE_INCLUDE_DIRS="$HOME/FFmpeg" -DSWSCALE_LIBRARIES="$HOME/FFmpegbin/libswscale/libswscale.so" -DBUILD_TESTS=1 -DBUILD_FUZZ=1 -DCMAKE_C_COMPILER=`which clang` -DCMAKE_CXX_COMPILER=`which clang++`
- make VERBOSE=1 -j $THREADS
- LD_LIBRARY_PATH="$HOME/FFmpegbin/libavcodec:$HOME/FFmpegbin/libavfilter:$HOME/FFmpegbin/libavformat:$HOME/FFmpegbin/libavutil:$HOME/FFmpegbin/libswresample:$HOME/FFmpegbin/libswscale" ./ts3audiobobtest

# Building the AudioBot (C# stuff)
- cd "$TRAVIS_BUILD_DIR"
- xbuild /p:Configuration=Release TS3AudioBot.sln
- mono ./nunit/NUnit.ConsoleRunner.*.*.*/tools/nunit3-console.exe ./TS3ABotUnitTests/bin/Release/TS3ABotUnitTests.dll
- docker run -v "$TRAVIS_BUILD_DIR:/build" ts3audiobot sh -c "
export THREADS=\$((`nproc` + 1)) &&
echo \"THREADS = \$THREADS\" &&

echo Building the AudioBob \(C++ stuff\) &&
cd TS3AudioBob &&
mkdir bin && cd bin &&
cmake .. -DBUILD_TESTS=1 -DBUILD_FUZZ=1 &&
make VERBOSE=1 -j \$THREADS &&
./ts3audiobobtest &&
cd ../.. &&

echo Building the AudioBot \(C# Stuff\) &&
nuget restore TS3AudioBot.sln &&
nuget install NUnit.Runners -OutputDirectory nunit &&
xbuild /p:Configuration=Release TS3AudioBot.sln &&
mono ./nunit/NUnit.ConsoleRunner.*.*.*/tools/nunit3-console.exe ./TS3ABotUnitTests/bin/Release/TS3ABotUnitTests.dll
"
after_script:
- cd $TRAVIS_BUILD_DIR
Expand Down
Binary file modified ClassDiagram.dia
Binary file not shown.
707 changes: 430 additions & 277 deletions ClassDiagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:xenial

# Get dependencies
RUN apt-get update && apt-get -y install build-essential cmake libcppunit-dev \
libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev \
libavutil-dev git mono-xbuild nuget mono-devel

RUN mkdir /build
WORKDIR /build
6 changes: 6 additions & 0 deletions PluginTests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
16 changes: 16 additions & 0 deletions PluginTests/PluginA.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PluginTests
{
class PluginA : IPlugin
{
public void Initialize(MainClass mc)
{

}
}
}
62 changes: 62 additions & 0 deletions PluginTests/PluginTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{DDBB1943-929D-43F6-A7E1-01903DD05D64}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PluginTests</RootNamespace>
<AssemblyName>PluginTests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</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>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PluginA.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
135 changes: 135 additions & 0 deletions PluginTests/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Linq;

namespace PluginTests
{
class Program
{
static void Main(string[] args)
{
var mc = new MainClass();
mc.LoadPlugin(new FileInfo("PluginA.cs"));
}
}

public class MainClass
{
public void Feature1() { }
public void Feature2(int value) { int x = value + 10; var x2 = x.ToString().Split('1'); }
public int Feature3() { return 42; }
public MainClass Feature4() { return this; }

private static readonly FileInfo ts3File = new FileInfo(typeof(IPlugin).Assembly.Location);
public AppDomain domain;

public PluginResponse LoadPlugin(FileInfo file)
{
try
{
if (file.Extension != ".cs" && file.Extension != ".dll" && file.Extension != ".exe")
return PluginResponse.UnsupportedFile;

domain = AppDomain.CreateDomain(
"Plugin_" + file.Name,
AppDomain.CurrentDomain.Evidence,
new AppDomainSetup
{
ShadowCopyFiles = "true",
ShadowCopyDirectories = ts3File.Directory.FullName,
ApplicationBase = ts3File.Directory.FullName,
PrivateBinPath = "Plugin/..;Plugin",
PrivateBinPathProbe = ""
});
domain.UnhandledException += (s, e) => { Console.WriteLine("Plugin unex: {0}", e.ExceptionObject); };

//domain.Load()

Assembly result;
if (file.Extension == ".cs")
result = PrepareSource(file);
else if (file.Extension == ".dll" || file.Extension == ".exe")
result = PrepareBinary(file);
else throw new InvalidProgramException();

return PluginResponse.Ok;
}
catch (Exception ex)
{
Console.WriteLine("Possible plugin failed to load: ", ex);
return PluginResponse.Crash;
}
}

private static CompilerParameters GenerateCompilerParameter()
{
var cp = new CompilerParameters();
Assembly[] aarr = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < aarr.Length; i++)
{
if (aarr[i].IsDynamic) continue;
cp.ReferencedAssemblies.Add(aarr[i].Location);
}
cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);

// set preferences
cp.WarningLevel = 3;
cp.CompilerOptions = "/target:library /optimize";
cp.GenerateExecutable = false;
cp.GenerateInMemory = true;
return cp;
}

private Assembly PrepareSource(FileInfo file)
{
var provider = CodeDomProvider.CreateProvider("CSharp");
var cp = GenerateCompilerParameter();
var result = provider.CompileAssemblyFromFile(cp, file.FullName);

if (result.Errors.Count > 0)
{
bool containsErrors = false;
foreach (CompilerError error in result.Errors)
{
containsErrors |= !error.IsWarning;
Console.WriteLine("Plugin_{0}: {1} L{2}/C{3}: {4}\n",
file.Name,
error.IsWarning ? "Warning" : "Error",
error.Line,
error.Column,
error.ErrorText);
}

if (containsErrors)
return null;
}

return result.CompiledAssembly;
}

private Assembly PrepareBinary(FileInfo file)
{
return null;
}
}

public interface IPlugin
{
void Initialize(MainClass mc);
}

public enum PluginResponse
{
Ok,
UnsupportedFile,
Crash,
NoTypeMatch,
TooManyPlugins,
UnknownStatus,
PluginNotFound,
CompileError,
}
}
36 changes: 36 additions & 0 deletions PluginTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("PluginTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PluginTests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[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("ddbb1943-929d-43f6-a7e1-01903dd05d64")]

// 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")]
Loading

0 comments on commit ae4f64a

Please sign in to comment.