This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen-entitys
executable file
·83 lines (63 loc) · 2.18 KB
/
autogen-entitys
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/make -sf
# -*- makefile -*-
# This is a Makefile that will execute macros for each supported lang.
# Copyright 2012,2013 Docstream A/S.
# This file is part of 'auto-ent'.
# 'auto-ent' is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 'auto-ent' is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with 'auto-ent'. If not, see <http://www.gnu.org/licenses/>.
NAME := autogen-entitys
SRC := ./demo/mymodels.m4
PKG := mymodel
TOP_CLASS := Beans
ORM_DEP=1
SQL_DEP=1
M4 := m4
SED := sed
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
COMMON_M4 := $(SELF_DIR)macros/common.m4
GO_M4 := $(SELF_DIR)macros/go.m4
J_M4 := $(SELF_DIR)macros/java.m4
# sed functions
rewrite_comments := $(SED) -E "s|(^[ \t]*)\#([^;])|\1//\2|"
rm_dbl_commented_line := $(SED) -E "/(^[ \t]*)\#[;].*/d"
# targets
.PHONY: help toolcheck java go sql
help:
@echo
@echo "Usage: $(NAME) <java|go|sql|help> [Variables]"
@echo
@echo " Variables:"
@echo
@echo " SRC=<path> . The DSL file, defaults to '$(SRC)'"
@echo " PKG=<name> . Defaults to '$(PKG)'"
@echo " TOP_CLASS=<name> . Java only. Defaults to '$(TOP_CLASS)'"
@echo " ORM_DEP=<1|0> . Go only. Defaults to 1."
@echo " SQL_DEP=<1|0> . Go only. Defaults to 1."
@echo
java: toolcheck
@$(M4) -DPACKAGE=$(PKG) -DTOP_CLASS=$(TOP_CLASS) \
$(COMMON_M4) $(J_M4) $(SRC) |\
$(rewrite_comments) | $(rm_dbl_commented_line)
go: toolcheck
@$(M4) -DPACKAGE=$(PKG) $(COMMON_M4) $(GO_M4) $(SRC) |\
$(rewrite_comments) | $(rm_dbl_commented_line)
sql: toolcheck
@echo " .. not yet"
toolcheck:
M4_PATH := $(shell which $(M4))
ifndef M4_PATH
$(error ERROR: Depends on pkg : '$(M4)')
endif
SED_PATH := $(shell which $(SED))
ifndef SED_PATH
$(error ERROR: Depends on pkg : '$(SED)')
endif
# end toolcheck