1695b41eeSopenharmony_ci// Copyright 2015 Google Inc. All Rights Reserved. 2695b41eeSopenharmony_ci// 3695b41eeSopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4695b41eeSopenharmony_ci// you may not use this file except in compliance with the License. 5695b41eeSopenharmony_ci// You may obtain a copy of the License at 6695b41eeSopenharmony_ci// 7695b41eeSopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8695b41eeSopenharmony_ci// 9695b41eeSopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10695b41eeSopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 11695b41eeSopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12695b41eeSopenharmony_ci// See the License for the specific language governing permissions and 13695b41eeSopenharmony_ci// limitations under the License. 14695b41eeSopenharmony_ci 15695b41eeSopenharmony_ci#ifndef NINJA_DYNDEP_LOADER_H_ 16695b41eeSopenharmony_ci#define NINJA_DYNDEP_LOADER_H_ 17695b41eeSopenharmony_ci 18695b41eeSopenharmony_ci#include <map> 19695b41eeSopenharmony_ci#include <string> 20695b41eeSopenharmony_ci#include <vector> 21695b41eeSopenharmony_ci 22695b41eeSopenharmony_cistruct DiskInterface; 23695b41eeSopenharmony_cistruct Edge; 24695b41eeSopenharmony_cistruct Node; 25695b41eeSopenharmony_cistruct State; 26695b41eeSopenharmony_ci 27695b41eeSopenharmony_ci/// Store dynamically-discovered dependency information for one edge. 28695b41eeSopenharmony_cistruct Dyndeps { 29695b41eeSopenharmony_ci Dyndeps() : used_(false), restat_(false) {} 30695b41eeSopenharmony_ci bool used_; 31695b41eeSopenharmony_ci bool restat_; 32695b41eeSopenharmony_ci std::vector<Node*> implicit_inputs_; 33695b41eeSopenharmony_ci std::vector<Node*> implicit_outputs_; 34695b41eeSopenharmony_ci}; 35695b41eeSopenharmony_ci 36695b41eeSopenharmony_ci/// Store data loaded from one dyndep file. Map from an edge 37695b41eeSopenharmony_ci/// to its dynamically-discovered dependency information. 38695b41eeSopenharmony_ci/// This is a struct rather than a typedef so that we can 39695b41eeSopenharmony_ci/// forward-declare it in other headers. 40695b41eeSopenharmony_cistruct DyndepFile: public std::map<Edge*, Dyndeps> {}; 41695b41eeSopenharmony_ci 42695b41eeSopenharmony_ci/// DyndepLoader loads dynamically discovered dependencies, as 43695b41eeSopenharmony_ci/// referenced via the "dyndep" attribute in build files. 44695b41eeSopenharmony_cistruct DyndepLoader { 45695b41eeSopenharmony_ci DyndepLoader(State* state, DiskInterface* disk_interface) 46695b41eeSopenharmony_ci : state_(state), disk_interface_(disk_interface) {} 47695b41eeSopenharmony_ci 48695b41eeSopenharmony_ci /// Load a dyndep file from the given node's path and update the 49695b41eeSopenharmony_ci /// build graph with the new information. One overload accepts 50695b41eeSopenharmony_ci /// a caller-owned 'DyndepFile' object in which to store the 51695b41eeSopenharmony_ci /// information loaded from the dyndep file. 52695b41eeSopenharmony_ci bool LoadDyndeps(Node* node, std::string* err) const; 53695b41eeSopenharmony_ci bool LoadDyndeps(Node* node, DyndepFile* ddf, std::string* err) const; 54695b41eeSopenharmony_ci 55695b41eeSopenharmony_ci private: 56695b41eeSopenharmony_ci bool LoadDyndepFile(Node* file, DyndepFile* ddf, std::string* err) const; 57695b41eeSopenharmony_ci 58695b41eeSopenharmony_ci bool UpdateEdge(Edge* edge, Dyndeps const* dyndeps, std::string* err) const; 59695b41eeSopenharmony_ci 60695b41eeSopenharmony_ci State* state_; 61695b41eeSopenharmony_ci DiskInterface* disk_interface_; 62695b41eeSopenharmony_ci}; 63695b41eeSopenharmony_ci 64695b41eeSopenharmony_ci#endif // NINJA_DYNDEP_LOADER_H_ 65