tritonservercppsharp #27
This file contains hidden or 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 | |
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 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("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 | |
echo $DOTNETSDKVER $DOTNETFWKVER | |
# -r:CppSharp/bin/Release_x64/CppSharp.dll -r:CppSharp/bin/Release_x64/CppSharp.AST.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.dll | |
#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 | |
find CppSharp/bin/Release_x64 -name 'CppSharp*.dll' | |
# -r:CppSharp/bin/Release_x64/CppSharp.dll -r:CppSharp/bin/Release_x64/CppSharp.AST.dll -r:CppSharp/bin/Release_x64/CppSharp.Runtime.dll -r:CppSharp/bin/Release_x64/CppSharp.CLI.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.CSharp.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.Bootstrap.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.Gen.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:exe -out:tritonservercppsharp.exe tritonservercppsharp.cs | |
echo '{"runtimeOptions":{"framework":{"name":"Microsoft.NETCore.App","version":"'$DOTNETFWKVER'"}}}' > tritonservercppsharp.runtimeconfig.json | |
echo BEFORE | |
find CppSharp/bin -name "*.dll" -o -name "*.so" -exec cp {} . ';' | |
dotnet tritonservercppsharp.exe | |
# - uses: actions/upload-artifact@v4 | |
# with: | |
# path: CppSharp/bin/ |