diff --git a/.gitignore b/.gitignore index 126959e..5cdbbb1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,19 @@ public/dsp.main.js *.sln *.sw? *.swp + +# CMake +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +# native +native/SRVB_artefacts/ diff --git a/README.md b/README.md index 5b360d9..3cff800 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,21 @@ available at the command line: * [CMake](https://cmake.org/) * [Node.js](https://nodejs.org/en) * Bash: the build steps below expect to run scripts in a Bash environment. For Windows machines, consider running the following steps in a Git Bash environment, or with WSL. +* For Linux you'll need the following: + +``` +sudo apt install -y build-essential \ + gnome-devel \ + libxinerama-dev \ + libxrandr-dev \ + libxcursor-dev \ + libxft2-dev \ + libwebkit2gtk-4.0-dev \ + libgtk-3-dev \ + libalsaplayer-dev \ + libcurl4-dev-openssl \ + libasound2-dev +``` Next, we fetch the SRVB project and its dependencies, diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index b25ac63..bd30c96 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -52,6 +52,18 @@ target_sources(${TARGET_NAME} PluginProcessor.cpp WebViewEditor.cpp) +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + find_package(PkgConfig REQUIRED) + pkg_check_modules (gtk3 REQUIRED gtk+-3.0 IMPORTED_TARGET) + pkg_check_modules (webkit2 REQUIRED webkit2gtk-4.0 IMPORTED_TARGET) + target_link_libraries (${TARGET_NAME} + PRIVATE + pthread + PkgConfig::gtk3 + PkgConfig::webkit2 + ) +endif() + target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/choc/gui diff --git a/native/PluginProcessor.cpp b/native/PluginProcessor.cpp index 2b7ab85..a1bab12 100644 --- a/native/PluginProcessor.cpp +++ b/native/PluginProcessor.cpp @@ -16,10 +16,14 @@ juce::File getAssetsDirectory() .getParentDirectory() // Plugin.vst3/Contents// .getParentDirectory() // Plugin.vst3/Contents/ .getChildFile("Resources/dist"); +#elif JUCE_LINUX + auto assetsDir = juce::File::getSpecialLocation(juce::File::SpecialLocationType::currentExecutableFile) // $HOME/.vst3 + .getParentDirectory() // Plugin.vst3/Contents// + .getParentDirectory() // Plugin.vst3/Contents/ + .getChildFile("Resources/dist"); #else -#error "We only support Mac and Windows here yet." + #error "We only support Mac, Windows, and Linux here yet." #endif - return assetsDir; } diff --git a/native/WebViewEditor.cpp b/native/WebViewEditor.cpp index 5a39609..575d697 100644 --- a/native/WebViewEditor.cpp +++ b/native/WebViewEditor.cpp @@ -59,8 +59,12 @@ WebViewEditor::WebViewEditor(juce::AudioProcessor* proc, juce::File const& asset viewContainer.setView(webView->getViewHandle()); #elif JUCE_WINDOWS viewContainer.setHWND(webView->getViewHandle()); +#elif JUCE_LINUX + // TODO + // viewContainer.setView(webView->getViewHandle()); #else #error "We only support MacOS and Windows here yet." + #endif addAndMakeVisible(viewContainer); diff --git a/native/WebViewEditor.h b/native/WebViewEditor.h index 5504d10..01e0bf6 100644 --- a/native/WebViewEditor.h +++ b/native/WebViewEditor.h @@ -33,7 +33,9 @@ class WebViewEditor : public juce::AudioProcessorEditor juce::NSViewComponent viewContainer; #elif JUCE_WINDOWS juce::HWNDComponent viewContainer; +#elif JUCE_LINUX + juce::XEmbedComponent viewContainer; #else - #error "We only support MacOS and Windows here yet." + #error "We only support MacOS, Windows, and Linux here yet." #endif }; diff --git a/scripts/build-native.mjs b/scripts/build-native.mjs index f60322a..c58bdbf 100644 --- a/scripts/build-native.mjs +++ b/scripts/build-native.mjs @@ -1,6 +1,5 @@ #!/usr/bin/env zx - let rootDir = await path.resolve(__dirname, '..'); let buildDir = await path.join(rootDir, 'native', 'build', 'scripted'); @@ -16,5 +15,6 @@ cd(buildDir); let buildType = argv.dev ? 'Debug' : 'Release'; let devFlag = argv.dev ? '-DELEM_DEV_LOCALHOST=1' : ''; + await $`cmake -DCMAKE_BUILD_TYPE=${buildType} -DCMAKE_INSTALL_PREFIX=./out/ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 ${devFlag} ../..`; -await $`cmake --build . --config ${buildType} -j 4`; +await $`cmake --build ../.. --config ${buildType} -j 4`;