Skip to content

Commit

Permalink
Testing (#12)
Browse files Browse the repository at this point in the history
* delete juce header

* set up JUCE library target

* extract code to library target

* add test

* integrate test with CI
  • Loading branch information
Barabas5532 authored Jan 19, 2025
1 parent edc4c18 commit 2242a5f
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 45 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ jobs:
run: ccache --zero-stats

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} host
run: cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build_type}}

- name: Build
run: cmake --build build --target Valvestate_Standalone

- name: Test
run: |
cmake --build build --target test/all
ctest --test-dir build -C ${{matrix.build_type}}
- name: ccache statistics
run: ccache --show-stats
run: ccache --show-stats
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "JUCE"]
path = JUCE
path = JUCE/JUCE
url = https://github.com/juce-framework/JUCE.git
38 changes: 5 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.15)
project(Valvestate VERSION 0.0.1)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(CTest)

add_subdirectory(JUCE)
add_subdirectory(Source)
add_subdirectory(test)

juce_add_plugin(Valvestate
BUNDLE_ID "me.barabas.valvestate"
Expand All @@ -12,35 +15,4 @@ juce_add_plugin(Valvestate
FORMATS VST3 Standalone
PRODUCT_NAME "HYBRID 8100")

juce_generate_juce_header(Valvestate)

target_sources(Valvestate
PRIVATE
Source/PluginProcessor.cpp
Source/dsp/Clipping.cpp
Source/dsp/Contour.cpp
Source/dsp/FMV.cpp
Source/dsp/GainControl.cpp
Source/dsp/InputFilter.cpp
Source/dsp/WaveShape.cpp
Source/ui/PluginEditor.cpp)


target_include_directories(Valvestate
PRIVATE
Source)

target_compile_definitions(Valvestate
PUBLIC
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0)

target_link_libraries(Valvestate
PRIVATE
juce::juce_audio_utils
juce::juce_dsp
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
target_link_libraries(Valvestate PUBLIC valvestate::lib)
29 changes: 29 additions & 0 deletions JUCE/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
add_subdirectory(JUCE)

add_library(juce_modules STATIC)
add_library(valvestate::juce_modules ALIAS juce_modules)

target_link_libraries(juce_modules
PRIVATE
juce::juce_audio_utils
juce::juce_dsp
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_warning_flags)

# We're linking the modules privately, but we need to export
# their compile flags
target_compile_definitions(juce_modules
PUBLIC
JUCE_VST3_CAN_REPLACE_VST2=0
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
JucePlugin_Build_Standalone=1
JUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone
INTERFACE
$<TARGET_PROPERTY:juce_modules,COMPILE_DEFINITIONS>)

# We also need to export the include directories for the modules
target_include_directories(juce_modules
SYSTEM INTERFACE
$<TARGET_PROPERTY:juce_modules,INCLUDE_DIRECTORIES>)
Submodule JUCE updated from 000000 to 5179f4
22 changes: 22 additions & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
add_library(valvestate_lib STATIC)
add_library(valvestate::lib ALIAS valvestate_lib )

target_sources(valvestate_lib
PRIVATE
PluginProcessor.cpp
dsp/Clipping.cpp
dsp/Contour.cpp
dsp/FMV.cpp
dsp/GainControl.cpp
dsp/InputFilter.cpp
dsp/WaveShape.cpp
ui/PluginEditor.cpp)

target_include_directories(valvestate_lib PRIVATE .)

target_link_libraries(valvestate_lib
PUBLIC
valvestate::juce_modules
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
2 changes: 1 addition & 1 deletion Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ValvestateAudioProcessor::~ValvestateAudioProcessor()
//==============================================================================
const String ValvestateAudioProcessor::getName() const
{
return JucePlugin_Name;
return "HYBRID 8100";
}

bool ValvestateAudioProcessor::acceptsMidi() const
Expand Down
4 changes: 3 additions & 1 deletion Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

#pragma once

#include "JuceHeader.h"
#include "juce_audio_processors/juce_audio_processors.h"
#include "dsp/InputFilter.h"
#include "dsp/GainControl.h"
#include "dsp/Clipping.h"
#include "dsp/FMV.h"
#include "dsp/Contour.h"

using namespace juce;

class ValvestateAudioProcessor : public AudioProcessor
{
public:
Expand Down
4 changes: 3 additions & 1 deletion Source/dsp/Clipping.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/

#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_dsp/juce_dsp.h>

using namespace juce;

class Clipping
{
Expand Down
4 changes: 3 additions & 1 deletion Source/dsp/Contour.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/

#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_dsp/juce_dsp.h>

using namespace juce;

class ContourFilter
{
Expand Down
4 changes: 3 additions & 1 deletion Source/dsp/FMV.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_dsp/juce_dsp.h>

using namespace juce;

class FMVFilter
{
Expand Down
4 changes: 3 additions & 1 deletion Source/dsp/GainControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_dsp/juce_dsp.h>

using namespace juce;

class GainControl
{
Expand Down
3 changes: 2 additions & 1 deletion Source/dsp/InputFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_dsp/juce_dsp.h>

using namespace juce;

class InputFilter
{
Expand Down
5 changes: 4 additions & 1 deletion Source/ui/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_dsp/juce_dsp.h>

#include "PluginProcessor.h"
#include "UI.h"

using namespace juce;

//==============================================================================
/**
*/
Expand Down
2 changes: 1 addition & 1 deletion Source/ui/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#pragma once

#include "../JuceLibraryCode/JuceHeader.h"
#include <juce_gui_basics/juce_gui_basics.h>

const Colour GOLD(0xffa1781b);
const Colour DARKER(0xff111111);
Expand Down
23 changes: 23 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.22)
project (ValvestateTest LANGUAGES CXX)

include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

add_executable(
test_clipping
test_clipping.cpp
)
target_link_libraries(
test_clipping
GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(test_clipping)
9 changes: 9 additions & 0 deletions test/test_clipping.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}

0 comments on commit 2242a5f

Please sign in to comment.