test(opcua): package cross-platform lifecycle memory controls
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build optional local capture/summary tools using the user's installed dotnet-trace libraries."""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--libraries", required=True, type=Path, help="dotnet-trace tools/net8.0/any directory")
|
||||
parser.add_argument("--output", required=True, type=Path, help="Fresh local output directory")
|
||||
args = parser.parse_args()
|
||||
args.output = args.output.resolve()
|
||||
args.output.mkdir(parents=True, exist_ok=False)
|
||||
for name, source, references in [
|
||||
("capture", "EventPipeCapture.cs", ["Microsoft.Diagnostics.NETCore.Client"]),
|
||||
("summary", "TraceSummary.cs", ["Microsoft.Diagnostics.Tracing.TraceEvent", "Microsoft.Diagnostics.FastSerialization", "Microsoft.Diagnostics.NETCore.Client"])
|
||||
]:
|
||||
output = args.output / name
|
||||
output.mkdir()
|
||||
project = ET.Element("Project", Sdk="Microsoft.NET.Sdk")
|
||||
properties = ET.SubElement(project, "PropertyGroup")
|
||||
for key, value in {"OutputType": "Exe", "TargetFramework": "net10.0", "ImplicitUsings": "enable",
|
||||
"EnableDefaultCompileItems": "false"}.items():
|
||||
ET.SubElement(properties, key).text = value
|
||||
items = ET.SubElement(project, "ItemGroup")
|
||||
ET.SubElement(items, "FrameworkReference", Include="Microsoft.AspNetCore.App")
|
||||
ET.SubElement(items, "Compile", Include=str(Path(__file__).resolve().parent / source))
|
||||
for reference in references:
|
||||
dll = (args.libraries / (reference + ".dll")).resolve(strict=True)
|
||||
item = ET.SubElement(items, "Reference", Include=reference)
|
||||
ET.SubElement(item, "HintPath").text = str(dll)
|
||||
path = output / (name + ".csproj")
|
||||
ET.indent(project)
|
||||
ET.ElementTree(project).write(path, encoding="unicode")
|
||||
with (output / "build.log").open("w") as log:
|
||||
result = subprocess.run(["dotnet", "build", str(path), "-c", "Release", "-m:2"], stdout=log, stderr=subprocess.STDOUT)
|
||||
if result.returncode:
|
||||
raise SystemExit(result.returncode)
|
||||
Reference in New Issue
Block a user