diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ae32fbef5..fe80330b82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,8 @@ configure_package_config_file("${JUCE_CMAKE_UTILS_DIR}/JUCEConfig.cmake.in" install(FILES "${JUCE_BINARY_DIR}/JUCEConfigVersion.cmake" "${JUCE_BINARY_DIR}/JUCEConfig.cmake" + "${JUCE_CMAKE_UTILS_DIR}/JUCEHelperTargets.cmake" + "${JUCE_CMAKE_UTILS_DIR}/JUCEUtils.cmake" "${JUCE_CMAKE_UTILS_DIR}/LaunchScreen.storyboard" "${JUCE_CMAKE_UTILS_DIR}/PIPAudioProcessor.cpp.in" "${JUCE_CMAKE_UTILS_DIR}/PIPComponent.cpp.in" @@ -121,6 +123,5 @@ install(FILES "${JUCE_BINARY_DIR}/JUCEConfigVersion.cmake" "${JUCE_CMAKE_UTILS_DIR}/RecentFilesMenuTemplate.nib" "${JUCE_CMAKE_UTILS_DIR}/UnityPluginGUIScript.cs.in" "${JUCE_CMAKE_UTILS_DIR}/copyDir.cmake" - "${JUCE_CMAKE_UTILS_DIR}/JUCEHelperTargets.cmake" - "${JUCE_CMAKE_UTILS_DIR}/JUCEUtils.cmake" + "${JUCE_CMAKE_UTILS_DIR}/juce_runtime_arch_detection.cpp" DESTINATION "${JUCE_INSTALL_DESTINATION}") diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index e47240e926..05300d5ecd 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -119,9 +119,32 @@ endfunction() # ================================================================================================== +set(JUCE_CMAKE_UTILS_DIR ${CMAKE_CURRENT_LIST_DIR} + CACHE INTERNAL "The path to the folder holding this file and other resources") + +include("${JUCE_CMAKE_UTILS_DIR}/JUCEHelperTargets.cmake") + +# Tries to discover the target platform architecture, which is necessary for +# naming VST3 bundle folders correctly. +function(_juce_find_linux_target_architecture result) + set(test_file "${JUCE_CMAKE_UTILS_DIR}/juce_runtime_arch_detection.cpp") + try_compile(compile_result "${CMAKE_CURRENT_BINARY_DIR}" "${test_file}" + OUTPUT_VARIABLE compile_output) + string(REGEX REPLACE ".*JUCE_ARCH ([a-zA-Z0-9_-]*).*" "\\1" match_result "${compile_output}") + set("${result}" "${match_result}" PARENT_SCOPE) +endfunction() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") _juce_create_pkgconfig_target(JUCE_CURL_LINUX_DEPS libcurl) _juce_create_pkgconfig_target(JUCE_BROWSER_LINUX_DEPS webkit2gtk-4.0 gtk+-x11-3.0) + + # If you really need to override the detected arch for some reason, + # you can configure the build with -DJUCE_LINUX_TARGET_ARCHITECTURE= + if(NOT DEFINED JUCE_LINUX_TARGET_ARCHITECTURE) + _juce_find_linux_target_architecture(target_arch) + set(JUCE_LINUX_TARGET_ARCHITECTURE "${target_arch}" + CACHE INTERNAL "The target architecture, used to name internal folders in VST3 bundles") + endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") find_program(JUCE_RC_COMPILER Rez NO_DEFAULT_PATHS PATHS "/Applications/Xcode.app/Contents/Developer/usr/bin") @@ -130,11 +153,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() endif() -set(JUCE_CMAKE_UTILS_DIR ${CMAKE_CURRENT_LIST_DIR} - CACHE INTERNAL "The path to the folder holding this file and other resources") - -include("${JUCE_CMAKE_UTILS_DIR}/JUCEHelperTargets.cmake") - # We set up default/fallback copy dirs here. If you need different copy dirs, use # set_directory_properties or set_target_properties to adjust the values of `JUCE_*_COPY_DIR` at # the appropriate scope. @@ -1235,13 +1253,9 @@ function(_juce_set_plugin_target_properties shared_code_target kind) set(output_path "${products_folder}/${product_name}.vst3") if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # On linux we assume that the output arch is the same as the that of the host platform - set(is_platform_x64 $) - set(arch_string $) - set_target_properties(${target_name} PROPERTIES SUFFIX .so - LIBRARY_OUTPUT_DIRECTORY "${output_path}/Contents/${arch_string}-linux") + LIBRARY_OUTPUT_DIRECTORY "${output_path}/Contents/${JUCE_LINUX_TARGET_ARCHITECTURE}-linux") endif() _juce_copy_after_build(${shared_code_target} ${target_name} "${output_path}" JUCE_VST3_COPY_DIR) diff --git a/extras/Build/CMake/juce_runtime_arch_detection.cpp b/extras/Build/CMake/juce_runtime_arch_detection.cpp new file mode 100644 index 0000000000..7aea5fbbfe --- /dev/null +++ b/extras/Build/CMake/juce_runtime_arch_detection.cpp @@ -0,0 +1,57 @@ +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__) + + #if defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__) + #error JUCE_ARCH arm64 + #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 8) || defined(__ARMv8__) || defined(__ARMv8_A__) + #error JUCE_ARCH armv8l + #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 7) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(_ARM_ARCH_7) || defined(__CORE_CORTEXA__) + #error JUCE_ARCH armv7l + #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6M__) + #error JUCE_ARCH armv6l + #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 5) || defined(__ARM_ARCH_5TEJ__) + #error JUCE_ARCH armv5l + #else + #error JUCE_ARCH arm + #endif + +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + + #error JUCE_ARCH i386 + +#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + + #error JUCE_ARCH x86_64 + +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + + #error JUCE_ARCH ia64 + +#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000) + + #if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) + #error JUCE_ARCH mips64 + #else + #error JUCE_ARCH mips + #endif + +#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) || defined(_M_MPPC) || defined(_M_PPC) + + #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) + #error JUCE_ARCH ppc64 + #else + #error JUCE_ARCH ppc + #endif + +#elif defined(__riscv) + + #if __riscv_xlen == 64 + #error JUCE_ARCH riscv64 + #else + #error JUCE_ARCH riscv + #endif + +#else + + #error JUCE_ARCH unknown + +#endif diff --git a/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj b/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj index 7f3c46cf79..a3b33241a9 100644 --- a/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj +++ b/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj/project.pbxproj @@ -1987,6 +1987,13 @@ path = "../../Source/Utility/UI/jucer_Icons.h"; sourceTree = "SOURCE_ROOT"; }; + C5A1549AD0C20CF42C1FE630 = { + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = "juce_runtime_arch_detection.cpp"; + path = "../../../Build/CMake/juce_runtime_arch_detection.cpp"; + sourceTree = "SOURCE_ROOT"; + }; C607639897ED2538CBB860D0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; @@ -2683,6 +2690,7 @@ 86B4069D904AB46AC86FB383, 41105E536155E394E54BDD35, 5F6584B675E30761521A9F42, + C5A1549AD0C20CF42C1FE630, ); name = BinaryData; sourceTree = ""; diff --git a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj index 67ebd94137..b72edc559f 100644 --- a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj @@ -185,6 +185,9 @@ true + + true + diff --git a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj.filters index 43d6a6f1a0..f3263ed4bc 100644 --- a/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj.filters @@ -373,6 +373,9 @@ Projucer\BinaryData\Templates + + Projucer\BinaryData + Projucer\CodeEditor diff --git a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj index b1cacb246d..05f9e99d01 100644 --- a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj @@ -185,6 +185,9 @@ true + + true + diff --git a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters index b063d17eb2..bab64ae06f 100644 --- a/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj.filters @@ -373,6 +373,9 @@ Projucer\BinaryData\Templates + + Projucer\BinaryData + Projucer\CodeEditor diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj index 76194bea74..acf2eed144 100644 --- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj @@ -185,6 +185,9 @@ true + + true + diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters index 1478263905..13a8a68509 100644 --- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters @@ -373,6 +373,9 @@ Projucer\BinaryData\Templates + + Projucer\BinaryData + Projucer\CodeEditor diff --git a/extras/Projucer/CMakeLists.txt b/extras/Projucer/CMakeLists.txt index 910559615d..3346e8819f 100644 --- a/extras/Projucer/CMakeLists.txt +++ b/extras/Projucer/CMakeLists.txt @@ -158,7 +158,8 @@ juce_add_binary_data(ProjucerData SOURCES ../Build/CMake/PIPComponent.cpp.in ../Build/CMake/PIPConsole.cpp.in ../Build/CMake/RecentFilesMenuTemplate.nib - ../Build/CMake/UnityPluginGUIScript.cs.in) + ../Build/CMake/UnityPluginGUIScript.cs.in + ../Build/CMake/juce_runtime_arch_detection.cpp) target_link_libraries(Projucer PRIVATE ProjucerData diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.cpp b/extras/Projucer/JuceLibraryCode/BinaryData.cpp index e45fc929cb..79ff0becd6 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.cpp +++ b/extras/Projucer/JuceLibraryCode/BinaryData.cpp @@ -7481,6 +7481,70 @@ static const unsigned char temp_binary_data_60[] = const char* colourscheme_light_xml = (const char*) temp_binary_data_60; +//================== juce_runtime_arch_detection.cpp ================== +static const unsigned char temp_binary_data_61[] = +"#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)\n" +"\n" +" #if defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)\n" +" #error JUCE_ARCH arm64\n" +" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 8) || defined(__ARMv8__) || defined(__ARMv8_A__)\n" +" #error JUCE_ARCH armv8l\n" +" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 7) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(_ARM_ARCH_7) || defined(__CORE_CORTEX" +"A__)\n" +" #error JUCE_ARCH armv7l\n" +" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_A" +"RCH_6M__)\n" +" #error JUCE_ARCH armv6l\n" +" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 5) || defined(__ARM_ARCH_5TEJ__)\n" +" #error JUCE_ARCH armv5l\n" +" #else\n" +" #error JUCE_ARCH arm\n" +" #endif\n" +"\n" +"#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)\n" +"\n" +" #error JUCE_ARCH i386\n" +"\n" +"#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)\n" +"\n" +" #error JUCE_ARCH x86_64\n" +"\n" +"#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)\n" +"\n" +" #error JUCE_ARCH ia64\n" +"\n" +"#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000)\n" +"\n" +" #if defined(_MIPS_ARCH_MIPS64) || defined(__mips64)\n" +" #error JUCE_ARCH mips64\n" +" #else\n" +" #error JUCE_ARCH mips\n" +" #endif\n" +"\n" +"#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) || defined(_M_MPPC) || defined(_M_PPC)\n" +"\n" +" #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)\n" +" #error JUCE_ARCH ppc64\n" +" #else\n" +" #error JUCE_ARCH ppc\n" +" #endif\n" +"\n" +"#elif defined(__riscv)\n" +"\n" +" #if __riscv_xlen == 64\n" +" #error JUCE_ARCH riscv64\n" +" #else\n" +" #error JUCE_ARCH riscv\n" +" #endif\n" +"\n" +"#else\n" +"\n" +" #error JUCE_ARCH unknown\n" +"\n" +"#endif\n"; + +const char* juce_runtime_arch_detection_cpp = (const char*) temp_binary_data_61; + const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) { @@ -7553,6 +7617,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) case 0x0b16e320: numBytes = 517; return jucer_PIPTemplate_h; case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml; case 0xe8b08520: numBytes = 1050; return colourscheme_light_xml; + case 0x7c03d519: numBytes = 2070; return juce_runtime_arch_detection_cpp; default: break; } @@ -7622,7 +7687,8 @@ const char* namedResourceList[] = "jucer_PIPAudioProcessorTemplate_h", "jucer_PIPTemplate_h", "colourscheme_dark_xml", - "colourscheme_light_xml" + "colourscheme_light_xml", + "juce_runtime_arch_detection_cpp" }; const char* originalFilenames[] = @@ -7687,7 +7753,8 @@ const char* originalFilenames[] = "jucer_PIPAudioProcessorTemplate.h", "jucer_PIPTemplate.h", "colourscheme_dark.xml", - "colourscheme_light.xml" + "colourscheme_light.xml", + "juce_runtime_arch_detection.cpp" }; const char* getNamedResourceOriginalFilename (const char* resourceNameUTF8) diff --git a/extras/Projucer/JuceLibraryCode/BinaryData.h b/extras/Projucer/JuceLibraryCode/BinaryData.h index 15c13abc0e..307c71feb4 100644 --- a/extras/Projucer/JuceLibraryCode/BinaryData.h +++ b/extras/Projucer/JuceLibraryCode/BinaryData.h @@ -191,8 +191,11 @@ namespace BinaryData extern const char* colourscheme_light_xml; const int colourscheme_light_xmlSize = 1050; + extern const char* juce_runtime_arch_detection_cpp; + const int juce_runtime_arch_detection_cppSize = 2070; + // Number of elements in the namedResourceList and originalFileNames arrays. - const int namedResourceListSize = 61; + const int namedResourceListSize = 62; // Points to the start of a list of resource names. extern const char* namedResourceList[]; diff --git a/extras/Projucer/Projucer.jucer b/extras/Projucer/Projucer.jucer index 29a3b66836..29fdc5c2be 100644 --- a/extras/Projucer/Projucer.jucer +++ b/extras/Projucer/Projucer.jucer @@ -290,6 +290,8 @@ file="Source/BinaryData/colourscheme_dark.xml"/> + &1 | tr '\\n' ' ' | sed \"s/.*JUCE_ARCH \\([a-zA-Z0-9_-]*\\).*/\\1/\")"); + s.add ("JUCE_VST3SUBDIR := Contents/$(VST3_PLATFORM_ARCH)-linux"); targetName = "$(JUCE_VST3DIR)/$(JUCE_VST3SUBDIR)/" + targetName; } @@ -478,6 +477,14 @@ public: mo.setNewLineString ("\n"); writeMakefile (mo); }); + + if (project.shouldBuildVST3()) + { + auto helperDir = getTargetFolder().getChildFile ("make_helpers"); + helperDir.createDirectory(); + build_tools::overwriteFileIfDifferentOrThrow (helperDir.getChildFile ("arch_detection.cpp"), + BinaryData::juce_runtime_arch_detection_cpp); + } } //==============================================================================