Make it so the github extension updates.

This commit is contained in:
Brendan Dahl 2012-01-06 16:20:11 -08:00
parent 4bb289ec49
commit c33e3df143
2 changed files with 62 additions and 20 deletions

View File

@ -5,7 +5,9 @@ DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json
DEFAULT_TESTS := test_manifest.json
EXTENSION_SRC := ./extensions/
EXTENSION_BASE_VERSION := 4bb289ec499013de66eb421737a4dbb4a9273eda
FIREFOX_EXTENSION_NAME := pdf.js.xpi
FIREFOX_AMO_EXTENSION_NAME := pdf.js.amo.xpi
CHROME_EXTENSION_NAME := pdf.js.crx
all: bundle
@ -147,7 +149,7 @@ web: | production extension compiler pages-repo
@cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET)
@cp -R web/* $(GH_PAGES)/web
@cp web/images/* $(GH_PAGES)/web/images
@cp $(EXTENSION_SRC)/firefox/*.xpi $(GH_PAGES)/$(EXTENSION_SRC)/firefox/
@cp $(FIREFOX_BUILD_DIR)/$(FIREFOX_EXTENSION_NAME) $(FIREFOX_BUILD_DIR)/update.rdf $(GH_PAGES)/$(EXTENSION_SRC)/firefox/
@cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html;
@mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html;
@cd $(GH_PAGES); git add -A;
@ -190,8 +192,7 @@ pages-repo: | $(BUILD_DIR)
# This target produce a restartless firefox extension containing a
# copy of the pdf.js source.
CONTENT_DIR := content
FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/
CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/
BUILD_NUMBER := `git log --format=oneline $(EXTENSION_BASE_VERSION).. | wc -l | awk '{print $$1}'`
PDF_WEB_FILES = \
web/images \
web/compatibility.js \
@ -199,26 +200,66 @@ PDF_WEB_FILES = \
web/viewer.js \
web/viewer-production.html \
$(NULL)
FIREFOX_BUILD_DIR := $(BUILD_DIR)/firefox
FIREFOX_BUILD_CONTENT := $(FIREFOX_BUILD_DIR)/$(CONTENT_DIR)/
FIREFOX_CONTENT_DIR := $(EXTENSION_SRC)/firefox/$(CONTENT_DIR)/
FIREFOX_EXTENSION_FILES_TO_COPY = \
*.js \
*.rdf \
chrome.manifest \
components \
$(NULL)
FIREFOX_EXTENSION_FILES = \
content \
*.js \
install.rdf \
chrome.manifest \
components \
content \
$(NULL)
CHROME_BUILD_DIR := $(BUILD_DIR)/chrome
CHROME_CONTENT_DIR := $(EXTENSION_SRC)/chrome/$(CONTENT_DIR)/
CHROME_BUILD_CONTENT := $(CHROME_BUILD_DIR)/$(CONTENT_DIR)/
CHROME_EXTENSION_FILES = \
extensions/chrome/*.json \
extensions/chrome/*.html \
$(NULL)
extension: | production
# Clear out everything in the firefox extension build directory
@rm -Rf $(FIREFOX_BUILD_DIR)
@mkdir -p $(FIREFOX_BUILD_CONTENT)
@mkdir -p $(FIREFOX_BUILD_CONTENT)/$(BUILD_DIR)
@mkdir -p $(FIREFOX_BUILD_CONTENT)/web
@cd extensions/firefox; cp -r $(FIREFOX_EXTENSION_FILES_TO_COPY) ../../$(FIREFOX_BUILD_DIR)/
# Copy a standalone version of pdf.js inside the content directory
@rm -Rf $(FIREFOX_CONTENT_DIR)
@mkdir -p $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
@mkdir -p $(FIREFOX_CONTENT_DIR)/web
@cp $(BUILD_TARGET) $(FIREFOX_CONTENT_DIR)/$(BUILD_DIR)
@cp -r $(PDF_WEB_FILES) $(FIREFOX_CONTENT_DIR)/web/
@mv -f $(FIREFOX_CONTENT_DIR)/web/viewer-production.html $(FIREFOX_CONTENT_DIR)/web/viewer.html
@cp $(BUILD_TARGET) $(FIREFOX_BUILD_CONTENT)/$(BUILD_DIR)/
@cp -r $(PDF_WEB_FILES) $(FIREFOX_BUILD_CONTENT)/web/
@mv -f $(FIREFOX_BUILD_CONTENT)/web/viewer-production.html $(FIREFOX_BUILD_CONTENT)/web/viewer.html
# Update the build version number
@sed -i.bak "s/PDFJSSCRIPT_BUILD/$(BUILD_NUMBER)/" $(FIREFOX_BUILD_DIR)/install.rdf
@sed -i.bak "s/PDFJSSCRIPT_BUILD/$(BUILD_NUMBER)/" $(FIREFOX_BUILD_DIR)/update.rdf
@rm -f $(FIREFOX_BUILD_DIR)/*.bak
# Create the xpi
@cd $(EXTENSION_SRC)/firefox; zip -r $(FIREFOX_EXTENSION_NAME) *
@cd $(FIREFOX_BUILD_DIR); zip -r $(FIREFOX_EXTENSION_NAME) $(FIREFOX_EXTENSION_FILES)
@echo "extension created: " $(FIREFOX_EXTENSION_NAME)
# Build the amo extension too (remove the updateUrl)
@sed -i.bak "/updateURL/d" $(FIREFOX_BUILD_DIR)/install.rdf
@rm -f $(FIREFOX_BUILD_DIR)/*.bak
@cd $(FIREFOX_BUILD_DIR); zip -r $(FIREFOX_AMO_EXTENSION_NAME) $(FIREFOX_EXTENSION_FILES)
@echo "AMO extension created: " $(FIREFOX_AMO_EXTENSION_NAME)
# Copy a standalone version of pdf.js inside the extension directory
@rm -Rf $(CHROME_CONTENT_DIR)
@mkdir -p $(CHROME_CONTENT_DIR)/$(BUILD_DIR)
@mkdir -p $(CHROME_CONTENT_DIR)/web
@cp $(BUILD_TARGET) $(CHROME_CONTENT_DIR)/$(BUILD_DIR)
@cp -r $(PDF_WEB_FILES) $(CHROME_CONTENT_DIR)/web/
@mv -f $(CHROME_CONTENT_DIR)/web/viewer-production.html $(CHROME_CONTENT_DIR)/web/viewer.html
# Clear out everything in the chrome extension build directory
@rm -Rf $(CHROME_BUILD_DIR)
@mkdir -p $(CHROME_BUILD_CONTENT)
@mkdir -p $(CHROME_BUILD_CONTENT)/$(BUILD_DIR)
@mkdir -p $(CHROME_BUILD_CONTENT)/web
@cp -R $(CHROME_EXTENSION_FILES) $(CHROME_BUILD_DIR)/
# Copy a standalone version of pdf.js inside the content directory
@cp $(BUILD_TARGET) $(CHROME_BUILD_CONTENT)/$(BUILD_DIR)/
@cp -r $(PDF_WEB_FILES) $(CHROME_BUILD_CONTENT)/web/
@mv -f $(CHROME_BUILD_CONTENT)/web/viewer-production.html $(CHROME_BUILD_CONTENT)/web/viewer.html
# Create the crx
#TODO

View File

@ -6,7 +6,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>uriloader@pdf.js</em:id>
<em:name>pdf.js</em:name>
<em:version>0.1.0</em:version>
<em:version>0.2.PDFJSSCRIPT_BUILD</em:version>
<em:iconURL>chrome://pdf.js/skin/logo.png</em:iconURL>
<em:targetApplication>
<Description>
@ -17,9 +17,10 @@
</em:targetApplication>
<em:bootstrap>true</em:bootstrap>
<em:unpack>true</em:unpack>
<em:creator>Vivien Nicolas</em:creator>
<em:creator>Mozilla Labs</em:creator>
<em:description>pdf.js uri loader</em:description>
<em:homepageURL>https://github.com/mozilla/pdf.js/</em:homepageURL>
<em:type>2</em:type>
<em:updateURL>https://github.com/mozilla/pdf.js/raw/gh-pages/extensions/firefox/update.rdf</em:updateURL>
</Description>
</RDF>