Llvm submodule (#3108)
authorZoltan Varga <vargaz@gmail.com>
Tue, 7 Jun 2016 14:46:33 +0000 (10:46 -0400)
committerZoltan Varga <vargaz@gmail.com>
Tue, 7 Jun 2016 14:46:33 +0000 (10:46 -0400)
* Move the versions.mk infrastructure to scripts/submodules so it can be used elsewhere too.

* Add a conditional submodule for llvm.

* Fix commit messages emitted by the bump- targets.

* Use a anonymous git url for llvm.

acceptance-tests/versions.mk
acceptance-tests/versions.py [deleted file]
configure.ac
llvm/Makefile.am [new file with mode: 0644]
llvm/SUBMODULES.json [new file with mode: 0644]
scripts/submodules/versions.mk [new file with mode: 0644]
scripts/submodules/versions.py [new file with mode: 0755]

index 9cf7d89bbea89f5c5cd3f6fb3067f484fc53eb3c..491b67e11ce18921c10b7d20e73767d5eb3db52a 100644 (file)
 .PHONY: validate-versions reset-versions
 
-CONFIG=SUBMODULES.json
-
-# usage $(call ValidateVersionTemplate (name,MAKEFILE VAR,repo name))
-# usage $(call ValidateVersionTemplate (mono,MONO,mono))
-
-define ValidateVersionTemplate
-#$(eval REPOSITORY_$(2):=$(shell test -z $(3) && echo $(1) || echo "$(3)"))
-#$(eval DIRECTORY_$(2):=$(shell python versions.py get-dir $(1)))
-#$(eval DIRECTORY_$(2):=$(shell test -z $(DIRECTORY_$(2)) && echo $(1) || echo $(DIRECTORY_$(2))))
-#$(eval MODULE_$(2):=$(shell python versions.py get-url $(1)))
-#$(eval NEEDED_$(2)_VERSION:=$(shell python versions.py get-rev $(1)))
-#$(eval $(2)_BRANCH_AND_REMOTE:=$(shell python versions.py get-remote-branch $(1)))
-
-#$(eval $(2)_VERSION:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git rev-parse HEAD ))
-
-#$(eval NEEDED_$(2)_BRANCH:=$(word 2, $(subst /, ,$($(2)_BRANCH_AND_REMOTE))))
-#$(eval NEEDED_$(2)_REMOTE:=$(word 1, $(subst /, ,$($(2)_BRANCH_AND_REMOTE))))
-#$(eval $(2)_BRANCH:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git symbolic-ref --short HEAD 2>/dev/null))
-
-validate-$(1)::
-       @if test x$$(IGNORE_$(2)_VERSION) = "x"; then \
-           if test ! -d $($(2)_PATH); then \
-                       if test x$$(RESET_VERSIONS) != "x"; then \
-                               $(MAKE) reset-$(1) || exit 1; \
-                       else \
-                               echo "Your $(1) checkout is missing, please run 'make reset-$(1)'"; \
-                               touch .validate-versions-failure; \
-                       fi; \
-           else \
-                       if test "x$($(2)_VERSION)" != "x$(NEEDED_$(2)_VERSION)" ; then \
-                               if test x$$(RESET_VERSIONS) != "x"; then \
-                                       $(MAKE) reset-$(1) || exit 1; \
-                               else \
-                                   echo "Your $(1) version is out of date, please run 'make reset-$(1)' (found $($(2)_VERSION), expected $(NEEDED_$(2)_VERSION))"; \
-                                   test -z "$(BUILD_REVISION)" || $(MAKE) test-$(1); \
-                               touch .validate-versions-failure; \
-                               fi; \
-               elif test "x$($(2)_BRANCH)" != "x$(NEEDED_$(2)_BRANCH)" ; then \
-                               if test x$$(RESET_VERSIONS) != "x"; then \
-                                       test -z "$(BUILD_REVISION)" || $(MAKE) test-$(1); \
-                                       $(MAKE) reset-$(1) || exit 1; \
-                               else \
-                                   echo "Your $(1) branch is out of date, please run 'make reset-$(1)' (found $($(2)_BRANCH), expected $(NEEDED_$(2)_BRANCH))"; \
-                               touch .validate-versions-failure; \
-                               fi; \
-              fi; \
-           fi; \
-       fi
-
-test-$(1)::
-       @echo $(1)
-       @echo "   REPOSITORY_$(2)=$(REPOSITORY_$(2))"
-       @echo "   DIRECTORY_$(2)=$(DIRECTORY_$(2))"
-       @echo "   MODULE_$(2)=$(MODULE_$(2))"
-       @echo "   NEEDED_$(2)_VERSION=$(NEEDED_$(2)_VERSION)"
-       @echo "   $(2)_VERSION=$($(2)_VERSION)"
-       @echo "   $(2)_BRANCH_AND_REMOTE=$($(2)_BRANCH_AND_REMOTE)"
-       @echo "   NEEDED_$(2)_BRANCH=$(NEEDED_$(2)_BRANCH)"
-       @echo "   NEEDED_$(2)_REMOTE=$(NEEDED_$(2)_REMOTE)"
-       @echo "   $(2)_BRANCH=$($(2)_BRANCH)"
-       @echo "   $(2)_PATH=$($(2)_PATH) => $(abspath $($(2)_PATH))"
-
-reset-$(1)::
-       @if test -d $($(2)_PATH); then \
-               if ! (cd $($(2)_PATH) && git show $(NEEDED_$(2)_VERSION) >/dev/null 2>&1 && git log -1 $(NEEDED_$(2)_REMOTE) >/dev/null 2>&1) ; then \
-                       echo "*** git fetch `basename $$($(2)_PATH)`" && (cd $($(2)_PATH) && git fetch); \
-               fi;  \
-       else \
-               echo "*** git clone $(MODULE_$(2)) --recursive $(DIRECTORY_$(2))" && (cd `dirname $($(2)_PATH)` && git clone $(MODULE_$(2)) --recursive $(DIRECTORY_$(2)) || exit 1 ); \
-       fi
-       @if test x$$(IGNORE_$(2)_VERSION) = "x"; then \
-               echo "*** [$(1)] git checkout -f" $(NEEDED_$(2)_BRANCH) && (cd $($(2)_PATH) ; git checkout -f $(NEEDED_$(2)_BRANCH) || git checkout -f -b $($(2)_BRANCH_AND_REMOTE)); \
-               echo "*** [$(1)] git reset --hard $(NEEDED_$(2)_VERSION)" && (cd $($(2)_PATH) && git reset --hard $(NEEDED_$(2)_VERSION)); \
-       fi
-       @echo "*** [$(1)] git submodule update --init --recursive" && (cd $($(2)_PATH) && git submodule update --init --recursive)
-
-print-$(1)::
-       @printf "*** %-16s %-45s %s (%s)\n" "$(DIRECTORY_$(2))" "$(MODULE_$(2))" "$(NEEDED_$(2)_VERSION)" "$(NEEDED_$(2)_BRANCH)"
-
-.PHONY: validate-$(1) reset-$(1) print-$(1)
-
-reset-versions:: reset-$(1)
-validate-versions:: Validate-$(1)
-print-versions:: print-$(1)
-
-endef
+include $(top_srcdir)/scripts/submodules/versions.mk
 
 $(eval $(call ValidateVersionTemplate,roslyn,ROSLYN))
 $(eval $(call ValidateVersionTemplate,coreclr,CORECLR))
 $(eval $(call ValidateVersionTemplate,ms-test-suite,MSTESTSUITE))
 
-reset-versions::
-
-validate-versions::
-       @if test -e .validate-versions-failure; then  \
-               rm .validate-versions-failure; \
-               echo One or more modules needs update;  \
-               exit 1; \
-       else \
-               echo All dependent modules up to date;  \
-       fi
-
-reset:
-       @$(MAKE) validate-versions RESET_VERSIONS=1
-
-__bump-version-%:
-       @if [ "$(REV)" = "" ]; then echo "Usage: make bump-version-$* REV=<ref>"; exit 1; fi
-       python versions.py set-rev $* $(REV)
-       @if [ "$(COMMIT)" = "1" ]; then echo "[acceptance-tests] Bump $* to pick up $(REV)." | git commit -F - $(CONFIG); fi
-
-__bump-branch-%:
-       @if [ "$(BRANCH)" = "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
-       @if [ "$(REMOTE_BRANCH)" == "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
-       python versions.py set-branch $* $(BRANCH)
-       python versions.py set-remote-branch $* $(REMOTE_BRANCH)
-       @if [ "$(COMMIT)" = "1" ]; then echo "[acceptance-tests] Bump $* to switch to $(BRANCH) $(REMOTE BRANCH)." | git commit -F - $(CONFIG); fi
-
-__bump-current-version-%:
-       REV=$(shell cd $(ACCEPTANCE_TESTS_PATH)/$* && git log -1 --pretty=format:%H); \
-       python versions.py set-rev $* $$REV; \
-       if [ "$(COMMIT)" = "1" ]; then echo "[acceptance-tests] Bump $* to pick up $$REV:" | git commit -F - $(CONFIG); fi
-
 # Bump the given submodule to the revision given by the REV make variable
 # If COMMIT is 1, commit the change
 bump-roslyn: __bump-version-roslyn
diff --git a/acceptance-tests/versions.py b/acceptance-tests/versions.py
deleted file mode 100755 (executable)
index 35ded0c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import json
-
-def find_module(submodules, name):
-    for item in submodules:
-        if item["name"] == name:
-            return item
-
-    print("Not found")
-    sys.exit(1)
-
-
-if len(sys.argv) < 2:
-    print("Usage: versions.py <command>")
-    sys.exit(1)
-
-CONFIG_FILE = "SUBMODULES.json"
-command = sys.argv[1]
-
-submodules = json.load(open(CONFIG_FILE))
-
-if command == "get-rev":
-    mod = find_module(submodules, sys.argv[2])
-    print(mod["rev"])
-elif command == "get-url":
-    mod = find_module(submodules, sys.argv[2])
-    print(mod["url"])
-elif command == "get-dir":
-    mod = find_module(submodules, sys.argv[2])
-    print(mod["directory"])
-elif command == "get-remote-branch":
-    mod = find_module(submodules, sys.argv[2])
-    print(mod["remote-branch"])
-elif command == "set-rev":
-    mod = find_module(submodules, sys.argv[2])
-    mod["rev"] = sys.argv[3]
-    json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
-elif command == "set-branch":
-    mod = find_module(submodules, sys.argv[2])
-    mod["branch"] = sys.argv[3]
-    json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
-elif command == "set-remote-branch":
-    mod = find_module(submodules, sys.argv[2])
-    mod["remote-branch"] = sys.argv[3]
-    json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
-elif command == "cat":
-    print(json.dumps(submodules, indent = 2))
-else:
-    print("Unknown command "" + command + "".")
-    sys.exit(1)
index 00fdad109b91359b89969c09d1e8341017cb96b4..96616f87fc23a27e5d698e09a683a338554d1fd8 100644 (file)
@@ -3923,6 +3923,7 @@ AC_OUTPUT([
 Makefile
 mono-uninstalled.pc
 acceptance-tests/Makefile
+llvm/Makefile
 scripts/mono-find-provides
 scripts/mono-find-requires
 mono/Makefile
diff --git a/llvm/Makefile.am b/llvm/Makefile.am
new file mode 100644 (file)
index 0000000..e380f2b
--- /dev/null
@@ -0,0 +1,27 @@
+#
+# Conditional submodule for llvm
+#
+# make reset-llvm will checkout a version of llvm which is suitable for this version of mono
+# into $top_srcdir/llvm/llvm.
+#
+
+LLVM_PATH=llvm
+
+include $(top_srcdir)/scripts/submodules/versions.mk
+
+$(eval $(call ValidateVersionTemplate,llvm,LLVM))
+
+# Bump the given submodule to the revision given by the REV make variable
+# If COMMIT is 1, commit the change
+bump-llvm: __bump-version-llvm
+
+# Bump the given submodule to the branch given by the BRANCH/REMOTE_BRANCH make variables
+# If COMMIT is 1, commit the change
+bump-branch-llvm: __bump-branch-llvm
+
+# Bump the given submodule to its current GIT version
+# If COMMIT is 1, commit the change
+bump-current-llvm: __bump-current-version-llvm
+
+clean-local:
+       $(RM) -r $(LLVM_PATH)
diff --git a/llvm/SUBMODULES.json b/llvm/SUBMODULES.json
new file mode 100644 (file)
index 0000000..e4fbbb0
--- /dev/null
@@ -0,0 +1,10 @@
+[
+  {
+      "name": "llvm", 
+      "url": "git://github.com/mono/llvm.git",
+      "rev": "9f79399f87282524fee099b328bd8cbf07929daf",
+      "remote-branch": "origin/master", 
+      "branch": "master", 
+      "directory": "llvm"
+  }
+]
diff --git a/scripts/submodules/versions.mk b/scripts/submodules/versions.mk
new file mode 100644 (file)
index 0000000..440476d
--- /dev/null
@@ -0,0 +1,123 @@
+#
+# This is a python script and a set of make targets to implement support for conditional submodules
+# There should be a SUBMODULES.json file which contains information about the submodules.
+#
+
+CONFIG=SUBMODULES.json
+SCRIPT=$(top_srcdir)/scripts/submodules/versions.py
+
+# usage $(call ValidateVersionTemplate (name,MAKEFILE VAR,repo name))
+# usage $(call ValidateVersionTemplate (mono,MONO,mono))
+
+define ValidateVersionTemplate
+#$(eval REPOSITORY_$(2):=$(shell test -z $(3) && echo $(1) || echo "$(3)"))
+#$(eval DIRECTORY_$(2):=$(shell python $(SCRIPT) get-dir $(1)))
+#$(eval DIRECTORY_$(2):=$(shell test -z $(DIRECTORY_$(2)) && echo $(1) || echo $(DIRECTORY_$(2))))
+#$(eval MODULE_$(2):=$(shell python $(SCRIPT) get-url $(1)))
+#$(eval NEEDED_$(2)_VERSION:=$(shell python $(SCRIPT) get-rev $(1)))
+#$(eval $(2)_BRANCH_AND_REMOTE:=$(shell python $(SCRIPT) get-remote-branch $(1)))
+
+#$(eval $(2)_VERSION:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git rev-parse HEAD ))
+
+#$(eval NEEDED_$(2)_BRANCH:=$(word 2, $(subst /, ,$($(2)_BRANCH_AND_REMOTE))))
+#$(eval NEEDED_$(2)_REMOTE:=$(word 1, $(subst /, ,$($(2)_BRANCH_AND_REMOTE))))
+#$(eval $(2)_BRANCH:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git symbolic-ref --short HEAD 2>/dev/null))
+
+validate-$(1)::
+       @if test x$$(IGNORE_$(2)_VERSION) = "x"; then \
+           if test ! -d $($(2)_PATH); then \
+                       if test x$$(RESET_VERSIONS) != "x"; then \
+                               $(MAKE) reset-$(1) || exit 1; \
+                       else \
+                               echo "Your $(1) checkout is missing, please run 'make reset-$(1)'"; \
+                               touch .validate-versions-failure; \
+                       fi; \
+           else \
+                       if test "x$($(2)_VERSION)" != "x$(NEEDED_$(2)_VERSION)" ; then \
+                               if test x$$(RESET_VERSIONS) != "x"; then \
+                                       $(MAKE) reset-$(1) || exit 1; \
+                               else \
+                                   echo "Your $(1) version is out of date, please run 'make reset-$(1)' (found $($(2)_VERSION), expected $(NEEDED_$(2)_VERSION))"; \
+                                   test -z "$(BUILD_REVISION)" || $(MAKE) test-$(1); \
+                               touch .validate-versions-failure; \
+                               fi; \
+               elif test "x$($(2)_BRANCH)" != "x$(NEEDED_$(2)_BRANCH)" ; then \
+                               if test x$$(RESET_VERSIONS) != "x"; then \
+                                       test -z "$(BUILD_REVISION)" || $(MAKE) test-$(1); \
+                                       $(MAKE) reset-$(1) || exit 1; \
+                               else \
+                                   echo "Your $(1) branch is out of date, please run 'make reset-$(1)' (found $($(2)_BRANCH), expected $(NEEDED_$(2)_BRANCH))"; \
+                               touch .validate-versions-failure; \
+                               fi; \
+              fi; \
+           fi; \
+       fi
+
+test-$(1)::
+       @echo $(1)
+       @echo "   REPOSITORY_$(2)=$(REPOSITORY_$(2))"
+       @echo "   DIRECTORY_$(2)=$(DIRECTORY_$(2))"
+       @echo "   MODULE_$(2)=$(MODULE_$(2))"
+       @echo "   NEEDED_$(2)_VERSION=$(NEEDED_$(2)_VERSION)"
+       @echo "   $(2)_VERSION=$($(2)_VERSION)"
+       @echo "   $(2)_BRANCH_AND_REMOTE=$($(2)_BRANCH_AND_REMOTE)"
+       @echo "   NEEDED_$(2)_BRANCH=$(NEEDED_$(2)_BRANCH)"
+       @echo "   NEEDED_$(2)_REMOTE=$(NEEDED_$(2)_REMOTE)"
+       @echo "   $(2)_BRANCH=$($(2)_BRANCH)"
+       @echo "   $(2)_PATH=$($(2)_PATH) => $(abspath $($(2)_PATH))"
+
+reset-$(1)::
+       @if test -d $($(2)_PATH); then \
+               if ! (cd $($(2)_PATH) && git show $(NEEDED_$(2)_VERSION) >/dev/null 2>&1 && git log -1 $(NEEDED_$(2)_REMOTE) >/dev/null 2>&1) ; then \
+                       echo "*** git fetch `basename $$($(2)_PATH)`" && (cd $($(2)_PATH) && git fetch); \
+               fi;  \
+       else \
+               echo "*** git clone $(MODULE_$(2)) --recursive $(DIRECTORY_$(2))" && (cd `dirname $($(2)_PATH)` && git clone $(MODULE_$(2)) --recursive $(DIRECTORY_$(2)) || exit 1 ); \
+       fi
+       @if test x$$(IGNORE_$(2)_VERSION) = "x"; then \
+               echo "*** [$(1)] git checkout -f" $(NEEDED_$(2)_BRANCH) && (cd $($(2)_PATH) ; git checkout -f $(NEEDED_$(2)_BRANCH) || git checkout -f -b $($(2)_BRANCH_AND_REMOTE)); \
+               echo "*** [$(1)] git reset --hard $(NEEDED_$(2)_VERSION)" && (cd $($(2)_PATH) && git reset --hard $(NEEDED_$(2)_VERSION)); \
+       fi
+       @echo "*** [$(1)] git submodule update --init --recursive" && (cd $($(2)_PATH) && git submodule update --init --recursive)
+
+print-$(1)::
+       @printf "*** %-16s %-45s %s (%s)\n" "$(DIRECTORY_$(2))" "$(MODULE_$(2))" "$(NEEDED_$(2)_VERSION)" "$(NEEDED_$(2)_BRANCH)"
+
+.PHONY: validate-$(1) reset-$(1) print-$(1)
+
+reset-versions:: reset-$(1)
+validate-versions:: validate-$(1)
+print-versions:: print-$(1)
+
+endef
+
+reset-versions::
+
+validate-versions::
+       @if test -e .validate-versions-failure; then  \
+               rm .validate-versions-failure; \
+               echo One or more modules needs update;  \
+               exit 1; \
+       else \
+               echo All dependent modules up to date;  \
+       fi
+
+reset:
+       @$(MAKE) validate-versions RESET_VERSIONS=1
+
+__bump-version-%:
+       @if [ "$(REV)" = "" ]; then echo "Usage: make bump-version-$* REV=<ref>"; exit 1; fi
+       python $(SCRIPT) set-rev $* $(REV)
+       @if [ "$(COMMIT)" = "1" ]; then echo "[submodules] Bump $* to pick up $(REV)." | git commit -F - $(CONFIG); fi
+
+__bump-branch-%:
+       @if [ "$(BRANCH)" = "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
+       @if [ "$(REMOTE_BRANCH)" == "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
+       python $(SCRIPT) set-branch $* $(BRANCH)
+       python $(SCRIPT) set-remote-branch $* $(REMOTE_BRANCH)
+       @if [ "$(COMMIT)" = "1" ]; then echo "[submodules] Bump $* to switch to $(BRANCH) $(REMOTE BRANCH)." | git commit -F - $(CONFIG); fi
+
+__bump-current-version-%:
+       REV=$(shell cd $(ACCEPTANCE_TESTS_PATH)/$* && git log -1 --pretty=format:%H); \
+       python $(SCRIPT) set-rev $* $$REV; \
+       if [ "$(COMMIT)" = "1" ]; then echo "[submodules] Bump $* to pick up $$REV:" | git commit -F - $(CONFIG); fi
diff --git a/scripts/submodules/versions.py b/scripts/submodules/versions.py
new file mode 100755 (executable)
index 0000000..35ded0c
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+import sys
+import json
+
+def find_module(submodules, name):
+    for item in submodules:
+        if item["name"] == name:
+            return item
+
+    print("Not found")
+    sys.exit(1)
+
+
+if len(sys.argv) < 2:
+    print("Usage: versions.py <command>")
+    sys.exit(1)
+
+CONFIG_FILE = "SUBMODULES.json"
+command = sys.argv[1]
+
+submodules = json.load(open(CONFIG_FILE))
+
+if command == "get-rev":
+    mod = find_module(submodules, sys.argv[2])
+    print(mod["rev"])
+elif command == "get-url":
+    mod = find_module(submodules, sys.argv[2])
+    print(mod["url"])
+elif command == "get-dir":
+    mod = find_module(submodules, sys.argv[2])
+    print(mod["directory"])
+elif command == "get-remote-branch":
+    mod = find_module(submodules, sys.argv[2])
+    print(mod["remote-branch"])
+elif command == "set-rev":
+    mod = find_module(submodules, sys.argv[2])
+    mod["rev"] = sys.argv[3]
+    json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
+elif command == "set-branch":
+    mod = find_module(submodules, sys.argv[2])
+    mod["branch"] = sys.argv[3]
+    json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
+elif command == "set-remote-branch":
+    mod = find_module(submodules, sys.argv[2])
+    mod["remote-branch"] = sys.argv[3]
+    json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
+elif command == "cat":
+    print(json.dumps(submodules, indent = 2))
+else:
+    print("Unknown command "" + command + "".")
+    sys.exit(1)