more work on Makefile...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-01-08 07:29:33 +03:00
parent 1b7288a4cf
commit fa0df0c5d9

View File

@ -11,8 +11,14 @@
APP_NAME=ImageGrid.Viewer APP_NAME=ImageGrid.Viewer
ELECTRON_DOWNOAD_URL=https://github.com/electron/electron/releases/download ELECTRON_DOWNOAD_URL=https://github.com/electron/electron/releases/download
# XXX autodetect this....
TARGET_OS=win32
# XXX get this automatically... # XXX get this automatically...
# ...also might be good to make this flexible and use these as parameters... # ...also might be good to make this flexible and use these as parameters...
ELECTRON_VERSION=1.7.10 ELECTRON_VERSION=1.7.10
@ -52,29 +58,38 @@ APP_DATE=$(BUILD_DIR)/DATE
APP_NODE=$(BUILD_DIR)/NODE APP_NODE=$(BUILD_DIR)/NODE
#********************************************************************** #**********************************************************************
.PHONY: all css dev clean cleanall win64e win32e
all: dev all: dev
.PHONY: all css dev clean cleanall dist \
electron-dist-x64 electron-dist-ia32
css: $(CSS_FILES) css: $(CSS_FILES)
dev: $(NODE_DIR) css dev: $(NODE_DIR) css
#clean: clean:
# rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
# XXX for some reason this is called on make win64e... # XXX for some reason this is called on make win64e...
#cleanall: clean cleanall: clean
# rm -rf $(DIST_DIR) $(TARGET_DIR) rm -rf $(DIST_DIR) $(TARGET_DIR)
# XXX these still depend on the current arch, need to pass architecture to npm... # XXX autodetect arch/os...
win64e: $(DIST_DIR)/$(APP_NAME)-win32-x64.zip # XXX add support for nw...
electron-dist-x64: $(DIST_DIR)/$(APP_NAME)-$(TARGET_OS)-x64.zip
win32e: $(DIST_DIR)/$(APP_NAME)-win32-ia32.zip electron-dist-ia32: $(DIST_DIR)/$(APP_NAME)-$(TARGET_OS)-ia32.zip
dist: electron-dist-x64
@ -90,6 +105,7 @@ $(APP_NODE):
echo "$(NODE_VERSION)" > $(APP_NODE) echo "$(NODE_VERSION)" > $(APP_NODE)
# XXX need to make this arch/os specific for cross compiling...
$(NODE_DIR): $(NODE_DIR):
npm install npm install
@ -102,6 +118,7 @@ $(NODE_DIR):
# build app dir... # build app dir...
# XXX need to make this arch/os specific... # XXX need to make this arch/os specific...
# XXX make junction to $(NODE_DIR) -- does not work with asar # XXX make junction to $(NODE_DIR) -- does not work with asar
# XXX this is electron-specific...
$(BUILD_DIR)/$(APP_NAME): $(CSS_FILES) $(NODE_DIR) $(PROJECT_FILES) \ $(BUILD_DIR)/$(APP_NAME): $(CSS_FILES) $(NODE_DIR) $(PROJECT_FILES) \
$(JS_FILES) $(CSS_FILES) $(HTML_FILES) $(JS_FILES) $(CSS_FILES) $(HTML_FILES)
@mkdir -p $@ @mkdir -p $@
@ -114,6 +131,7 @@ $(BUILD_DIR)/$(APP_NAME): $(CSS_FILES) $(NODE_DIR) $(PROJECT_FILES) \
#ln -s $(NODE_DIR) "$(BUILD_DIR)/$(APP_NAME)/$(NODE_DIR)" #ln -s $(NODE_DIR) "$(BUILD_DIR)/$(APP_NAME)/$(NODE_DIR)"
#cmd /c mklink /j "$(BUILD_DIR)\$(APP_NAME)\$(NODE_DIR)" \ #cmd /c mklink /j "$(BUILD_DIR)\$(APP_NAME)\$(NODE_DIR)" \
# $(NODE_DIR) # $(NODE_DIR)
touch "$@"
# pack app.asar # pack app.asar
@ -125,6 +143,7 @@ $(BUILD_DIR)/app.asar: $(BUILD_DIR)/$(APP_NAME)
# get the electron binary... # get the electron binary...
# XXX for some odd reason this is deleted adter extraction... # XXX for some odd reason this is deleted adter extraction...
.PRECIOUS: $(TARGET_DIR)/electron-v$(ELECTRON_VERSION)-%.zip
$(TARGET_DIR)/electron-v$(ELECTRON_VERSION)-%.zip: $(TARGET_DIR)/electron-v$(ELECTRON_VERSION)-%.zip:
@mkdir -p $(@D) @mkdir -p $(@D)
wget \ wget \
@ -132,13 +151,19 @@ $(TARGET_DIR)/electron-v$(ELECTRON_VERSION)-%.zip:
-O "$@" -O "$@"
# XXX nwjs...
# build the app dir... # build the app dir...
# XXX this is electron-specific...
.PRECIOUS: $(BUILD_DIR)/$(APP_NAME)-%
$(BUILD_DIR)/$(APP_NAME)-%: $(TARGET_DIR)/electron-v$(ELECTRON_VERSION)-%.zip $(BUILD_DIR)/app.asar $(BUILD_DIR)/$(APP_NAME)-%: $(TARGET_DIR)/electron-v$(ELECTRON_VERSION)-%.zip $(BUILD_DIR)/app.asar
unzip -u "$<" -d "$@" unzip -u "$<" -d "$@"
chmod +x "$@/"*dll "$@/"*exe chmod +x "$@/"*dll "$@/"*exe
cp "$(BUILD_DIR)/app.asar" "$@/resources/" cp "$(BUILD_DIR)/app.asar" "$@/resources/"
rm -f "$@/resources/default_app.asar" rm -f "$@/resources/default_app.asar"
mv "$@/electron.exe" "$@/$(APP_NAME).exe" mv "$@/electron.exe" "$@/$(APP_NAME).exe"
touch "$@"
# package the app dir... # package the app dir...