Skip to content

Commit f566e0a

Browse files
committed
Initial proof-of-concept hacked together.
1 parent 9860b61 commit f566e0a

File tree

20 files changed

+233276
-57
lines changed

20 files changed

+233276
-57
lines changed

tools/server/server.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<PackageReference Include="Bond.Compiler" Version="9.0.4" />
2020
<PackageReference Include="Bond.Core.CSharp" Version="9.0.3" />
2121
<PackageReference Include="Bond.Runtime.CSharp" Version="9.0.3" />
22+
<PackageReference Include="FiddlerCore5" Version="5.0.2" />
2223
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2324
</ItemGroup>
2425

wrappers/rust/Cargo.toml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
[package]
2-
name = "msft-client-telemetry"
3-
version = "0.1.0"
4-
edition = "2021"
5-
publish = false
6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1+
[workspace]
2+
resolver = "2"
73

8-
[dependencies]
9-
10-
[dev-dependencies]
11-
12-
[build-dependencies]
13-
bindgen = "0.65.1"
4+
members = [
5+
"telemetry",
6+
"telemetry-sample"
7+
]

wrappers/rust/build.cmd

Lines changed: 0 additions & 12 deletions
This file was deleted.

wrappers/rust/build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @echo off
2+
3+
# set VSTOOLS_VERSION=vs2019
4+
# cd %~dp0
5+
6+
# call ..\..\tools\vcvars.cmd
7+
#![allow(non_upper_case_globals)]
8+
#![allow(non_camel_case_types)]
9+
#![allow(non_snake_case)]
10+
#deploy-dll.cmd
11+
#generate-bindings.cmd
12+
13+
cargo run

wrappers/rust/deploy-dll.cmd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@echo off
2+
set PROJECT_DIR=%~dp0
3+
4+
@mkdir %PROJECT_DIR%\include
5+
copy %PROJECT_DIR%..\..\lib\include\public\mat.h %PROJECT_DIR%\include
6+
copy %PROJECT_DIR%..\..\lib\include\public\Version.h %PROJECT_DIR%\include
7+
copy %PROJECT_DIR%..\..\lib\include\public\ctmacros.hpp %PROJECT_DIR%\include
8+
9+
@mkdir %PROJECT_DIR%\lib\%1\%2
10+
copy %PROJECT_DIR%..\..\Solutions\out\%1\%2\win32-dll\*.lib %PROJECT_DIR%\lib\%1\%2
11+
copy %PROJECT_DIR%..\..\Solutions\out\Release\x64\lib\Release\*.lib %PROJECT_DIR%\lib\%1\%2
12+
13+
exit /b 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
clang -E mat.h -D HAVE_DYNAMIC_C_LIB > mat.out.h

wrappers/rust/include/ctmacros.hpp

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
#ifndef CTMACROS_HPP
6+
#define CTMACROS_HPP
7+
8+
#ifdef HAVE_MAT_SHORT_NS
9+
#define MAT_NS_BEGIN MAT
10+
#define MAT_NS_END
11+
#define PAL_NS_BEGIN PAL
12+
#define PAL_NS_END
13+
#else
14+
#define MAT_NS_BEGIN Microsoft { namespace Applications { namespace Events
15+
#define MAT_NS_END }}
16+
#define MAT ::Microsoft::Applications::Events
17+
#define PAL_NS_BEGIN Microsoft { namespace Applications { namespace Events { namespace PlatformAbstraction
18+
#define PAL_NS_END }}}
19+
#define PAL ::Microsoft::Applications::Events::PlatformAbstraction
20+
#endif
21+
22+
#define MAT_v1 ::Microsoft::Applications::Telemetry
23+
24+
#ifdef _WIN32 // Windows platforms
25+
26+
#ifndef MATSDK_SPEC // we use __cdecl by default
27+
#define MATSDK_SPEC __cdecl
28+
#define MATSDK_LIBABI_CDECL __cdecl
29+
# if defined(MATSDK_SHARED_LIB)
30+
# define MATSDK_LIBABI __declspec(dllexport)
31+
# elif defined(MATSDK_STATIC_LIB)
32+
# define MATSDK_LIBABI
33+
# else // Header file included by client
34+
# ifndef MATSDK_LIBABI
35+
# define MATSDK_LIBABI
36+
# endif
37+
# endif
38+
#endif
39+
40+
#else // Non-windows platforms
41+
42+
#ifndef MATSDK_SPEC
43+
#define MATSDK_SPEC
44+
#endif
45+
46+
#ifndef MATSDK_LIBABI_CDECL
47+
#define MATSDK_LIBABI_CDECL
48+
#endif
49+
50+
#ifndef MATSDK_LIBABI
51+
#define MATSDK_LIBABI
52+
#endif
53+
54+
// TODO: [MG] - ideally we'd like to use __attribute__((unused)) with gcc/clang
55+
#ifndef UNREFERENCED_PARAMETER
56+
#define UNREFERENCED_PARAMETER(...)
57+
#endif
58+
59+
#define OACR_USE_PTR(...)
60+
61+
#ifndef _Out_writes_bytes_
62+
#define _Out_writes_bytes_(...)
63+
#endif
64+
65+
#endif
66+
67+
#ifdef MATSDK_UNUSED
68+
#elif defined(__GNUC__) || defined(__clang__)
69+
# define MATSDK_UNUSED(x) (x) /* __attribute__((unused)) */
70+
#elif defined(__LCLINT__)
71+
# define MATSDK_UNUSED(x) /*@unused@*/ x
72+
#elif defined(__cplusplus)
73+
# define MATSDK_UNUSED(x)
74+
#else
75+
# define MATSDK_UNUSED(x) x
76+
#endif
77+
78+
#define STRINGIZE_DETAIL(x) #x
79+
#define STRINGIZE(x) STRINGIZE_DETAIL(x)
80+
#define STRINGIFY(x) #x
81+
#define TOKENPASTE(x, y) x ## y
82+
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
83+
84+
// Macro for mutex issues debugging. Supports both std::mutex and std::recursive_mutex
85+
#define LOCKGUARD(macro_mutex) LOG_DEBUG("LOCKGUARD lockin at %s:%d", __FILE__, __LINE__); std::lock_guard<decltype(macro_mutex)> TOKENPASTE2(__guard_, __LINE__) (macro_mutex); LOG_DEBUG("LOCKGUARD locked at %s:%d", __FILE__, __LINE__);
86+
87+
#if defined(_WIN32) || defined(_WIN64)
88+
#ifdef _WIN64
89+
#define ARCH_64BIT
90+
#else
91+
#define ARCH_32BIT
92+
#endif
93+
#endif
94+
95+
#if __GNUC__
96+
#if defined(__x86_64__) || defined(__ppc64__)
97+
#define ARCH_64BIT
98+
#else
99+
#define ARCH_32BIT
100+
#endif
101+
#endif
102+
103+
/* Exceptions support is optional */
104+
#if (__cpp_exceptions) || defined(__EXCEPTIONS)
105+
#define HAVE_EXCEPTIONS 1
106+
#else
107+
#define HAVE_EXCEPTIONS 0
108+
#endif
109+
110+
// allow to disable exceptions
111+
#if (HAVE_EXCEPTIONS)
112+
# define MATSDK_TRY try
113+
# define MATSDK_CATCH catch
114+
# define MATSDK_THROW throw
115+
#else
116+
# define MATSDK_TRY if (true)
117+
# define MATSDK_CATCH(...) if (false)
118+
# define MATSDK_THROW(...) std::abort()
119+
#endif
120+
121+
#if defined(__arm__) || defined(_M_ARM) || defined(_M_ARMT)
122+
/* TODO: add support for 64-bit aarch64 */
123+
#define ARCH_ARM
124+
#endif
125+
126+
#define EVTSDK_LIBABI MATSDK_LIBABI
127+
#define EVTSDK_LIBABI_CDECL MATSDK_LIBABI_CDECL
128+
#define EVTSDK_SPEC MATSDK_SPEC
129+
130+
#endif

0 commit comments

Comments
 (0)