CORD-1468: Write helper target to make life easier for 3.0 service
developers
Change-Id: Id40732c1444b09932fa0c24c9095e1485f4e46e6
diff --git a/xos/genx/targets/service_extender.xtarget b/xos/genx/targets/service_extender.xtarget
new file mode 100644
index 0000000..5b4bc03
--- /dev/null
+++ b/xos/genx/targets/service_extender.xtarget
@@ -0,0 +1,20 @@
+from core.models.xosbase import *
+{% for m in proto.messages %}
+from models_decl import {{ m.name }}_decl
+{%- endfor %}
+
+{% for m in proto.messages %}
+{% for l in m.links %}{% set peer_name=l.peer.name -%}
+{% if peer_name not in proto.message_names -%}
+from core.models import {{ peer_name }}
+{% endif -%}
+{% endfor -%}
+{% endfor -%}
+
+{% for m in proto.messages %}
+class {{ m.name }}({{ m.name }}_decl):
+ class Meta:
+ proxy = True
+
+{% endfor %}
++++ models.py
diff --git a/xos/genx/tool/Makefile.service b/xos/genx/tool/Makefile.service
index 6bdb823..ffbc783 100644
--- a/xos/genx/tool/Makefile.service
+++ b/xos/genx/tool/Makefile.service
@@ -3,6 +3,8 @@
XOSGEN=$(PREFIX)/tool/xosgen
DJANGO_TARGET=$(PREFIX)/targets/service.xtarget
+EXTENSION_TARGET=$(PREFIX)/targets/service_extender.xtarget
+
XPROTOS_TMP := $(shell mktemp)
xprotos = $(wildcard *.xproto)
@@ -10,7 +12,10 @@
all: $(xprotos)
$(XOSGEN) --attic attic --target $(DJANGO_TARGET) --output $@ $<
-.PHONY: all
+service_extender: $(xprotos)
+ $(XOSGEN) --attic attic --target $(EXTENSION_TARGET) --output $@ $<
+
+.PHONY: all service_extender
clean:
- rm -f models.py
+ rm -f models.py models_decl.py