Skip to content

Commit 4ab9331

Browse files
committed
lib: cprofiles: upgrade to v0.1.0
Signed-off-by: Eduardo Silva <[email protected]>
1 parent be91b40 commit 4ab9331

31 files changed

+22564
-198
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "actionlint",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"message": 4,
12+
"code": 5
13+
}
14+
]
15+
}
16+
]
17+
}

lib/cprofiles/.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
# Maintain dependencies for GitHub Actions
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
name: Build PR(s) and master branch.
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
types: [opened, reopened, synchronize]
10+
jobs:
11+
build-windows:
12+
name: Build sources on amd64 for ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [windows-latest, windows-2019]
18+
permissions:
19+
contents: read
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
25+
- name: Build on ${{ matrix.os }} with vs-2019
26+
run: |
27+
.\scripts\win_build.bat
28+
29+
- name: Run unit tests.
30+
run: |
31+
ctest --rerun-failed --output-on-failure -C Debug --test-dir .\tests\
32+
33+
build-centos:
34+
name: CentOS 7 build to confirm no issues once used downstream
35+
runs-on: ubuntu-latest
36+
container: centos:7
37+
permissions:
38+
contents: none
39+
steps:
40+
- name: Set up base image dependencies
41+
run: |
42+
sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
43+
sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
44+
yum -y update && \
45+
yum install -y ca-certificates cmake curl-devel gcc gcc-c++ git make wget && \
46+
yum install -y epel-release
47+
yum install -y cmake3
48+
shell: bash
49+
50+
- name: Clone repo without submodules (1.8.3 version of Git)
51+
run: |
52+
git clone https://github.com/fluent/cprofiles.git
53+
shell: bash
54+
55+
- name: Check out the branch (1.8.3 version of Git)
56+
env:
57+
BRANCH_NAME: ${{ github.head_ref }}
58+
run: |
59+
git checkout "$BRANCH_NAME"
60+
shell: bash
61+
working-directory: cprofiles
62+
63+
- name: Fetch the appropriate sub modules
64+
run: |
65+
git submodule init
66+
git submodule update
67+
shell: bash
68+
working-directory: cprofiles
69+
70+
- name: Run compilation
71+
run: |
72+
cmake3 -DCPROF_DEV=on ../
73+
make
74+
shell: bash
75+
working-directory: cprofiles/build
76+
77+
build-unix-arm64:
78+
name: Build sources on arm64 for ${{ matrix.os }} - ${{ matrix.compiler }}
79+
runs-on: ${{ matrix.os }}
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
os: [ubuntu-latest]
84+
compiler: [ gcc, clang ]
85+
permissions:
86+
contents: read
87+
steps:
88+
- uses: actions/checkout@v4
89+
with:
90+
submodules: true
91+
92+
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
93+
uses: uraimo/[email protected]
94+
with:
95+
arch: aarch64
96+
distro: ubuntu20.04
97+
run: |
98+
apt-get update && \
99+
apt-get install -y --no-install-recommends \
100+
build-essential \
101+
cmake \
102+
file \
103+
make
104+
export CC=${{ env.compiler }}
105+
cd build
106+
cmake -DCPROF_TESTS=On ../
107+
cmake --build .
108+
CTEST_OUTPUT_ON_FAILURE=1 ctest
109+
env:
110+
CC: ${{ matrix.compiler }}
111+
112+
build-unix-amd64:
113+
name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }}
114+
runs-on: ${{ matrix.os }}
115+
strategy:
116+
fail-fast: false
117+
matrix:
118+
os: [ubuntu-latest, macos-latest]
119+
compiler: [ gcc, clang ]
120+
permissions:
121+
contents: read
122+
steps:
123+
- uses: actions/checkout@v4
124+
with:
125+
submodules: true
126+
127+
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
128+
run: |
129+
echo "CC = $CC, CXX = $CXX"
130+
cmake -DCPROF_TESTS=On ../
131+
cmake --build .
132+
CTEST_OUTPUT_ON_FAILURE=1 ctest
133+
shell: bash
134+
working-directory: build
135+
env:
136+
CC: ${{ matrix.compiler }}
137+
138+
build-analysis-tests:
139+
name: Build with various code analysis tools
140+
strategy:
141+
fail-fast: false
142+
matrix:
143+
preset:
144+
- clang-sanitize-address
145+
- clang-sanitize-memory
146+
- clang-sanitize-undefined
147+
- clang-sanitize-dataflow
148+
- clang-sanitize-safe-stack
149+
- valgrind
150+
permissions:
151+
contents: read
152+
runs-on: ubuntu-latest
153+
steps:
154+
- uses: actions/checkout@v4
155+
with:
156+
submodules: true
157+
158+
- uses: docker://lpenz/ghaction-cmake:0.19
159+
with:
160+
preset: ${{ matrix.preset }}
161+
# dependencies_debian: ''
162+
cmakeflags: '-DCPROF_TESTS=On -DCPROF_DEV=on .'
163+
build_command: make all
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Lint PRs
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
8+
shellcheck-pr:
9+
runs-on: ubuntu-latest
10+
name: PR - Shellcheck
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: ludeeus/action-shellcheck@master
14+
15+
actionlint-pr:
16+
runs-on: ubuntu-latest
17+
name: PR - Actionlint
18+
steps:
19+
- uses: actions/checkout@v4
20+
- run: |
21+
echo "::add-matcher::.github/actionlint-matcher.json"
22+
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
23+
./actionlint -color -shellcheck=
24+
shell: bash
25+
26+
docslint-pr:
27+
runs-on: ubuntu-latest
28+
name: PR - Markdownlint
29+
steps:
30+
- uses: actions/checkout@v4
31+
- name: Run markdownlint
32+
uses: actionshub/[email protected]

lib/cprofiles/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*~
2+
.vscode/*
3+
build/*

lib/cprofiles/.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
[submodule "lib/fluent-otel-proto"]
55
path = lib/fluent-otel-proto
66
url = https://github.com/fluent/fluent-otel-proto
7+

lib/cprofiles/CMakeLists.txt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55

66
# CMetrics Version
77
set(CPROF_VERSION_MAJOR 0)
8-
set(CPROF_VERSION_MINOR 0)
9-
set(CPROF_VERSION_PATCH 1)
8+
set(CPROF_VERSION_MINOR 1)
9+
set(CPROF_VERSION_PATCH 0)
1010
set(CPROF_VERSION_STR "${CPROF_VERSION_MAJOR}.${CPROF_VERSION_MINOR}.${CPROF_VERSION_PATCH}")
1111

1212
# Include helpers
@@ -56,14 +56,6 @@ endif()
5656
include(cmake/libraries.cmake)
5757
include(cmake/headers.cmake)
5858

59-
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
60-
find_package(Sanitizers)
61-
62-
if(SANITIZE_ADDRESS)
63-
CPROF_DEFINITION(CPROF_HAVE_SANITIZE_ADDRESS)
64-
endif()
65-
66-
6759
# Include headers and dependency headers
6860
include_directories(
6961
src
@@ -146,14 +138,16 @@ endif()
146138
# Configure header files
147139
configure_file(
148140
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_info.h.in"
149-
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_info.h"
141+
"${PROJECT_BINARY_DIR}/include/cprofiles/cprof_info.h"
150142
)
151143

152144
configure_file(
153145
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_version.h.in"
154-
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_version.h"
146+
"${PROJECT_BINARY_DIR}/include/cprofiles/cprof_version.h"
155147
)
156148

149+
include_directories("${PROJECT_BINARY_DIR}/include/")
150+
157151
# Installation Directories
158152
# ========================
159153
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
@@ -223,7 +217,7 @@ endif()
223217
# fluent-otel-proto
224218
if (NOT CPROF_HAVE_FLUENT_OTEL_PROTO)
225219
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${CPROF_PATH_LIB_FLUENT_OTEL_PROTO}/include)
226-
CPROF_OPTION(FLUENT_PROTO_METRICS "on")
220+
CPROF_OPTION(FLUENT_PROTO_PROFILES "on")
227221
CPROF_OPTION(FLUENT_PROTO_EXAMPLES "off")
228222
add_subdirectory(lib/fluent-otel-proto)
229223
CPROF_DEFINITION(CPROF_HAVE_FLUENT_OTEL_PROTO)
@@ -353,7 +347,6 @@ if(CPROF_SYSTEM_MACOS)
353347

354348
if (CPACK_GENERATOR MATCHES "productbuild")
355349
set(CPACK_SET_DESTDIR "ON")
356-
configure_file(cpack/macos/welcome.txt.cmakein ${CMAKE_CURRENT_SOURCE_DIR}/welcome.txt)
357350
configure_file(LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
358351
find_program(CONVERTER textutil)
359352
if (NOT CONVERTER)
@@ -363,14 +356,13 @@ if(CPROF_SYSTEM_MACOS)
363356
execute_process(COMMAND ${CONVERTER} -convert html "${CMAKE_CURRENT_SOURCE_DIR}/README.md" -output "${CMAKE_CURRENT_SOURCE_DIR}/README.html")
364357
endif()
365358
set(CPACK_PACKAGE_FILE_NAME "${CMETRICS_PKG}")
366-
set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_SOURCE_DIR}/welcome.txt)
367359
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
368360
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.html)
369361
set(CPACK_PRODUCTBUILD_IDENTIFIER "com.calyptia.${CPACK_PACKAGE_NAME}")
370362
endif()
371363
endif()
372364

373365
# Create tarball
374-
# add_custom_target(tarball COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/create-submoduled-tarball.sh" "cprofiles-${CPROF_VERSION_STR}")
366+
add_custom_target(cprofiles_tarball COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/create-submoduled-tarball.sh" "cprofiles-${CPROF_VERSION_STR}")
375367

376368
include(CPack)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* CProfiles
4+
* ========
5+
* Copyright 2024 The CProfiles Authors
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#ifndef CPROF_DECODE_MSGPACK_H
21+
#define CPROF_DECODE_MSGPACK_H
22+
23+
#include <cprofiles/cprofiles.h>
24+
#include <mpack/mpack.h>
25+
26+
#define CPROF_DECODE_MSGPACK_SUCCESS 0
27+
#define CPROF_DECODE_MSGPACK_ALLOCATION_ERROR 1
28+
#define CPROF_DECODE_MSGPACK_INSUFFICIENT_DATA 2
29+
#define CPROF_DECODE_MSGPACK_INVALID_ARGUMENT_ERROR 3
30+
31+
struct crof_msgpack_decode_context {
32+
struct cprof *inner_context;
33+
mpack_reader_t reader;
34+
};
35+
36+
int cprof_decode_msgpack_create(struct cprof **result_context,
37+
unsigned char *in_buf,
38+
size_t in_size,
39+
size_t *offset);
40+
41+
void cprof_decode_msgpack_destroy(struct cprof *context);
42+
43+
#endif

0 commit comments

Comments
 (0)