Skip to content

tritonservercppsharp #18

tritonservercppsharp

tritonservercppsharp #18

name: tritonservercppsharp
on: workflow_dispatch
env:
PLATFORM: x64
jobs:
tritonservercppsharp:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Write down the bindings code
run: |
tee tritonservercppsharp.cs <<EOF
namespace CppSharpTransformer {
public static class Program { public static void Main(string[] args) { CppSharp.ConsoleDriver.Run(new DllDemoGenerator()); } }
public class DllDemoGenerator : CppSharp.ILibrary {
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("core/include");
module.Headers.Add("triton/core/tritonserver.h");
module.Headers.Add("triton/core/tritonbackend.h");
module.Headers.Add("triton/core/tritoncache.h");
module.Headers.Add("triton/core/tritonrepoagent.h");
//module.LibraryDirs.Add("/path/to/triton/server.so");
//module.Libraries.Add("tritonserver.so");
}
} }
EOF
- name: Clone and build CppSharp
run: |
#wget https://dot.net/v1/dotnet-install.sh && bash dotnet-install.sh --channel 9.0
git clone --single-branch --depth 1 https://github.com/mono/CppSharp
cd CppSharp
bash build/build.sh generate -configuration Release -platform $PLATFORM
bash build/build.sh download_llvm -platform $PLATFORM
bash build/build.sh restore -platform $PLATFORM
bash build/build.sh -platform $PLATFORM -build_only
find bin
- name: Generating bindings
run: |
git clone --single-branch --depth 1 https://github.com/triton-inference-server/core
#"$HOME/.dotnet"
DOTNET_ROOT=/usr/share/dotnet
DOTNETSDKVER=$(dotnet --version)
DOTNETFWKVER=$(dotnet --list-runtimes | grep Microsoft.NETCore.App | tail -n 1 | cut -d " " -f2)
DOTNETLIBDIR="$DOTNET_ROOT/shared/Microsoft.NETCore.App/$DOTNETFWKVER"
dotnet --version
dotnet --list-runtimes
ls $DOTNET_ROOT/sdk
echo $DOTNETSDKVER $DOTNETFWKVER
find CppSharp/bin/ -name "*.dll"
# -r:CppSharp/bin/Release_x64/CppSharp.dll -r:CppSharp/bin/Release_x64/CppSharp.AST.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.dll
export LD_LIBRARY_PATH=CppSharp/bin/Release_x64/
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:library -out:tritonservercppsharptest.exe tritonservercppsharp.cs
echo '{"runtimeOptions":{"framework":{"name":"Microsoft.NETCore.App","version":"'$DOTNETFWKVER'"}}}' > tritonservercppsharptest.runtimeconfig.json
dotnet tritonservercppsharptest.exe
find
- uses: actions/upload-artifact@v4
with:
path: CppSharp/bin/