2017-11-25 12:52:55 +01:00
|
|
|
# Makefile for OOMAnalyser
|
|
|
|
#
|
2023-01-08 13:46:36 +01:00
|
|
|
# Copyright (c) 2017-2023 Carsten Grohmann
|
2017-11-25 12:52:55 +01:00
|
|
|
# License: MIT (see LICENSE.txt)
|
|
|
|
# THIS PROGRAM COMES WITH NO WARRANTY
|
|
|
|
|
2021-07-24 08:43:48 +02:00
|
|
|
.PHONY: help clean distclean venv venv-clean venv-freeze build websrv test
|
2017-11-25 12:52:55 +01:00
|
|
|
|
|
|
|
# Makefile defaults
|
|
|
|
SHELL = /bin/sh
|
|
|
|
|
|
|
|
BASE_DIR = .
|
2020-12-08 10:50:40 +01:00
|
|
|
PYTHON3_BIN = /usr/bin/python3.7
|
2021-07-24 08:43:48 +02:00
|
|
|
TARGET_DIR = $(BASE_DIR)/__target__
|
|
|
|
VIRTUAL_ENV_DIR = env
|
|
|
|
|
|
|
|
HTML_FILE = $(BASE_DIR)/OOMAnalyser.html
|
|
|
|
JS_OUT_FILE = $(BASE_DIR)/OOMAnalyser.js
|
|
|
|
JS_TEMP_FILE = $(TARGET_DIR)/OOMAnalyser.js
|
|
|
|
PY_SOURCE = $(BASE_DIR)/OOMAnalyser.py
|
2021-12-23 13:07:36 +01:00
|
|
|
TEST_FILE = $(BASE_DIR)/test.py
|
|
|
|
|
2022-01-14 21:05:56 +01:00
|
|
|
# e.g. 0.6.0 or 0.6.0_devel
|
|
|
|
VERSION = 0.6.0_devel
|
2021-12-23 13:07:36 +01:00
|
|
|
RELEASE_DIR = $(BASE_DIR)/release
|
2022-01-12 20:36:59 +01:00
|
|
|
RELEASE_FILES = $(HTML_FILE) $(JS_OUT_FILE) $(PY_SOURCE) $(TEST_FILE) rollup.config.js Makefile requirements.txt \
|
2021-12-26 23:03:04 +01:00
|
|
|
LICENSE.txt README.md
|
2021-12-23 13:07:36 +01:00
|
|
|
RELEASE_INST_DIR = $(RELEASE_DIR)/OOMAnalyser-$(VERSION)
|
|
|
|
RELEASE_TARGZ = OOMAnalyser-$(VERSION).tar.gz
|
|
|
|
RELEASE_ZIP = OOMAnalyser-$(VERSION).zip
|
2021-07-24 08:43:48 +02:00
|
|
|
|
2022-11-11 20:44:32 +01:00
|
|
|
BLACK_BIN = black
|
|
|
|
BLACK_OPTS = --verbose
|
|
|
|
|
2020-12-07 15:05:02 +01:00
|
|
|
ROLLUP_BIN = rollup
|
2022-11-19 09:39:06 +01:00
|
|
|
ROLLUP_OPTS = --config rollup.config.mjs
|
2021-07-24 08:43:48 +02:00
|
|
|
|
2020-12-07 15:05:02 +01:00
|
|
|
TRANSCRYPT_BIN = transcrypt
|
|
|
|
TRANSCRYPT_OPTS = --build --map --nomin --sform --esv 6
|
2017-11-25 12:52:55 +01:00
|
|
|
|
2020-11-19 15:11:25 +01:00
|
|
|
export VIRTUAL_ENV := $(abspath ${VIRTUAL_ENV_DIR})
|
|
|
|
export PATH := ${VIRTUAL_ENV_DIR}/bin:${PATH}
|
2017-11-25 12:52:55 +01:00
|
|
|
|
|
|
|
HELP= @grep -B1 '^[a-zA-Z\-]*:' Makefile |\
|
|
|
|
awk 'function p(h,t){printf"%-12s=%s\n",h,t;};\
|
|
|
|
/\#+/{t=$$0;};\
|
|
|
|
/:/{gsub(":.*","");h=$$0};\
|
|
|
|
/^--/{p(h,t);t=h="";};\
|
|
|
|
END{p(h,t)}' |\
|
|
|
|
sed -n 's/=.*\#+/:/gp'
|
|
|
|
|
|
|
|
#+ Show this text
|
|
|
|
help:
|
|
|
|
$(HELP)
|
|
|
|
|
2022-11-11 20:44:32 +01:00
|
|
|
#+ Run source code formatter black
|
|
|
|
black:
|
|
|
|
$(BLACK_BIN) $(BLACK_OPTS) $(PY_SOURCE) $(TEST_FILE)
|
|
|
|
|
|
|
|
#+ Run source code formatter black in check-only mode
|
|
|
|
black-check:
|
|
|
|
$(BLACK_BIN) --check $(BLACK_OPTS) $(PY_SOURCE) $(TEST_FILE)
|
|
|
|
|
2017-11-25 12:52:55 +01:00
|
|
|
#+ Clean python compiler files and automatically generated files
|
|
|
|
clean:
|
|
|
|
@echo "Remove all automatically generated files ..."
|
|
|
|
@find $(BASE_DIR) -depth -type f -name "*.pyc" -exec rm -f {} \;
|
|
|
|
@find $(BASE_DIR) -depth -type f -name "*.pyo" -exec rm -f {} \;
|
|
|
|
@find $(BASE_DIR) -depth -type f -name "*.orig" -exec rm -f {} \;
|
|
|
|
@find $(BASE_DIR) -depth -type f -name "*~" -exec rm -f {} \;
|
2021-07-21 22:40:41 +02:00
|
|
|
@$(RM) --force --recursive .wdm
|
2022-01-14 20:50:37 +01:00
|
|
|
@$(RM) --force --recursive ${RELEASE_DIR} ${TARGET_DIR} ${RELEASE_TARGZ} ${RELEASE_ZIP}
|
2017-11-25 12:52:55 +01:00
|
|
|
|
|
|
|
#+ Remove all automatically generated and Git repository data
|
|
|
|
distclean: clean venv-clean
|
|
|
|
@echo "Remove Git repository data (.git*) ..."
|
|
|
|
@(RM) --force .git .gitignore
|
|
|
|
|
2020-11-19 15:11:25 +01:00
|
|
|
$(VIRTUAL_ENV_DIR)/bin/activate: requirements.txt
|
2020-12-08 10:50:40 +01:00
|
|
|
test -d $(VIRTUAL_ENV_DIR) || virtualenv -p $(PYTHON3_BIN) $(VIRTUAL_ENV_DIR)
|
2020-11-19 15:11:25 +01:00
|
|
|
. $(VIRTUAL_ENV_DIR)/bin/activate
|
|
|
|
$(VIRTUAL_ENV_DIR)/bin/pip install -Ur requirements.txt
|
|
|
|
touch $(VIRTUAL_ENV_DIR)/bin/activate
|
2017-11-25 12:52:55 +01:00
|
|
|
|
|
|
|
#+ Setup the virtual environment from scratch
|
2020-11-19 15:11:25 +01:00
|
|
|
venv: $(VIRTUAL_ENV_DIR)/bin/activate
|
2017-11-25 12:52:55 +01:00
|
|
|
|
|
|
|
#+ Freeze the current virtual environment by update requirements.txt
|
|
|
|
venv-freeze:
|
2020-11-19 15:11:25 +01:00
|
|
|
source $(VIRTUAL_ENV_DIR)/bin/activate && $(VIRTUAL_ENV_DIR)/bin/pip freeze > requirements.txt
|
2017-11-25 12:52:55 +01:00
|
|
|
|
|
|
|
#+ Remove the virtual environment
|
|
|
|
venv-clean:
|
2020-11-19 15:11:25 +01:00
|
|
|
rm -rf $(VIRTUAL_ENV_DIR)
|
2017-11-25 12:52:55 +01:00
|
|
|
|
2021-07-24 08:43:48 +02:00
|
|
|
${JS_TEMP_FILE}: $(VIRTUAL_ENV_DIR)/bin/activate ${PY_SOURCE}
|
|
|
|
. $(VIRTUAL_ENV_DIR)/bin/activate
|
|
|
|
$(TRANSCRYPT_BIN) $(TRANSCRYPT_OPTS) ${PY_SOURCE}
|
|
|
|
|
|
|
|
${JS_OUT_FILE}: $(VIRTUAL_ENV_DIR)/bin/activate ${JS_TEMP_FILE}
|
2020-11-19 15:11:25 +01:00
|
|
|
. $(VIRTUAL_ENV_DIR)/bin/activate
|
2021-12-26 23:03:04 +01:00
|
|
|
$(ROLLUP_BIN) $(ROLLUP_OPTS)
|
2021-07-24 08:43:48 +02:00
|
|
|
|
2022-01-14 21:05:56 +01:00
|
|
|
${RELEASE_TARGZ} ${RELEASE_ZIP}:
|
|
|
|
mkdir -p $(RELEASE_INST_DIR) && \
|
|
|
|
cp -p $(RELEASE_FILES) $(RELEASE_INST_DIR) && \
|
|
|
|
cd $(RELEASE_DIR) && \
|
|
|
|
tar cvzf $(RELEASE_TARGZ) OOMAnalyser-$(VERSION) && \
|
|
|
|
zip -vr $(RELEASE_ZIP) OOMAnalyser-$(VERSION) && \
|
|
|
|
mv $(RELEASE_TARGZ) $(RELEASE_ZIP) ..
|
|
|
|
|
2021-07-24 08:43:48 +02:00
|
|
|
#+ Compile Python to JavaScript
|
|
|
|
build: $(VIRTUAL_ENV_DIR)/bin/activate ${JS_OUT_FILE}
|
2017-11-29 20:10:25 +01:00
|
|
|
|
|
|
|
#+ Serve the current directory on http://127.0.0.1:8080
|
2021-07-24 08:43:48 +02:00
|
|
|
websrv: $(VIRTUAL_ENV_DIR)/bin/activate ${JS_OUT_FILE}
|
2021-07-14 23:49:31 +02:00
|
|
|
$(PYTHON3_BIN) -m http.server 8080 --bind 127.0.0.1
|
|
|
|
|
|
|
|
#+ Run Selenium based web tests
|
2021-07-24 08:43:48 +02:00
|
|
|
test: $(VIRTUAL_ENV_DIR)/bin/activate ${JS_OUT_FILE}
|
2021-07-14 23:49:31 +02:00
|
|
|
. $(VIRTUAL_ENV_DIR)/bin/activate
|
2021-12-23 13:07:36 +01:00
|
|
|
DISPLAY=:1 xvfb-run python $(TEST_FILE)
|
|
|
|
|
|
|
|
#+ Build release packages
|
2022-01-14 21:05:56 +01:00
|
|
|
release: ${JS_OUT_FILE} ${RELEASE_TARGZ} ${RELEASE_ZIP}
|