-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (59 loc) · 4.99 KB
/
tritonservercppsharp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: tritonservercppsharp
on: workflow_dispatch
env:
PLATFORM: x64
FRAMEWORK: net80
FRAMEWORKDOT: net8.0
jobs:
tritonservercppsharp:
runs-on: ubuntu-22.04
steps:
- 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: 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: Generate bindings oftritonserver
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
./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
# 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/