Skip to content

Commit

Permalink
lib: cprofiles: upgrade to v0.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Dec 18, 2024
1 parent be91b40 commit 4ab9331
Show file tree
Hide file tree
Showing 31 changed files with 22,564 additions and 198 deletions.
17 changes: 17 additions & 0 deletions lib/cprofiles/.github/actionlint-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "actionlint",
"pattern": [
{
"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)* \\[(.+?)\\]$",
"file": 1,
"line": 2,
"column": 3,
"message": 4,
"code": 5
}
]
}
]
}
12 changes: 12 additions & 0 deletions lib/cprofiles/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
163 changes: 163 additions & 0 deletions lib/cprofiles/.github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Build PR(s) and master branch.
on:
push:
branches:
- master
pull_request:
branches:
- master
types: [opened, reopened, synchronize]
jobs:
build-windows:
name: Build sources on amd64 for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, windows-2019]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build on ${{ matrix.os }} with vs-2019
run: |
.\scripts\win_build.bat
- name: Run unit tests.
run: |
ctest --rerun-failed --output-on-failure -C Debug --test-dir .\tests\
build-centos:
name: CentOS 7 build to confirm no issues once used downstream
runs-on: ubuntu-latest
container: centos:7
permissions:
contents: none
steps:
- name: Set up base image dependencies
run: |
sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
yum -y update && \
yum install -y ca-certificates cmake curl-devel gcc gcc-c++ git make wget && \
yum install -y epel-release
yum install -y cmake3
shell: bash

- name: Clone repo without submodules (1.8.3 version of Git)
run: |
git clone https://github.com/fluent/cprofiles.git
shell: bash

- name: Check out the branch (1.8.3 version of Git)
env:
BRANCH_NAME: ${{ github.head_ref }}
run: |
git checkout "$BRANCH_NAME"
shell: bash
working-directory: cprofiles

- name: Fetch the appropriate sub modules
run: |
git submodule init
git submodule update
shell: bash
working-directory: cprofiles

- name: Run compilation
run: |
cmake3 -DCPROF_DEV=on ../
make
shell: bash
working-directory: cprofiles/build

build-unix-arm64:
name: Build sources on arm64 for ${{ matrix.os }} - ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
compiler: [ gcc, clang ]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
uses: uraimo/[email protected]
with:
arch: aarch64
distro: ubuntu20.04
run: |
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
cmake \
file \
make
export CC=${{ env.compiler }}
cd build
cmake -DCPROF_TESTS=On ../
cmake --build .
CTEST_OUTPUT_ON_FAILURE=1 ctest
env:
CC: ${{ matrix.compiler }}

build-unix-amd64:
name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
compiler: [ gcc, clang ]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
run: |
echo "CC = $CC, CXX = $CXX"
cmake -DCPROF_TESTS=On ../
cmake --build .
CTEST_OUTPUT_ON_FAILURE=1 ctest
shell: bash
working-directory: build
env:
CC: ${{ matrix.compiler }}

build-analysis-tests:
name: Build with various code analysis tools
strategy:
fail-fast: false
matrix:
preset:
- clang-sanitize-address
- clang-sanitize-memory
- clang-sanitize-undefined
- clang-sanitize-dataflow
- clang-sanitize-safe-stack
- valgrind
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: docker://lpenz/ghaction-cmake:0.19
with:
preset: ${{ matrix.preset }}
# dependencies_debian: ''
cmakeflags: '-DCPROF_TESTS=On -DCPROF_DEV=on .'
build_command: make all
32 changes: 32 additions & 0 deletions lib/cprofiles/.github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint PRs
on:
pull_request:
workflow_dispatch:

jobs:

shellcheck-pr:
runs-on: ubuntu-latest
name: PR - Shellcheck
steps:
- uses: actions/checkout@v4
- uses: ludeeus/action-shellcheck@master

actionlint-pr:
runs-on: ubuntu-latest
name: PR - Actionlint
steps:
- uses: actions/checkout@v4
- run: |
echo "::add-matcher::.github/actionlint-matcher.json"
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color -shellcheck=
shell: bash
docslint-pr:
runs-on: ubuntu-latest
name: PR - Markdownlint
steps:
- uses: actions/checkout@v4
- name: Run markdownlint
uses: actionshub/[email protected]
3 changes: 3 additions & 0 deletions lib/cprofiles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
.vscode/*
build/*
1 change: 1 addition & 0 deletions lib/cprofiles/.gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
[submodule "lib/fluent-otel-proto"]
path = lib/fluent-otel-proto
url = https://github.com/fluent/fluent-otel-proto

24 changes: 8 additions & 16 deletions lib/cprofiles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# CMetrics Version
set(CPROF_VERSION_MAJOR 0)
set(CPROF_VERSION_MINOR 0)
set(CPROF_VERSION_PATCH 1)
set(CPROF_VERSION_MINOR 1)
set(CPROF_VERSION_PATCH 0)
set(CPROF_VERSION_STR "${CPROF_VERSION_MAJOR}.${CPROF_VERSION_MINOR}.${CPROF_VERSION_PATCH}")

# Include helpers
Expand Down Expand Up @@ -56,14 +56,6 @@ endif()
include(cmake/libraries.cmake)
include(cmake/headers.cmake)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
find_package(Sanitizers)

if(SANITIZE_ADDRESS)
CPROF_DEFINITION(CPROF_HAVE_SANITIZE_ADDRESS)
endif()


# Include headers and dependency headers
include_directories(
src
Expand Down Expand Up @@ -146,14 +138,16 @@ endif()
# Configure header files
configure_file(
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_info.h.in"
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_info.h"
"${PROJECT_BINARY_DIR}/include/cprofiles/cprof_info.h"
)

configure_file(
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_version.h.in"
"${PROJECT_SOURCE_DIR}/include/cprofiles/cprof_version.h"
"${PROJECT_BINARY_DIR}/include/cprofiles/cprof_version.h"
)

include_directories("${PROJECT_BINARY_DIR}/include/")

# Installation Directories
# ========================
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
Expand Down Expand Up @@ -223,7 +217,7 @@ endif()
# fluent-otel-proto
if (NOT CPROF_HAVE_FLUENT_OTEL_PROTO)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${CPROF_PATH_LIB_FLUENT_OTEL_PROTO}/include)
CPROF_OPTION(FLUENT_PROTO_METRICS "on")
CPROF_OPTION(FLUENT_PROTO_PROFILES "on")
CPROF_OPTION(FLUENT_PROTO_EXAMPLES "off")
add_subdirectory(lib/fluent-otel-proto)
CPROF_DEFINITION(CPROF_HAVE_FLUENT_OTEL_PROTO)
Expand Down Expand Up @@ -353,7 +347,6 @@ if(CPROF_SYSTEM_MACOS)

if (CPACK_GENERATOR MATCHES "productbuild")
set(CPACK_SET_DESTDIR "ON")
configure_file(cpack/macos/welcome.txt.cmakein ${CMAKE_CURRENT_SOURCE_DIR}/welcome.txt)
configure_file(LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
find_program(CONVERTER textutil)
if (NOT CONVERTER)
Expand All @@ -363,14 +356,13 @@ if(CPROF_SYSTEM_MACOS)
execute_process(COMMAND ${CONVERTER} -convert html "${CMAKE_CURRENT_SOURCE_DIR}/README.md" -output "${CMAKE_CURRENT_SOURCE_DIR}/README.html")
endif()
set(CPACK_PACKAGE_FILE_NAME "${CMETRICS_PKG}")
set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_SOURCE_DIR}/welcome.txt)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.html)
set(CPACK_PRODUCTBUILD_IDENTIFIER "com.calyptia.${CPACK_PACKAGE_NAME}")
endif()
endif()

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

include(CPack)
43 changes: 43 additions & 0 deletions lib/cprofiles/include/cprofiles/cprof_decode_msgpack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* CProfiles
* ========
* Copyright 2024 The CProfiles Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef CPROF_DECODE_MSGPACK_H
#define CPROF_DECODE_MSGPACK_H

#include <cprofiles/cprofiles.h>
#include <mpack/mpack.h>

#define CPROF_DECODE_MSGPACK_SUCCESS 0
#define CPROF_DECODE_MSGPACK_ALLOCATION_ERROR 1
#define CPROF_DECODE_MSGPACK_INSUFFICIENT_DATA 2
#define CPROF_DECODE_MSGPACK_INVALID_ARGUMENT_ERROR 3

struct crof_msgpack_decode_context {
struct cprof *inner_context;
mpack_reader_t reader;
};

int cprof_decode_msgpack_create(struct cprof **result_context,
unsigned char *in_buf,
size_t in_size,
size_t *offset);

void cprof_decode_msgpack_destroy(struct cprof *context);

#endif
Loading

0 comments on commit 4ab9331

Please sign in to comment.