Skip to content
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

[lbuild] Warn if submodules are not up-to-date #267

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions repo.lb
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,37 @@ from distutils.version import StrictVersion
from git import Repo
from os.path import normpath

sys.path.append(repopath("ext/modm-devices/tools/device"))
try:
import modm_devices.parser
except Exception as e:
print(e, "\n")
print("You might be missing the git submodules in `ext/`.\n"
"Try:\n"
" cd modm\n"
" git submodule update --init\n"
"then build again.")
exit(1)

# Check for miminum required lbuild version
import lbuild
min_lbuild_version = "1.12.1"
if StrictVersion(getattr(lbuild, "__version__", "0.1.0")) < StrictVersion(min_lbuild_version):
print("modm requires at least lbuild v{}, please upgrade!\n"
" pip3 install -U lbuild".format(min_lbuild_version))
exit(1)

# Check for submodule existance and their version
def check_submodules():
repo = Repo(localpath("."))
has_error = True
if any(not sm.module_exists() for sm in repo.submodules):
print("\n>> modm: One or more git submodules in `modm/ext/` is missing!\n"
">> modm: Please checkout the submodules:\n\n"
" cd modm\n"
" git submodule update --init\n")
exit(1)
elif any(sm.hexsha != sm.module().commit().hexsha for sm in repo.submodules):
print("\n>> modm: One or more git submodules in `modm/ext/` is not up-to-date!\n"
">> modm: Please update the submodules:\n\n"
" cd modm\n"
" git submodule sync\n"
" git submodule update --init\n")

# Import modm-device tools
sys.path.append(repopath("ext/modm-devices/tools/device"))
try:
import modm_devices.parser
except ModuleNotFoundError:
check_submodules()

# =============================================================================
class DevicesCache(dict):
Expand Down Expand Up @@ -123,7 +135,8 @@ class DevicesCache(dict):
recompute_required = True

if recompute_required:
print("Recomputing device cache...")
check_submodules()
print(">> modm: Recomputing device cache...")
content = self.parse_all()
# prefix the files with a / so we can distinguish them from partnames
files = ["/{} {}".format(Path(f).relative_to(repopath(".")),
Expand Down