1 //===- BuildNode.h ----------------------------------------------*- C++ -*-===// 2 // 3 // This source file is part of the Swift.org open source project 4 // 5 // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors 6 // Licensed under Apache License v2.0 with Runtime Library Exception 7 // 8 // See http://swift.org/LICENSE.txt for license information 9 // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLBUILD_BUILDSYSTEM_BUILDNODE_H 14 #define LLBUILD_BUILDSYSTEM_BUILDNODE_H 15 16 #include "BuildDescription.h" 17 18 #include "llbuild/Basic/LLVM.h" 19 #include "llbuild/BuildSystem/BuildFile.h" 20 21 #include "llvm/ADT/StringRef.h" 22 23 namespace llbuild { 24 namespace basic { 25 26 struct FileInfo; 27 class FileSystem; 28 29 } 30 31 namespace buildsystem { 32 33 // FIXME: Figure out how this is going to be organized. 34 class BuildNode : public Node { 35 /// Whether or not this node is a directory. 36 // 37 // FIXME: We need a type enumeration here. 38 bool directory; 39 40 /// Whether or not this node is "virtual" (i.e., not a filesystem path). 41 bool virtualNode; 42 43 /// Whether this node represents a "command timestamp". 44 /// 45 /// Such nodes should always also be virtual. 46 bool commandTimestamp; 47 48 /// Whether this node is mutated by the build. 49 /// 50 /// This flag cannot currently be honored to provide a strongly consistent 51 /// build, but it is used to detect when the file system information on a node 52 /// cannot be safely used to track *output* file state. 53 bool mutated; 54 55 public: BuildNode(StringRef name,bool isDirectory,bool isVirtual,bool isCommandTimestamp,bool isMutated)56 explicit BuildNode(StringRef name, bool isDirectory, bool isVirtual, 57 bool isCommandTimestamp, bool isMutated) 58 : Node(name), directory(isDirectory), virtualNode(isVirtual), 59 commandTimestamp(isCommandTimestamp), mutated(isMutated) {} 60 61 /// Check whether this is a "virtual" (non-filesystem related) node. isVirtual()62 bool isVirtual() const { return virtualNode; } 63 64 /// Check whether this node is intended to represent a directory's contents 65 /// recursively. isDirectory()66 bool isDirectory() const { return directory; } 67 isCommandTimestamp()68 bool isCommandTimestamp() const { return commandTimestamp; } 69 isMutated()70 bool isMutated() const { return mutated; } 71 72 virtual bool configureAttribute(const ConfigureContext& ctx, StringRef name, 73 StringRef value) override; 74 virtual bool configureAttribute(const ConfigureContext& ctx, StringRef name, 75 ArrayRef<StringRef> values) override; 76 virtual bool configureAttribute( 77 const ConfigureContext& ctx, StringRef name, 78 ArrayRef<std::pair<StringRef, StringRef>> values) override; 79 80 basic::FileInfo getFileInfo(basic::FileSystem&) const; 81 basic::FileInfo getLinkInfo(basic::FileSystem&) const; 82 }; 83 84 } 85 } 86 87 #endif 88