From b260ecf16c33446757b4a882dc9a69aebe15fb1e Mon Sep 17 00:00:00 2001 From: Alexander Seleznev Date: Sun, 9 Mar 2014 16:47:09 +0700 Subject: [PATCH] Change Makefile: add .build dir, usage preprocessor.py --- .gitignore | 1 + Makefile | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 32c3f8c..44e98e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.build/ *.xpi *.pyc diff --git a/Makefile b/Makefile index 25de1c5..4afc16d 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,49 @@ -all: xpi +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. -xpi: - cd "extension"; \ - zip -FS -r "../firefox-extension-htitle.xpi" *; \ +XPI = "firefox-extension-htitle.xpi" + +DIRS = $(shell find extension/ -type d) +DIRS := $(filter-out extension/chrome/skin/shared, $(DIRS)) + +INCLUDES = $(shell find extension/ -type f -name '*.css.inc') + +FILES = $(shell find extension/ -type f ! -name '*.css.inc') + +TARGET_DIRS = $(patsubst extension/%, .build/%, $(DIRS)) +TARGET_FILES = $(patsubst extension/%, .build/%, $(FILES)) + +all: prepare $(TARGET_DIRS) $(TARGET_FILES) $(XPI) + +prepare: + @mkdir -p ".build/" + +$(TARGET_DIRS): + @echo Create directory "$@" + @mkdir -p "$@" + +.build/%.css: extension/%.css $(INCLUDES) + @echo Convert "$<" to "$@" + @python2 preprocessor.py --marker="%" \ + --output="$@" "$<" + +.build/%: extension/% + @echo Copy "$<" to "$@" + @cp "$<" "$@" + +$(XPI): + @echo Create $(XPI) + @cd ".build/"; \ + zip -FS -r "../$(XPI)" *; \ cd .. +.PHONY : clean + clean: - rm -f "firefox-extension-htitle.xpi" + @echo Remove $(XPI) + @rm -f $(XPI) + @echo Remove .build/ + @rm -rf ".build" + @echo Remove *.pyc + @rm -f *.pyc