Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj4668 committed Feb 15, 2024
1 parent 34b4de4 commit 8df48a2
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 133 deletions.
56 changes: 30 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
SUBDIRS = c_src src plugins

all:
@set -e ; \
for d in $(SUBDIRS) ; do \
if [ -f $$d/Makefile ]; then \
( cd $$d && $(MAKE) ) || exit 1 ; \
fi ; \
done

clean: $(LOCALCLEAN)
@set -e ; \
for d in $(SUBDIRS) ; do \
if [ -f $$d/Makefile ]; then \
( cd $$d && $(MAKE) $@ ) || exit 1 ; \
fi ; \
done
DESCRIPTION = Erlang YANG compiler

SUBDIRS = plugins

ERL_MODULES = yang_llerror xpath_parse

include erl.mk

erl.mk:
curl -s -O https://raw.githubusercontent.com/mbj4668/erl.mk/main/$@

ERLC_OPTS := $(filter-out +warn_export_vars,$(ERLC_OPTS))

include vsn.mk
dialyzer:
dialyzer -DVSN=\"$(VSN)\" -pa ../yanger/ebin --src src/*.erl

# requires 'lux' in the PATH (https://github.com/hawk/lux)
# the tree test requires 'pyang' (https://github.com/mbj4668/pyang)
# checked out next to 'yanger' and in the PATH
test:
(cd test; $(MAKE))
.PHONY: test
ERLC_OPTS += -DVSN=\"$(VSN)\"
DIALYZER_OPTS = -DVSN=\"$(VSN)\"

src/yang_llerror.erl: c_src/yang_error.h
awk -f src/mk_llerror.awk < $< > $@

src/yang_llerror.hrl: c_src/yang_error.h
awk -f src/mk_llerror_hrl.awk < $< > $@

ebin/yang.beam: src/yang_llerror.hrl

src/%.erl: src/%.yrl
erlc -o src $<

clean: clean-gen

clean-gen:
rm -rf src/yang_llerror.erl src/yang_llerror.hrl src/xpath_parse.erl
41 changes: 14 additions & 27 deletions c_src/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@

PARSER_NIF = ../priv/yang_parser_nif.so
REGEX_NIF = ../priv/w3cregex_nif.so

PRIV_FILES = $(PARSER_NIF) $(REGEX_NIF)

CFLAGS = -std=c99
all: $(PRIV_FILES)

include c_src.mk

c_src.mk:
$(MAKE) -f ../erl.mk $@

CFLAGS += -std=c99
CWARNINGS = \
-Werror \
-Wall \
Expand All @@ -15,8 +21,6 @@ CWARNINGS = \
-Wwrite-strings \
-Wnested-externs

CFLAGS += -fpic -DDYNAMIC_DRIVER

ifneq ($(DEBUG),)
CFLAGS += -g -ggdb
CWARNINGS += -Wuninitialized
Expand All @@ -27,12 +31,6 @@ endif

CFLAGS += $(CWARNINGS)

ERL_EVAL = 'io:format("~s", [os:getenv("ROOTDIR")]), erlang:halt(0)'
ERL_ROOTDIR = $(shell erl -noinput -eval $(ERL_EVAL))
ifneq ($(findstring /, $(ERL_ROOTDIR)),)
CFLAGS += -I$(ERL_ROOTDIR)/usr/include
endif

XML_CFLAGS ?= $(shell pkg-config --cflags libxml-2.0)
ifeq ($(XML_CFLAGS),)
XML_CFLAGS = -I/usr/include/libxml2
Expand All @@ -46,26 +44,15 @@ LIBS += $(XML_LIBS)

LD = $(CC)

ifeq ($(shell uname -s), Darwin)
LDDRV_FLAGS = -bundle -undefined dynamic_lookup
else
LDDRV_FLAGS = -shared
endif


C_SOURCES := $(wildcard yang*.c)
C_HEADERS := $(wildcard yang*.h)
OBJS := $(C_SOURCES:%.c=./%.o)

all: $(PRIV_FILES)

$(OBJS): $(C_HEADERS)
PARSER_SOURCES := $(wildcard yang*.c)
PARSER_HEADERS := $(wildcard yang*.h)
PARSER_OBJS := $(PARSER_SOURCES:%.c=./%.o)

$(PARSER_NIF): $(OBJS)
$(LD) $(LDDRV_FLAGS) -o $@ $^ $(LIBS)
$(PARSER_NIF): $(PARSER_OBJS)
$(LD) $(LDFLAGS_NIF) -o $@ $^ $(LIBS)

$(REGEX_NIF): w3cregex_nif.o
$(LD) $(LDDRV_FLAGS) -o $@ $^ $(LIBS)
$(LD) $(LDFLAGS_NIF) -o $@ $^ $(LIBS)

debug:
$(MAKE) DEBUG=true all
Expand Down
1 change: 0 additions & 1 deletion ebin/.gitkeep

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../vsn.mk

ERL_SOURCES := $(wildcard *.erl)
ERL_SOURCES := $(wildcard *.erl)
ERL_OBJECTS := $(ERL_SOURCES:%.erl=../priv/%.beam)

ERLC_FLAGS += -pa ../../yanger/ebin -Werror
Expand Down
61 changes: 0 additions & 61 deletions src/Makefile

This file was deleted.

12 changes: 0 additions & 12 deletions src/yanger.app.src

This file was deleted.

2 changes: 1 addition & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DIRS = lux eunit
DIRS = eunit

all: test

Expand Down
2 changes: 1 addition & 1 deletion test/lux/ENG-24068-submodule-post-expand-leafref/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ include ../../support/*_testcases.mk

build:

clean: iclean
clean:
rm -rf lux_logs
2 changes: 1 addition & 1 deletion test/lux/eng-25448_deviated_type_scope/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../../support/*_testcases.mk

build:
lux run.lux

clean:
rm -f *.fxs
Expand Down
3 changes: 1 addition & 2 deletions test/lux/invalidate_default/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

# Mandatory targets
build:
@echo "Build complete"

clean:
rm -r lux_logs
rm -rf lux_logs

0 comments on commit 8df48a2

Please sign in to comment.