1/****************************************************************************
2 * Copyright (C) 2012-2016 Woboq GmbH
3 * Olivier Goffart <contact at woboq.com>
4 * https://woboq.com/codebrowser.html
5 *
6 * This file is part of the Woboq Code Browser.
7 *
8 * Commercial License Usage:
9 * Licensees holding valid commercial licenses provided by Woboq may use
10 * this file in accordance with the terms contained in a written agreement
11 * between the licensee and Woboq.
12 * For further information see https://woboq.com/codebrowser.html
13 *
14 * Alternatively, this work may be used under a Creative Commons
15 * Attribution-NonCommercial-ShareAlike 3.0 (CC-BY-NC-SA 3.0) License.
16 * http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US
17 * This license does not allow you to use the code browser to assist the
18 * development of your commercial software. If you intent to do so, consider
19 * purchasing a commercial licence.
20 ****************************************************************************/
21
22#pragma once
23
24#include <llvm/ADT/StringRef.h>
25#include <string>
26#include <unordered_map>
27#include <vector>
28
29struct ProjectInfo
30{
31 std::string name;
32 std::string source_path;
33 // std::string description;
34 // std::string version_info;
35 // std::string repo_url; //may contains tags;
36 std::string revision;
37
38 std::string external_root_url;
39
40 // TODO
41 std::string fileRepoUrl(const std::string &file) const
42 {
43 return {};
44 }
45 enum Type {
46 Normal,
47 Internal, // includes and stuffs
48 External, // links to external projects somewhere else, do not generate refs or anything,
49 // and link to a different ref source
50 } type = Normal;
51
52 ProjectInfo(std::string name, std::string source_path, Type t = Normal)
53 : name(std::move(name))
54 , source_path(std::move(source_path))
55 , type(t)
56 {
57 }
58 ProjectInfo(std::string name, std::string source_path, std::string rev)
59 : name(std::move(name))
60 , source_path(std::move(source_path))
61 , revision(std::move(rev))
62 {
63 }
64};
65
66struct ProjectManager
67{
68 explicit ProjectManager(std::string outputPrefix, std::string _dataPath);
69
70 bool addProject(ProjectInfo info);
71
72 std::vector<ProjectInfo> projects;
73
74 std::string outputPrefix;
75 std::string dataPath;
76
77 // the file name need to be canonicalized
78 ProjectInfo *projectForFile(llvm::StringRef filename); // don't keep a cache
79
80 // return true if the filename should be proesseded.
81 // 'project' is the value returned by projectForFile
82 bool shouldProcess(llvm::StringRef filename, ProjectInfo *project);
83
84 std::string includeRecovery(llvm::StringRef includeName, llvm::StringRef from);
85
86private:
87 static std::vector<ProjectInfo> systemProjects();
88
89 std::unordered_multimap<std::string, std::string> includeRecoveryCache;
90};
91

source code of codebrowser/generator/projectmanager.h