Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine makefiles #131

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@

PYTHON = python3
SPHINX = sphinx-build
BUILD_DIR = "build"
BASE_CLASS_DIR := base_classes
CONTRIB_DIR := contributed_definitions
APPDEF_DIR := applications
NXDL_DIRS := $(BASE_CLASS_DIR) $(CONTRIB_DIR) $(APPDEF_DIR)
NYAML_SUBDIR := nyaml
NYAML_APPENDIX := _parsed
BUILD_DIR = build
BASE_CLASS_DIR = base_classes
CONTRIB_DIR = contributed_definitions
APPDEF_DIR = applications
NYAML_SUBDIR = nyaml

NXDL_BC := $(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml)
NXDL_CONTRIB := $(wildcard $(CONTRIB_DIR)/*.nxdl.xml)
NXDL_APPDEF := $(wildcard $(APPDEF_DIR)/*.nxdl.xml)
YBC_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(BASE_CLASS_DIR)/nyaml/*.yaml)))
YCONTRIB_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(CONTRIB_DIR)/nyaml/*.yaml)))
YAPPDEF_NXDL_TARGETS = $(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 nyaml nxdl

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

help ::
@echo ""
Expand All @@ -29,12 +28,15 @@ help ::
@echo "make autoformat Format all files to the coding style conventions."
@echo "make test Run NXDL syntax and documentation tests."
@echo "make clean Remove all build files."
@echo "make clean-nyaml Remove all nyaml files."
@echo "make prepare (Re)create all build files."
@echo "make html Build HTML version of manual. Requires prepare first."
@echo "make pdf Build PDF version of manual. Requires prepare first."
@echo "make impatient-guide Build html & PDF versions of the Guide for the Impatient. Requires prepare first."
@echo "make all Builds complete web site for the manual (in build directory)."
@echo "make local (Developer use) Test, prepare and build the HTML manual."
@echo "make nxdl Build NXDL files from NYAML files in nyaml subdirectories."
@echo "make nyaml Build NYAML files to nyaml subdirectories from NXDL files."
@echo ""
@echo "Note: All builds of the manual will occur in the 'build/' directory."
@echo " For a complete build, run 'make all' in the root directory."
Expand Down Expand Up @@ -99,27 +101,19 @@ all ::
@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 $<
mv $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/$*.nxdl.xml $@
nyaml2nxdl $< --output-file $@

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

$(APPDEF_DIR)/%.nxdl.xml : $(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml
nyaml2nxdl $<
mv $(APPDEF_DIR)/$(NYAML_SUBDIR)/$*.nxdl.xml $@

NXDLS := $(NXDL_APPDEF) $(NXDL_CONTRIB) $(NXDL_BC)
nyaml :
domna marked this conversation as resolved.
Show resolved Hide resolved
for file in $(NXDLS); do\
mkdir -p "$${file%/*}/nyaml";\
nyaml2nxdl $${file};\
FNAME=$${file##*/};\
mv -- "$${file%.nxdl.xml}_parsed.yaml" "$${file%/*}/nyaml/$${FNAME%.nxdl.xml}.yaml";\
done

nxdl: $(NXDL_APPDEF) $(NXDL_CONTRIB) $(NXDL_BC)
nyaml2nxdl $< --output-file $@

nxdl: $(YBC_NXDL_TARGETS) $(YCONTRIB_NXDL_TARGETS) $(YAPPDEF_NXDL_TARGETS)

nyaml:
$(MAKE) -f nyaml.mk


# NeXus - Neutron and X-ray Common Data Format
#
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ Note: If set this will increase the build time of the documentation by approxima

setenv GH_TOKEN <access token>

### Working with nyaml files

There exists a simplified format of nxdl, which is called nyaml.
There is a [tool](https://github.com/FAIRmat-NFDI/nyaml) (`nyaml2nxdl`) available to convert between nxdl and nyaml.
This tool is already installed when you installed the requirements for this repository and it is conveniently available from the make command.

You can build nyaml files for all nxdl files with invoking

make nyaml

which will created `.yaml` files in a subfolder called `nyaml` in the respective directory.

From this you can do your changes and create nxdl files with

make nxdl

from the yaml files.

## Repository content

These are the components that define the structure of NeXus data files
Expand Down
25 changes: 25 additions & 0 deletions nyaml.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BASE_CLASS_DIR := base_classes
CONTRIB_DIR := contributed_definitions
APPDEF_DIR := applications
NYAML_SUBDIR := nyaml
NXDL_BC_TARGETS = $(addprefix $(BASE_CLASS_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml))))
NXDL_APPDEF_TARGETS = $(addprefix $(APPDEF_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(APPDEF_DIR)/*.nxdl.xml))))
NXDL_CONTRIB_TARGETS = $(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
@mkdir -p $(@D)
nyaml2nxdl $< --output-file $@

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

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

nyaml: $(NXDL_BC_TARGETS) $(NXDL_APPDEF_TARGETS) $(NXDL_CONTRIB_TARGETS)

all: nyaml
Loading