mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Modules: Update JUCE module format for improved consistency
This commit is contained in:
parent
05d5c94990
commit
c04354e1ee
4 changed files with 38 additions and 41 deletions
|
|
@ -65,28 +65,28 @@ adding these files to their projects.
|
||||||
The names of these source files must begin with the name of the module, but they can have
|
The names of these source files must begin with the name of the module, but they can have
|
||||||
a number or other suffix if there is more than one.
|
a number or other suffix if there is more than one.
|
||||||
|
|
||||||
In order to specify that a source file should only be compiled on a specific platform,
|
In order to specify that a source file should only be compiled for a specific platform,
|
||||||
then the filename can be suffixed with one of the following strings:
|
then the filename can be suffixed with one of the following (case insensitive) strings:
|
||||||
|
|
||||||
_OSX
|
_mac or _osx <- compiled for macOS and OSX platforms only
|
||||||
_Windows
|
_windows <- compiled for Windows platforms only
|
||||||
_Linux
|
_linux <- compiled for Linux and FreeBSD platforms only
|
||||||
_Android
|
_andoid <- compiled for Android platforms only
|
||||||
_iOS
|
_ios <- compiled for iOS platforms only
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
juce_mymodule/juce_mymodule_1.cpp <- compiled on all platforms
|
juce_mymodule/juce_mymodule_1.cpp <- compiled for all platforms
|
||||||
juce_mymodule/juce_mymodule_2.cpp <- compiled on all platforms
|
juce_mymodule/juce_mymodule_2.cpp <- compiled for all platforms
|
||||||
juce_mymodule/juce_mymodule_OSX.cpp <- compiled only on OSX
|
juce_mymodule/juce_mymodule_mac.cpp <- compiled for macOS and OSX platforms only
|
||||||
juce_mymodule/juce_mymodule_Windows.cpp <- compiled only on Windows
|
juce_mymodule/juce_mymodule_windows.cpp <- compiled for Windows platforms only
|
||||||
|
|
||||||
Often this isn't necessary, as in most cases you can easily add checks inside the files
|
Often this isn't necessary, as in most cases you can easily add checks inside the files
|
||||||
to do different things depending on the platform, but this may be handy just to avoid
|
to do different things depending on the platform, but this may be handy just to avoid
|
||||||
clutter in user projects where files aren't needed.
|
clutter in user projects where files aren't needed.
|
||||||
|
|
||||||
To simplify the use of obj-C++ there's also a special-case rule: If the folder contains
|
To simplify the use of obj-C++ there's also a special-case rule: If the folder contains
|
||||||
both a .mm and a .cpp file whose names are otherwise identical, then on OSX/iOS the .mm
|
both a .mm and a .cpp file whose names are otherwise identical, then on macOS/iOS the .mm
|
||||||
will be used and the cpp ignored. (And vice-versa for other platforms, of course).
|
will be used and the cpp ignored. (And vice-versa for other platforms, of course).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,24 +155,25 @@ function(_juce_get_metadata target key out_var)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# ==================================================================================================
|
# ==================================================================================================
|
||||||
|
|
||||||
function(_juce_should_build_module_source filename output_var)
|
function(_juce_should_build_module_source filename output_var)
|
||||||
get_filename_component(trimmed_name "${filename}" NAME_WE)
|
get_filename_component(trimmed_filename "${filename}" NAME_WE)
|
||||||
|
string(TOLOWER "${trimmed_filename}" trimmed_filename_lowercase)
|
||||||
|
|
||||||
|
set(system_name_regex_for_suffix
|
||||||
|
"android\;Android"
|
||||||
|
"ios\;iOS"
|
||||||
|
"linux\;Linux|.*BSD"
|
||||||
|
"mac\;Darwin"
|
||||||
|
"osx\;Darwin"
|
||||||
|
"windows\;Windows")
|
||||||
|
|
||||||
set(result TRUE)
|
set(result TRUE)
|
||||||
|
|
||||||
set(pairs
|
foreach(pair IN LISTS system_name_regex_for_suffix)
|
||||||
"OSX\;Darwin"
|
|
||||||
"Windows\;Windows"
|
|
||||||
"Linux\;Linux"
|
|
||||||
"Android\;Android"
|
|
||||||
"iOS\;iOS")
|
|
||||||
|
|
||||||
foreach(pair IN LISTS pairs)
|
|
||||||
list(GET pair 0 suffix)
|
list(GET pair 0 suffix)
|
||||||
list(GET pair 1 system_name)
|
list(GET pair 1 regex)
|
||||||
|
|
||||||
if((trimmed_name MATCHES "_${suffix}$") AND NOT (CMAKE_SYSTEM_NAME STREQUAL "${system_name}"))
|
if((trimmed_filename_lowercase MATCHES "_${suffix}$") AND NOT (CMAKE_SYSTEM_NAME MATCHES "${regex}"))
|
||||||
set(result FALSE)
|
set(result FALSE)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
|
||||||
|
|
@ -266,15 +266,20 @@ void LibraryModule::findBrowseableFiles (const File& folder, Array<File>& filesF
|
||||||
|
|
||||||
bool LibraryModule::CompileUnit::isNeededForExporter (ProjectExporter& exporter) const
|
bool LibraryModule::CompileUnit::isNeededForExporter (ProjectExporter& exporter) const
|
||||||
{
|
{
|
||||||
if ((hasSuffix (file, "_osx") && ! exporter.isOSX())
|
const auto trimmedFileNameLowercase = file.getFileNameWithoutExtension().toLowerCase();
|
||||||
|| (hasSuffix (file, "_mac") && ! exporter.isOSX())
|
|
||||||
|| (hasSuffix (file, "_ios") && ! exporter.isiOS())
|
|
||||||
|| (hasSuffix (file, "_windows") && ! exporter.isWindows())
|
|
||||||
|| (hasSuffix (file, "_linux") && ! exporter.isLinux())
|
|
||||||
|| (hasSuffix (file, "_android") && ! exporter.isAndroid()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
auto targetType = Project::getTargetTypeFromFilePath (file, false);
|
const std::tuple<const char*, bool> shouldBuildForSuffix[] { { "_android", exporter.isAndroid() },
|
||||||
|
{ "_ios", exporter.isiOS() },
|
||||||
|
{ "_linux", exporter.isLinux() },
|
||||||
|
{ "_mac", exporter.isOSX() },
|
||||||
|
{ "_osx", exporter.isOSX() },
|
||||||
|
{ "_windows", exporter.isWindows() } };
|
||||||
|
|
||||||
|
for (const auto& [suffix, shouldBuild] : shouldBuildForSuffix)
|
||||||
|
if (trimmedFileNameLowercase.endsWith (suffix))
|
||||||
|
return shouldBuild;
|
||||||
|
|
||||||
|
const auto targetType = Project::getTargetTypeFromFilePath (file, false);
|
||||||
|
|
||||||
if (targetType != build_tools::ProjectType::Target::unspecified && ! exporter.shouldBuildTargetType (targetType))
|
if (targetType != build_tools::ProjectType::Target::unspecified && ! exporter.shouldBuildTargetType (targetType))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -288,14 +293,6 @@ String LibraryModule::CompileUnit::getFilenameForProxyFile() const
|
||||||
return "include_" + file.getFileName();
|
return "include_" + file.getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LibraryModule::CompileUnit::hasSuffix (const File& f, const char* suffix)
|
|
||||||
{
|
|
||||||
auto fileWithoutSuffix = f.getFileNameWithoutExtension() + ".";
|
|
||||||
|
|
||||||
return fileWithoutSuffix.containsIgnoreCase (suffix + String ("."))
|
|
||||||
|| fileWithoutSuffix.containsIgnoreCase (suffix + String ("_"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Array<LibraryModule::CompileUnit> LibraryModule::getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget) const
|
Array<LibraryModule::CompileUnit> LibraryModule::getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget) const
|
||||||
{
|
{
|
||||||
auto files = getFolder().findChildFiles (File::findFiles, false);
|
auto files = getFolder().findChildFiles (File::findFiles, false);
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ public:
|
||||||
|
|
||||||
bool isNeededForExporter (ProjectExporter&) const;
|
bool isNeededForExporter (ProjectExporter&) const;
|
||||||
String getFilenameForProxyFile() const;
|
String getFilenameForProxyFile() const;
|
||||||
static bool hasSuffix (const File&, const char*);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Array<CompileUnit> getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget =
|
Array<CompileUnit> getAllCompileUnits (build_tools::ProjectType::Target::Type forTarget =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue