Skip to content

Commit

Permalink
Find all nested projects to download packages. (#2676)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Dec 11, 2024
1 parent 966e318 commit 6283f95
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 14 deletions.
46 changes: 32 additions & 14 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,39 @@ foreach(REPO ${TOIT_REPOS})
add_dependencies(download_external "${TARGET_NAME}")
endforeach()

# Finds projects (folders with package.lock/yaml files) in the given repo.
function(find_toit_projects REPO)
get_filename_component(REPO_NAME "${REPO}" NAME)
set(REPO_PATH "${DOWNLOADS_DIR}/${REPO_NAME}")
foreach(LOCATION "" "examples" "tests" "tools" "app" "bin")
set(LOCATION_PATH "${REPO_PATH}/${LOCATION}")
if (EXISTS "${LOCATION_PATH}/package.yaml" OR EXISTS "${LOCATION_PATH}/package.lock")
set(PROJECT_NAME "${REPO_NAME}")
if (NOT "${LOCATION}" STREQUAL "")
set(PROJECT_NAME "${PROJECT_NAME}-${LOCATION}")
endif()
# Mark it as a toit-project so we download its dependencies.
toit_project("${PROJECT_NAME}" "${LOCATION_PATH}")
function(find_toit_projects directory)
# Helper function to process directories recursively.
function(process_directory current_dir project_name)
# Check if package.yaml or package.lock exists in the current directory.
if(EXISTS "${current_dir}/package.yaml" OR EXISTS "${current_dir}/package.lock")
toit_project("${project_name}" "${current_dir}")
endif()
endforeach()

# Get the list of all files and directories in the current directory.
file(GLOB ALL_FILES_AND_DIRS RELATIVE "${current_dir}" "${current_dir}/*")

foreach(item IN LISTS ALL_FILES_AND_DIRS)
set(full_path "${current_dir}/${item}")

if(IS_DIRECTORY "${full_path}")
# Skip .packages directories.
if(NOT item MATCHES "^\.packages$")
# Recurse into subdirectory.
process_directory("${full_path}" "${project_name}-${item}")
endif()
endif()
endforeach()
endfunction()

get_filename_component(repo_name "${directory}" NAME)
set(repo_path "${DOWNLOADS_DIR}/${repo_name}")

# Start processing the provided directory.
if(EXISTS "${repo_path}")
process_directory("${repo_path}" "${repo_name}")
else()
message(WARNING "Directory ${repo_path} does not exist.")
endif()
endfunction()

include(fail.cmake OPTIONAL)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
toit-pixel-display/tests/toit-png-tools/bin/pngdiff.toit:12:1: error: Failed to import '.version'
import .version
^~~~~~
toit-pixel-display/tests/toit-png-tools/bin/pngdiff.toit:12:9: note: Missing library file. Tried 'toit-pixel-display/tests/toit-png-tools/bin/version.toit' and 'toit-pixel-display/tests/toit-png-tools/bin/version/version.toit'
import .version
^~~~~~~
toit-pixel-display/tests/toit-png-tools/bin/pngdiff.toit:81:21: error: Unresolved identifier: 'PNGDIFF-VERSION'
print "pngdiff $PNGDIFF-VERSION"
^~~~~~~~~~~~~~~
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
toit-pixel-display/tests/toit-png-tools/bin/pnginfo.toit:12:1: error: Failed to import '.version'
import .version
^~~~~~
toit-pixel-display/tests/toit-png-tools/bin/pnginfo.toit:12:9: note: Missing library file. Tried 'toit-pixel-display/tests/toit-png-tools/bin/version.toit' and 'toit-pixel-display/tests/toit-png-tools/bin/version/version.toit'
import .version
^~~~~~~
toit-pixel-display/tests/toit-png-tools/bin/pnginfo.toit:83:21: error: Unresolved identifier: 'PNGDIFF-VERSION'
print "pnginfo $PNGDIFF-VERSION"
^~~~~~~~~~~~~~~
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
toit-pixel-display/tests/toit-png-tools/bin/pngunzip.toit:12:1: error: Failed to import '.version'
import .version
^~~~~~
toit-pixel-display/tests/toit-png-tools/bin/pngunzip.toit:12:9: note: Missing library file. Tried 'toit-pixel-display/tests/toit-png-tools/bin/version.toit' and 'toit-pixel-display/tests/toit-png-tools/bin/version/version.toit'
import .version
^~~~~~~
toit-pixel-display/tests/toit-png-tools/bin/pngunzip.toit:73:22: error: Unresolved identifier: 'PNGDIFF-VERSION'
print "pngunzip $PNGDIFF-VERSION"
^~~~~~~~~~~~~~~

0 comments on commit 6283f95

Please sign in to comment.