Skip to content

Commit 8516668

Browse files
authored
Refine makefiles (#131)
* Adds refined makefiles * Adds all target for nyaml.mk * Call sub makefile from main makefile * Makefile algined with NIAC PR 1336
1 parent 04b69ac commit 8516668

File tree

3 files changed

+65
-28
lines changed

3 files changed

+65
-28
lines changed

Makefile

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55

66
PYTHON = python3
77
SPHINX = sphinx-build
8-
BUILD_DIR = "build"
9-
BASE_CLASS_DIR := base_classes
10-
CONTRIB_DIR := contributed_definitions
11-
APPDEF_DIR := applications
12-
NXDL_DIRS := $(BASE_CLASS_DIR) $(CONTRIB_DIR) $(APPDEF_DIR)
13-
NYAML_SUBDIR := nyaml
14-
NYAML_APPENDIX := _parsed
8+
BUILD_DIR = build
9+
BASE_CLASS_DIR = base_classes
10+
CONTRIB_DIR = contributed_definitions
11+
APPDEF_DIR = applications
12+
NYAML_SUBDIR = nyaml
1513

16-
NXDL_BC := $(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml)
17-
NXDL_CONTRIB := $(wildcard $(CONTRIB_DIR)/*.nxdl.xml)
18-
NXDL_APPDEF := $(wildcard $(APPDEF_DIR)/*.nxdl.xml)
14+
YBC_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(BASE_CLASS_DIR)/nyaml/*.yaml)))
15+
YCONTRIB_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(CONTRIB_DIR)/nyaml/*.yaml)))
16+
YAPPDEF_NXDL_TARGETS = $(patsubst %.yaml,%.nxdl.xml,$(subst /nyaml/,/, $(wildcard $(APPDEF_DIR)/nyaml/*.yaml)))
1917

20-
.PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local nyaml nxdl
18+
19+
.PHONY: help install style autoformat test clean prepare html pdf impatient-guide all local nxdl nyaml
2120

2221
help ::
2322
@echo ""
@@ -29,12 +28,15 @@ help ::
2928
@echo "make autoformat Format all files to the coding style conventions."
3029
@echo "make test Run NXDL syntax and documentation tests."
3130
@echo "make clean Remove all build files."
31+
@echo "make clean-nyaml Remove all nyaml files."
3232
@echo "make prepare (Re)create all build files."
3333
@echo "make html Build HTML version of manual. Requires prepare first."
3434
@echo "make pdf Build PDF version of manual. Requires prepare first."
3535
@echo "make impatient-guide Build html & PDF versions of the Guide for the Impatient. Requires prepare first."
3636
@echo "make all Builds complete web site for the manual (in build directory)."
3737
@echo "make local (Developer use) Test, prepare and build the HTML manual."
38+
@echo "make nxdl Build NXDL files from NYAML files in nyaml subdirectories."
39+
@echo "make nyaml Build NYAML files to nyaml subdirectories from NXDL files."
3840
@echo ""
3941
@echo "Note: All builds of the manual will occur in the 'build/' directory."
4042
@echo " For a complete build, run 'make all' in the root directory."
@@ -99,27 +101,19 @@ all ::
99101
@echo "PDF built: `ls -lAFgh $(BUILD_DIR)/manual/build/latex/nexus-fairmat.pdf`"
100102

101103
$(BASE_CLASS_DIR)/%.nxdl.xml : $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml
102-
nyaml2nxdl $<
103-
mv $(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/$*.nxdl.xml $@
104+
nyaml2nxdl $< --output-file $@
104105

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

109109
$(APPDEF_DIR)/%.nxdl.xml : $(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml
110-
nyaml2nxdl $<
111-
mv $(APPDEF_DIR)/$(NYAML_SUBDIR)/$*.nxdl.xml $@
112-
113-
NXDLS := $(NXDL_APPDEF) $(NXDL_CONTRIB) $(NXDL_BC)
114-
nyaml :
115-
for file in $(NXDLS); do\
116-
mkdir -p "$${file%/*}/nyaml";\
117-
nyaml2nxdl $${file};\
118-
FNAME=$${file##*/};\
119-
mv -- "$${file%.nxdl.xml}_parsed.yaml" "$${file%/*}/nyaml/$${FNAME%.nxdl.xml}.yaml";\
120-
done
121-
122-
nxdl: $(NXDL_APPDEF) $(NXDL_CONTRIB) $(NXDL_BC)
110+
nyaml2nxdl $< --output-file $@
111+
112+
nxdl: $(YBC_NXDL_TARGETS) $(YCONTRIB_NXDL_TARGETS) $(YAPPDEF_NXDL_TARGETS)
113+
114+
nyaml:
115+
$(MAKE) -f nyaml.mk
116+
123117

124118
# NeXus - Neutron and X-ray Common Data Format
125119
#

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ Note: If set this will increase the build time of the documentation by approxima
4848

4949
setenv GH_TOKEN <access token>
5050

51+
### Working with nyaml files
52+
53+
There exists a simplified format of nxdl, which is called nyaml.
54+
There is a [tool](https://github.com/FAIRmat-NFDI/nyaml) (`nyaml2nxdl`) available to convert between nxdl and nyaml.
55+
This tool is already installed when you installed the requirements for this repository and it is conveniently available from the make command.
56+
57+
You can build nyaml files for all nxdl files with invoking
58+
59+
make nyaml
60+
61+
which will created `.yaml` files in a subfolder called `nyaml` in the respective directory.
62+
63+
From this you can do your changes and create nxdl files with
64+
65+
make nxdl
66+
67+
from the yaml files.
68+
5169
## Repository content
5270

5371
These are the components that define the structure of NeXus data files

nyaml.mk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BASE_CLASS_DIR := base_classes
2+
CONTRIB_DIR := contributed_definitions
3+
APPDEF_DIR := applications
4+
NYAML_SUBDIR := nyaml
5+
NXDL_BC_TARGETS = $(addprefix $(BASE_CLASS_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(BASE_CLASS_DIR)/*.nxdl.xml))))
6+
NXDL_APPDEF_TARGETS = $(addprefix $(APPDEF_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(APPDEF_DIR)/*.nxdl.xml))))
7+
NXDL_CONTRIB_TARGETS = $(addprefix $(CONTRIB_DIR)/nyaml/,$(notdir $(patsubst %.nxdl.xml,%.yaml,$(wildcard $(CONTRIB_DIR)/*.nxdl.xml))))
8+
9+
.PHONY: all nyaml
10+
11+
$(BASE_CLASS_DIR)/$(NYAML_SUBDIR)/%.yaml : $(BASE_CLASS_DIR)/%.nxdl.xml
12+
@mkdir -p $(@D)
13+
nyaml2nxdl $< --output-file $@
14+
15+
$(CONTRIB_DIR)/$(NYAML_SUBDIR)/%.yaml : $(CONTRIB_DIR)/%.nxdl.xml
16+
@mkdir -p $(@D)
17+
nyaml2nxdl $< --output-file $@
18+
19+
$(APPDEF_DIR)/$(NYAML_SUBDIR)/%.yaml : $(APPDEF_DIR)/%.nxdl.xml
20+
@mkdir -p $(@D)
21+
nyaml2nxdl $< --output-file $@
22+
23+
nyaml: $(NXDL_BC_TARGETS) $(NXDL_APPDEF_TARGETS) $(NXDL_CONTRIB_TARGETS)
24+
25+
all: nyaml

0 commit comments

Comments
 (0)