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_cvs_mode(); |
---|
53 | void enable_unix_lines(); |
---|
54 | void enable_scan_mode(); |
---|
55 | void enable_license_mode(); |
---|
56 | void enable_bsl_convert_mode(); |
---|
57 | void enable_bsl_summary_mode(); |
---|
58 | void set_boost_path(const char* p); |
---|
59 | void set_destination(const char* p); |
---|
60 | void add_module(const char* p); |
---|
61 | |
---|
62 | virtual int run(); |
---|
63 | private: |
---|
64 | // internal helper functions: |
---|
65 | void scan_cvs_path(const fs::path& p); |
---|
66 | void add_path(const fs::path& p); |
---|
67 | void add_directory(const fs::path& p); |
---|
68 | void add_file(const fs::path& p); |
---|
69 | void copy_path(const fs::path& p); |
---|
70 | void add_file_dependencies(const fs::path& p, bool scanfile); |
---|
71 | bool is_source_file(const fs::path& p); |
---|
72 | bool is_html_file(const fs::path& p); |
---|
73 | bool is_binary_file(const fs::path& p); |
---|
74 | void add_dependent_lib(const std::string& libname, const fs::path& p); |
---|
75 | void create_path(const fs::path& p); |
---|
76 | // license code: |
---|
77 | void scan_license(const fs::path& p, const fileview& v); |
---|
78 | void output_license_info(); |
---|
79 | |
---|
80 | std::list<std::string> m_module_list; // the modules to process |
---|
81 | bool m_list_mode; // list files only |
---|
82 | bool m_license_mode; // generate license information for files listed |
---|
83 | bool m_cvs_mode; // check cvs for files |
---|
84 | bool m_unix_lines; // fix line endings |
---|
85 | bool m_scan_mode; // scan non-boost files. |
---|
86 | bool m_bsl_convert_mode; // try to convert to the BSL |
---|
87 | bool m_bsl_summary_mode; // summarise BSL issues only |
---|
88 | fs::path m_boost_path; // the path to the boost root |
---|
89 | fs::path m_dest_path; // the path to copy to |
---|
90 | std::map<fs::path, bool, path_less> m_cvs_paths; // valid files under cvs control |
---|
91 | std::set<fs::path, path_less> m_copy_paths; // list of files to copy |
---|
92 | std::map<int, license_data> m_license_data; // licenses in use |
---|
93 | std::set<fs::path, path_less> m_unknown_licenses; // files with no known license |
---|
94 | std::set<fs::path, path_less> m_unknown_authors; // files with no known copyright/author |
---|
95 | std::set<fs::path, path_less> m_can_migrate_to_bsl; // files that can migrate to the BSL |
---|
96 | std::set<fs::path, path_less> m_cannot_migrate_to_bsl; // files that cannot migrate to the BSL |
---|
97 | std::set<std::string> m_bsl_authors; // authors giving blanket permission to use the BSL |
---|
98 | std::set<std::string> m_authors_for_bsl_migration; // authors we need for BSL migration |
---|
99 | std::map<fs::path, std::pair<std::string, std::string>, path_less> m_converted_to_bsl; |
---|
100 | std::map<std::string, std::set<fs::path, path_less> > m_author_data; // all the authors |
---|
101 | std::map<fs::path, fs::path, path_less> m_dependencies; // dependency information |
---|
102 | }; |
---|