2017-11-25 12:52:55 +01:00
|
|
|
# Makefile for OOMAnalyser
|
|
|
|
#
|
2021-02-05 17:04:09 +01:00
|
|
|
# Copyright (c) 2017-2021 Carsten Grohmann
|
2017-11-25 12:52:55 +01:00
|
|
|
# License: MIT (see LICENSE.txt)
|
|
|
|
# THIS PROGRAM COMES WITH NO WARRANTY
|
|
|
|
|
|
|
|
.PHONY: help clean distclean
|
|
|
|
|
|
|
|
# Makefile defaults
|
|
|
|
SHELL = /bin/sh
|
|
|
|
|
|
|
|
BASE_DIR = .
|
2020-12-08 10:50:40 +01:00
|
|
|
PYTHON3_BIN = /usr/bin/python3.7
|
2020-12-07 15:05:02 +01:00
|
|
|
ROLLUP_BIN = rollup
|
|
|
|
ROLLUP_OPTS = --format=umd --name OOMAnalyser --file=OOMAnalyser.js
|
|
|
|
TRANSCRYPT_BIN = transcrypt
|
|
|
|
TRANSCRYPT_OPTS = --build --map --nomin --sform --esv 6
|
2020-11-19 15:11:25 +01:00
|
|
|
VIRTUAL_ENV_DIR = env
|
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)
|
|
|
|
|
|
|
|
#+ 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 {} \;
|
2020-10-29 09:16:28 +01:00
|
|
|
@$(RM) --force --recursive __target__
|
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
|
|
|
|
|
|
|
#+ Compile Python to JavaScript
|
|
|
|
build: venv
|
2020-11-19 15:11:25 +01:00
|
|
|
. $(VIRTUAL_ENV_DIR)/bin/activate
|
2020-12-07 15:05:02 +01:00
|
|
|
$(TRANSCRYPT_BIN) $(TRANSCRYPT_OPTS) OOMAnalyser.py
|
|
|
|
$(ROLLUP_BIN) $(ROLLUP_OPTS) -- __target__/OOMAnalyser.js
|
2017-11-29 20:10:25 +01:00
|
|
|
|
|
|
|
#+ Serve the current directory on http://127.0.0.1:8080
|
|
|
|
websrv:
|
|
|
|
$(PYTHON3_BIN) -m http.server 8080 --bind 127.0.0.1
|