Subversion Repositories DevTools

Rev

Go to most recent revision | 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;
908 mhunt 84
 
85
  private boolean mSupported = true;
814 mhunt 86
 
87
  /**constructor
88
   */
89
  BuildStandard(RippleEngine rippleEngine)
90
  {
91
    mLogger.debug("BuildStandard");
92
    mRippleEngine = rippleEngine;
93
  }
94
 
908 mhunt 95
  /**constructor
814 mhunt 96
   */
908 mhunt 97
  BuildStandard(RippleEngine rippleEngine, String buildMachine, String buildStandardAddendum)
814 mhunt 98
  {
908 mhunt 99
    mLogger.debug("BuildStandard");
100
    mRippleEngine = rippleEngine;
101
 
102
    if ( buildMachine.compareTo("Solaris") == 0 )
103
    {
104
      setSolaris();
105
    }
106
    else if ( buildMachine.compareTo("Win32") == 0 )
107
    {
108
      setWin32();
109
    }
110
    else if ( buildMachine.compareTo("Linux") == 0 )
111
    {
112
      setLinux();
113
    }
114
    else if ( buildMachine.compareTo("Generic") == 0 )
115
    {
116
      setGeneric();
117
    }
118
    else
119
    {
120
      mSupported = false;
121
    }
122
 
123
    if ( buildStandardAddendum.compareTo("Production") == 0 )
124
    {
125
      setProduction();
126
    }
127
    else if ( buildStandardAddendum.compareTo("Debug") == 0 )
128
    {
129
      setDebug();
130
    }
131
    else if ( buildStandardAddendum.compareTo("Production and Debug") == 0 )
132
    {
133
      setAll();
134
    }
135
    else if ( buildStandardAddendum.compareTo("Java 1.4") == 0 )
136
    {
137
      set1_4();
138
    }
139
    else if ( buildStandardAddendum.compareTo("Java 1.5") == 0 )
140
    {
141
      set1_5();
142
    }
143
    else if ( buildStandardAddendum.compareTo("Java 1.6") == 0 )
144
    {
145
      set1_6();
146
    }
147
    else
148
    {
149
      mSupported = false;
150
    }
151
  }
152
 
153
  /**returns for xml purposes
154
   * "<platform gbe_machtype="win32"/>",
155
   * "<platform gbe_machtype="solaris10_sparc32"/>"
156
   * "<platform gbe_machtype="solaris10_x86"/>"
157
   * "<platform gbe_machtype="sparc"/>"
158
   * "<platform gbe_machtype="linux_i386"/>"
159
   * 
160
   * returns for non xml purposes
161
   * "win32",
162
   * "solaris10_sparc32"
163
   * "solaris10_x86"
164
   * "sparc"
165
   * "linux_i386"
166
   */
167
  String getPlatform(boolean utf, boolean xml)
168
  {
814 mhunt 169
     mLogger.debug("getPlatform");  
170
     String retVal = new String();
171
 
172
     if (mGeneric && mRippleEngine.mDaemon)
173
     {
174
       mLogger.info("getPlatform mGeneric && mRippleEngine.mDaemon");
175
 
908 mhunt 176
       if ( xml )
177
       {
178
         retVal = "  <platform gbe_machtype=\"";
179
       }
180
 
814 mhunt 181
       if ( utf )
182
       {
183
         mLogger.info("getPlatform utf");
184
         // avoid reliance on environment variables
185
         retVal += "win32\"/>";
186
       }
187
       else
188
       {
189
         // Package.mGenericMachtype has been checked to be not null
190
         if ( Package.mGenericMachtype.compareTo("win32") == 0
191
           || Package.mGenericMachtype.compareTo("solaris10_sparc32") == 0
192
           || Package.mGenericMachtype.compareTo("solaris10_x86") == 0
193
           || Package.mGenericMachtype.compareTo("sparc") == 0
194
           || Package.mGenericMachtype.compareTo("linux_i386") == 0 )
195
         {
196
           retVal += Package.mGenericMachtype;
908 mhunt 197
 
198
           if ( xml )
199
           {
200
             retVal += "\"/>";
201
           }
814 mhunt 202
         }
203
       }
204
     }
205
     else if (mGeneric)
206
     {
207
       mLogger.info("getPlatform mGeneric");
864 mhunt 208
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 209
       {
864 mhunt 210
         String gbemachtype = it.next();
814 mhunt 211
 
212
         if ( gbemachtype.compareTo("win32") == 0 ||
213
              gbemachtype.compareTo("linux_i386") == 0 ||
214
              gbemachtype.compareTo("sparc") == 0 ||
215
              gbemachtype.compareTo("solaris10_x86") == 0 ||
216
              gbemachtype.compareTo("solaris10_sparc32") == 0 )
217
         {
218
           if ( retVal.length() > 0 )
219
           {
220
             retVal += System.getProperty("line.separator");
221
           }
908 mhunt 222
 
223
           if ( xml )
224
           {
225
             retVal += "  <platform gbe_machtype=\"";
226
           }
227
 
814 mhunt 228
           retVal += gbemachtype;
908 mhunt 229
 
230
           if ( xml )
231
           {
232
             retVal += "\"/>";
233
           }
814 mhunt 234
         }
235
       }
236
     }
237
     else if (mWin32)
238
     {
239
       mLogger.info("getPlatform mWin32");
864 mhunt 240
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 241
       {
864 mhunt 242
         String gbemachtype = it.next();
814 mhunt 243
 
244
         if ( gbemachtype.compareTo("win32") == 0 )
245
         {
908 mhunt 246
           if ( xml )
247
           {
248
             retVal = "  <platform gbe_machtype=\"win32\"/>";
249
           }
250
           else
251
           {
252
             retVal = "win32";
253
           }
814 mhunt 254
           break;
255
         }
256
       }
257
     }
258
     else if (mSolaris)
259
     {
260
       mLogger.info("getPlatform mSolaris");
864 mhunt 261
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 262
       {
864 mhunt 263
         String gbemachtype = it.next();
814 mhunt 264
 
265
         if ( gbemachtype.compareTo("sparc") == 0 || gbemachtype.compareTo("solaris10_x86") == 0 || gbemachtype.compareTo("solaris10_sparc32") == 0 )
266
         {
267
           if ( retVal.length() > 0 )
268
           {
908 mhunt 269
             if ( xml )
270
             {
271
               retVal += System.getProperty("line.separator");
272
             }
273
             else
274
             {
275
               retVal += "<br>";
276
             }
814 mhunt 277
           }
908 mhunt 278
 
279
           if ( xml )
280
           {
281
             retVal += "  <platform gbe_machtype=\"";
282
           }
283
 
814 mhunt 284
           retVal += gbemachtype;
908 mhunt 285
 
286
           if ( xml )
287
           {
288
             retVal += "\"/>";
289
           }
814 mhunt 290
         }
291
       }
292
     }
293
     else
294
     {
295
       mLogger.info("getPlatform mLinux");
864 mhunt 296
       for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 297
       {
864 mhunt 298
         String gbemachtype = it.next();
814 mhunt 299
 
300
         if ( gbemachtype.compareTo("linux_i386") == 0 )
301
         {
908 mhunt 302
           if ( xml )
303
           {
304
             retVal = "  <platform gbe_machtype=\"linux_i386\"/>";
305
           }
306
           else
307
           {
308
             retVal = "linux_i386";
309
           }
814 mhunt 310
           break;
311
         }
312
       }
313
     }
314
 
315
     mLogger.info("getPlatform returned " + retVal);
316
     return retVal;
317
   }
318
 
908 mhunt 319
  /**returns for xml purposes
320
   * "<ant java="1.4"/>",
321
   * "<ant java="1.5"/>",
322
   * "<ant java="1.6"/>",
323
   * "<ant java="none"/>",
324
   * "<jats target="production"/>",
325
   * "<jats target="debug"/>",
326
   * "<jats target="all"/>",
327
   * "<jats target="none"/>"
328
   * 
329
   * returns for non xml purposes
330
   * "ant java 1.4",
331
   * "ant java 1.5",
332
   * "ant java 1.6",
333
   * "ant none",
334
   * "jats production",
335
   * "jats debug",
336
   * "jats all",
337
   * "jats none"
814 mhunt 338
   */
908 mhunt 339
  String getBuildStandard(boolean utf, boolean xml)
814 mhunt 340
  {
341
    mLogger.debug("getBuildStandard");
342
    boolean validPlatform = false;
343
    int numberOfPlatforms = 0;
344
    String retVal = new String();
345
 
346
    if (mGeneric && mRippleEngine.mDaemon)
347
    {
348
      mLogger.info("getBuildStandard mGeneric && mRippleEngine.mDaemon");
349
 
350
      if ( utf )
351
      {
352
        mLogger.info("getBuildStandard utf");
353
        // avoid reliance on environment variables
354
        validPlatform = true;
355
        numberOfPlatforms = 1;
356
      }
357
      else
358
      {
359
        // Package.mGenericMachtype has been checked to be not null
360
        if ( Package.mGenericMachtype.compareTo("win32") == 0
361
          || Package.mGenericMachtype.compareTo("solaris10_sparc32") == 0
362
          || Package.mGenericMachtype.compareTo("solaris10_x86") == 0
363
          || Package.mGenericMachtype.compareTo("sparc") == 0
364
          || Package.mGenericMachtype.compareTo("linux_i386") == 0 )
365
        {
366
          validPlatform = true;
367
          numberOfPlatforms = 1;
368
        }
369
      }
370
    }
371
    else if (mGeneric)
372
    {
373
      mLogger.info("getBuildStandard mGeneric");
864 mhunt 374
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 375
      {
864 mhunt 376
        String gbemachtype = it.next();
814 mhunt 377
 
378
        if ( gbemachtype.compareTo("win32") == 0 ||
379
             gbemachtype.compareTo("linux_i386") == 0 ||
380
             gbemachtype.compareTo("sparc") == 0 ||
381
             gbemachtype.compareTo("solaris10_x86") == 0 ||
382
             gbemachtype.compareTo("solaris10_sparc32") == 0 )
383
        {
384
          validPlatform = true;
385
          numberOfPlatforms++;
386
        }
387
      }
388
    }
389
    else if (mWin32)
390
    {
391
      mLogger.info("getBuildStandard mWin32");
864 mhunt 392
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 393
      {
864 mhunt 394
        String gbemachtype = it.next();
814 mhunt 395
 
396
        if ( gbemachtype.compareTo("win32") == 0 )
397
        {
398
          validPlatform = true;
399
          numberOfPlatforms = 1;
400
          break;
401
        }
402
      }
403
    }
404
    else if (mSolaris)
405
    {
406
      mLogger.info("getBuildStandard mSolaris");
864 mhunt 407
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 408
      {
864 mhunt 409
        String gbemachtype = it.next();
814 mhunt 410
 
411
        if ( gbemachtype.compareTo("sparc") == 0 || gbemachtype.compareTo("solaris10_x86") == 0 || gbemachtype.compareTo("solaris10_sparc32") == 0 )
412
        {
413
          validPlatform = true;
414
          numberOfPlatforms++;
415
        }
416
      }
417
    }
418
    else
419
    {
420
      mLogger.info("getBuildStandard mLinux");
864 mhunt 421
      for (Iterator<String> it = mRippleEngine.mGbeMachtypeCollection.iterator(); it.hasNext(); )
814 mhunt 422
      {
864 mhunt 423
        String gbemachtype = it.next();
814 mhunt 424
 
425
        if ( gbemachtype.compareTo("linux_i386") == 0 )
426
        {
427
          validPlatform = true;
428
          numberOfPlatforms = 1;
429
          break;
430
        }
431
      }
432
    }
433
 
434
    if (validPlatform)
435
    {
436
 
437
      if (mJava1_4)
438
      {
908 mhunt 439
        if ( xml )
440
        {
441
          retVal = "  <ant java=\"1.4\"/>";
442
        }
443
        else
444
        {
445
          retVal = "ant java 1.4";
446
        }
814 mhunt 447
      }
448
      else if (mJava1_5)
449
      {
908 mhunt 450
        if ( xml )
451
        {
452
          retVal = "  <ant java=\"1.5\"/>";
453
        }
454
        else
455
        {
456
          retVal = "ant java 1.5";
457
        }
814 mhunt 458
      }
459
      else if (mJava1_6)
460
      {
908 mhunt 461
        if ( xml )
462
        {
463
          retVal = "  <ant java=\"1.6\"/>";
464
        }
465
        else
466
        {
467
          retVal = "ant java 1.6";
468
        }
814 mhunt 469
      }
470
      else if (mAntNone)
471
      {
908 mhunt 472
        if ( xml )
473
        {
474
          retVal = "  <ant java=\"none\"/>";
475
        }
476
        else
477
        {
478
          retVal = "ant none";
479
        }
814 mhunt 480
      }
481
      else if (mJatsNone)
482
      {
908 mhunt 483
        if ( xml )
484
        {
485
          retVal = "  <jats target=\"none\"/>";
486
        }
487
        else
488
        {
489
          retVal = "jats none";
490
        }
814 mhunt 491
      }
492
      else
493
      {
494
        if (mProduction)
495
        {
496
          if (mDebug)
497
          {
908 mhunt 498
            if ( xml )
499
            {
500
              retVal = "  <jats target=\"all\"/>";
501
            }
502
            else
503
            {
504
              retVal = "jats all";
505
            }
814 mhunt 506
          }
507
          else
508
          {
908 mhunt 509
            if ( xml )
510
            {
511
              retVal = "  <jats target=\"production\"/>";
512
            }
513
            else
514
            {
515
              retVal = "jats production";
516
            }
814 mhunt 517
          }
518
        }
519
        else
520
        {
908 mhunt 521
          if ( xml )
522
          {
523
            retVal = "  <jats target=\"debug\"/>";
524
          }
525
          else
526
          {
527
            retVal = "jats debug";
528
          }
814 mhunt 529
        }
530
      }
908 mhunt 531
 
814 mhunt 532
      String line = new String(retVal);
533
 
534
      for ( int i = 1; i < numberOfPlatforms; i++ )
535
      {
908 mhunt 536
        if ( xml )
537
        {
538
          retVal += System.getProperty("line.separator");
539
        }
540
        else
541
        {
542
          retVal += "<br>";
543
        }
814 mhunt 544
        retVal += line;
545
      }
546
    }
547
 
548
    mLogger.info("getBuildStandard returned " + retVal);
549
    return retVal;
550
  }
551
 
552
  /**sets mDebug true, mProduction false, mJava1_4 false, mJava1_5 false, mJava1_6 false
553
   */
554
  void setDebug()
555
  {
556
    mLogger.debug("setDebug");
557
    mDebug = true;
558
    mProduction = false;
559
    mJava1_4 = false;
560
    mJava1_5 = false;
561
    mJava1_6 = false;
562
    mAntNone = false;
563
    mJatsNone = false;
564
  }
565
 
566
  /**sets mDebug false, mProduction true, mJava1_4 false, mJava1_5 false, mJava1_6 false
567
   */
568
  void setProduction()
569
  {
570
    mLogger.debug("setProduction");
571
    mDebug = false;
572
    mProduction = true;
573
    mJava1_4 = false;
574
    mJava1_5 = false;
575
    mJava1_6 = false;
576
    mAntNone = false;
577
    mJatsNone = false;
578
  }
579
 
580
  /**sets mDebug true, mProduction true, mJava1_4 false, mJava1_5 false, mJava1_6 false
581
   */
582
  void setAll()
583
  {
584
    mLogger.debug("setAll");
585
    mDebug = true;
586
    mProduction = true;
587
    mJava1_4 = false;
588
    mJava1_5 = false;
589
    mJava1_6 = false;
590
    mAntNone = false;
591
    mJatsNone = false;
592
  }
593
 
594
  /**sets mDebug false, mProduction false, mJava1_4 true, mJava1_5 false, mJava1_6 false
595
   */
596
  void set1_4()
597
  {
598
    mLogger.debug("set1_4");
599
    mDebug = false;
600
    mProduction = false;
601
    mJava1_4 = true;
602
    mJava1_5 = false;
603
    mJava1_6 = false;
604
    mAntNone = false;
605
    mJatsNone = false;
606
  }
607
 
608
  /**sets mDebug false, mProduction false, mJava1_4 false, mJava1_5 true, mJava1_6 false
609
   */
610
  void set1_5()
611
  {
612
    mLogger.debug("set1_5");
613
    mDebug = false;
614
    mProduction = false;
615
    mJava1_4 = false;
616
    mJava1_5 = true;
617
    mJava1_6 = false;
618
    mAntNone = false;
619
    mJatsNone = false;
620
  }
621
 
622
  /**sets mDebug false, mProduction false, mJava1_4 false, mJava1_5 false, mJava1_6 true
623
   */
624
   void set1_6()
625
   {
626
     mLogger.debug("set1_6");
627
     mDebug = false;
628
     mProduction = false;
629
     mJava1_4 = false;
630
     mJava1_5 = false;
631
     mJava1_6 = true;
632
     mAntNone = false;
633
     mJatsNone = false;
634
   }
635
 
636
  void setAntNone()
637
  {
638
    mLogger.debug("setAntNone");
639
    mDebug = false;
640
    mProduction = false;
641
    mJava1_4 = false;
642
    mJava1_5 = false;
643
    mJava1_6 = false;
644
    mAntNone = true;
645
    mJatsNone = false;
646
  }
647
 
648
  void setJatsNone()
649
  {
650
    mLogger.debug("setJatsNone");
651
    mDebug = false;
652
    mProduction = false;
653
    mJava1_4 = false;
654
    mJava1_5 = false;
655
    mJava1_6 = false;
656
    mAntNone = false;
657
    mJatsNone = true;
658
  }
659
 
660
  /**sets mGeneric true
661
   */
662
  void setGeneric()
663
  {
664
    mLogger.debug("setGeneric");
832 mhunt 665
    mLinux = false;
666
    mSolaris = false;
667
    mWin32 = false;
814 mhunt 668
    mGeneric = true;
669
  }
670
 
671
  /**sets mLinux true, mSolaris false, mWin32 false
672
   */
673
  void setLinux()
674
  {
675
    mLogger.debug("setLinux");
676
    mLinux = true;
677
    mSolaris = false;
678
    mWin32 = false;
679
  }
680
 
681
  /**sets mLinux false, mSolaris true, mWin32 false
682
   */
683
  void setSolaris()
684
  {
685
    mLogger.debug("setSolaris");
686
    mLinux = false;
687
    mSolaris = true;
688
    mWin32 = false;
689
  }
690
 
691
  /**sets mLinux false, mSolaris false, mWin32 true
692
   */
693
  void setWin32()
694
  {
695
    mLogger.debug("setWin32");
696
    mLinux = false;
697
    mSolaris = false;
698
    mWin32 = true;
699
  }
700
 
701
  /**sets mGeneric false
702
   */
703
  void clearGeneric()
704
  {
705
    mLogger.debug("clearGeneric");
706
    mGeneric = false;
707
  }
708
 
709
  /**accessor method
710
   */
711
  boolean getWin32()
712
  {
713
    mLogger.debug("getWin32");
714
    mLogger.info("getWin32 returned " + mWin32);
715
    return mWin32;
716
  }
717
 
718
  /**accessor method
719
   */
720
  boolean getGeneric()
721
  {
722
    mLogger.debug("getGeneric");
723
    mLogger.info("getGeneric returned " + mGeneric);
724
    return mGeneric;
725
  }
726
 
727
  /**accessor method
728
   */
729
  boolean getSolaris()
730
  {
731
    mLogger.debug("getSolaris");
732
    mLogger.info("getSolaris returned " + mSolaris);
733
    return mSolaris;
734
  }
735
 
736
  /**accessor method
737
   */
738
  boolean getLinux()
739
  {
740
    mLogger.debug("getLinux");
741
    mLogger.info("getLinux returned " + mLinux);
742
    return mLinux;
743
  }
908 mhunt 744
 
745
  /**accessor method
746
   */
747
  boolean supportedBuildStandard()
748
  {
749
    mLogger.debug("supportedBuildStandard");
750
    mLogger.info("supportedBuildStandard returned " + mSupported);
751
    return mSupported;
752
  }
814 mhunt 753
}