rubu 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7e9367474ff7dcf3a1764e1fc00214c6c7eae7e
4
- data.tar.gz: 5ac3d1475cb9c3167c8a33039a2a2fa7bdad958d
3
+ metadata.gz: d1ea71531899cbeacd6c533c4fcdfc273e55d8be
4
+ data.tar.gz: 153b0a4bbce0fbbe4d02fbe702557b0be270ebc4
5
5
  SHA512:
6
- metadata.gz: d577a12a0388735fbf34dd54c81597c9c7411ffadbb9ff2c0cc3c20528aa691e9ca506029c9bdad88e0f2c35c9340df08a771b0e42763b04b718a51e75fb4f05
7
- data.tar.gz: e2fc1ede87e074eea4b1796b77e23f7cc2e50cf8691c751d11e950c30279541117cfe5f10bcba48d9d9c39adb65a03e0948edad5768ed8310c692f1be75a317e
6
+ metadata.gz: 5bdb9bd55c14df5269492c3d26c645d6ec9c121db25bcac7539310ddc91feef97351b9a0895df565556fa03adb0787baed4eca3bb1cfd54c18c231e0312edfae
7
+ data.tar.gz: c92f0f0bd1601901b0ea31bd2c8f5ec7227ea6d9b76ab9d9c209c34b8b5c79290b681e0a0b72954cbba30ac4153da76e3e240a572838df9e7ceac117ac03f940
@@ -1,3 +1,6 @@
1
1
  = Version history
2
2
 
3
+ [0.0.2] Documentation updates.
4
+ Some name changes to Rubu classes.
5
+
3
6
  [0.0.1] Initial version.
@@ -6,7 +6,7 @@ of tools. {Rubu} is targeted to provide means for creating flexible
6
6
  build environments.
7
7
 
8
8
  Make and Rake are rule and recipe based, and they are very effective
9
- when the build process can be captured to these rules and are fairly
9
+ when the build process can be captured to these rules and is fairly
10
10
  fixed. {Rubu} includes declarations which correspond to rules, but the
11
11
  declarations are lower level and provide more control over the
12
12
  behavior. {Rubu} also provides direct control over when the rules are
@@ -15,7 +15,7 @@ executed.
15
15
  Make and Rake are more compact for the simplest build environments,
16
16
  but there is a break-even point where {Rubu} becomes more
17
17
  convenient. This is likely to happen when the user needs many
18
- exceptions to basic rules, also when other tasks than just build task
18
+ exceptions to basic rules, also when other tasks than just build tasks
19
19
  are needed.
20
20
 
21
21
  {Rubu} library can be used from any Ruby program, since it is just a
@@ -23,10 +23,9 @@ library. It can also be part of a larger program as less significant
23
23
  part of the overall functionality. From maintenance point of view this
24
24
  can be a win in many cases.
25
25
 
26
-
27
- == Concepts
28
-
29
- TBD
26
+ The easiest way to get started with {Rubu} is to study examples (See:
27
+ "Example" chapter below). However for longer term the main concepts
28
+ are important as well (See: "Concepts" chapter below).
30
29
 
31
30
 
32
31
  == Example
@@ -39,7 +38,7 @@ It builds a "hello world" type program which is split into two C
39
38
  source files. The main file is hand written and the other file is
40
39
  generated with a script. File generation is part of the build program.
41
40
 
42
- Various executions of the build is captured in:
41
+ Different execution variations of the build program is captured in:
43
42
 
44
43
  example/runme
45
44
 
@@ -49,7 +48,7 @@ the "example" directory:
49
48
  cd example
50
49
  runme
51
50
 
52
- Also take a look into the build program:
51
+ Also take a look into the build program itself:
53
52
 
54
53
  cat example/bin/rubu_example
55
54
 
@@ -57,6 +56,235 @@ There are comments which highlight purpose of the build program
57
56
  content.
58
57
 
59
58
 
59
+ == Concepts
60
+
61
+ {Rubu} Build Program, RBP, is a Ruby program that uses the {Rubu}
62
+ library. Typically command line options are accepted to give options
63
+ for the build process.
64
+
65
+ Build programs are about collecting source files and transforming them
66
+ into targets. This process is explicit in {Rubu}. Each file, whether
67
+ it's source or target, is collected within the {Rubu} build
68
+ program. The files are converted into *Mark* objects. Basically *Mark*
69
+ corresponds to a file, but it includes methods that make the build
70
+ process convenient.
71
+
72
+ *Step* is build action that transforms source file(s) to target
73
+ file(s). For example, a C source file compilation is a *Step* where
74
+ one source file is converted to a corresponding object file. *Step* is
75
+ given source *Mark* and target *Mark* as arguments. Hence this type of
76
+ *Step* a is one-to-one mapping.
77
+
78
+ Linking multiple objects to an executable is a many-to-one
79
+ mapping. This is performed by a *Step* where there are multiple
80
+ sources and one target, i.e. objects and the executable respectively.
81
+
82
+ *Step* class (or object) has "step" method which includes the *Move*
83
+ that is needed to create the target. *Move* is either a Shell or a
84
+ Ruby command. *Move* is executed only if necessary. Typically the
85
+ *Step* is sensitive to source being newer that the target, just as
86
+ with Make and Rake. However, it is possible to have a *Step* that is
87
+ sensitive to file content, for example. Timestamp might change, but if
88
+ the content is the same as previously, no *Move* is made.
89
+
90
+ *Step* is typically a simple command. In some cases *Step* can include
91
+ multiple *Moves*. These can be performed in sequence or in parallel,
92
+ with a multicore CPU.
93
+
94
+ *Trail* is a collection of *Steps*. *Trail* has a name, and it can be
95
+ references by another *Trail*. *Trail* can be sequential or
96
+ parallel. For example, C source to object compilation can be done in
97
+ parallel, but linking of objects to executable must occur after all
98
+ objects have been created.
99
+
100
+ {Rubu} Build Program includes all of the above, and the last step is
101
+ to select which *Trail* is executed. There should be at least
102
+ "default" *Trail*, and typically there is also a "clean" *Trail*.
103
+
104
+ {Rubu} supports the configuration spaces: *Order*, *Var*, and
105
+ *Info*. *Order* is meant to be used for controlling {Rubu} itself. For
106
+ example if user wants to see all executed command, then "verbose"
107
+ option should be selected.
108
+
109
+ *Var* is used to control how *Steps* behave and also details of *Move*
110
+ internals. *Info* is meant for runtime generated information. The
111
+ division is semantic and user might choose to combine everything to
112
+ *Var* space, for example.
113
+
114
+ To summarize and highlight the relationships between concepts, see the
115
+ diagram below:
116
+
117
+ RBP => Trial+ => Step+ [s/p] => Move+ [s/p] => Source*, Target*
118
+ => Order+
119
+ => Var*
120
+ => Info*
121
+
122
+ * = Zero or more
123
+ + = One or more
124
+ s = Serial
125
+ p = Parallel
126
+
127
+ RBP includes *Trials*, *Orders*, and possibly *Vars* and
128
+ *Infos*. *Trial* includes one or more *Steps*, which can be executed
129
+ in sequence or in parallel.
130
+
131
+ *Step* includes one or more *Moves*, and they can also be sequential
132
+ or parallel. *Move* has typically at least one *Source* and at least
133
+ one *Target*. However, there are exceptions as well.
134
+
135
+
136
+ The suggested ordering within {Rubu} Build Program is:
137
+
138
+ [configuration] Process command line arguments and assign options that
139
+ are used to control the build process.
140
+
141
+ [file collection] Collect source and target files either using Ruby
142
+ with glob pattern, direct references, or through
143
+ manifest files. Convert file names to *Mark*
144
+ objects.
145
+
146
+ [step definition] Define *Steps*. Inherit one of the *Step* types
147
+ (classes) and define at least the "step" method.
148
+
149
+ [trail definition] Define *Trails*. Create all possible flows that
150
+ user wants to execute. Use hierarchy for your
151
+ benefit in order to make RBP maintenance as light
152
+ as possible.
153
+
154
+ [trail selection] Find the selected *Trail* or *Trails* and execute.
155
+
156
+
157
+ == Configuration
158
+
159
+ *Order* space default are set by the {Rubu} library and user can
160
+ override the default based on command line parameters if needed.
161
+
162
+ Set default values for *Var* space. After default setting, override
163
+ the defaults with possible control from command line arguments.
164
+
165
+ Finally setup *Trails* by calling:
166
+
167
+ Trail.setup
168
+
169
+
170
+ == File collection
171
+
172
+ If the build environment has clear and clean directory structure, it
173
+ is typically easiest to collect files programmatically. For example,
174
+ to get all C source files:
175
+
176
+ cee_files = Mark.glob( "#{Var[:source_dir]}/*.c" )
177
+
178
+ This creates a list of *Mark* objects which are source files. The
179
+ corresponding object files can be created with "peer" method:
180
+
181
+ obj_files = cee_files.peer( Var[ :build_dir ], '.o' )
182
+
183
+ This method invocation takes an Array of *Mark* objects and calls
184
+ "peer" method for them. "peer" method changes the directory and
185
+ extension, and returns a new *Mark* object. In some cases also the
186
+ "basename" of the file is changed. This is achieved by giving the
187
+ "peer" method a third argument specifying the new "basename".
188
+
189
+
190
+ == Step definition
191
+
192
+ *Step* is defined by inheriting of the {Rubu} *Step* classes and
193
+ defining the custom "step" method. If a specific setup for the *Step*
194
+ is required, then an additional "setup" method can be defined as well.
195
+
196
+ class CleanUp < StepAlways
197
+ def step
198
+ shrun "rm -f #{Var[ :build_dir ]}/*.o"
199
+ end
200
+ end
201
+
202
+
203
+ "setup" method is typically used to change the command according to
204
+ user configuration. "step" method is the action for *Step*. {Rubu}
205
+ executes it, if necessary. For example, if *Step* is a *StepAged*
206
+ class, then the "step" method is only called if the source *Mark* is
207
+ newer than the target *Mark*.
208
+
209
+ "step" method may include only one command or a set of commands. If
210
+ one command is needed, it can be simply executed:
211
+
212
+ def step
213
+ shrun "rm -f #{Var[ :build_dir ]}/*.o"
214
+ end
215
+
216
+ If there are multiple commands, then the commands can be grouped for
217
+ sequential ("walk") or parallel execution ("fork").
218
+
219
+ def step
220
+ fork do
221
+ shuse "rm -f #{Info[ :gen_files ].rpath}"
222
+ shuse "rm -f #{Var[ :build_dir ]}/*.o"
223
+ end
224
+ end
225
+
226
+ Note that the commands are defined with "shuse". The logic is that we
227
+ don't execute the commands right away as in "shrun". Instead we just
228
+ register the commands to the group. When the group definition is
229
+ closed ("end" keyword), it is complete, and we execute it either
230
+ sequentially or in parallel.
231
+
232
+
233
+ == Trail definition
234
+
235
+ *Trail* is a collection of *Steps* or other *Trails*, or a mix of
236
+ both. For example, in order to compile a set of C source files to
237
+ object files, we might define:
238
+
239
+ Fork.form 'compile-cee' do
240
+ GccCompileFile.usezip( cee_files, obj_files )
241
+ end
242
+
243
+ This creates a parallel ("Fork") *Trail* called
244
+ "compile-cee". Collection of *Steps* is created with "usezip"
245
+ method. "usezip" performs two operations: it creates a zip type mix of
246
+ "cee_files" and "obj_files". The "zip" method of Ruby Array is
247
+ used. "zip" creates an Array of *Mark* pairs. Each pair is passed to a
248
+ "GccCompileFile" *Step* object. Finally we have a collection of
249
+ *Steps* which are executed in parallel when "compile-cee" is invoked.
250
+
251
+ Here the defined *Trail* from above is referenced in order to create a
252
+ *Trail* for the complete compile flow:
253
+
254
+ Walk.form 'default' do
255
+ pick 'compile-cee'
256
+ GccLinkExe.use( obj_files, exe_file )
257
+ end
258
+
259
+ This *Trail* definition defines that we want to first execute
260
+ "compile-cee" and then a *Step* which will create an executable from
261
+ object file collection. "GccLinkExe" *Step* is called with "use"
262
+ method, which will register the *Step* to the enclosing *Trail*,
263
+ "default".
264
+
265
+
266
+ == Trail selection
267
+
268
+ The final stage in RBP execution is to use command line control for
269
+ selecting the executed *Trails* and then execute them. The above
270
+ definition (from previous section) is executed with:
271
+
272
+ Trail.run( 'default' )
273
+
274
+
275
+ == Final notes
276
+
277
+ {Rubu} treats single *Mark* objects and Array of *Mark* objects the
278
+ "same" way. In practice this means that the most common methods for
279
+ *Mark* objects are implemented for Array as well. Hence, you can call
280
+ a *Mark* method for an Array, and they will actually be applied for
281
+ each individual *Mark* in the collection.
282
+
283
+ *Step* has sources and targets. Even if a step has only one source and
284
+ one target, the actual container is an Array. If you want to refer to
285
+ the source, i.e. the only existing source, you can use the "source"
286
+ method. Same applies to targets (i.e. use the "target" method).
287
+
60
288
 
61
289
  == Testing
62
290
 
@@ -142,7 +142,9 @@
142
142
 
143
143
 
144
144
 
145
- <span class="summary_desc"><div class='inline'></div></span>
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>Array version of Mark#path.</p>
147
+ </div></span>
146
148
 
147
149
  </li>
148
150
 
@@ -164,7 +166,9 @@
164
166
 
165
167
 
166
168
 
167
- <span class="summary_desc"><div class='inline'></div></span>
169
+ <span class="summary_desc"><div class='inline'>
170
+ <p>Array version of Mark#peer.</p>
171
+ </div></span>
168
172
 
169
173
  </li>
170
174
 
@@ -186,7 +190,9 @@
186
190
 
187
191
 
188
192
 
189
- <span class="summary_desc"><div class='inline'></div></span>
193
+ <span class="summary_desc"><div class='inline'>
194
+ <p>Array version of Mark#rpath.</p>
195
+ </div></span>
190
196
 
191
197
  </li>
192
198
 
@@ -208,7 +214,9 @@
208
214
 
209
215
 
210
216
 
211
- <span class="summary_desc"><div class='inline'></div></span>
217
+ <span class="summary_desc"><div class='inline'>
218
+ <p>Array version of Mark#set_opt.</p>
219
+ </div></span>
212
220
 
213
221
  </li>
214
222
 
@@ -230,7 +238,9 @@
230
238
 
231
239
 
232
240
 
233
- <span class="summary_desc"><div class='inline'></div></span>
241
+ <span class="summary_desc"><div class='inline'>
242
+ <p>Array version of Move#use.</p>
243
+ </div></span>
234
244
 
235
245
  </li>
236
246
 
@@ -253,18 +263,29 @@
253
263
 
254
264
 
255
265
 
256
- </h3><table class="source_code">
266
+ </h3><div class="docstring">
267
+ <div class="discussion">
268
+
269
+ <p>Array version of Mark#path.</p>
270
+
271
+
272
+ </div>
273
+ </div>
274
+ <div class="tags">
275
+
276
+
277
+ </div><table class="source_code">
257
278
  <tr>
258
279
  <td>
259
280
  <pre class="lines">
260
281
 
261
282
 
262
- 782
263
- 783
264
- 784</pre>
283
+ 864
284
+ 865
285
+ 866</pre>
265
286
  </td>
266
287
  <td>
267
- <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 782</span>
288
+ <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 864</span>
268
289
 
269
290
  <span class='kw'>def</span> <span class='id identifier rubyid_path'>path</span><span class='lparen'>(</span> <span class='id identifier rubyid_joiner'>joiner</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'> </span><span class='tstring_end'>&#39;</span></span> <span class='rparen'>)</span>
270
291
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_path'>path</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span> <span class='id identifier rubyid_joiner'>joiner</span> <span class='rparen'>)</span>
@@ -283,20 +304,31 @@
283
304
 
284
305
 
285
306
 
286
- </h3><table class="source_code">
307
+ </h3><div class="docstring">
308
+ <div class="discussion">
309
+
310
+ <p>Array version of Mark#peer.</p>
311
+
312
+
313
+ </div>
314
+ </div>
315
+ <div class="tags">
316
+
317
+
318
+ </div><table class="source_code">
287
319
  <tr>
288
320
  <td>
289
321
  <pre class="lines">
290
322
 
291
323
 
292
- 776
293
- 777
294
- 778
295
- 779
296
- 780</pre>
324
+ 857
325
+ 858
326
+ 859
327
+ 860
328
+ 861</pre>
297
329
  </td>
298
330
  <td>
299
- <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 776</span>
331
+ <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 857</span>
300
332
 
301
333
  <span class='kw'>def</span> <span class='id identifier rubyid_peer'>peer</span><span class='lparen'>(</span> <span class='id identifier rubyid_rdir'>rdir</span><span class='comma'>,</span> <span class='id identifier rubyid_ext'>ext</span><span class='comma'>,</span> <span class='id identifier rubyid_base'>base</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
302
334
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
@@ -317,18 +349,29 @@
317
349
 
318
350
 
319
351
 
320
- </h3><table class="source_code">
352
+ </h3><div class="docstring">
353
+ <div class="discussion">
354
+
355
+ <p>Array version of Mark#rpath.</p>
356
+
357
+
358
+ </div>
359
+ </div>
360
+ <div class="tags">
361
+
362
+
363
+ </div><table class="source_code">
321
364
  <tr>
322
365
  <td>
323
366
  <pre class="lines">
324
367
 
325
368
 
326
- 786
327
- 787
328
- 788</pre>
369
+ 869
370
+ 870
371
+ 871</pre>
329
372
  </td>
330
373
  <td>
331
- <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 786</span>
374
+ <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 869</span>
332
375
 
333
376
  <span class='kw'>def</span> <span class='id identifier rubyid_rpath'>rpath</span><span class='lparen'>(</span> <span class='id identifier rubyid_joiner'>joiner</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'> </span><span class='tstring_end'>&#39;</span></span> <span class='rparen'>)</span>
334
377
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_rpath'>rpath</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span> <span class='id identifier rubyid_joiner'>joiner</span> <span class='rparen'>)</span>
@@ -347,21 +390,32 @@
347
390
 
348
391
 
349
392
 
350
- </h3><table class="source_code">
393
+ </h3><div class="docstring">
394
+ <div class="discussion">
395
+
396
+ <p>Array version of Mark#set_opt.</p>
397
+
398
+
399
+ </div>
400
+ </div>
401
+ <div class="tags">
402
+
403
+
404
+ </div><table class="source_code">
351
405
  <tr>
352
406
  <td>
353
407
  <pre class="lines">
354
408
 
355
409
 
356
- 769
357
- 770
358
- 771
359
- 772
360
- 773
361
- 774</pre>
410
+ 849
411
+ 850
412
+ 851
413
+ 852
414
+ 853
415
+ 854</pre>
362
416
  </td>
363
417
  <td>
364
- <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 769</span>
418
+ <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 849</span>
365
419
 
366
420
  <span class='kw'>def</span> <span class='id identifier rubyid_set_opt'>set_opt</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_val'>val</span> <span class='rparen'>)</span>
367
421
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
@@ -383,20 +437,31 @@
383
437
 
384
438
 
385
439
 
386
- </h3><table class="source_code">
440
+ </h3><div class="docstring">
441
+ <div class="discussion">
442
+
443
+ <p>Array version of Move#use.</p>
444
+
445
+
446
+ </div>
447
+ </div>
448
+ <div class="tags">
449
+
450
+
451
+ </div><table class="source_code">
387
452
  <tr>
388
453
  <td>
389
454
  <pre class="lines">
390
455
 
391
456
 
392
- 763
393
- 764
394
- 765
395
- 766
396
- 767</pre>
457
+ 842
458
+ 843
459
+ 844
460
+ 845
461
+ 846</pre>
397
462
  </td>
398
463
  <td>
399
- <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 763</span>
464
+ <pre class="code"><span class="info file"># File 'lib/rubu.rb', line 842</span>
400
465
 
401
466
  <span class='kw'>def</span> <span class='id identifier rubyid_use'>use</span>
402
467
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
@@ -413,7 +478,7 @@
413
478
  </div>
414
479
 
415
480
  <div id="footer">
416
- Generated on Fri Jun 29 10:04:08 2018 by
481
+ Generated on Sun Jul 1 17:48:17 2018 by
417
482
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
418
483
  0.8.7.6 (ruby-2.3.3).
419
484
  </div>