From a1100b640f2ed9469158cb0bc42f2f9bf288f917 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Fri, 21 Jun 2013 16:53:40 -0700 Subject: Move gh-pages management stuff to mk/gh-pages.mk --- Makefile | 54 +++++++++++------------------------------------------- doc/build.mk | 1 + mk/gh-pages.mk | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 mk/gh-pages.mk diff --git a/Makefile b/Makefile index 497caa7..e5e983b 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,10 @@ distclean:: clean .PHONY: test test: +# Generate and commit all changed files to the gh-pages branch. There is a good +# chance that this will always produce a new commit for the extensions, so use +# it with care. If you only want to deploy the manual/doc changes, use +# generate-docs, defined in doc/build.mk .PHONY: generate generate: @@ -65,8 +69,7 @@ endif # Build Directory Staging ###################################################### build-dir := $(topdir)/build - -gh-pages-dir := $(build-dir)/gh-pages +include mk/gh-pages.mk $(build-dir): $(call cmd,mkdir) @@ -92,49 +95,14 @@ $(eval $(call subdir,doc)) # GH-Pages Generation ########################################################## -ifeq "$(git-cmd)" "" -$(call strict-error,"unable to locate git") -endif - -remote-url := $(shell $(git-cmd) config remote.origin.url) - -$(gh-pages-dir): | $(build-dir) - $(call label,CLONE $(call drop-prefix,$@))\ - ( $(git-cmd) clone $(if $(Q),-q) $(topdir) $@ \ - && cd $(gh-pages-dir) \ - && $(git-cmd) remote set-url origin $(remote-url) \ - && $(git-cmd) fetch $(if $(Q),-q) origin gh-pages \ - && $(git-cmd) checkout $(if $(Q),-q) gh-pages ) - - -generate: pull-gh-pages - -.PHONY: pull-gh-pages -ifeq "$(pull)" "0" -pull-gh-pages: -else -pull-gh-pages: $(gh-pages-dir) - $(call label,PULL $(call drop-prefix,$(gh-pages-dir)))\ - ( cd $(gh-pages-dir) \ - && $(git-cmd) pull $(if $(Q),-q) ) -endif +generate: generate-exts +.PHONY: generate-exts +generate-exts: $(build-dir)/gh-pages/binaries/fiveui.xpi \ + $(build-dir)/gh-pages/binaries/fiveui.crx \ + | pull-gh-pages + $(call commit,binaries,"deploy extensions") # Move extensions into the binaries directory of the gh-pages branch $(gh-pages-dir)/binaries/%: $(build-dir)/% pull-gh-pages $(call cmd,cp) - -generate: $(build-dir)/gh-pages/binaries/fiveui.xpi -generate: $(build-dir)/gh-pages/binaries/fiveui.crx - - -# GH-Pages Deployment ########################################################## - -# this should be the only implementation of deploy. -deploy: generate - $(call label,DEPLOY)\ - ( cd $(gh-pages-dir) \ - && $(git-cmd) commit $(if $(Q),-q) -m "deploy gh-pages" \ - && $(git-cmd) add \ - && $(git-cmd) add -u \ - && git push $(if $(Q),-q) origin gh-pages ) diff --git a/doc/build.mk b/doc/build.mk index 8015747..f49f83c 100644 --- a/doc/build.mk +++ b/doc/build.mk @@ -80,6 +80,7 @@ $(gh-pages-dir)/manual: web-manual | pull-gh-pages $(call cmd,copydir) generate-docs: $(gh-pages-dir)/jsdoc + $(call commit,manual jsdoc,"update documentation") $(gh-pages-dir)/jsdoc: DIR := $(jsdoc-dir) $(gh-pages-dir)/jsdoc: $(jsdoc-dir)/index.html | pull-gh-pages diff --git a/mk/gh-pages.mk b/mk/gh-pages.mk new file mode 100644 index 0000000..cfa67c5 --- /dev/null +++ b/mk/gh-pages.mk @@ -0,0 +1,53 @@ + +# gh-pages Branch Management ################################################### + +gh-pages-dir := $(build-dir)/gh-pages + +ifeq "$(git-cmd)" "" +$(call strict-error,"unable to locate git") +else + +# figure out the url of the origin that the current work repo uses +remote-url := $(shell $(git-cmd) config remote.origin.url) + +endif + + +# Pull in the gh-pages directory. +.PHONY: pull-gh-pages +ifeq "$(pull)" "0" +pull-gh-pages: +else +pull-gh-pages: | $(gh-pages-dir) + $(call label,PULL $(call drop-prefix,$(gh-pages-dir)))\ + ( cd $(gh-pages-dir) \ + && $(git-cmd) pull $(if $(Q),-q) ) +endif + + +# checkout the gh-pages branch in a temp repo under the build tree +$(gh-pages-dir): | $(build-dir) + $(call label,CLONE $(call drop-prefix,$@))\ + ( $(git-cmd) clone $(if $(Q),-q) $(topdir) $@ \ + && cd $(gh-pages-dir) \ + && $(git-cmd) remote set-url origin $(remote-url) \ + && $(git-cmd) fetch $(if $(Q),-q) origin gh-pages \ + && $(git-cmd) checkout $(if $(Q),-q) gh-pages ) + + +# Generate a commit in the gh-pages-dir, after adding some files that may have +# changed. +commit = $(call label,COMMIT $(call drop-prefix,$(gh-pages-dir)))\ + ( cd $(gh-pages-dir) \ + && if test -n "`$(git-cmd) status -s`"; then \ + $(git-cmd) add $1 \ + && $(git-cmd) commit $(if $(Q),-q) -m $2 \ + ; fi ) + + + +# push to the gh-pages branch from the temp repo +deploy: | pull-gh-pages + $(call label,DEPLOY)\ + ( cd $(gh-pages-dir) \ + && git push $(if $(Q),-q) origin gh-pages ) -- cgit v1.2.3