tritonservercppsharp #84
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 | |
FRAMEWORKDOT: net8.0 | |
jobs: | |
tritonservercppsharp: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Clone tritonserver | |
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 | |
- 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 | |
- name: Variant 1 | |
run: ./CppSharp/bin/Release_x64/CppSharp.CLI -m tritonserver -g csharp -p linux -a x64 -o ./variant1/ -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 | |
- name: Variant 3 | |
run: ./CppSharp/bin/Release_x64/CppSharp.CLI -m tritondevelopertoolsserver -g csharp -p linux -a x64 -o ./variant3/ -I=developer_tools/server/include -I=core/include -I=developer_tools/server/include/triton/developer_tools developer_tools/server/include/triton/developer_tools/server_wrapper.h developer_tools/server/include/triton/developer_tools/generic_server_wrapper.h || true # developer_tools/server/include/triton/developer_tools/common.h # https://github.com/mono/CppSharp/issues/1860#issuecomment-2322838240 | |
- name: Variant 2 | |
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("tritonserver"); | |
options.OutputDir = "variant2"; | |
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 | |
mkdir -p bin/x64/Release/$FRAMEWORKDOT && cp -r ./CppSharp/bin/Release_x64/lib bin/x64/Release/$FRAMEWORKDOT/lib | |
LD_PRELOAD=$PWD/CppSharp/bin/Release_x64/libCppSharp.CppParser.so:$PWD/CppSharp/bin/Release_x64/libStd-symbols.so dotnet run -c Release | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: | | |
variant1/ | |
variant2/ | |
variant3/ |