Nico Huber has uploaded this change for review. ( https://review.coreboot.org/21163
Change subject: [WIP] payloads/external: Provide generic Makefile.git
......................................................................
[WIP] payloads/external: Provide generic Makefile.git
Provide a Makefile.git to be included by payloads built from Git.
Featuring:
* Offline mode, e.g. don't care if a later fetch failed.
* Fetching of origin, including tags and branch updates.
* Simplyfied checkout:
Should work with commit hashes, local/remote branches and tags.
* Patch application, ported from tianocore, untested.
* Unexporting of variables exported by coreboot:
No more sub-make confusion!
* The usual boilerplate.
Change-Id: I7557ca81fa1e32cd5c17c757e9458d048ff1ec99
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
A payloads/external/Makefile.git
1 file changed, 64 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/21163/1
diff --git a/payloads/external/Makefile.git b/payloads/external/Makefile.git
new file mode 100644
index 0000000..560991c
--- /dev/null
+++ b/payloads/external/Makefile.git
@@ -0,0 +1,64 @@
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2017 Nico Huber <nico.h(a)gmx.de>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 2 of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+
+project_rev := $(if $(strip $(project_rev)),$(project_rev),origin/master)
+project_dir := $(abspath $(project_dir))
+project_patches ?= $(wildcard $(CURDIR)/patches/*.patch)
+
+unexport $(COREBOOT_EXPORTS)
+MAKEOVERRIDES :=
+
+all: $(project_output)
+
+$(project_dir)/.git:
+ printf " CLONE $(project_name) into $(project_dir)\n"
+ git clone "$(project_repo)" "$(project_dir)"
+
+fetch: $(project_dir)/.git
+ -cd "$(project_dir)" && git fetch origin
+
+checkout: fetch
+ cd "$(project_dir)" && \
+ if ! git diff --quiet _cb_checkout "$(project_rev)" -- 2>/dev/null; \
+ then \
+ printf " CHECKOUT $(project_name) [$(project_rev)]\n"; \
+ git checkout $$(git rev-parse HEAD) >/dev/null 2>&1; \
+ git branch -f _cb_checkout "$(project_rev)" && \
+ git checkout _cb_checkout && \
+ $(if $(project_patches), \
+ for patch in $(project_patches); do \
+ printf " PATCH $$patch\n"; \
+ git am --keep-cr "$$patch" || \
+ ( printf "Error when applying patches.\n"; \
+ git am --abort; exit 1; ); \
+ done;,true;) \
+ fi
+
+$(project_output): checkout
+ printf " MAKE $(project_name) [$(project_rev)]\n"
+ $(MAKE) -C"$(dir $(project_output))" $(project_params)
+
+clean:
+ if [ -f "$(dir $(project_output))Makefile" ]; then \
+ $(MAKE) -C $(dir $(project_output)) clean || true; \
+ fi
+
+distclean:
+ rm -rf $(project_dir)
+
+print-repo-info:
+ printf "$(project_repo) $(project_dir)\n"
+
+.PHONY: all fetch checkout clean distclean print-repo-info
--
To view, visit https://review.coreboot.org/21163
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7557ca81fa1e32cd5c17c757e9458d048ff1ec99
Gerrit-Change-Number: 21163
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>