Skip to content

Commit

Permalink
Adds makefile refinements and nyaml as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
domna committed Dec 19, 2023
1 parent df84535 commit 080a88f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
PYTHON = python3
SPHINX = sphinx-build
BUILD_DIR = "build"
BASE_CLASS_DIR := base_classes
CONTRIB_DIR := contributed_definitions
APPDEF_DIR := applications
NYAML_SUBDIR := nyaml

.PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local
YBC_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(BASE_CLASS_DIR)/nyaml/*.yaml)))
YCONTRIB_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(CONTRIB_DIR)/nyaml/*.yaml)))
YAPPDEF_NXDL = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(APPDEF_DIR)/nyaml/*.yaml)))


.PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local nxdl nyaml

help ::
@echo ""
Expand Down Expand Up @@ -50,13 +59,18 @@ test ::
clean ::
$(RM) -rf $(BUILD_DIR)

clean-nyaml ::
$(RM) -rf $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)
$(RM) -rf $(APPDEF_DIR)/$(NYAML_SUBDIR)
$(RM) -rf $(CONTRIB_DIR)/$(NYAML_SUBDIR)

prepare ::
$(PYTHON) -m dev_tools manual --prepare --build-root $(BUILD_DIR)
$(PYTHON) -m dev_tools impatient --prepare --build-root $(BUILD_DIR)

pdf ::
$(SPHINX) -M latexpdf $(BUILD_DIR)/manual/source/ $(BUILD_DIR)/manual/build
cp $(BUILD_DIR)/manual/build/latex/nexus.pdf $(BUILD_DIR)/manual/source/_static/NeXusManual.pdf
cp $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf $(BUILD_DIR)/manual/source/_static/NeXusManual.pdf

html ::
$(SPHINX) -b html -W $(BUILD_DIR)/manual/source/ $(BUILD_DIR)/manual/build/html
Expand All @@ -81,7 +95,21 @@ all ::
@echo "HTML built: `ls -lAFgh $(BUILD_DIR)/impatient-guide/build/html/index.html`"
@echo "PDF built: `ls -lAFgh $(BUILD_DIR)/impatient-guide/build/latex/NXImpatient.pdf`"
@echo "HTML built: `ls -lAFgh $(BUILD_DIR)/manual/build/html/index.html`"
@echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus.pdf`"
@echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf`"

$(BASE_CLASS_DIR)/%.nxdl.xml : $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml
nyaml2nxdl $< --output-file $@

$(CONTRIB_DIR)/%.nxdl.xml : $(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml
nyaml2nxdl $< --output-file $@

$(APPDEF_DIR)/%.nxdl.xml : $(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml
nyaml2nxdl $< --output-file $@

nxdl: $(YBC_NXDL) $(YCONTRIB_NXDL) $(YAPPDEF_NXDL)

nyaml:
$(MAKE) -f nyaml.mk


# NeXus - Neutron and X-ray Common Data Format
Expand Down
22 changes: 22 additions & 0 deletions nyaml.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
BASE_CLASS_DIR := base_classes
CONTRIB_DIR := contributed_definitions
APPDEF_DIR := applications
NYAML_SUBDIR := nyaml
NXDL_BC = $(addprefix $(BASE_CLASS_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml))))
NXDL_APPDEF = $(addprefix $(APPDEF_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(APPDEF_DIR)/*.nxdl.xml))))
NXDL_CONTRIB = $(addprefix $(CONTRIB_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(CONTRIB_DIR)/*.nxdl.xml))))

.PHONY: all nyaml

$(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml : $(BASE_CLASS_DIR)/%.nxdl.xml
nyaml2nxdl $< --output-file $@

$(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml : $(CONTRIB_DIR)/%.nxdl.xml
nyaml2nxdl $< --output-file $@

$(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml : $(APPDEF_DIR)/%.nxdl.xml
nyaml2nxdl $< --output-file $@

nyaml: $(NXDL_BC) $(NXDL_APPDEF) $(NXDL_CONTRIB)

all: nyaml
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Prepare for Documentation
lxml
pyyaml
nyaml

# Documentation building
sphinx>=5
Expand Down

0 comments on commit 080a88f

Please sign in to comment.