-
Notifications
You must be signed in to change notification settings - Fork 3
/
Atdgen.om
120 lines (113 loc) · 4.26 KB
/
Atdgen.om
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Atdgen.om: atdgen plugin for the OMake build system http://omake.metaprl.org/
#
# Author: Martin Jambon
# Copyright (c) 2011 MyLife
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
######################### About this version #########################
ATDGEN_OMAKE_VERSION = 2.1
# Version 2.1:
# - uses CamlGeneratedFiles instead of LocalOCamlGeneratedFiles
# New in 2.0:
# - version identifier ATDGEN_OMAKE_VERSION
# - support for the validation mode (atdgen 1.2)
# - uses the new modes -t, -b, -j, -v with the effect that create_* functions
# are now in the *_v modules instead of *_t.
# - options to Atdgen() for different modes collapsed in only one argument
# (possible since atdgen 1.2.0).
# - AtdgenBiniou() and AtdgenJson() are gone because they are now redundant
# with Atdgen().
#
# Upgrading from 1.0 to 2.0:
#
# - Replace AtdgenBiniou and AtdgenJson by Atdgen in your OMakefiles.
# AtdgenJson(foo bar, -j-std)
# becomes
# Atdgen(foo bar, -j-std)
#
#
# - Collapse arguments 2 and 3 of Atdgen:
# Atdgen(foo bar, $(EMPTY), $(EMPTY))
# becomes:
# Atdgen(foo bar, $(EMPTY))
######################### Setup and usage #########################
# Requires: omake, atdgen >= 1.2.0
#
# Usage:
#
# Once in the OMakeroot (or OMakefile):
#
# include Atdgen
#
# For ATD files foo.atd and bar.atd, place this in the OMakefile:
#
# Atdgen(foo bar, $(EMPTY))
# # file names without .atd extension
# # options
#
# For standard JSON output, use -std-json:
#
# Atdgen(foo bar, -std-json)
#
# The statement above creates rules for building the following files:
# - type definitions: foo_t.mli, foo_t.ml
# - biniou serialization/deserialization: foo_b.mli foo_b.ml
# - JSON serialization/deserialization: foo_j.mli, foo_j.ml
# [same with files bar*]
#
# The following functions are also provided:
# - AtdgenBiniou(files, options): provides only biniou support
# - AtdgenJson(files, options): provides only JSON support
#
# Generated files are added to the variable ATDGEN_OUTFILES which
# is convenient for removing them. A "clean" target for an OCaml
# project might look like this:
#
# .PHONY: clean
# clean:
# rm -f *.o *.a *.cm* *~ *.annot $(ATDGEN_OUTFILES)
#
# Output files without .mli or .ml extension, e.g. foo_t foo_b foo_j
ATDGEN_OUT =
# Output files (.mli, .ml) generated by atdgen
ATDGEN_OUTFILES =
# atdgen base command
ATDGEN = atdgen
Atdgen(prefixes, options) =
foreach(x, $(prefixes))
ATDGEN_OUT += $(x)_t $(x)_b $(x)_j $(x)_v
OUTFILES = $(x)_t.mli $(x)_t.ml $(x)_b.mli $(x)_b.ml \
$(x)_j.mli $(x)_j.ml $(x)_v.mli $(x)_v.ml
ATDGEN_OUTFILES += $(OUTFILES)
OCamlGeneratedFiles($(OUTFILES))
$(x)_t.mli $(x)_t.ml: $(x).atd
$(ATDGEN) -t $(options) $<
$(x)_b.mli $(x)_b.ml: $(x).atd
$(ATDGEN) -b $(options) $<
$(x)_j.mli $(x)_j.ml: $(x).atd
$(ATDGEN) -j $(options) $<
$(x)_v.mli $(x)_v.ml: $(x).atd
$(ATDGEN) -v $(options) $<
export
export