Makefile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .PHONY: all all_javascript all_python clean clean_javascript clean_python test test_javascript test_python help
  2. SCCDC = python ../python_sccd_compiler/sccdc.py
  3. PYTHON = python
  4. BROWSER = firefox 2>/dev/null -new-window
  5. JS_FLAGS = -l javascript -p eventloop
  6. PY_FLAGS = -l python -p threads
  7. JS_EXT = js
  8. PY_EXT = py
  9. SRC_DIR = src
  10. TARGET_DIR_PREFIX = target_
  11. JS_TARGET_DIR = $(TARGET_DIR_PREFIX)js
  12. PY_TARGET_DIR = $(TARGET_DIR_PREFIX)py
  13. #SOURCES = after.xml associate_event.xml correct_duplicate_state_id.xml enter_exit_hierarchy.xml guard.xml history_deep.xml history_parallel_deep.xml history.xml inner_first.xml instate.xml multiple_target.xml object_manager.xml outer_first.xml parallel_history_2.xml parallel_history.xml parallel.xml
  14. SRC_SUBDIRS = $(shell ls $(SRC_DIR))
  15. JS_TARGET_SUBDIRS = $(SRC_SUBDIRS:%=$(JS_TARGET_DIR)/%)
  16. PY_TARGET_SUBDIRS = $(SRC_SUBDIRS:%=$(PY_TARGET_DIR)/%)
  17. PY_MODULES = $(PY_TARGET_DIR)/__init__.py $(PY_TARGET_SUBDIRS:%=%/__init__.py)
  18. SOURCES = $(shell find src -type f -name *\.xml)
  19. #SOURCES_JS = inheritance_js.xml # javascript-only tests
  20. #SOURCES_PY = #inheritance_py.xml # python-only tests
  21. JS_TARGETS = $(SOURCES:$(SRC_DIR)/%.xml=$(JS_TARGET_DIR)/%.js) $(SOURCES_JS:$(SRC_DIR)/%.xml=$(JS_TARGET_DIR)/%.js)
  22. PY_TARGETS = $(SOURCES:$(SRC_DIR)/%.xml=$(PY_TARGET_DIR)/%.py) $(SOURCES_PY:$(SRC_DIR)/%.xml=$(PY_TARGET_DIR)/%.py)
  23. PY_BYPRODUCTS = $(PY_TARGETS:%.py=%.pyc) $(PY_MODULES:%.py=%.pyc)
  24. ##
  25. ##Target Description
  26. ##
  27. all: ## Build all tests.
  28. all: all_javascript all_python
  29. all_javascript: ## Build Javascript tests.
  30. all_javascript: $(JS_TARGET_SUBDIRS) $(JS_TARGETS) $(JS_ONLY_TARGETS)
  31. all_python: ## Build Python tests.
  32. all_python: $(PY_TARGET_SUBDIRS) $(PY_TARGETS) $(PY_ONLY_TARGETS) $(PY_MODULES)
  33. clean: ## Remove all build artifacts.
  34. clean: clean_javascript clean_python
  35. clean_javascript: ## Remove Javascript build artifacts.
  36. -rm -f $(JS_TARGETS) $(JS_ONLY_TARGETS)
  37. -rmdir $(JS_TARGET_SUBDIRS) $(JS_TARGET_DIR)
  38. clean_python: ## Remove Python build artifacts.
  39. -rm -f $(PY_TARGETS) $(PY_ONLY_TARGETS) $(PY_BYPRODUCTS) $(PY_MODULES)
  40. -rmdir $(PY_TARGET_SUBDIRS) $(PY_TARGET_DIR)
  41. test: ## Run all tests.
  42. test: test_javascript test_python
  43. test_javascript: ## Run Javascript tests. This will cause a browser window to open.
  44. test_javascript: all_javascript run_tests.html
  45. $(BROWSER) run_tests.html &
  46. test_python: ## Run Python tests.
  47. test_python: all_python run_tests.py
  48. $(PYTHON) run_tests.py
  49. $(JS_TARGET_DIR)/%.js :: $(SRC_DIR)/%.xml
  50. $(SCCDC) $(JS_FLAGS) -o $@ $<
  51. $(PY_TARGET_DIR)/%.py :: $(SRC_DIR)/%.xml
  52. $(SCCDC) $(PY_FLAGS) -o $@ $<
  53. $(JS_TARGET_DIR) $(PY_TARGET_DIR):
  54. -mkdir $@
  55. $(PY_TARGET_SUBDIRS): $(PY_TARGET_DIR)
  56. -mkdir $@
  57. $(JS_TARGET_SUBDIRS): $(JS_TARGET_DIR)
  58. -mkdir $@
  59. $(PY_MODULES):
  60. touch $@
  61. help: ## Show this help.
  62. @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
  63. ##