1 | /* |
---|
2 | * |
---|
3 | * Copyright (c) 2003 Dr John Maddock |
---|
4 | * Use, modification and distribution is subject to the |
---|
5 | * Boost Software License, Version 1.0. (See accompanying file |
---|
6 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | * |
---|
8 | */ |
---|
9 | |
---|
10 | #include "bcp.hpp" |
---|
11 | #include <string> |
---|
12 | #include <cstring> |
---|
13 | #include <list> |
---|
14 | #include <set> |
---|
15 | #include <map> |
---|
16 | #include <boost/filesystem/path.hpp> |
---|
17 | |
---|
18 | namespace fs = boost::filesystem; |
---|
19 | |
---|
20 | class fileview; |
---|
21 | |
---|
22 | // |
---|
23 | //path operations: |
---|
24 | // |
---|
25 | int compare_paths(const fs::path& a, const fs::path& b); |
---|
26 | inline bool equal_paths(const fs::path& a, const fs::path& b) |
---|
27 | { return compare_paths(a, b) == 0; } |
---|
28 | |
---|
29 | struct path_less |
---|
30 | { |
---|
31 | bool operator()(const fs::path& a, const fs::path& b)const |
---|
32 | { return compare_paths(a, b) < 0; } |
---|
33 | }; |
---|
34 | |
---|
35 | struct license_data |
---|
36 | { |
---|
37 | std::set<fs::path, path_less> files; |
---|
38 | std::set<std::string> authors; |
---|
39 | }; |
---|
40 | |
---|
41 | class bcp_implementation |
---|
42 | : public bcp_application |
---|
43 | { |
---|
44 | public: |
---|
45 | bcp_implementation(); |
---|
46 | ~bcp_implementation(); |
---|
47 | private: |
---|
48 | // |
---|
49 | // the following are the overridden virtuals from the base class: |
---|
50 | // |
---|
51 | void enable_list_mode(); |
---|
52 | void enable_summary_list_mode(); |
---|
53 | void enable_cvs_mode(); |
---|
54 | void enable_unix_lines(); |
---|
55 | void enable_scan_mode(); |
---|
56 | void enable_license_mode(); |
---|
57 | void enable_bsl_convert_mode(); |
---|
58 | void enable_bsl_summary_mode(); |
---|
59 | void set_boost_path(const char* p); |
---|
60 | void set_destination(const char* p); |
---|
61 | void add_module(const char* p); |
---|
62 | |
---|
63 | virtual int run(); |
---|
64 | private: |
---|
65 | // internal helper functions: |
---|
66 | void scan_cvs_path(const fs::path& p); |
---|
67 | void add_path(const fs::path& p); |
---|
68 | void add_directory(const fs::path& p); |
---|
69 | void add_file(const fs::path& p); |
---|
70 | void copy_path(const fs::path& p); |
---|
71 | void add_file_dependencies(const fs::path& p, bool scanfile); |
---|
72 | bool is_source_file(const fs::path& p); |
---|
73 | bool is_html_file(const fs::path& p); |
---|
74 | bool is_binary_file(const fs::path& p); |
---|
75 | void add_dependent_lib(const std::string& libname, const fs::path& p); |
---|
76 | void create_path(const fs::path& p); |
---|
77 | // license code: |
---|
78 | void scan_license(const fs::path& p, const fileview& v); |
---|
79 | void output_license_info(); |
---|
80 | |
---|
81 | std::list<std::string> m_module_list; // the modules to process |
---|
82 | bool m_list_mode; // list files only |
---|
83 | bool m_list_summary_mode; // list file summary only |
---|
84 | bool m_license_mode; // generate license information for files listed |
---|
85 | bool m_cvs_mode; // check cvs for files |
---|
86 | bool m_unix_lines; // fix line endings |
---|
87 | bool m_scan_mode; // scan non-boost files. |
---|
88 | bool m_bsl_convert_mode; // try to convert to the BSL |
---|
89 | bool m_bsl_summary_mode; // summarise BSL issues only |
---|
90 | fs::path m_boost_path; // the path to the boost root |
---|
91 | fs::path m_dest_path; // the path to copy to |
---|
92 | std::map<fs::path, bool, path_less> m_cvs_paths; // valid files under cvs control |
---|
93 | std::set<fs::path, path_less> m_copy_paths; // list of files to copy |
---|
94 | std::map<int, license_data> m_license_data; // licenses in use |
---|
95 | std::set<fs::path, path_less> m_unknown_licenses; // files with no known license |
---|
96 | std::set<fs::path, path_less> m_unknown_authors; // files with no known copyright/author |
---|
97 | std::set<fs::path, path_less> m_can_migrate_to_bsl; // files that can migrate to the BSL |
---|
98 | std::set<fs::path, path_less> m_cannot_migrate_to_bsl; // files that cannot migrate to the BSL |
---|
99 | std::set<std::string> m_bsl_authors; // authors giving blanket permission to use the BSL |
---|
100 | std::set<std::string> m_authors_for_bsl_migration; // authors we need for BSL migration |
---|
101 | std::map<fs::path, std::pair<std::string, std::string>, path_less> m_converted_to_bsl; |
---|
102 | std::map<std::string, std::set<fs::path, path_less> > m_author_data; // all the authors |
---|
103 | std::map<fs::path, fs::path, path_less> m_dependencies; // dependency information |
---|
104 | }; |
---|