Skip to content

Instantly share code, notes, and snippets.

@tynn
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tynn/c30e07db2fe8e41a02c8 to your computer and use it in GitHub Desktop.
Save tynn/c30e07db2fe8e41a02c8 to your computer and use it in GitHub Desktop.
Build Mozilla Add-on file from directory.
#!/bin/sh
# 2014 CC0 http://creativecommons.org/publicdomain/zero/1.0/
IFS="$(printf '\n\t')"
[ -f .xpi-include ] && I="-d $(cat .xpi-include)"
[ -f .xpi-exclude ] && X=-x@.xpi-exclude
ls $I | zip -r "$(basename $(pwd)).xpi" -@ -x"*.xpi" $X
#!/usr/bin/make -f
# 2014 CC0 http://creativecommons.org/publicdomain/zero/1.0/
NAME := $(notdir $(CURDIR))
XPI := $(NAME).xpi
DEFAULT_LOCALE := en
LOCALE_DIR := locale
default_locale = $(LOCALE_DIR)/$(DEFAULT_LOCALE)/
L10N := $(wildcard $(LOCALE_DIR)/*/*)
chrome.manifest.in = $(wildcard chrome.manifest.in)
CONTENT := $(wildcard bootstrap.js) $(wildcard icon.png) $(wildcard icon64.png)\
install.rdf $(if $(L10N)$(chrome.manifest.in),chrome.manifest)\
$(shell cat .xpi-include) $(wildcard options.xul)
.PHONY: clean realclean
$(XPI): $(CONTENT) $(L10N)
zip -r $@ $?
chrome.manifest: $(chrome.manifest.in) $(L10N)
@echo creating $@ ...
$(shell sed '/^locale[[:space:]]\+$(NAME)/d' $@.in >$@)
$(if $(L10N),\
$(eval locales := $(dir $(L10N)))\
$(foreach locale,\
$(findstring $(default_locale),$(locales)) $(filter-out $(default_locale),$(locales)),\
$(file >>$@,locale $(NAME) $(notdir $(locale:%/=%)) $(locale))))
clean:
$(RM) $(XPI)
realclean: clean
$(RM) chrome.manifest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment