-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Don't fetch submodules for plugins that aren't being built #5182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+186
−128
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fe28b38
Add PLUGIN_LIST support to CheckSubmodules
tresf 9b504b8
Remove comment
tresf c7c4dd6
@lukas-w don't change your name :D
tresf 5adbeae
Revert "@lukas-w don't change your name :D"
tresf bac2a1b
Fix shallow clone issues for submodules
tresf e92dafb
Remove unused var
tresf 7f3509a
Add shallow clone flag
tresf dbdb2d3
Attempt to localize variable
tresf e5184b5
Support git versions older than 1.8.3
tresf 5c82692
Fix typo
tresf f3ca7ab
Fix more bugs
tresf 5df372f
Documenation and error checking
tresf 2cac306
Add option definitions per request
tresf dcfc210
Add full clone option
tresf 051810b
Sanitize and improve code
tresf bc79da1
Remove SKIP_SUBMODULES
tresf e326fd2
Remove unecessary validation
tresf cea4b50
Fix documentation
tresf a46b979
Remove lingering LIST_SUBMODULES option
tresf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,26 +7,28 @@ | |
| # INCLUDE(CheckSubmodules) | ||
| # | ||
| # Options: | ||
| # SET(SKIP_SUBMODULES "foo;bar") | ||
| # SET(PLUGIN_LIST "zynaddsubfx;...") # skips submodules for plugins not explicitely listed | ||
| # | ||
| # Or via command line: | ||
| # cmake -DSKIP_SUBMODULES=foo;bar | ||
| # cmake -PLUGIN_LIST=foo;bar | ||
| # | ||
| # Copyright (c) 2017, Tres Finocchiaro, <[email protected]> | ||
| # Copyright (c) 2019, Tres Finocchiaro, <[email protected]> | ||
| # | ||
| # Redistribution and use is allowed according to the terms of the BSD license. | ||
| # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
|
|
||
| # Files which confirm a successful clone | ||
| SET(VALID_CRUMBS "CMakeLists.txt;Makefile;Makefile.in;Makefile.am;configure.ac;configure.py;autogen.sh;.gitignore;LICENSE;Home.md") | ||
|
|
||
| OPTION(NO_SHALLOW_CLONE "Disable shallow cloning of submodules" OFF) | ||
|
|
||
| # Try and use the specified shallow clone on submodules, if supported | ||
| SET(DEPTH_VALUE 100) | ||
|
|
||
| # Number of times git commands will retry before failing | ||
| SET(MAX_ATTEMPTS 2) | ||
|
|
||
| MESSAGE("\nValidating submodules...") | ||
| MESSAGE("\nChecking submodules...") | ||
| IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/.gitmodules") | ||
| MESSAGE("Skipping the check because .gitmodules not detected." | ||
| "Please make sure you have all submodules in the source tree!" | ||
|
|
@@ -41,74 +43,110 @@ SET(LANG_BACKUP "$ENV{LANG}") | |
| SET(ENV{LC_ALL} "C") | ||
| SET(ENV{LANG} "en_US") | ||
|
|
||
| # Assume alpha-numeric paths | ||
| STRING(REGEX MATCHALL "path = [-0-9A-Za-z/]+" SUBMODULE_LIST ${SUBMODULE_DATA}) | ||
| STRING(REGEX MATCHALL "url = [.:%-0-9A-Za-z/]+" SUBMODULE_URL_LIST ${SUBMODULE_DATA}) | ||
| # Submodule list pairs, unparsed (WARNING: Assumes alpha-numeric paths) | ||
| STRING(REGEX MATCHALL "path = [-0-9A-Za-z/]+" SUBMODULE_LIST_RAW ${SUBMODULE_DATA}) | ||
| STRING(REGEX MATCHALL "url = [.:%-0-9A-Za-z/]+" SUBMODULE_URL_RAW ${SUBMODULE_DATA}) | ||
|
|
||
| # Submodule list pairs, parsed | ||
| SET(SUBMODULE_LIST "") | ||
| SET(SUBMODULE_URL "") | ||
|
|
||
| FOREACH(_part ${SUBMODULE_LIST}) | ||
| STRING(REPLACE "path = " "" SUBMODULE_PATH ${_part}) | ||
| FOREACH(_path ${SUBMODULE_LIST_RAW}) | ||
| # Parse SUBMODULE_PATH | ||
| STRING(REPLACE "path = " "" SUBMODULE_PATH "${_path}") | ||
|
|
||
| LIST(FIND SUBMODULE_LIST ${_part} SUBMODULE_INDEX) | ||
| LIST(GET SUBMODULE_URL_LIST ${SUBMODULE_INDEX} _url) | ||
| STRING(REPLACE "url = " "" SUBMODULE_URL ${_url}) | ||
| # Grab index for matching SUBMODULE_URL | ||
| LIST(FIND SUBMODULE_LIST_RAW "${_path}" SUBMODULE_INDEX) | ||
| LIST(GET SUBMODULE_URL_RAW ${SUBMODULE_INDEX} _url) | ||
|
|
||
| # Parse SUBMODULE_URL | ||
| STRING(REPLACE "url = " "" SUBMODULE_URL "${_url}") | ||
|
|
||
| # Remove submodules from validation as specified in -DSKIP_SUBMODULES=foo;bar | ||
| SET(SKIP false) | ||
|
|
||
| # Loop over skipped plugins, add to SKIP_SUBMODULES (e.g. -DPLUGIN_LIST=foo;bar) | ||
| IF(${SUBMODULE_PATH} MATCHES "^plugins/") | ||
| SET(REMOVE_PLUGIN true) | ||
| FOREACH(_plugin ${PLUGIN_LIST}) | ||
| IF(_plugin STREQUAL "") | ||
| CONTINUE() | ||
| ENDIF() | ||
| IF(${SUBMODULE_PATH} MATCHES "${_plugin}") | ||
| SET(REMOVE_PLUGIN false) | ||
| ENDIF() | ||
| ENDFOREACH() | ||
|
|
||
| IF(REMOVE_PLUGIN) | ||
| LIST(APPEND SKIP_SUBMODULES "${SUBMODULE_PATH}") | ||
| ENDIF() | ||
| ENDIF() | ||
|
|
||
| # Finally, loop and mark "SKIP" on match | ||
| IF(SKIP_SUBMODULES) | ||
| FOREACH(_skip ${SKIP_SUBMODULES}) | ||
| IF(${SUBMODULE_PATH} MATCHES ${_skip}) | ||
| MESSAGE("-- Skipping ${SUBMODULE_PATH} matches \"${_skip}\"") | ||
| IF("${SUBMODULE_PATH}" MATCHES "${_skip}") | ||
| MESSAGE("-- Skipping ${SUBMODULE_PATH} matches \"${_skip}\" (absent in PLUGIN_LIST)") | ||
| SET(SKIP true) | ||
| BREAK() | ||
| ENDIF() | ||
| ENDFOREACH() | ||
| ENDIF() | ||
|
|
||
| IF(NOT SKIP) | ||
| LIST(INSERT SUBMODULE_LIST ${SUBMODULE_INDEX} ${SUBMODULE_PATH}) | ||
| LIST(INSERT SUBMODULE_URL_LIST ${SUBMODULE_INDEX} ${SUBMODULE_URL}) | ||
| LIST(APPEND SUBMODULE_LIST "${SUBMODULE_PATH}") | ||
| LIST(APPEND SUBMODULE_URL "${SUBMODULE_URL}") | ||
| ENDIF() | ||
| LIST(REMOVE_ITEM SUBMODULE_LIST ${_part}) | ||
| LIST(REMOVE_ITEM SUBMODULE_URL_LIST ${_url}) | ||
| ENDFOREACH() | ||
|
|
||
|
|
||
| # Once called, status is stored in GIT_RESULT respectively. | ||
| # Note: Git likes to write to stderr. Don't assume stderr is error; Check GIT_RESULT instead. | ||
| MACRO(GIT_SUBMODULE SUBMODULE_PATH FORCE_DEINIT FORCE_REMOTE) | ||
| MACRO(GIT_SUBMODULE SUBMODULE_PATH FORCE_DEINIT FORCE_REMOTE FULL_CLONE) | ||
| FIND_PACKAGE(Git REQUIRED) | ||
| # Handle missing commits | ||
| SET(FORCE_REMOTE_FLAG "${FORCE_REMOTE}") | ||
| SET(FULL_CLONE_FLAG "${FULL_CLONE}") | ||
| IF(FORCE_REMOTE_FLAG) | ||
| MESSAGE("-- Adding remote submodulefix to ${SUBMODULE_PATH}") | ||
| EXECUTE_PROCESS( | ||
| COMMAND ${GIT_EXECUTABLE} remote rm submodulefix | ||
| COMMAND ${GIT_EXECUTABLE} remote add submodulefix ${FORCE_REMOTE} | ||
| COMMAND ${GIT_EXECUTABLE} fetch submodulefix | ||
| WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH} | ||
| COMMAND "${GIT_EXECUTABLE}" remote rm submodulefix | ||
| COMMAND "${GIT_EXECUTABLE}" remote add submodulefix ${FORCE_REMOTE} | ||
| COMMAND "${GIT_EXECUTABLE}" fetch submodulefix | ||
| WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH}" | ||
| OUTPUT_QUIET ERROR_QUIET | ||
| ) | ||
| # Recurse | ||
| GIT_SUBMODULE(${SUBMODULE_PATH} false false) | ||
| GIT_SUBMODULE(${SUBMODULE_PATH} false false ${FULL_CLONE_FLAG}) | ||
| ELSEIF(${FORCE_DEINIT}) | ||
| MESSAGE("-- Resetting ${SUBMODULE_PATH}") | ||
| EXECUTE_PROCESS( | ||
| COMMAND ${GIT_EXECUTABLE} submodule deinit -f ${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH} | ||
| WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
| COMMAND "${GIT_EXECUTABLE}" submodule deinit -f "${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH}" | ||
| WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | ||
| OUTPUT_QUIET | ||
| ) | ||
| # Recurse | ||
| GIT_SUBMODULE(${SUBMODULE_PATH} false false) | ||
| GIT_SUBMODULE(${SUBMODULE_PATH} false false ${FULL_CLONE_FLAG}) | ||
| ELSE() | ||
| # Try to use the depth switch | ||
| SET(DEPTH_CMD "") | ||
| IF(NO_SHALLOW_CLONE OR GIT_VERSION_STRING VERSION_LESS "1.8.4") | ||
| # Shallow submodules were introduced in 1.8.4 | ||
| MESSAGE("-- Fetching ${SUBMODULE_PATH}") | ||
| SET(DEPTH_CMD "") | ||
| SET(DEPTH_VAL "") | ||
| ELSEIF(FULL_CLONE_FLAG) | ||
| # Depth doesn't revert easily... It should be "--no-recommend-shallow" | ||
| # but it's ignored by nested submodules, use the highest value instead. | ||
| MESSAGE("-- Fetching ${SUBMODULE_PATH}") | ||
| IF(DEPTH_VALUE) | ||
| SET(DEPTH_CMD "--depth" ) | ||
| SET(DEPTH_CMD "--depth") | ||
| SET(DEPTH_VAL "2147483647") | ||
| ELSE() | ||
| MESSAGE("-- Fetching ${SUBMODULE_PATH} @ --depth ${DEPTH_VALUE}") | ||
| SET(DEPTH_CMD "--depth") | ||
| SET(DEPTH_VAL "${DEPTH_VALUE}") | ||
| ENDIF() | ||
|
|
||
| EXECUTE_PROCESS( | ||
| COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive ${DEPTH_CMD} ${DEPTH_VALUE} ${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH} | ||
| WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
| COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive ${DEPTH_CMD} ${DEPTH_VAL} "${CMAKE_SOURCE_DIR}/${SUBMODULE_PATH}" | ||
| WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | ||
| RESULT_VARIABLE GIT_RESULT | ||
| OUTPUT_VARIABLE GIT_STDOUT | ||
| ERROR_VARIABLE GIT_STDERR | ||
|
|
@@ -124,7 +162,7 @@ SET(RETRY_PHRASES "Failed to recurse;cannot create directory;already exists;${MI | |
|
|
||
| # Attempt to do lazy clone | ||
| FOREACH(_submodule ${SUBMODULE_LIST}) | ||
| STRING(REPLACE "/" ";" PATH_PARTS ${_submodule}) | ||
| STRING(REPLACE "/" ";" PATH_PARTS "${_submodule}") | ||
| LIST(REVERSE PATH_PARTS) | ||
| LIST(GET PATH_PARTS 0 SUBMODULE_NAME) | ||
|
|
||
|
|
@@ -138,7 +176,7 @@ FOREACH(_submodule ${SUBMODULE_LIST}) | |
| ENDIF() | ||
| ENDFOREACH() | ||
| IF(NOT CRUMB_FOUND) | ||
| GIT_SUBMODULE(${_submodule} false false) | ||
| GIT_SUBMODULE("${_submodule}" false false false) | ||
|
|
||
| SET(COUNTED 0) | ||
| SET(COUNTING "") | ||
|
|
@@ -154,25 +192,22 @@ FOREACH(_submodule ${SUBMODULE_LIST}) | |
| ENDIF() | ||
| ENDFOREACH() | ||
| FOREACH(_phrase ${RETRY_PHRASES}) | ||
| IF(${MISSING_COMMIT}) | ||
| IF(${MISSING_COMMIT} AND COUNTED LESS 2) | ||
| LIST(FIND SUBMODULE_LIST ${_submodule} SUBMODULE_INDEX) | ||
| LIST(GET SUBMODULE_URL_LIST ${SUBMODULE_INDEX} SUBMODULE_URL) | ||
| MESSAGE("-- Retrying ${_submodule} using 'remote add submodulefix' (attempt ${COUNTED} of ${MAX_ATTEMPTS})...") | ||
|
|
||
| GIT_SUBMODULE(${_submodule} false "${SUBMODULE_URL}") | ||
| GIT_SUBMODULE("${_submodule}" false "${SUBMODULE_URL}" false) | ||
| BREAK() | ||
| ELSEIF("${GIT_MESSAGE}" MATCHES "${_phrase}") | ||
| MESSAGE("-- Retrying ${_submodule} using 'deinit' (attempt ${COUNTED} of ${MAX_ATTEMPTS})...") | ||
|
|
||
| # Shallow submodules were introduced in 1.8.4 | ||
| # Shallow commits can fail to clone from non-default branches, only try once | ||
| IF(GIT_VERSION_STRING VERSION_GREATER "1.8.3" AND COUNTED LESS 2) | ||
| # Try a shallow submodule clone | ||
| IF(COUNTED LESS 2) | ||
| SET(FULL_CLONE false) | ||
| ELSE() | ||
| UNSET(DEPTH_VALUE) | ||
| SET(FULL_CLONE true) | ||
| ENDIF() | ||
|
|
||
| GIT_SUBMODULE(${_submodule} true false) | ||
| GIT_SUBMODULE("${_submodule}" true false ${FULL_CLONE}) | ||
| BREAK() | ||
| ENDIF() | ||
| ENDFOREACH() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # Provides a fast mechanism for filtering the plugins used at build-time | ||
| SET(PLUGIN_LIST "" CACHE STRING "List of plug-ins to build") | ||
| STRING(REPLACE " " ";" PLUGIN_LIST "${PLUGIN_LIST}") | ||
| OPTION(LMMS_MINIMAL "Build a minimal list of plug-ins" OFF) | ||
| OPTION(LIST_PLUGINS "Lists the available plugins for building" OFF) | ||
|
|
||
| SET(MINIMAL_LIST | ||
| audio_file_processor | ||
| kicker | ||
| triple_oscillator | ||
| ) | ||
|
|
||
| IF(LMMS_MINIMAL) | ||
| IF("${PLUGIN_LIST}" STREQUAL "") | ||
| STRING(REPLACE ";" " " MINIMAL_LIST_STRING "${MINIMAL_LIST}") | ||
| MESSAGE( | ||
| "-- Using minimal plug-ins: ${MINIMAL_LIST_STRING}\n" | ||
| " Note: You can specify specific plug-ins using -DPLUGIN_LIST=\"foo bar\"" | ||
| ) | ||
| ENDIF() | ||
| SET(PLUGIN_LIST ${MINIMAL_LIST} ${PLUGIN_LIST}) | ||
| ENDIF() | ||
|
|
||
| SET(LMMS_PLUGIN_LIST | ||
| ${MINIMAL_LIST} | ||
| Amplifier | ||
| BassBooster | ||
| bit_invader | ||
| Bitcrush | ||
| carlabase | ||
| carlapatchbay | ||
| carlarack | ||
| CrossoverEQ | ||
| Delay | ||
| DualFilter | ||
| dynamics_processor | ||
| Eq | ||
| Flanger | ||
| HydrogenImport | ||
| ladspa_browser | ||
| LadspaEffect | ||
| lb302 | ||
| MidiImport | ||
| MidiExport | ||
| MultitapEcho | ||
| monstro | ||
| nes | ||
| OpulenZ | ||
| organic | ||
| FreeBoy | ||
| patman | ||
| peak_controller_effect | ||
| GigPlayer | ||
| ReverbSC | ||
| sf2_player | ||
| sfxr | ||
| sid | ||
| SpectrumAnalyzer | ||
| stereo_enhancer | ||
| stereo_matrix | ||
| stk | ||
| vst_base | ||
| vestige | ||
| VstEffect | ||
| watsyn | ||
| waveshaper | ||
| vibed | ||
| Xpressive | ||
| zynaddsubfx | ||
| ) | ||
|
|
||
| IF("${PLUGIN_LIST}" STREQUAL "") | ||
| SET(PLUGIN_LIST ${LMMS_PLUGIN_LIST}) | ||
| ENDIF() | ||
|
|
||
| MACRO(LIST_ALL_PLUGINS) | ||
| MESSAGE("\n\nAll possible -DPLUGIN_LIST values") | ||
| MESSAGE("\n KEYWORD:") | ||
| MESSAGE(" -DLMMS_MINIMAL=True") | ||
| FOREACH(item IN LISTS MINIMAL_LIST) | ||
| MESSAGE(" ${item}") | ||
| ENDFOREACH() | ||
| MESSAGE("\n NAME:") | ||
| FOREACH(item IN LISTS LMMS_PLUGIN_LIST) | ||
| MESSAGE(" ${item}") | ||
| ENDFOREACH() | ||
| MESSAGE("\nNote: This value also impacts the fetching of git submodules.\n") | ||
| MESSAGE(FATAL_ERROR "Information was requested, aborting build!") | ||
| ENDMACRO() | ||
|
|
||
| IF(LIST_PLUGINS) | ||
JohannesLorenz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| UNSET(LIST_PLUGINS CACHE) | ||
| LIST_ALL_PLUGINS() | ||
| ENDIF() | ||
|
|
||
| IF(MSVC) | ||
| SET(MSVC_INCOMPATIBLE_PLUGINS | ||
| LadspaEffect | ||
| zynaddsubfx | ||
| ) | ||
| message(WARNING "Compiling with MSVC. The following plugins are not available: ${MSVC_INCOMPATIBLE_PLUGINS}") | ||
| LIST(REMOVE_ITEM PLUGIN_LIST ${MSVC_INCOMPATIBLE_PLUGINS}) | ||
| ENDIF() | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.