From 9cf61d6597a0d476ced5502df90021670a0632cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Roussel?= Date: Wed, 3 Jul 2024 14:05:49 +0200 Subject: [PATCH] [build-system] Migrate test/ directory to CMakeLists - remove MakeFile, replaced with equivalent CMakeLists.txt - add advanced option TRACY_DEMANGLE in client for CI testing --- .github/workflows/linux.yml | 26 +++++++++++++++----- .vscode/settings.json | 1 + CMakeLists.txt | 4 ++++ test/CMakeLists.txt | 37 +++++++++++++++++++++++++++++ test/Makefile | 47 ------------------------------------- test/test.cpp | 14 +++++++---- 6 files changed, 72 insertions(+), 57 deletions(-) create mode 100644 test/CMakeLists.txt delete mode 100644 test/Makefile diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index dab51ead..13c18d83 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -42,12 +42,26 @@ jobs: run: meson setup -Dprefix=$GITHUB_WORKSPACE/bin/lib build && meson compile -C build && meson install -C build - name: Test application run: | - make -j`nproc` -C test - make -j`nproc` -C test clean - make -j`nproc` -C test TRACYFLAGS=-DTRACY_ON_DEMAND - make -j`nproc` -C test clean - make -j`nproc` -C test TRACYFLAGS="-DTRACY_DELAYED_INIT -DTRACY_MANUAL_LIFETIME" - make -C test -B ../public/TracyClient.o DEFINES='-DTRACY_DEMANGLE' + # test compilation with different flags + # we clean the build folder to reset cached variables between runs + cmake -B test/build -S test -DCMAKE_BUILD_TYPE=Release + cmake --build test/build --parallel + rm -rf test/build + + # same with TRACY_ON_DEMAND + cmake -B test/build -S test -DCMAKE_BUILD_TYPE=Release -DTRACY_ON_DEMAND=ON . + cmake --build test/build --parallel + rm -rf test/build + + # same with TRACY_DELAYED_INIT TRACY_MANUAL_LIFETIME + cmake -B test/build -S test -DCMAKE_BUILD_TYPE=Release -DTRACY_DELAYED_INIT=ON -DTRACY_MANUAL_LIFETIME=ON . + cmake --build test/build --parallel + rm -rf test/build + + # same with TRACY_DEMANGLE + cmake -B test/build -S test -DCMAKE_BUILD_TYPE=Release -DTRACY_DEMANGLE=ON . + cmake --build test/build --parallel + rm -rf test/build - name: Find Artifacts id: find_artifacts run: | diff --git a/.vscode/settings.json b/.vscode/settings.json index a43d1784..f5fe6944 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "${workspaceFolder}/import-chrome", "${workspaceFolder}/import-fuchsia", "${workspaceFolder}/update", + "${workspaceFolder}/test", "${workspaceFolder}", ], "cmake.buildDirectory": "${sourceDirectory}/build", diff --git a/CMakeLists.txt b/CMakeLists.txt index f0ca55eb..3ba5dc29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,10 @@ set_option(TRACY_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" set_option(TRACY_SYMBOL_OFFLINE_RESOLVE "Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution" OFF) set_option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation" OFF) +# advanced +set_option(TRACY_DEMANGLE "[advanced] Don't use default demangling function - You'll need to provide your own" OFF) +mark_as_advanced(TRACY_DEMANGLE) + if(NOT TRACY_STATIC) target_compile_definitions(TracyClient PRIVATE TRACY_EXPORTS) target_compile_definitions(TracyClient PUBLIC TRACY_IMPORTS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..7dfa200d --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.16) + +option(USE_DEBUGINFOD "Compile with debuginfod integration" OFF) + +include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) + +# we target C++11 for the client part +set(CMAKE_CXX_STANDARD 11) + +project( + tracy-test + LANGUAGES C CXX + VERSION ${TRACY_VERSION_STRING}) + +# a bit weird but works: include the client cmake config coming from top-level +# cmake needs us to specify the build subfolder -> client/ this way we can +# simply link the test executable against TracyClient +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/.. client/) + +add_executable(tracy-test test.cpp) +target_link_options(tracy-test PRIVATE -rdynamic) +target_link_libraries(tracy-test TracyClient) + +# OS-specific options + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND USE_DEBUGINFOD) + target_compile_definitions(tracy-test PRIVATE TRACY_DEBUGINFOD) + target_link_libraries(tracy-test "debuginfod") +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + target_link_libraries(tracy-test "execinfo") +endif() + + +# copy image file in build folder +configure_file(${CMAKE_CURRENT_LIST_DIR}/image.jpg image.jpg COPYONLY) diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 19b34384..00000000 --- a/test/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -OPTFLAGS := -g3 -fmerge-constants -CFLAGS := $(OPTFLAGS) -Wall -DTRACY_ENABLE -CXXFLAGS := $(CFLAGS) -std=gnu++11 -DEFINES += -INCLUDES := -I../public/tracy -LIBS := -lpthread -ldl -LDFLAGS := -rdynamic -IMAGE := tracy_test - -SRC := \ - test.cpp \ - ../public/TracyClient.cpp - -OBJ := $(SRC:%.cpp=%.o) - -ifeq ($(shell uname -o),FreeBSD) -LIBS += -lexecinfo -endif - -ifeq ($(shell uname),Linux) -DEFINES += -DTRACY_DEBUGINFOD -LIBS += -ldebuginfod -endif - -all: $(IMAGE) - -%.o: %.cpp - $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ - -%.d : %.cpp - @echo Resolving dependencies of $< - @mkdir -p $(@D) - @$(CXX) -MM $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< > $@.$$$$; \ - sed 's,.*\.o[ :]*,$(<:.cpp=.o) $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -$(IMAGE): $(OBJ) - $(CXX) $(CXXFLAGS) $(DEFINES) $(OBJ) $(LIBS) $(LDFLAGS) -o $@ - -ifneq "$(MAKECMDGOALS)" "clean" --include $(SRC:.cpp=.d) -endif - -clean: - rm -f $(OBJ) $(SRC:.cpp=.d) $(IMAGE) - -.PHONY: clean all diff --git a/test/test.cpp b/test/test.cpp index 3e7dcc04..fe678b53 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,9 +1,9 @@ #include +#include #include #include #include -#include "Tracy.hpp" -#include "../common/TracySystem.hpp" +#include "tracy/Tracy.hpp" #define STB_IMAGE_IMPLEMENTATION #define STBI_ONLY_JPEG @@ -328,7 +328,10 @@ int main() int x, y; auto image = stbi_load( "image.jpg", &x, &y, nullptr, 4 ); - + if(image == nullptr) + { + std::cerr << "Could not find image.jpg in the current working directory, skipping" << std::endl; + } for(;;) { TracyMessageL( "Tick" ); @@ -337,7 +340,10 @@ int main() ZoneScoped; std::this_thread::sleep_for( std::chrono::milliseconds( 2 ) ); } - FrameImage( image, x, y, 0, false ); + if(image != nullptr) + { + FrameImage( image, x, y, 0, false ); + } FrameMark; } }