hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java
author duke
Wed, 05 Jul 2017 22:53:30 +0200
changeset 43880 b5015f742ba6
parent 38247 6ff550a6307e
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38247
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     1
/*
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     2
 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     4
 *
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     7
 * published by the Free Software Foundation.
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     8
 *
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    13
 * accompanied this code).
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    14
 *
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    18
 *
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    21
 * questions.
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    22
 *
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    23
 */
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    24
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    25
package build.tools.projectcreator;
6ff550a6307e 8156018: Hotspot visual studio project generation broken
erikj
parents: 19277
diff changeset
    26
13892
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    27
import java.nio.file.FileSystems;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    28
import java.nio.file.Path;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    29
import java.nio.file.SimpleFileVisitor;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    30
import java.util.HashSet;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    31
import java.util.Stack;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    32
import java.util.Vector;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    33
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    34
public class FileTreeCreator extends SimpleFileVisitor<Path>
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    35
{
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    36
   Path vcProjLocation;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    37
   Path startDir;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    38
   final int startDirLength;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    39
   Stack<DirAttributes> attributes = new Stack<DirAttributes>();
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    40
   Vector<BuildConfig> allConfigs;
19277
8952a5e25673 8022740: Visual 2008 IDE build is broken
iklam
parents: 13892
diff changeset
    41
   WinGammaPlatform wg;
8952a5e25673 8022740: Visual 2008 IDE build is broken
iklam
parents: 13892
diff changeset
    42
   WinGammaPlatformVC10 wg10;
13892
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    43
19277
8952a5e25673 8022740: Visual 2008 IDE build is broken
iklam
parents: 13892
diff changeset
    44
   public FileTreeCreator(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {
13892
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    45
      super();
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    46
      this.wg = wg;
19277
8952a5e25673 8022740: Visual 2008 IDE build is broken
iklam
parents: 13892
diff changeset
    47
      if (wg instanceof WinGammaPlatformVC10) {
8952a5e25673 8022740: Visual 2008 IDE build is broken
iklam
parents: 13892
diff changeset
    48
          wg10 = (WinGammaPlatformVC10)wg;
8952a5e25673 8022740: Visual 2008 IDE build is broken
iklam
parents: 13892
diff changeset
    49
      }
13892
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    50
      this.allConfigs = allConfigs;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    51
      this.startDir = startDir;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    52
      startDirLength = startDir.toAbsolutePath().toString().length();
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    53
      vcProjLocation = FileSystems.getDefault().getPath(allConfigs.firstElement().get("BuildSpace"));
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    54
      attributes.push(new DirAttributes());
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    55
   }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    56
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    57
   public class DirAttributes {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    58
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    59
      private HashSet<BuildConfig> ignores;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    60
      private HashSet<BuildConfig> disablePch;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    61
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    62
      public DirAttributes() {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    63
         ignores = new HashSet<BuildConfig>();
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    64
         disablePch = new HashSet<BuildConfig>();
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    65
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    66
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    67
      public DirAttributes(HashSet<BuildConfig> excludes2, HashSet<BuildConfig> disablePch2) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    68
         ignores = excludes2;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    69
         disablePch = disablePch2;
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    70
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    71
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    72
      @SuppressWarnings("unchecked")
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    73
      public DirAttributes clone() {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    74
         return new DirAttributes((HashSet<BuildConfig>)this.ignores.clone(), (HashSet<BuildConfig>)this.disablePch.clone());
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    75
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    76
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    77
      public void setIgnore(BuildConfig conf) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    78
         ignores.add(conf);
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    79
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    80
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    81
      public boolean hasIgnore(BuildConfig cfg) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    82
         return ignores.contains(cfg);
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    83
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    84
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    85
      public void removeFromIgnored(BuildConfig cfg) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    86
         ignores.remove(cfg);
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    87
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    88
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    89
      public void setDisablePch(BuildConfig conf) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    90
         disablePch.add(conf);
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    91
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    92
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    93
      public boolean hasDisablePch(BuildConfig cfg) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    94
         return disablePch.contains(cfg);
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    95
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    96
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    97
      public void removeFromDisablePch(BuildConfig cfg) {
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    98
         disablePch.remove(cfg);
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
    99
      }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
   100
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
   101
   }
9ba13acea673 7163863: Updated projectcreator
neliasso
parents:
diff changeset
   102
}