-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbuild.py
More file actions
64 lines (50 loc) · 2.38 KB
/
build.py
File metadata and controls
64 lines (50 loc) · 2.38 KB
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
from pathlib import Path
from cffi import FFI # type: ignore
ffibuilder = FFI()
includes_dir = Path(__file__).parent.joinpath("instrument-hooks/includes")
header_text = (includes_dir / "core.h").read_text()
# Manually copied from `instrument-hooks/includes/core.h` to avoid parsing issues
ffibuilder.cdef("""
typedef uint64_t *InstrumentHooks;
InstrumentHooks *instrument_hooks_init(void);
void instrument_hooks_deinit(InstrumentHooks *);
bool instrument_hooks_is_instrumented(InstrumentHooks *);
uint8_t instrument_hooks_start_benchmark(InstrumentHooks *);
uint8_t instrument_hooks_stop_benchmark(InstrumentHooks *);
uint8_t instrument_hooks_set_executed_benchmark(InstrumentHooks *, int32_t pid,
const char *uri);
uint8_t instrument_hooks_set_integration(InstrumentHooks *, const char *name,
const char *version);
#define MARKER_TYPE_SAMPLE_START 0
#define MARKER_TYPE_SAMPLE_END 1
#define MARKER_TYPE_BENCHMARK_START 2
#define MARKER_TYPE_BENCHMARK_END 3
uint8_t instrument_hooks_add_marker(InstrumentHooks *, uint32_t pid,
uint8_t marker_type, uint64_t timestamp);
uint64_t instrument_hooks_current_timestamp(void);
void callgrind_start_instrumentation();
void callgrind_stop_instrumentation();
void instrument_hooks_set_feature(uint64_t feature, bool enabled);
uint8_t instrument_hooks_set_environment(InstrumentHooks *, const char *section_name,
const char *key, const char *value);
uint8_t instrument_hooks_set_environment_list(InstrumentHooks *,
const char *section_name,
const char *key,
const char *const *values,
uint32_t count);
uint8_t instrument_hooks_write_environment(InstrumentHooks *, uint32_t pid);
""")
ffibuilder.set_source(
"pytest_codspeed.instruments.hooks.dist_instrument_hooks",
"""
#include "core.h"
""",
sources=[
"src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c",
],
include_dirs=[str(includes_dir)],
# IMPORTANT: Keep in sync with instrument-hooks/ci.yml (COMMON_CFLAGS)
extra_compile_args=["-Wno-format-security"],
)
if __name__ == "__main__":
ffibuilder.compile(verbose=True)