tritonservercppsharp #4
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 { 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) { } | |
void CppSharp.ILibrary.Setup(CppSharp.Driver driver) { } | |
void Setup(CppSharp.Driver driver) { | |
var options = driver.Options; | |
options.GeneratorKind = GeneratorKind.CSharp; | |
var module = options.AddModule("TritonServerCppSharp"); | |
module.IncludeDirs.Add("core/include"); | |
module.Headers.Add("triton/core/tritonserver.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 | |
dotnet --version | |
- 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" | |
# -r:CppSharp/bin/Release_x64/CppSharp.dll -r:CppSharp/bin/Release_x64/CppSharp.AST.dll -r:CppSharp/bin/Release_x64/CppSharp.Parser.dll | |
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:tritonservercppsharp.exe tritonservercppsharp.cs | |
dotnet tritonservercppsharp.exe | |
find | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: CppSharp/bin/ |