Merge .gitmodules with repos.conf (#1430)
* Fix naming discrepancies between repos.conf & .gitmodules
The .gitmodules was unintentionally set up with different names as this
is the default for "git submodule add". Rename submodulse to use the
names chosen in repos.conf.
* Merge repos.conf with .gitmodules
These duplicate the same information. Merge them.
* Add commits to .gitmodules
This avoids having a dirty tree after running
make -f Makefile-bootstrap repos
which was happening because repos.conf doesn't track versions.
* Add a transition script to rename submodules.
After fixing .gitmodules to use the same names as repos.conf, we need a
way to transition checkouts to the new names.
Add a sript to do this and run it from bootstrap.
* Restyle
diff --git a/.gitmodules b/.gitmodules
index 776c08c..d022976 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,36 +1,54 @@
-[submodule "third_party/nlunit-test/repo"]
- path = third_party/nlunit-test/repo
- url = https://github.com/nestlabs/nlunit-test.git
- ignore = dirty
-[submodule "third_party/nlio/repo"]
- path = third_party/nlio/repo
- url = https://github.com/nestlabs/nlio.git
- ignore = dirty
-[submodule "third_party/nlfaultinjection/repo"]
- path = third_party/nlfaultinjection/repo
- url = https://github.com/nestlabs/nlfaultinjection.git
- ignore = dirty
-[submodule "third_party/nlassert/repo"]
- path = third_party/nlassert/repo
- url = https://github.com/nestlabs/nlassert.git
- ignore = dirty
-[submodule "third_party/mbedtls/repo"]
- path = third_party/mbedtls/repo
- url = https://github.com/ARMmbed/mbedtls.git
- ignore = dirty
-[submodule "examples/common/QRCode/repo"]
- path = examples/common/QRCode/repo
- url = https://github.com/nayuki/QR-Code-generator.git
- ignore = dirty
-[submodule "examples/common/m5stack-tft/repo"]
- path = examples/common/m5stack-tft/repo
- url = https://github.com/jeremyjh/ESP32_TFT_library.git
- ignore = dirty
-[submodule "third_party/pigweed"]
- path = third_party/pigweed
- url = https://pigweed.googlesource.com/pigweed/pigweed
- ignore = dirty
-[submodule "third_party/openthread/repo"]
- path = third_party/openthread/repo
- url = https://github.com/openthread/openthread
- ignore = dirty
+[submodule "nlassert"]
+ path = third_party/nlassert/repo
+ url = https://github.com/nestlabs/nlassert.git
+ branch = master
+ ignore = dirty
+ commit = bd2f082102d4456ca750189ee853fa8c7443af59
+[submodule "nlfaultinjection"]
+ path = third_party/nlfaultinjection/repo
+ url = https://github.com/nestlabs/nlfaultinjection.git
+ branch = master
+ ignore = dirty
+ commit = 79f92f309de58c4591f53a9b492600550b473c84
+[submodule "nlio"]
+ path = third_party/nlio/repo
+ url = https://github.com/nestlabs/nlio.git
+ branch = master
+ ignore = dirty
+ commit = dbb78fb4f188bb09ba51626341e1dffa636aa0da
+[submodule "nlunit-test"]
+ path = third_party/nlunit-test/repo
+ url = https://github.com/nestlabs/nlunit-test.git
+ branch = master
+ ignore = dirty
+ commit = ef5a2b9a8b71ad592fcf3681968fd63c844e3d81
+[submodule "mbedtls"]
+ path = third_party/mbedtls/repo
+ url = https://github.com/ARMmbed/mbedtls.git
+ branch = mbedtls-2.18
+ ignore = dirty
+ commit = ca933c7e0c9e84738b168b6b0feb89af4183a60a
+[submodule "qrcode"]
+ path = examples/common/QRCode/repo
+ url = https://github.com/nayuki/QR-Code-generator.git
+ branch = master
+ ignore = dirty
+ commit = 08ac806145aa6ab5d3e9df61d023092bb6cfe761
+[submodule "m5stack-tft"]
+ path = examples/common/m5stack-tft/repo
+ url = https://github.com/jeremyjh/ESP32_TFT_library.git
+ branch = master
+ ignore = dirty
+ commit = 3a841faacb218dbdba2f54edb251d3a64d9833fb
+[submodule "pigweed"]
+ path = third_party/pigweed
+ url = https://pigweed.googlesource.com/pigweed/pigweed
+ branch = master
+ ignore = dirty
+ commit = 16bde6b17e0fabdf4b6877f0d62bd49d3110ee7f
+[submodule "openthread"]
+ path = third_party/openthread/repo
+ url = https://github.com/openthread/openthread.git
+ branch = master
+ ignore = dirty
+ commit = 9e291e62ed92d1132467489c4483330c46c0bce4
diff --git a/Makefile-bootstrap b/Makefile-bootstrap
index 7e673fd..555279b 100644
--- a/Makefile-bootstrap
+++ b/Makefile-bootstrap
@@ -113,5 +113,13 @@
#
clean-repos-hook:
+# Transition submodule names.
+repos: rename-submodules
+clean-repos: rename-submodules
+rename-submodules:
+ @if test -f $(top_srcdir)/scripts/helpers/rename_submodules.sh; then \
+ $(top_srcdir)/scripts/helpers/rename_submodules.sh; \
+ fi
+
include $(abs_top_nlbuild_autotools_dir)/make/post.mak
include $(abs_top_nlbuild_autotools_dir)/make/post/rules/bootstrap.mak
diff --git a/bootstrap.sh b/bootstrap.sh
index 36e7516..b682aa7 100644
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -19,6 +19,10 @@
export PW_BRANDING_BANNER="$CHIP_ROOT/.chip-banner.txt"
export PW_BRANDING_BANNER_COLOR="bold_white"
+if test -f "$CHIP_ROOT/scripts/helpers/rename_submodules.sh"; then
+ "$CHIP_ROOT/scripts/helpers/rename_submodules.sh"
+fi
+
git submodule update --init
# shellcheck source=/dev/null
diff --git a/repos.conf b/repos.conf
deleted file mode 100644
index 3038a2c..0000000
--- a/repos.conf
+++ /dev/null
@@ -1,40 +0,0 @@
-[submodule "nlassert"]
- path = third_party/nlassert/repo
- url = https://github.com/nestlabs/nlassert.git
- branch = master
- update = none
-[submodule "nlfaultinjection"]
- path = third_party/nlfaultinjection/repo
- url = https://github.com/nestlabs/nlfaultinjection.git
- branch = master
- update = none
-[submodule "nlio"]
- path = third_party/nlio/repo
- url = https://github.com/nestlabs/nlio.git
- branch = master
- update = none
-[submodule "nlunit-test"]
- path = third_party/nlunit-test/repo
- url = https://github.com/nestlabs/nlunit-test.git
- branch = master
- update = none
-[submodule "mbedtls"]
- path = third_party/mbedtls/repo
- url = https://github.com/ARMmbed/mbedtls.git
- branch = mbedtls-2.18
- update = none
-[submodule "qrcode"]
- path = examples/common/QRCode/repo
- url = https://github.com/nayuki/QR-Code-generator.git
- branch = master
- update = none
-[submodule "m5stack-tft"]
- path = examples/common/m5stack-tft/repo
- url = https://github.com/jeremyjh/ESP32_TFT_library.git
- branch = master
- update = none
-[submodule "openthread"]
- path = third_party/openthread/repo
- url = https://github.com/openthread/openthread.git
- branch = master
- update = none
diff --git a/repos.conf b/repos.conf
new file mode 120000
index 0000000..7837f9c
--- /dev/null
+++ b/repos.conf
@@ -0,0 +1 @@
+.gitmodules
\ No newline at end of file
diff --git a/scripts/helpers/rename_submodules.sh b/scripts/helpers/rename_submodules.sh
new file mode 100755
index 0000000..c124f1e
--- /dev/null
+++ b/scripts/helpers/rename_submodules.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+#
+# Copyright (c) 2020 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+CHIP_ROOT="$(dirname "$0")/../.."
+
+if [[ ! -e "$CHIP_ROOT/.git" ]]; then
+ exit 0
+fi
+
+# Transitional: Remove keys for submodules with mismatched names
+OLD_SUBMODULE_KEYS='submodule\.third_party/.*|submodule\.examples/.*'
+
+if ! git -C "$CHIP_ROOT" config --get-regexp "$OLD_SUBMODULE_KEYS" >&/dev/null; then
+ exit 0
+fi
+
+# Remove renamed submodules from config
+git -C "$CHIP_ROOT" config --get-regexp "$OLD_SUBMODULE_KEYS" | while read key value; do
+ git -C "$CHP_ROOT" config --unset "$key"
+done
+
+# Re-init with new submodule names.
+git submodule update --init