summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/build/example/generator
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/boost/tools/build/example/generator
parentInitial commit. (diff)
downloadceph-upstream/18.2.2.tar.xz
ceph-upstream/18.2.2.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/tools/build/example/generator')
-rw-r--r--src/boost/tools/build/example/generator/README.txt6
-rw-r--r--src/boost/tools/build/example/generator/foo.gci10
-rw-r--r--src/boost/tools/build/example/generator/jamroot.jam6
-rw-r--r--src/boost/tools/build/example/generator/soap.jam86
4 files changed, 108 insertions, 0 deletions
diff --git a/src/boost/tools/build/example/generator/README.txt b/src/boost/tools/build/example/generator/README.txt
new file mode 100644
index 000000000..f26a856a5
--- /dev/null
+++ b/src/boost/tools/build/example/generator/README.txt
@@ -0,0 +1,6 @@
+# Copyright 2006 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+This example shows how to declare a new generator class. It is necessary when
+generator's logic is more complex that just running a single tool.
diff --git a/src/boost/tools/build/example/generator/foo.gci b/src/boost/tools/build/example/generator/foo.gci
new file mode 100644
index 000000000..2ccc45c6c
--- /dev/null
+++ b/src/boost/tools/build/example/generator/foo.gci
@@ -0,0 +1,10 @@
+
+int main()
+{
+ return 0;
+}
+/*
+Copyright 2006 Vladimir Prus
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ */
diff --git a/src/boost/tools/build/example/generator/jamroot.jam b/src/boost/tools/build/example/generator/jamroot.jam
new file mode 100644
index 000000000..b77c63ddb
--- /dev/null
+++ b/src/boost/tools/build/example/generator/jamroot.jam
@@ -0,0 +1,6 @@
+# Copyright 2006 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
+
+import soap ;
+exe foo : foo.gci : <server>on ;
diff --git a/src/boost/tools/build/example/generator/soap.jam b/src/boost/tools/build/example/generator/soap.jam
new file mode 100644
index 000000000..d53f3a54d
--- /dev/null
+++ b/src/boost/tools/build/example/generator/soap.jam
@@ -0,0 +1,86 @@
+# Copyright 2006 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
+
+# This is example of a fictional code generator tool.
+# It accepts a single input of type '.gci' and produces
+# either one or two outputs of type .cpp, depending
+# on the value of the feature <server-mode>
+#
+# This example is loosely based on gSOAP code generator.
+
+import type ;
+import generators ;
+import feature ;
+import common ;
+import "class" : new ;
+import os ;
+
+type.register GCI : gci ;
+
+feature.feature server : off on : incidental ;
+
+class soap-generator : generator
+{
+ import "class" : new ;
+
+ rule __init__ ( * : * )
+ {
+ generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
+ }
+
+ rule run ( project name ? : property-set : sources * )
+ {
+ if ! $(sources[2])
+ {
+ # Accept only single source.
+ local t = [ $(sources[1]).type ] ;
+ if $(t) = GCI
+ {
+ # The type is correct.
+
+ # If no output name is specified, guess it from sources.
+ if ! $(name)
+ {
+ name = [ generator.determine-output-name $(sources) ] ;
+ }
+
+ # Produce one output, using just copy.
+ local a = [ new action $(sources[1])
+ : common.copy : $(property-set) ] ;
+ local t = [ new file-target $(name) : CPP : $(project)
+ : $(a) ] ;
+
+ # If in server mode, create another output -- an
+ # empty file. If this were a real SOAP generator, we
+ # might have created a single action, and two targets
+ # both using that action.
+ local t2 ;
+ if [ $(property-set).get <server> ] = "on"
+ {
+ local a = [ new action : soap.touch : $(property-set) ] ;
+ t2 = [ new file-target $(name)_server : CPP : $(project)
+ : $(a) ] ;
+ }
+ return [ virtual-target.register $(t) ]
+ [ virtual-target.register $(t2) ] ;
+ }
+ }
+ }
+}
+
+generators.register [ new soap-generator soap.soap : GCI : CPP ] ;
+
+TOUCH = [ common.file-touch-command ] ;
+actions touch
+{
+ $(TOUCH) $(<)
+}
+
+if [ os.name ] = VMS
+{
+ actions touch
+ {
+ $(TOUCH) $(<:W)
+ }
+}