Skip to content

Commit

Permalink
Linux: Fixed a bug setting the VST3 plug-in bundle arch dir
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoole committed Aug 5, 2020
1 parent 8fc1c1a commit 6f22faf
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 19 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ 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"
"${JUCE_CMAKE_UTILS_DIR}/PIPConsole.cpp.in"
"${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}")
34 changes: 24 additions & 10 deletions extras/Build/CMake/JUCEUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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=<custom arch>
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")

Expand All @@ -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.
Expand Down Expand Up @@ -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 $<EQUAL:${CMAKE_SIZEOF_VOID_P},8>)
set(arch_string $<IF:${is_platform_x64},x86_64,i386>)

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)
Expand Down
57 changes: 57 additions & 0 deletions extras/Build/CMake/juce_runtime_arch_detection.cpp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2683,6 +2690,7 @@
86B4069D904AB46AC86FB383,
41105E536155E394E54BDD35,
5F6584B675E30761521A9F42,
C5A1549AD0C20CF42C1FE630,
);
name = BinaryData;
sourceTree = "<group>";
Expand Down
3 changes: 3 additions & 0 deletions extras/Projucer/Builds/VisualStudio2015/Projucer_App.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
<ClCompile Include="..\..\Source\BinaryData\Templates\jucer_OpenGLComponentTemplate.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\Build\CMake\juce_runtime_arch_detection.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\Source\CodeEditor\jucer_DocumentEditorComponent.cpp"/>
<ClCompile Include="..\..\Source\CodeEditor\jucer_OpenDocumentManager.cpp"/>
<ClCompile Include="..\..\Source\CodeEditor\jucer_SourceCodeEditor.cpp"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@
<ClCompile Include="..\..\Source\BinaryData\Templates\jucer_OpenGLComponentTemplate.cpp">
<Filter>Projucer\BinaryData\Templates</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Build\CMake\juce_runtime_arch_detection.cpp">
<Filter>Projucer\BinaryData</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\CodeEditor\jucer_DocumentEditorComponent.cpp">
<Filter>Projucer\CodeEditor</Filter>
</ClCompile>
Expand Down
3 changes: 3 additions & 0 deletions extras/Projucer/Builds/VisualStudio2017/Projucer_App.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
<ClCompile Include="..\..\Source\BinaryData\Templates\jucer_OpenGLComponentTemplate.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\Build\CMake\juce_runtime_arch_detection.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\Source\CodeEditor\jucer_DocumentEditorComponent.cpp"/>
<ClCompile Include="..\..\Source\CodeEditor\jucer_OpenDocumentManager.cpp"/>
<ClCompile Include="..\..\Source\CodeEditor\jucer_SourceCodeEditor.cpp"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@
<ClCompile Include="..\..\Source\BinaryData\Templates\jucer_OpenGLComponentTemplate.cpp">
<Filter>Projucer\BinaryData\Templates</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Build\CMake\juce_runtime_arch_detection.cpp">
<Filter>Projucer\BinaryData</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\CodeEditor\jucer_DocumentEditorComponent.cpp">
<Filter>Projucer\CodeEditor</Filter>
</ClCompile>
Expand Down
3 changes: 3 additions & 0 deletions extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
<ClCompile Include="..\..\Source\BinaryData\Templates\jucer_OpenGLComponentTemplate.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\Build\CMake\juce_runtime_arch_detection.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\Source\CodeEditor\jucer_DocumentEditorComponent.cpp"/>
<ClCompile Include="..\..\Source\CodeEditor\jucer_OpenDocumentManager.cpp"/>
<ClCompile Include="..\..\Source\CodeEditor\jucer_SourceCodeEditor.cpp"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@
<ClCompile Include="..\..\Source\BinaryData\Templates\jucer_OpenGLComponentTemplate.cpp">
<Filter>Projucer\BinaryData\Templates</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Build\CMake\juce_runtime_arch_detection.cpp">
<Filter>Projucer\BinaryData</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\CodeEditor\jucer_DocumentEditorComponent.cpp">
<Filter>Projucer\CodeEditor</Filter>
</ClCompile>
Expand Down
3 changes: 2 additions & 1 deletion extras/Projucer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 69 additions & 2 deletions extras/Projucer/JuceLibraryCode/BinaryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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[] =
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion extras/Projucer/JuceLibraryCode/BinaryData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
2 changes: 2 additions & 0 deletions extras/Projucer/Projucer.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@
file="Source/BinaryData/colourscheme_dark.xml"/>
<FILE id="bvFank" name="colourscheme_light.xml" compile="0" resource="1"
file="Source/BinaryData/colourscheme_light.xml"/>
<FILE id="SDFoQY" name="juce_runtime_arch_detection.cpp" compile="0" resource="1"
file="../Build/CMake/juce_runtime_arch_detection.cpp"/>
</GROUP>
<GROUP id="{A5AE7471-B900-FD9D-8DE7-2FB68D11AE30}" name="CodeEditor">
<FILE id="w3ka6n" name="jucer_DocumentEditorComponent.cpp" compile="1"
Expand Down
13 changes: 10 additions & 3 deletions extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Make.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ class MakefileProjectExporter : public ProjectExporter
if (type == VST3PlugIn)
{
s.add ("JUCE_VST3DIR := " + escapeSpaces (targetName).upToLastOccurrenceOf (".", false, false) + ".vst3");

auto is32Bit = config.getArchitectureTypeString().contains ("m32");
s.add (String ("JUCE_VST3SUBDIR := Contents/") + (is32Bit ? "i386" : "x86_64") + "-linux");
s.add ("VST3_PLATFORM_ARCH := $(shell $(CXX) make_helpers/arch_detection.cpp 2>&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;
}
Expand Down Expand Up @@ -478,6 +477,14 @@ class MakefileProjectExporter : public ProjectExporter
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);
}
}

//==============================================================================
Expand Down

0 comments on commit 6f22faf

Please sign in to comment.