tritonservercppsharp #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: tritonservercppsharp | |
on: workflow_dispatch | |
env: | |
PLATFORM: x64 | |
FRAMEWORK: net80 | |
DOTNET_ROOT: /usr/share/dotnet | |
DOTNETSDKVER: 8.0.303 | |
DOTNETFWKVER: 8.0.7 | |
jobs: | |
tritonservercppsharp: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Write down the bindings code | |
run: | | |
echo '<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework><EnableDefaultItems>false</EnableDefaultItems></PropertyGroup><ItemGroup><Compile Remove="**/*.cs"/><Compile Include="tritonservercppsharp.cs"/><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.Runtime.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.AST.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.Generator.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.CLI.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.Parser.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.Parser.CSharp.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.Parser.Bootstrap.dll</HintPath></Reference><Reference Include="MyAssembly"><HintPath>./CppSharp/bin/Release_x64/CppSharp.Parser.Gen.dll</HintPath></Reference></ItemGroup></Project>' > tritonservercppsharp.csproj | |
tee tritonservercppsharp.cs <<EOF | |
namespace CppSharpTransformer { public class DllDemoGenerator : CppSharp.ILibrary { | |
public static void Main(string[] args) { CppSharp.ConsoleDriver.Run(new DllDemoGenerator()); } | |
public void SetupPasses(CppSharp.Driver driver) { } | |
public void Preprocess(CppSharp.Driver driver, CppSharp.AST.ASTContext ctx) { } | |
public void Postprocess(CppSharp.Driver driver, CppSharp.AST.ASTContext ctx) { } | |
public void Setup(CppSharp.Driver driver) { | |
var options = driver.Options; | |
options.GeneratorKind = CppSharp.Generators.GeneratorKind.CSharp; | |
var module = options.AddModule("TritonServerCppSharp"); | |
module.IncludeDirs.Add("."); | |
module.IncludeDirs.Add("core/include"); | |
module.Headers.Add("core/include/triton/core/tritonserver.h"); | |
module.Headers.Add("core/include/triton/core/tritonbackend.h"); | |
module.Headers.Add("core/include/triton/core/tritoncache.h"); | |
module.Headers.Add("core/include/triton/core/tritonrepoagent.h"); | |
//module.LibraryDirs.Add("/path/to/triton/server.so"); | |
//module.Libraries.Add("tritonserver.so"); | |
} } } | |
EOF | |
- name: Clone and build CppSharp | |
run: | | |
git clone --single-branch --depth 1 https://github.com/mono/CppSharp | |
cd CppSharp | |
bash build/build.sh generate -configuration Release -platform $PLATFORM -target-framework $FRAMEWORK | |
bash build/build.sh download_llvm -platform $PLATFORM -target-framework $FRAMEWORK | |
bash build/build.sh restore -platform $PLATFORM -target-framework $FRAMEWORK | |
bash build/build.sh -platform $PLATFORM -build_only -target-framework $FRAMEWORK | |
find bin | |
- name: Generating bindings | |
run: | | |
git clone --single-branch --depth 1 --branch r24.08 https://github.com/triton-inference-server/core | |
git clone --single-branch --depth 1 --branch r24.08 https://github.com/triton-inference-server/developer_tools | |
dotnet --version | |
dotnet --list-runtimes | |
#ls $DOTNET_ROOT/shared/Microsoft.NETCore.App | |
#DOTNETLIBDIR="$DOTNET_ROOT/shared/Microsoft.NETCore.App/$DOTNETFWKVER" | |
cp -r ./CppSharp/bin/Release_x64/libCppSharp.CppParser.so ./CppSharp/bin/Release_x64/libStd-symbols.so ./CppSharp/bin/Release_x64/lib . | |
mkdir output && ./CppSharp/bin/Release_x64/CppSharp.CLI -g csharp -p linux -a x64 -o ./output/ -I=core/include core/include/triton/core/tritonserver.h core/include/triton/core/tritonbackend.h core/include/triton/core/tritoncache.h core/include/triton/core/tritonrepoagent.h | |
echo AFTER CLI | |
#DOTNETSDKVER=$(dotnet --version) | |
#DOTNETFWKVER=$(dotnet --list-runtimes | grep Microsoft.NETCore.App | tail -n 1 | cut -d " " -f2) | |
#echo 'namespace ProgramNamespace { public static class Program { public static void Main(string[] args) { System.Console.WriteLine("Hello world!"); } } }' > footest.cs | |
#dotnet "$DOTNET_ROOT/sdk/$DOTNETSDKVER/Roslyn/bincore/csc.dll" $(find "$DOTNETLIBDIR" -name "*.dll" -printf '-r:"%p" ') -target:exe -out:footest.exe footest.cs | |
#echo '{"runtimeOptions":{"framework":{"name":"Microsoft.NETCore.App","version":"'$DOTNETFWKVER'"}}}' > footest.runtimeconfig.json | |
#dotnet footest.exe | |
#mkdir testproj && cd testproj | |
#dotnet new console | |
#cd .. | |
#dotnet "$DOTNET_ROOT/sdk/$DOTNETSDKVER/Roslyn/bincore/csc.dll" $(find "$DOTNETLIBDIR" -name "*.dll" -printf '-r:"%p" ') $(find CppSharp/bin -name "*.dll" -printf '-r:"%p" ') -target:exe -out:tritonservercppsharp tritonservercppsharp.cs | |
#echo '{"runtimeOptions":{"framework":{"name":"Microsoft.NETCore.App","version":"'$DOTNETFWKVER'"}}}' > tritonservercppsharp.runtimeconfig.json | |
#find CppSharp/bin -name "*.dll" -o -name "*.so" -exec cp {} . ';' | |
#./tritonservercppsharp | |
#strace -ff dotnet tritonservercppsharp.exe || true | |
echo BEFORE | |
mkdir -p bin/x64/Debug/net8.0 | |
cp -r lib bin/x64/Debug/net8.0/lib | |
LD_PRELOAD=$PWD/libCppSharp.CppParser.so:$PWD/libStd-symbols.so dotnet run | |
find -name 'Std.cs' | |
# - uses: actions/upload-artifact@v4 | |
# with: | |
# path: | | |
# testproj/ | |
# CppSharp/bin/ | |
# tritonservercppsharp.cs | |
# tritonservercppsharp.runtimeconfig.json | |
# tritonservercppsharp.exe |