2014-07-20 02:25:36 +04:00
|
|
|
#**********************************************************************
|
|
|
|
|
#
|
2018-01-08 22:08:16 +03:00
|
|
|
# ImageGrid.Viewer Makefile...
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# Make dependencies that need to be installed:
|
2018-01-09 06:44:26 +03:00
|
|
|
# - nodejs / npm
|
|
|
|
|
# also nodejs-legacy seems to be required by some code...
|
2018-01-09 21:32:11 +03:00
|
|
|
# - npm i -g electron asar less
|
2018-01-08 22:08:16 +03:00
|
|
|
# - wget
|
|
|
|
|
# - zip / unzip
|
|
|
|
|
# - Windows
|
|
|
|
|
# - MSVS -- to build node modules (sharp)
|
|
|
|
|
# - WiX
|
|
|
|
|
# - Linux
|
|
|
|
|
# - macOS
|
|
|
|
|
# - iOS
|
|
|
|
|
# - Android
|
|
|
|
|
# - web
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# ToDo:
|
|
|
|
|
# - add a cli-only build
|
|
|
|
|
# - installers:
|
|
|
|
|
# - msi
|
|
|
|
|
# - deb
|
2018-01-09 03:28:06 +03:00
|
|
|
# - ...
|
2018-01-09 02:27:54 +03:00
|
|
|
# - cross-compiling support...
|
2018-01-09 03:28:06 +03:00
|
|
|
# - upstream clean build: git clone -> make dist
|
2018-01-08 22:08:16 +03:00
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
#**********************************************************************
|
2018-01-09 02:27:54 +03:00
|
|
|
# variables...
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
APP_NAME ?= ImageGrid.Viewer
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
|
2018-01-09 02:27:54 +03:00
|
|
|
# Electron stuff...
|
2018-01-09 03:00:33 +03:00
|
|
|
#
|
|
|
|
|
# NOTE: Linux does not let an app run if some of the libs it is dynamically
|
|
|
|
|
# linked against are missing, this can happen if we try to run electron
|
|
|
|
|
# on a non-GUI box (i.e. no gtk)...
|
2018-01-09 02:27:54 +03:00
|
|
|
# ...love the "statically" linked "dynamic" libs...
|
2018-01-09 03:00:33 +03:00
|
|
|
ELECTRON_VERSION_FALLBACK = v1.8.1
|
|
|
|
|
ELECTRON_VERSION := $(strip $(shell electron -v || echo $(ELECTRON_VERSION_FALLBACK)))
|
|
|
|
|
ELECTRON_DOWNOAD_URL ?= https://github.com/electron/electron/releases/download
|
2014-07-20 02:25:36 +04:00
|
|
|
|
|
|
|
|
|
2018-01-08 22:08:16 +03:00
|
|
|
# OS-specific stuff...
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
2018-01-09 22:06:57 +03:00
|
|
|
APP_BIN ?= ig
|
|
|
|
|
ASAR_PATH = resources
|
2018-01-09 02:27:54 +03:00
|
|
|
EXT = .exe
|
2018-01-09 22:06:57 +03:00
|
|
|
|
2018-01-09 02:27:54 +03:00
|
|
|
DLLs = "$@/"*dll
|
2018-01-09 03:28:06 +03:00
|
|
|
# NOTE: this is electron naming convention...
|
2018-01-09 02:27:54 +03:00
|
|
|
TARGET_OS = win32
|
2018-01-08 22:08:16 +03:00
|
|
|
|
2018-01-09 03:28:06 +03:00
|
|
|
# set arch...
|
|
|
|
|
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
|
|
|
|
|
ARCH ?= x64
|
|
|
|
|
else
|
|
|
|
|
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
|
|
|
|
ARCH ?= x64
|
|
|
|
|
endif
|
|
|
|
|
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
|
|
|
|
|
ARCH ?= ia32
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2018-01-08 22:08:16 +03:00
|
|
|
else
|
2018-01-09 22:06:57 +03:00
|
|
|
APP_BIN ?= $(APP_NAME)
|
|
|
|
|
ASAR_PATH = Electron.app/Contents/Resources
|
|
|
|
|
EXT = .app
|
|
|
|
|
|
2018-01-08 22:08:16 +03:00
|
|
|
ifeq ($(shell uname -s),Linux)
|
2018-01-09 02:27:54 +03:00
|
|
|
TARGET_OS = linux
|
2018-01-09 03:28:06 +03:00
|
|
|
ARCH ?= x64
|
2018-01-08 22:08:16 +03:00
|
|
|
endif
|
|
|
|
|
ifeq ($(shell uname -s),Darwin)
|
2018-01-09 02:27:54 +03:00
|
|
|
TARGET_OS = darwin
|
2018-01-08 22:08:16 +03:00
|
|
|
endif
|
2018-01-09 03:28:06 +03:00
|
|
|
|
|
|
|
|
# set arch...
|
2018-01-09 21:49:23 +03:00
|
|
|
# XXX do we need this on a mac???
|
|
|
|
|
ifeq ($(shell uname -m),x86_64)
|
|
|
|
|
ARCH ?= x64
|
|
|
|
|
endif
|
|
|
|
|
ifneq ($(filter %86,$(shell uname -p)),)
|
|
|
|
|
ARCH ?= ia32
|
|
|
|
|
endif
|
2018-01-08 22:08:16 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
2018-01-09 02:27:54 +03:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
# Built-in make stuff...
|
|
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
# NOTE: some of the targets are directories so this will enable GNUMake's
|
|
|
|
|
# automatic cleanup to work.
|
|
|
|
|
# ...not sure if this is the right way to go...
|
2018-01-09 21:40:56 +03:00
|
|
|
RM += -r
|
2018-01-09 02:27:54 +03:00
|
|
|
|
|
|
|
|
|
2018-01-08 06:39:10 +03:00
|
|
|
|
2014-07-20 02:25:36 +04:00
|
|
|
#**********************************************************************
|
2018-01-09 03:28:06 +03:00
|
|
|
# Paths and lists...
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
TARGET_DIR = targets
|
|
|
|
|
BUILD_DIR = build
|
|
|
|
|
DIST_DIR = dist
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
NODE_DIR = node_modules
|
|
|
|
|
LIB_DIR = lib
|
|
|
|
|
EXT_LIB_DIR = ext-lib
|
|
|
|
|
CSS_DIR = css
|
|
|
|
|
CFG_DIR = cfg
|
|
|
|
|
DOMAIN_DIR = imagegrid
|
|
|
|
|
FEATURES_DIR = features
|
|
|
|
|
WORKERS_DIR = workers
|
|
|
|
|
IMAGES_DIR = images
|
2018-01-08 05:42:12 +03:00
|
|
|
|
2018-01-09 06:44:26 +03:00
|
|
|
BUILD_DATE = $(BUILD_DIR)/DATE
|
2018-01-09 02:36:02 +03:00
|
|
|
PROJECT_FILES = package.json
|
2018-01-09 03:00:33 +03:00
|
|
|
# get all .css build targets, in addition, get all the .less files and
|
|
|
|
|
# replace .less with .css making them build targets...
|
2018-01-08 05:42:12 +03:00
|
|
|
CSS_FILES := $(patsubst %.less,%.css,$(wildcard css/*.less))
|
2014-07-20 02:25:36 +04:00
|
|
|
HTML_FILES := $(wildcard *.html)
|
2018-01-09 03:28:06 +03:00
|
|
|
JS_FILES := $(wildcard *.js)
|
2014-07-20 02:25:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
#**********************************************************************
|
2018-01-09 02:27:54 +03:00
|
|
|
# User targets...
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 06:44:26 +03:00
|
|
|
all: dev dist
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
.PHONY: all css dev clean cleanall dist \
|
|
|
|
|
electron-dist-x64 electron-dist-ia32
|
|
|
|
|
|
|
|
|
|
|
2018-01-08 05:42:12 +03:00
|
|
|
css: $(CSS_FILES)
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
|
2018-01-08 05:42:12 +03:00
|
|
|
dev: $(NODE_DIR) css
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
clean:
|
2018-01-09 02:27:54 +03:00
|
|
|
$(RM) $(BUILD_DIR)
|
2018-01-08 05:42:12 +03:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
cleanall: clean
|
2018-01-09 02:27:54 +03:00
|
|
|
$(RM) $(DIST_DIR) $(TARGET_DIR)
|
2018-01-08 07:29:33 +03:00
|
|
|
|
|
|
|
|
|
2018-01-09 03:28:06 +03:00
|
|
|
electron-dist: $(DIST_DIR)/$(APP_NAME)-$(TARGET_OS)-$(ARCH).zip
|
|
|
|
|
electron-inst: $(DIST_DIR)/$(APP_NAME)-$(TARGET_OS)-$(ARCH).msi
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
|
2018-01-09 03:28:06 +03:00
|
|
|
dist: electron-dist
|
2014-07-20 02:25:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#**********************************************************************
|
2018-01-09 02:27:54 +03:00
|
|
|
# build rules...
|
2018-01-08 05:42:12 +03:00
|
|
|
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 02:27:54 +03:00
|
|
|
# build date...
|
2017-05-13 17:47:40 +03:00
|
|
|
# XXX add build version...
|
2018-01-09 06:44:26 +03:00
|
|
|
$(BUILD_DATE): $(CSS_FILES) $(NODE_DIR) $(PROJECT_FILES) \
|
2018-01-08 08:23:02 +03:00
|
|
|
$(JS_FILES) $(CSS_FILES) $(HTML_FILES)
|
2018-01-08 22:08:16 +03:00
|
|
|
@mkdir -p "$(@D)"
|
2018-01-09 06:44:26 +03:00
|
|
|
date "+%Y%m%d %H%M" > $(BUILD_DATE)
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-08 06:39:10 +03:00
|
|
|
|
2018-01-09 03:00:33 +03:00
|
|
|
%.css: %.less
|
|
|
|
|
lessc $< > $@
|
|
|
|
|
|
|
|
|
|
|
2018-01-08 07:29:33 +03:00
|
|
|
# XXX need to make this arch/os specific for cross compiling...
|
2018-01-08 05:42:12 +03:00
|
|
|
$(NODE_DIR):
|
|
|
|
|
npm install
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2017-11-26 07:56:26 +03:00
|
|
|
|
2018-01-08 05:42:12 +03:00
|
|
|
# build app dir...
|
2018-01-09 06:44:26 +03:00
|
|
|
# NOTE: making $(NODE_DIR) a link/junction would be quite a bit faster
|
|
|
|
|
# but it will also choke asar...
|
2018-01-08 05:42:12 +03:00
|
|
|
$(BUILD_DIR)/$(APP_NAME): $(CSS_FILES) $(NODE_DIR) $(PROJECT_FILES) \
|
2018-01-08 08:23:02 +03:00
|
|
|
$(JS_FILES) $(CSS_FILES) $(HTML_FILES) \
|
2018-01-09 06:44:26 +03:00
|
|
|
$(BUILD_DATE)
|
2018-01-08 05:42:12 +03:00
|
|
|
@mkdir -p $@
|
2018-01-09 21:32:11 +03:00
|
|
|
cp -r $(PROJECT_FILES) $(JS_FILES) $(HTML_FILES) \
|
2018-01-08 06:39:10 +03:00
|
|
|
$(CFG_DIR) $(LIB_DIR) $(EXT_LIB_DIR) $(FEATURES_DIR) \
|
2018-01-08 05:42:12 +03:00
|
|
|
$(DOMAIN_DIR) $(WORKERS_DIR) $(CSS_DIR) $(IMAGES_DIR) \
|
2018-01-09 06:44:26 +03:00
|
|
|
$(BUILD_DATE) \
|
2018-01-08 06:39:10 +03:00
|
|
|
"$(BUILD_DIR)/$(APP_NAME)"
|
2018-01-09 21:32:11 +03:00
|
|
|
cp -r $(NODE_DIR) \
|
2018-01-08 06:39:10 +03:00
|
|
|
"$(BUILD_DIR)/$(APP_NAME)"
|
2018-01-08 07:29:33 +03:00
|
|
|
touch "$@"
|
2014-07-20 02:25:36 +04:00
|
|
|
|
|
|
|
|
|
2018-01-08 22:08:16 +03:00
|
|
|
# pack app.asar (electron-specific)...
|
2018-01-08 05:42:12 +03:00
|
|
|
# XXX need to do $(BUILD_DIR)/$(APP_NAME) iff app.asar does not exist...
|
|
|
|
|
$(BUILD_DIR)/app.asar: $(BUILD_DIR)/$(APP_NAME)
|
|
|
|
|
cd $(BUILD_DIR) ; \
|
|
|
|
|
asar p "$(APP_NAME)" app.asar
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2016-04-09 18:39:01 +03:00
|
|
|
|
2018-01-09 03:28:06 +03:00
|
|
|
# get the electron binary (keep this cached)...
|
2018-01-08 07:46:38 +03:00
|
|
|
.PRECIOUS: $(TARGET_DIR)/electron-$(ELECTRON_VERSION)-%.zip
|
|
|
|
|
$(TARGET_DIR)/electron-$(ELECTRON_VERSION)-%.zip:
|
2018-01-08 05:42:12 +03:00
|
|
|
@mkdir -p $(@D)
|
|
|
|
|
wget \
|
2018-01-08 07:46:38 +03:00
|
|
|
-nc "$(ELECTRON_DOWNOAD_URL)/$(ELECTRON_VERSION)/$(@F)" \
|
2018-01-08 06:39:10 +03:00
|
|
|
-O "$@"
|
2014-11-03 06:43:23 +03:00
|
|
|
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2018-01-09 03:28:06 +03:00
|
|
|
# build the app dir (electron-specific)...
|
2018-01-08 07:29:33 +03:00
|
|
|
.PRECIOUS: $(BUILD_DIR)/$(APP_NAME)-%
|
2018-01-08 08:23:02 +03:00
|
|
|
$(BUILD_DIR)/$(APP_NAME)-%: $(TARGET_DIR)/electron-$(ELECTRON_VERSION)-%.zip \
|
2018-01-09 06:44:26 +03:00
|
|
|
$(BUILD_DIR)/app.asar $(BUILD_DATE)
|
2018-01-08 06:39:10 +03:00
|
|
|
unzip -u "$<" -d "$@"
|
2018-01-09 22:06:57 +03:00
|
|
|
cp "$(BUILD_DIR)/app.asar" "$@/$(ASAR_PATH)/"
|
2018-01-09 06:44:26 +03:00
|
|
|
cp -f "$(BUILD_DATE)" "$@/"
|
2018-01-09 22:06:57 +03:00
|
|
|
$(RM) "$@/$(ASAR_PATH)/default_app.asar"
|
2018-01-09 22:17:33 +03:00
|
|
|
mv "$@/[Ee]lectron$(EXT)" "$@/$(APP_BIN)$(EXT)"
|
2018-01-09 06:44:26 +03:00
|
|
|
chmod +x "$@/$(APP_BIN)$(EXT)" $(DLLs)
|
2018-01-08 07:29:33 +03:00
|
|
|
touch "$@"
|
2014-07-20 02:25:36 +04:00
|
|
|
|
|
|
|
|
|
2018-01-08 06:39:10 +03:00
|
|
|
# package the app dir...
|
2018-01-08 05:42:12 +03:00
|
|
|
$(DIST_DIR)/$(APP_NAME)-%.zip: $(BUILD_DIR)/$(APP_NAME)-%
|
2018-01-08 06:39:10 +03:00
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
|
cd "$(BUILD_DIR)" ; \
|
|
|
|
|
zip -r "../$@" "$(APP_NAME)-$*"
|
2014-07-20 02:25:36 +04:00
|
|
|
|
2016-04-30 03:38:52 +03:00
|
|
|
|
2018-01-09 02:27:54 +03:00
|
|
|
# XXX nwjs... (???)
|
|
|
|
|
|
2016-04-30 03:38:52 +03:00
|
|
|
|
2018-01-08 22:08:16 +03:00
|
|
|
# installer (WiX)...
|
2018-01-09 03:00:33 +03:00
|
|
|
# XXX add tools to path...
|
2018-01-08 22:08:16 +03:00
|
|
|
|
|
|
|
|
# harvest directory tree...
|
|
|
|
|
%.wxs:
|
|
|
|
|
heat dir $* -gg -o $<
|
|
|
|
|
|
|
|
|
|
# XXX provide -arch x64/ia32...
|
|
|
|
|
%.wixobj: %.wsx
|
|
|
|
|
candle -o $@ $<
|
|
|
|
|
|
|
|
|
|
%.msi: %.wixobj
|
|
|
|
|
light -o $@ $<
|
|
|
|
|
|
|
|
|
|
# installer (WiX)...
|
|
|
|
|
$(DIST_DIR)/$(APP_NAME)-%.msi: $(BUILD_DIR)/$(APP_NAME)-% $(BUILD_DIR)/$(APP_NAME).wxs
|
|
|
|
|
@mkdir -p "$(@D)"
|
|
|
|
|
|
|
|
|
|
|
2014-07-20 02:25:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#**********************************************************************
|