Skip to content

Commit

Permalink
Updated Makefile to build chromium extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-K committed Jun 24, 2018
1 parent b911981 commit e4a05a3
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions fx-vstup-ext/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
AWK=gawk
CHROME=google-chrome-stable

PROJECT_NAME=$(shell jq -r '.name' src/manifest.json)

VERSION=$(shell jq -r '.version' src/manifest.json)
NEW_VERSION=$(shell ./increment_version.sh -p $(VERSION))

BUILD_DIR = _build
SRC_DIR = src
Expand All @@ -19,7 +25,14 @@ NPM=$(shell which npm 2> /dev/null)
# # WEB_EXT_EXISTS=false
# endif

.PHONY: init
init:
@if [[ ! -d $(BUILD_DIR) ]]; then \
mkdir $(BUILD_DIR); \
fi

.PHONY: init_firefox
init_firefox: init
ifeq ("$(WEB_EXT)", "")
ifneq ("$(NPM)", "")
npm --global install web-ext
Expand All @@ -28,10 +41,10 @@ else
endif
endif

build:
build_firefox: init
web-ext build $(DIR_FLAGS)

build_signed:
build_firefox_signed: init
@if [[ -z "$(AMO_JWT_ISSUER)" ]]; then \
echo "Wrong AMO_JWT_ISSUER"; exit 1; \
fi
Expand All @@ -40,10 +53,10 @@ build_signed:
fi
web-ext sign $(DIR_FLAGS) --api-key=$(AMO_JWT_ISSUER) --api-secret=$(AMO_JWT_SECRET)

run:
run_firefox: init
web-ext run --no-reload $(DIR_FLAGS)

lint:
lint_firefox: init
web-ext lint $(DIR_FLAGS)

define AWK_COMMAND
Expand All @@ -55,11 +68,29 @@ define AWK_COMMAND
endef
export AWK_COMMAND

NEW_VERSION=$(shell ./increment_version.sh -p $$(jq -r '.version' src/manifest.json))

bumpversion:
$(AWK) -i inplace -v version=$(NEW_VERSION) "$$AWK_COMMAND" src/manifest.json

build_signed_inc_version:
build_firefox_signed_inc_version: init
$(MAKE) bumpversion
$(MAKE) build_signed
$(MAKE) build_firefox_signed

build_chrome: init
@if [[ ! -d "$(BUILD_DIR)/$(PROJECT_NAME)" ]]; then \
ln -s $$(realpath --relative-to=$(BUILD_DIR) $(SOURCE_DIR)) $(BUILD_DIR)/$(PROJECT_NAME); \
fi
@if [[ -e "$(PROJECT_NAME).pem" ]]; then \
$(CHROME) "--pack-extension=$(BUILD_DIR)/$(PROJECT_NAME)" "--pack-extension-key=$(PROJECT_NAME).pem"; \
else \
$(CHROME) "--pack-extension=$(BUILD_DIR)/$(PROJECT_NAME)"; \
mv "$(PROJECT_NAME).pem" ./; \
fi
mv "$(BUILD_DIR)/$(PROJECT_NAME).crx" "$(BUILD_DIR)/$(PROJECT_NAME)-$(VERSION).crx"

.PHONY: all
all:
$(MAKE) build_firefox_signed_inc_version
$(MAKE) build_chrome

# .PHONY: default
# default: all

0 comments on commit e4a05a3

Please sign in to comment.