Skip to content

Commit b504a9c

Browse files
authored
Read Git repository URL from versions.json (#34)
Currently, the location of the Git repository for dependencies is hard-codedinto the FetchContent. This patch instead reads it from the existing versions.json file, if a different location is desired - for example, using a mirror of the repo.
1 parent b332ef2 commit b504a9c

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

arm-software/embedded/cmake/fetch_newlib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ read_repo_version(newlib newlib)
1414
get_patch_command(${CMAKE_CURRENT_LIST_DIR}/.. newlib newlib_patch_command)
1515

1616
FetchContent_Declare(newlib
17-
GIT_REPOSITORY https://sourceware.org/git/newlib-cygwin.git
17+
GIT_REPOSITORY "${newlib_URL}"
1818
GIT_TAG "${newlib_TAG}"
1919
GIT_SHALLOW "${newlib_SHALLOW}"
2020
GIT_PROGRESS TRUE

arm-software/embedded/cmake/fetch_picolibc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ read_repo_version(picolibc picolibc)
1414
get_patch_command(${CMAKE_CURRENT_LIST_DIR}/.. picolibc picolibc_patch_command)
1515

1616
FetchContent_Declare(picolibc
17-
GIT_REPOSITORY https://github.com/picolibc/picolibc.git
17+
GIT_REPOSITORY "${picolibc_URL}"
1818
GIT_TAG "${picolibc_TAG}"
1919
GIT_SHALLOW "${picolibc_SHALLOW}"
2020
GIT_PROGRESS TRUE

arm-software/embedded/cmake/read_versions.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Read which revisions of the repos to use.
22
file(READ ${CMAKE_CURRENT_LIST_DIR}/../versions.json VERSIONS_JSON)
33
function(read_repo_version output_variable_prefix repo)
4+
string(JSON url GET ${VERSIONS_JSON} "repos" "${repo}" "url")
45
string(JSON tag GET ${VERSIONS_JSON} "repos" "${repo}" "tag")
56
string(JSON tagType GET ${VERSIONS_JSON} "repos" "${repo}" "tagType")
67
if(tagType STREQUAL "commithash")
@@ -17,6 +18,7 @@ function(read_repo_version output_variable_prefix repo)
1718
message(FATAL_ERROR "Unrecognised tagType ${tagType}")
1819
endif()
1920

21+
set(${output_variable_prefix}_URL "${url}" PARENT_SCOPE)
2022
set(${output_variable_prefix}_TAG "${tag}" PARENT_SCOPE)
2123
set(${output_variable_prefix}_SHALLOW "${shallow}" PARENT_SCOPE)
2224
endfunction()

arm-software/embedded/versions.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"comment": [
3-
"Release branches of Arm Toolchain for Embedded for Arm will use",
3+
"Release branches of Arm Toolchain for Embedded will use",
44
"specific revisions of the repos it depends on. This file provides",
55
"a single source of truth for which revisions to use that can be",
66
"queried by CMake and other automation software."
77
],
88
"repos": {
99
"picolibc": {
10+
"url": "https://github.com/picolibc/picolibc.git",
1011
"tagType": "branch",
1112
"tag": "main"
1213
},
1314
"newlib": {
15+
"url": "https://sourceware.org/git/newlib-cygwin.git",
1416
"tagType": "tag",
1517
"tag": "newlib-4.5.0"
1618
}

0 commit comments

Comments
 (0)