Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.ripple;
2
 
3
import java.util.Iterator;
4
 
5
import org.apache.log4j.Logger;
6
 
7
/**entity class representing how derived files are produced on a platform
8
 * recognises that a package may have different build standards on different platforms
9
 * for example, jats may be used to build production code on a win32 build machine and debug code on a solaris build machine
10
 * potentially supports mixing build standards
11
 * for example, jats may be used to build code on one build machine, and erg ant on another
12
 * this is not supported in the release manager 
13
 */
14
public class BuildStandard
15
{
16
  /**Logger
17
   * @attribute
18
   */
19
  private static final Logger mLogger = Logger.getLogger(BuildStandard.class);
20
 
21
  /**engine associated with the baseline in which this packages build standard is owned
22
   * @aggregation composite
23
   */
24
  private RippleEngine mRippleEngine;
25
 
26
  /**when true, the intent is to deliver Win32 derived content
27
   * in a daemon world, will be built on all Win32 based build machines associated with the baseline
28
   * will be accessed by Package::isWin32Built
29
   * @attribute
30
   */
31
  private boolean mWin32 = true;
32
 
33
  /**when true, the intent is to deliver Solaris derived content
34
   * in a daemon world, will be built on all Solaris based build machines associated with the baseline
35
   * will be accessed by Package::isSolarisBuilt
36
   * @attribute
37
   */
38
  private boolean mSolaris = false;
39
 
40
  /**when true, the intent is to deliver Linux derived content
41
   * in a daemon world, will be built on all Linux based build machines associated with the baseline
42
   * will be accessed by Package::isLinuxBuilt
43
   * @attribute
44
   */
45
  private boolean mLinux = false;
46
 
47
  /**when true, the intent is to deliver generic content
48
   * in a daemon build, will be built only on the build machine configured to run the Master build thread associated with the baseline
49
   * @attribute
50
   */
51
  private boolean mGeneric = false;
52
 
53
  /**when true, the intent is to deliver production code using jats
54
   * @attribute
55
   */
56
  private boolean mProduction = true;
57
 
58
  /**when true, the intent is to deliver debug code using jats
59
   * @attribute
60
   */
61
  private boolean mDebug = false;
62
 
63
  /**when true, the intent is to deliver java 1.4 built code
64
   * this is realized by using java 1.4 to launch ant
65
   * @attribute
66
   */
67
  private boolean mJava1_4 = false;
68
 
69
  /**when true, the intent is to deliver java 1.5 built code
70
   * this is realized by using java 1.5 to launch ant
71
   * @attribute
72
   */
73
  private boolean mJava1_5 = false;
74
 
75
  /**when true, the intent is to deliver java 1.6 built code
76
   * this is realized by using java 1.6 to launch ant
77
   * @attribute
78
   */
79
  private boolean mJava1_6 = false;
80
 
81
  private boolean mJatsNone = false;
82
 
83
  private boolean mAntNone = false;
84
 
85
  /**constructor
86
   */
87
  BuildStandard(RippleEngine rippleEngine)
88
  {
89
    mLogger.debug("BuildStandard");
90
    mRippleEngine = rippleEngine;
91
  }
92
 
93
  /**returns "<platform gbe_machtype="win32"/>",
94
   *         "<platform gbe_machtype="solaris10_sparc32"/>"
95
   *         "<platform gbe_machtype="solaris10_x86"/>"
96
   *         "<platform gbe_machtype="sparc"/>"
97
   *         "<platform gbe_machtype="linux_i386"/>"
98
   */
99
  String getPlatform(boolean utf)
100
  {
101
     mLogger.debug("getPlatform");  
102
     String retVal = new String();
103
 
104
     if (mGeneric && mRippleEngine.mDaemon)
105
     {
106
       mLogger.info("getPlatform mGeneric && mRippleEngine.mDaemon");
107
       retVal = "  <platform gbe_machtype=\"";
108
 
109
       if ( utf )
110
       {
111
         mLogger.info("getPlatform utf");
112
         // avoid reliance on environment variables
113
         retVal += "win32\"/>";
114
       }
115
       else
116
       {
117
         // Package.mGenericMachtype has been checked to be not null
118
         if ( Package.mGenericMachtype.compareTo("win32") == 0
119
           || Package.mGenericMachtype.compareTo("solaris10_sparc32") == 0
120
           || Package.mGenericMachtype.compareTo("solaris10_x86") == 0
121
           || Package.mGenericMachtype.compareTo("sparc") == 0
122
           || Package.mGenericMachtype.compareTo("linux_i386") == 0 )
123
         {
124
           retVal += Package.mGenericMachtype;
125
           retVal += "\"/>";
126
         }
127
       }
128
     }
129
     else if (mGeneric)
130
     {
131
       mLogger.info("getPlatform mGeneric");
864 mhunt 132
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 133
       {
864 mhunt 134
         String gbemachtype = it.next();
814 mhunt 135
 
136
         if ( gbemachtype.compareTo("win32") == 0 ||
137
              gbemachtype.compareTo("linux_i386") == 0 ||
138
              gbemachtype.compareTo("sparc") == 0 ||
139
              gbemachtype.compareTo("solaris10_x86") == 0 ||
140
              gbemachtype.compareTo("solaris10_sparc32") == 0 )
141
         {
142
           if ( retVal.length() > 0 )
143
           {
144
             retVal += System.getProperty("line.separator");
145
           }
146
           retVal += "  <platform gbe_machtype=\"";
147
           retVal += gbemachtype;
148
           retVal += "\"/>";
149
         }
150
       }
151
     }
152
     else if (mWin32)
153
     {
154
       mLogger.info("getPlatform mWin32");
864 mhunt 155
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 156
       {
864 mhunt 157
         String gbemachtype = it.next();
814 mhunt 158
 
159
         if ( gbemachtype.compareTo("win32") == 0 )
160
         {
161
           retVal = "  <platform gbe_machtype=\"win32\"/>";
162
           break;
163
         }
164
       }
165
     }
166
     else if (mSolaris)
167
     {
168
       mLogger.info("getPlatform mSolaris");
864 mhunt 169
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 170
       {
864 mhunt 171
         String gbemachtype = it.next();
814 mhunt 172
 
173
         if ( gbemachtype.compareTo("sparc") == 0 || gbemachtype.compareTo("solaris10_x86") == 0 || gbemachtype.compareTo("solaris10_sparc32") == 0 )
174
         {
175
           if ( retVal.length() > 0 )
176
           {
177
             retVal += System.getProperty("line.separator");
178
           }
179
           retVal += "  <platform gbe_machtype=\"";
180
           retVal += gbemachtype;
181
           retVal += "\"/>";
182
         }
183
       }
184
     }
185
     else
186
     {
187
       mLogger.info("getPlatform mLinux");
864 mhunt 188
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 189
       {
864 mhunt 190
         String gbemachtype = it.next();
814 mhunt 191
 
192
         if ( gbemachtype.compareTo("linux_i386") == 0 )
193
         {
194
           retVal = "  <platform gbe_machtype=\"linux_i386\"/>";
195
           break;
196
         }
197
       }
198
     }
199
 
200
     mLogger.info("getPlatform returned " + retVal);
201
     return retVal;
202
   }
203
 
204
  /**returns "<ant java="1.4"/>,
205
   *         "<ant java="1.5"/>,
206
   *         "<ant java="1.6"/>,
207
   *         "<ant java="none"/>,
208
   *         "<jats target="production"/>,
209
   *         "<jats target="debug"/>,
210
   *         "<jats target="all"/>
211
   *         "<jats target="none"/>
212
   */
213
  String getBuildStandard(boolean utf)
214
  {
215
    mLogger.debug("getBuildStandard");
216
    boolean validPlatform = false;
217
    int numberOfPlatforms = 0;
218
    String retVal = new String();
219
 
220
    if (mGeneric && mRippleEngine.mDaemon)
221
    {
222
      mLogger.info("getBuildStandard mGeneric && mRippleEngine.mDaemon");
223
 
224
      if ( utf )
225
      {
226
        mLogger.info("getBuildStandard utf");
227
        // avoid reliance on environment variables
228
        validPlatform = true;
229
        numberOfPlatforms = 1;
230
      }
231
      else
232
      {
233
        // Package.mGenericMachtype has been checked to be not null
234
        if ( Package.mGenericMachtype.compareTo("win32") == 0
235
          || Package.mGenericMachtype.compareTo("solaris10_sparc32") == 0
236
          || Package.mGenericMachtype.compareTo("solaris10_x86") == 0
237
          || Package.mGenericMachtype.compareTo("sparc") == 0
238
          || Package.mGenericMachtype.compareTo("linux_i386") == 0 )
239
        {
240
          validPlatform = true;
241
          numberOfPlatforms = 1;
242
        }
243
      }
244
    }
245
    else if (mGeneric)
246
    {
247
      mLogger.info("getBuildStandard mGeneric");
864 mhunt 248
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 249
      {
864 mhunt 250
        String gbemachtype = it.next();
814 mhunt 251
 
252
        if ( gbemachtype.compareTo("win32") == 0 ||
253
             gbemachtype.compareTo("linux_i386") == 0 ||
254
             gbemachtype.compareTo("sparc") == 0 ||
255
             gbemachtype.compareTo("solaris10_x86") == 0 ||
256
             gbemachtype.compareTo("solaris10_sparc32") == 0 )
257
        {
258
          validPlatform = true;
259
          numberOfPlatforms++;
260
        }
261
      }
262
    }
263
    else if (mWin32)
264
    {
265
      mLogger.info("getBuildStandard mWin32");
864 mhunt 266
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 267
      {
864 mhunt 268
        String gbemachtype = it.next();
814 mhunt 269
 
270
        if ( gbemachtype.compareTo("win32") == 0 )
271
        {
272
          validPlatform = true;
273
          numberOfPlatforms = 1;
274
          break;
275
        }
276
      }
277
    }
278
    else if (mSolaris)
279
    {
280
      mLogger.info("getBuildStandard mSolaris");
864 mhunt 281
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 282
      {
864 mhunt 283
        String gbemachtype = it.next();
814 mhunt 284
 
285
        if ( gbemachtype.compareTo("sparc") == 0 || gbemachtype.compareTo("solaris10_x86") == 0 || gbemachtype.compareTo("solaris10_sparc32") == 0 )
286
        {
287
          validPlatform = true;
288
          numberOfPlatforms++;
289
        }
290
      }
291
    }
292
    else
293
    {
294
      mLogger.info("getBuildStandard mLinux");
864 mhunt 295
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 296
      {
864 mhunt 297
        String gbemachtype = it.next();
814 mhunt 298
 
299
        if ( gbemachtype.compareTo("linux_i386") == 0 )
300
        {
301
          validPlatform = true;
302
          numberOfPlatforms = 1;
303
          break;
304
        }
305
      }
306
    }
307
 
308
    if (validPlatform)
309
    {
310
 
311
      if (mJava1_4)
312
      {
313
        retVal = "  <ant java=\"1.4\"/>";
314
      }
315
      else if (mJava1_5)
316
      {
317
        retVal = "  <ant java=\"1.5\"/>";
318
      }
319
      else if (mJava1_6)
320
      {
321
        retVal = "  <ant java=\"1.6\"/>";
322
      }
323
      else if (mAntNone)
324
      {
325
        retVal = "  <ant java=\"none\"/>";
326
      }
327
      else if (mJatsNone)
328
      {
329
        retVal = "  <jats target=\"none\"/>";
330
      }
331
      else
332
      {
333
        if (mProduction)
334
        {
335
          if (mDebug)
336
          {
337
            retVal = "  <jats target=\"all\"/>";
338
          }
339
          else
340
          {
341
            retVal = "  <jats target=\"production\"/>";
342
          }
343
        }
344
        else
345
        {
346
          retVal = "  <jats target=\"debug\"/>";
347
        }
348
      }
349
 
350
      String line = new String(retVal);
351
 
352
      for ( int i = 1; i < numberOfPlatforms; i++ )
353
      {
354
        retVal += System.getProperty("line.separator");
355
        retVal += line;
356
      }
357
    }
358
 
359
    mLogger.info("getBuildStandard returned " + retVal);
360
    return retVal;
361
  }
362
 
363
  /**sets mDebug true, mProduction false, mJava1_4 false, mJava1_5 false, mJava1_6 false
364
   */
365
  void setDebug()
366
  {
367
    mLogger.debug("setDebug");
368
    mDebug = true;
369
    mProduction = false;
370
    mJava1_4 = false;
371
    mJava1_5 = false;
372
    mJava1_6 = false;
373
    mAntNone = false;
374
    mJatsNone = false;
375
  }
376
 
377
  /**sets mDebug false, mProduction true, mJava1_4 false, mJava1_5 false, mJava1_6 false
378
   */
379
  void setProduction()
380
  {
381
    mLogger.debug("setProduction");
382
    mDebug = false;
383
    mProduction = true;
384
    mJava1_4 = false;
385
    mJava1_5 = false;
386
    mJava1_6 = false;
387
    mAntNone = false;
388
    mJatsNone = false;
389
  }
390
 
391
  /**sets mDebug true, mProduction true, mJava1_4 false, mJava1_5 false, mJava1_6 false
392
   */
393
  void setAll()
394
  {
395
    mLogger.debug("setAll");
396
    mDebug = true;
397
    mProduction = true;
398
    mJava1_4 = false;
399
    mJava1_5 = false;
400
    mJava1_6 = false;
401
    mAntNone = false;
402
    mJatsNone = false;
403
  }
404
 
405
  /**sets mDebug false, mProduction false, mJava1_4 true, mJava1_5 false, mJava1_6 false
406
   */
407
  void set1_4()
408
  {
409
    mLogger.debug("set1_4");
410
    mDebug = false;
411
    mProduction = false;
412
    mJava1_4 = true;
413
    mJava1_5 = false;
414
    mJava1_6 = false;
415
    mAntNone = false;
416
    mJatsNone = false;
417
  }
418
 
419
  /**sets mDebug false, mProduction false, mJava1_4 false, mJava1_5 true, mJava1_6 false
420
   */
421
  void set1_5()
422
  {
423
    mLogger.debug("set1_5");
424
    mDebug = false;
425
    mProduction = false;
426
    mJava1_4 = false;
427
    mJava1_5 = true;
428
    mJava1_6 = false;
429
    mAntNone = false;
430
    mJatsNone = false;
431
  }
432
 
433
  /**sets mDebug false, mProduction false, mJava1_4 false, mJava1_5 false, mJava1_6 true
434
   */
435
   void set1_6()
436
   {
437
     mLogger.debug("set1_6");
438
     mDebug = false;
439
     mProduction = false;
440
     mJava1_4 = false;
441
     mJava1_5 = false;
442
     mJava1_6 = true;
443
     mAntNone = false;
444
     mJatsNone = false;
445
   }
446
 
447
  void setAntNone()
448
  {
449
    mLogger.debug("setAntNone");
450
    mDebug = false;
451
    mProduction = false;
452
    mJava1_4 = false;
453
    mJava1_5 = false;
454
    mJava1_6 = false;
455
    mAntNone = true;
456
    mJatsNone = false;
457
  }
458
 
459
  void setJatsNone()
460
  {
461
    mLogger.debug("setJatsNone");
462
    mDebug = false;
463
    mProduction = false;
464
    mJava1_4 = false;
465
    mJava1_5 = false;
466
    mJava1_6 = false;
467
    mAntNone = false;
468
    mJatsNone = true;
469
  }
470
 
471
  /**sets mGeneric true
472
   */
473
  void setGeneric()
474
  {
475
    mLogger.debug("setGeneric");
832 mhunt 476
    mLinux = false;
477
    mSolaris = false;
478
    mWin32 = false;
814 mhunt 479
    mGeneric = true;
480
  }
481
 
482
  /**sets mLinux true, mSolaris false, mWin32 false
483
   */
484
  void setLinux()
485
  {
486
    mLogger.debug("setLinux");
487
    mLinux = true;
488
    mSolaris = false;
489
    mWin32 = false;
490
  }
491
 
492
  /**sets mLinux false, mSolaris true, mWin32 false
493
   */
494
  void setSolaris()
495
  {
496
    mLogger.debug("setSolaris");
497
    mLinux = false;
498
    mSolaris = true;
499
    mWin32 = false;
500
  }
501
 
502
  /**sets mLinux false, mSolaris false, mWin32 true
503
   */
504
  void setWin32()
505
  {
506
    mLogger.debug("setWin32");
507
    mLinux = false;
508
    mSolaris = false;
509
    mWin32 = true;
510
  }
511
 
512
  /**sets mGeneric false
513
   */
514
  void clearGeneric()
515
  {
516
    mLogger.debug("clearGeneric");
517
    mGeneric = false;
518
  }
519
 
520
  /**accessor method
521
   */
522
  boolean getWin32()
523
  {
524
    mLogger.debug("getWin32");
525
    mLogger.info("getWin32 returned " + mWin32);
526
    return mWin32;
527
  }
528
 
529
  /**accessor method
530
   */
531
  boolean getGeneric()
532
  {
533
    mLogger.debug("getGeneric");
534
    mLogger.info("getGeneric returned " + mGeneric);
535
    return mGeneric;
536
  }
537
 
538
  /**accessor method
539
   */
540
  boolean getSolaris()
541
  {
542
    mLogger.debug("getSolaris");
543
    mLogger.info("getSolaris returned " + mSolaris);
544
    return mSolaris;
545
  }
546
 
547
  /**accessor method
548
   */
549
  boolean getLinux()
550
  {
551
    mLogger.debug("getLinux");
552
    mLogger.info("getLinux returned " + mLinux);
553
    return mLinux;
554
  }
555
}