Skip to content

Commit 6bad66f

Browse files
authored
Merge pull request #36 from sudara/variadic_macro
Version 1.4.0
2 parents d7d75f0 + 34a6d95 commit 6bad66f

11 files changed

Lines changed: 55 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
include:
35+
- name: Linux
36+
os: ubuntu-latest
3537
- name: macOS
3638
os: macos-latest
3739
- name: Windows
3840
os: windows-latest
3941

4042
steps:
4143

44+
- name: Install JUCE's Linux Deps
45+
if: runner.os == 'Linux'
46+
run: |
47+
sudo apt-get update && sudo apt install libasound2-dev libcurl4-openssl-dev libx11-dev libxinerama-dev libxext-dev libfreetype6-dev libwebkit2gtk-4.1-dev libglu1-mesa-dev xvfb ninja-build
48+
sudo /usr/bin/Xvfb $DISPLAY &
49+
4250
- name: Checkout code
4351
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3
4452
with:

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
22

33
project(MelatoninPerfetto
4-
VERSION 1.3.0
4+
VERSION 1.4.0
55
LANGUAGES CXX
66
DESCRIPTION "JUCE module for profiling with Perfetto"
77
HOMEPAGE_URL "https://github.com/sudara/melatonin_perfetto")
@@ -27,7 +27,7 @@ set(MP_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/melatonin_perfetto"
2727

2828

2929
message (STATUS "Grabbing Perfetto...")
30-
CPMAddPackage(gh:google/perfetto@51.2)
30+
CPMAddPackage(gh:google/perfetto@53.0)
3131

3232
# we need to manually set up a target for Perfetto
3333
add_library(perfetto STATIC)
@@ -59,6 +59,7 @@ if (MSVC)
5959
/bigobj # only needed for compilation of perfetto itself
6060
PUBLIC
6161
/Zc:__cplusplus # we need the correct value of the __cplusplus macro
62+
/Zc:preprocessor # needed for __VA_OPT__(,) support
6263
/permissive- # see https://github.com/google/perfetto/issues/214
6364
)
6465
endif ()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ Go wild!
329329
330330
## Assumptions / Caveats
331331
332-
* On Mac, the trace is dumped to your Downloads folder. On Windows, it's dumped to your Desktop (sorry not sorry).
332+
* On Mac, the trace is dumped to your Downloads folder. On Windows, it's dumped to your Desktop. On Linux, it's dumped to the temp directory (`/tmp`).
333333
* Traces are set to in memory, 80MB by default.
334334
335335
## Troubleshooting

melatonin_perfetto/melatonin_perfetto.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ class MelatoninPerfetto
9595
{
9696
#if JUCE_WINDOWS
9797
return juce::File::getSpecialLocation (juce::File::SpecialLocationType::userDesktopDirectory);
98-
#else
98+
#elif JUCE_MAC || JUCE_IOS
9999
return juce::File::getSpecialLocation (juce::File::SpecialLocationType::userHomeDirectory).getChildFile ("Downloads");
100+
#else
101+
// Linux: use temp directory for CI compatibility (no desktop/Downloads on headless systems)
102+
return juce::File::getSpecialLocation (juce::File::SpecialLocationType::tempDirectory);
100103
#endif
101104
}
102105

@@ -256,7 +259,7 @@ namespace melatonin
256259
#if PERFETTO_ENABLE_TRACE_DSP
257260
#define TRACE_DSP(...) \
258261
static constexpr auto pf = melatonin::compileTimePrettierFunction (WRAP_COMPILE_TIME_STRING (PERFETTO_DEBUG_FUNCTION_IDENTIFIER())); \
259-
TRACE_EVENT ("dsp", perfetto::StaticString (pf.data()), ##__VA_ARGS__)
262+
TRACE_EVENT ("dsp", perfetto::StaticString (pf.data()) __VA_OPT__(,) __VA_ARGS__)
260263

261264
#define TRACE_DSP_BEGIN(name) TRACE_EVENT_BEGIN ("dsp", perfetto::StaticString (name))
262265
#define TRACE_DSP_END() TRACE_EVENT_END ("dsp")
@@ -269,7 +272,7 @@ namespace melatonin
269272
#if PERFETTO_ENABLE_TRACE_COMPONENT
270273
#define TRACE_COMPONENT(...) \
271274
static constexpr auto pf = melatonin::compileTimePrettierFunction (WRAP_COMPILE_TIME_STRING (PERFETTO_DEBUG_FUNCTION_IDENTIFIER())); \
272-
TRACE_EVENT ("component", perfetto::StaticString (pf.data()), ##__VA_ARGS__)
275+
TRACE_EVENT ("component", perfetto::StaticString (pf.data()) __VA_OPT__(,) __VA_ARGS__)
273276

274277
#define TRACE_COMPONENT_BEGIN(name) TRACE_EVENT_BEGIN ("component", perfetto::StaticString (name))
275278
#define TRACE_COMPONENT_END() TRACE_EVENT_END ("component")

scripts/RunTests.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from os import chdir, environ
1010
from shutil import rmtree
1111
import subprocess
12+
import platform
1213

1314
#
1415

@@ -29,7 +30,8 @@ def run_command(command, workingDir):
2930
print(cp.stderr)
3031

3132
except subprocess.CalledProcessError as error:
32-
print (error.output)
33+
print("STDOUT:", error.stdout)
34+
print("STDERR:", error.stderr)
3335
print (f"Command {error.cmd} failed with exit code {error.returncode}")
3436
exit (1)
3537

@@ -44,22 +46,34 @@ def run_command(command, workingDir):
4446

4547
environ["MP_PERFETTO_SHOULD_BE_ON"] = "FALSE"
4648

47-
run_command (command=f"cmake -B {BUILD_DIR}",
49+
# Single-config generators (Unix Makefiles, Ninja) require CMAKE_BUILD_TYPE at configure time
50+
# Multi-config generators (Xcode, Visual Studio) ignore it and use --config at build time
51+
if platform.system() == "Windows":
52+
build_type_flag = ""
53+
generator_flag = ""
54+
elif platform.system() == "Linux":
55+
build_type_flag = " -DCMAKE_BUILD_TYPE=Debug"
56+
generator_flag = " -G Ninja" # Ninja is faster and installed in CI
57+
else:
58+
build_type_flag = " -DCMAKE_BUILD_TYPE=Debug"
59+
generator_flag = ""
60+
61+
run_command (command=f"cmake -B {BUILD_DIR}{generator_flag}{build_type_flag}",
4862
workingDir=REPO_ROOT)
4963

50-
run_command (command=f"cmake --build {BUILD_DIR}",
64+
run_command (command=f"cmake --build {BUILD_DIR} --parallel",
5165
workingDir=REPO_ROOT)
5266

53-
run_command (command="ctest -C Debug",
67+
run_command (command="ctest -C Debug -j --output-on-failure",
5468
workingDir=BUILD_DIR)
5569

5670
environ["MP_PERFETTO_SHOULD_BE_ON"] = "TRUE"
5771

58-
run_command (command=f"cmake -B {BUILD_DIR} -D PERFETTO=ON",
72+
run_command (command=f"cmake -B {BUILD_DIR} -D PERFETTO=ON{generator_flag}{build_type_flag}",
5973
workingDir=REPO_ROOT)
6074

61-
run_command (command=f"cmake --build {BUILD_DIR}",
75+
run_command (command=f"cmake --build {BUILD_DIR} --parallel",
6276
workingDir=REPO_ROOT)
6377

64-
run_command (command="ctest -C Debug",
78+
run_command (command="ctest -C Debug -j --output-on-failure",
6579
workingDir=BUILD_DIR)

tests/AddSubdirectory/AddTests.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ add_test (NAME "${base_name}.configure"
66
COMMAND "${CMAKE_COMMAND}"
77
-S "${CMAKE_CURRENT_LIST_DIR}"
88
-B "${binary_dir}"
9+
-G "${CMAKE_GENERATOR}"
10+
-D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
911
-D "MELATONIN_PERFETTO_ROOT=${MelatoninPerfetto_SOURCE_DIR}"
1012
-D "FETCHCONTENT_SOURCE_DIR_JUCE=${juce_SOURCE_DIR}"
1113
-D "FETCHCONTENT_SOURCE_DIR_PERFETTO=${perfetto_SOURCE_DIR}")
@@ -18,7 +20,8 @@ set_tests_properties ("${base_name}.configure"
1820
add_test (NAME "${base_name}.build"
1921
COMMAND "${CMAKE_COMMAND}"
2022
--build "${binary_dir}"
21-
--config "$<CONFIG>")
23+
--config "$<CONFIG>"
24+
--parallel)
2225

2326
set_tests_properties ("${base_name}.build" PROPERTIES FIXTURES_REQUIRED MelatoninPerfettoAddSubdirectoryConfigure)
2427

tests/AddSubdirectory/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ juce_add_console_app (test VERSION 1.0.0)
2626

2727
target_sources (test PRIVATE main.cpp)
2828

29+
target_compile_definitions (test PRIVATE JUCE_USE_CURL=0)
30+
2931
target_link_libraries (test PRIVATE Melatonin::Perfetto)

tests/DumpFiles/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ add_executable (MelatoninDumpFileTest)
22

33
target_sources (MelatoninDumpFileTest PRIVATE main.cpp)
44

5+
target_compile_definitions (MelatoninDumpFileTest PRIVATE JUCE_USE_CURL=0)
6+
57
target_link_libraries (MelatoninDumpFileTest PRIVATE Melatonin::Perfetto)
68

79
add_test (NAME melatonin.perfetto.dump_file_creation

tests/FindPackage/AddTests.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ add_test (NAME "${base_name}.configure"
1717
-S "${CMAKE_CURRENT_LIST_DIR}"
1818
-B "${binary_dir}"
1919
-G "${CMAKE_GENERATOR}"
20+
-D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
2021
-D "MelatoninPerfetto_DIR=${prefix}/${CMAKE_INSTALL_LIBDIR}/cmake/melatonin_perfetto"
2122
-D "FETCHCONTENT_SOURCE_DIR_JUCE=${juce_SOURCE_DIR}"
2223
-D "FETCHCONTENT_SOURCE_DIR_PERFETTO=${perfetto_SOURCE_DIR}")
@@ -27,9 +28,10 @@ set_tests_properties ("${base_name}.configure" PROPERTIES
2728
ENVIRONMENT_MODIFICATION "MP_PERFETTO_SHOULD_BE_ON=unset:")
2829

2930
add_test (NAME "${base_name}.build"
30-
COMMAND "${CMAKE_COMMAND}"
31+
COMMAND "${CMAKE_COMMAND}"
3132
--build "${binary_dir}"
32-
--config "$<CONFIG>")
33+
--config "$<CONFIG>"
34+
--parallel)
3335

3436
set_tests_properties ("${base_name}.build" PROPERTIES FIXTURES_REQUIRED MelatoninPerfettoFindPackageConfigure)
3537

tests/FindPackage/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ juce_add_console_app (test VERSION 1.0.0)
2222

2323
target_sources (test PRIVATE main.cpp)
2424

25+
target_compile_definitions (test PRIVATE JUCE_USE_CURL=0)
26+
2527
target_link_libraries (test PRIVATE Melatonin::Perfetto)

0 commit comments

Comments
 (0)