2017-07-10 10:17:13 +00:00
|
|
|
# Configuration for Make
|
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
.PHONY: clean test repl example help
|
|
|
|
.SILENT:
|
|
|
|
|
|
|
|
# Executables used in this makefile
|
2017-05-25 19:12:29 +00:00
|
|
|
PULP := pulp
|
|
|
|
BOWER := bower
|
2017-07-10 10:17:13 +00:00
|
|
|
NODE := node
|
|
|
|
NPM := npm
|
|
|
|
|
|
|
|
# Package manifest files
|
2017-05-25 19:12:29 +00:00
|
|
|
BOWERJSON := bower.json
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
# Various input directories
|
2017-07-18 06:16:13 +00:00
|
|
|
SRCPATH := ./src
|
|
|
|
TESTPATH := ./test
|
|
|
|
OUTPUT := ./out
|
|
|
|
DOCS := ./docs
|
2017-07-10 19:06:14 +00:00
|
|
|
EXAMPLESPATH := $(DOCS)/Examples
|
2017-07-10 10:17:13 +00:00
|
|
|
EXAMPLEPATH := $(EXAMPLESPATH)/$(EXAMPLE)
|
|
|
|
|
|
|
|
# Various output directories
|
2017-07-18 06:16:13 +00:00
|
|
|
BUILD := $(OUTPUT)/build
|
|
|
|
COMPONENTS := $(OUTPUT)/components
|
|
|
|
OUTPUT_DOCS := $(OUTPUT)/docs
|
|
|
|
OUTPUT_EXAMPLE := $(OUTPUT)/examples/$(EXAMPLE)
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
# The entry point for the compiled example, if an EXAMPLE is specified
|
|
|
|
EXAMPLE_INDEX := $(OUTPUT_EXAMPLE)/index.js
|
|
|
|
|
|
|
|
# Globs that match all source files
|
2017-05-25 19:12:29 +00:00
|
|
|
SOURCES := $(SRCPATH)/**/*
|
|
|
|
TESTSOURCES := $(TESTPATH)/**/*
|
2017-07-10 10:17:13 +00:00
|
|
|
EXAMPLESOURCES := $(EXAMPLESPATH)/**/*
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
# This is the module name for the entry point for the test suite
|
|
|
|
TESTMAIN := HTTPure.HTTPureSpec
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
# Install bower components
|
2017-05-25 19:12:29 +00:00
|
|
|
$(COMPONENTS): $(BOWERJSON)
|
|
|
|
$(BOWER) install
|
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
# Build the source files
|
2017-07-17 23:42:13 +00:00
|
|
|
$(BUILD): $(COMPONENTS) $(SOURCES)
|
2017-07-10 10:17:13 +00:00
|
|
|
$(PULP) build \
|
|
|
|
--src-path $(SRCPATH) \
|
2017-07-18 02:10:01 +00:00
|
|
|
--build-path $(BUILD) \
|
|
|
|
-- --stash --censor-lib --strict
|
2017-07-10 10:17:13 +00:00
|
|
|
touch $(BUILD)
|
|
|
|
build: $(BUILD)
|
|
|
|
|
|
|
|
# Create the example output directory for the example in the environment
|
|
|
|
# variable EXAMPLE
|
|
|
|
$(OUTPUT_EXAMPLE):
|
|
|
|
mkdir -p $(OUTPUT_EXAMPLE)
|
|
|
|
|
|
|
|
# Build the example specified by the environment variable EXAMPLE
|
|
|
|
$(EXAMPLE_INDEX): $(OUTPUT_EXAMPLE) $(BUILD) $(EXAMPLEPATH)/Main.purs
|
|
|
|
$(PULP) build \
|
|
|
|
--src-path $(EXAMPLEPATH) \
|
|
|
|
--include $(SRCPATH) \
|
|
|
|
--build-path $(BUILD) \
|
|
|
|
--main $(EXAMPLE) \
|
2017-07-18 05:25:14 +00:00
|
|
|
--to $(EXAMPLE_INDEX)
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
# Run the example specified by the environment variable EXAMPLE
|
|
|
|
ifeq ($(EXAMPLE),)
|
|
|
|
example:
|
2017-08-05 01:47:59 +00:00
|
|
|
$(info Which example would you like to run?)
|
2017-07-10 10:17:13 +00:00
|
|
|
$(info )
|
|
|
|
$(info Available examples:)
|
2017-08-05 01:47:59 +00:00
|
|
|
ls -1 $(EXAMPLESPATH) | cat -n
|
|
|
|
read -rp " > " out; \
|
|
|
|
out=$$(echo $$out | sed 's/[^0-9]*//g'); \
|
|
|
|
$(MAKE) example EXAMPLE=$$([ $$out ] && ls -1 $(EXAMPLESPATH) | sed "$${out}q;d")
|
2017-07-10 10:17:13 +00:00
|
|
|
else
|
|
|
|
example: $(BUILD) $(EXAMPLE_INDEX)
|
|
|
|
$(NODE) $(EXAMPLE_INDEX)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Run the test suite
|
|
|
|
test: $(BUILD) $(TESTSOURCES) $(EXAMPLESOURCES)
|
|
|
|
$(PULP) test \
|
|
|
|
--src-path $(SRCPATH) \
|
2017-07-10 19:06:14 +00:00
|
|
|
--test-path $(TESTPATH) \
|
2017-07-10 10:17:13 +00:00
|
|
|
--include $(EXAMPLESPATH) \
|
|
|
|
--build-path $(BUILD) \
|
2017-07-18 02:10:01 +00:00
|
|
|
--main $(TESTMAIN) \
|
|
|
|
-- --stash --censor-lib --strict
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
# Launch a repl with all modules loaded
|
2017-07-17 23:42:13 +00:00
|
|
|
repl: $(COMPONENTS) $(SOURCES) $(TESTSOURCES) $(EXAMPLESOURCES)
|
2017-07-10 10:17:13 +00:00
|
|
|
$(PULP) repl \
|
|
|
|
--include $(EXAMPLESPATH) \
|
|
|
|
--src-path $(SRCPATH) \
|
2017-07-18 06:16:13 +00:00
|
|
|
--test-path $(TESTPATH)
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
# Remove all make output from the source tree
|
2017-05-25 19:12:29 +00:00
|
|
|
clean:
|
|
|
|
rm -rf $(OUTPUT)
|
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
# Print out a description of all the supported tasks
|
|
|
|
help:
|
|
|
|
$(info HTTPure make utility)
|
|
|
|
$(info )
|
|
|
|
$(info Usage: make [ test | docs | example | repl | clean | help ])
|
|
|
|
$(info )
|
|
|
|
$(info - make test Run the test suite)
|
|
|
|
$(info - make docs Build the documentation into $(OUTPUT_DOCS))
|
|
|
|
$(info - make example Run the example in environment variable EXAMPLE)
|
|
|
|
$(info - make repl Launch a repl with all project code loaded)
|
|
|
|
$(info - make clean Remove all build files)
|
|
|
|
$(info - make help Print this help)
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
# Build the documentation
|
2017-07-17 23:42:13 +00:00
|
|
|
$(OUTPUT_DOCS): $(COMPONENTS) $(SOURCES)
|
2017-07-10 10:17:13 +00:00
|
|
|
$(PULP) docs \
|
2017-07-18 06:16:13 +00:00
|
|
|
--src-path $(SRCPATH)
|
2017-07-10 10:17:13 +00:00
|
|
|
rm -rf $(OUTPUT_DOCS)
|
|
|
|
mv generated-docs $(OUTPUT_DOCS)
|
|
|
|
docs: $(OUTPUT_DOCS)
|