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
18namespace fs = boost::filesystem;
19
20class fileview;
21
22//
23//path operations:
24//
25int compare_paths(const fs::path& a, const fs::path& b);
26inline bool equal_paths(const fs::path& a, const fs::path& b)
27{ return compare_paths(a, b) == 0; }
28
29struct path_less
30{
31 bool operator()(const fs::path& a, const fs::path& b)const
32 { return compare_paths(a, b) < 0; }
33};
34
35struct license_data
36{
37 std::set<fs::path, path_less> files;
38 std::set<std::string> authors;
39};
40
41class bcp_implementation
42 : public bcp_application
43{
44public:
45 bcp_implementation();
46 ~bcp_implementation();
47 static bool is_source_file(const fs::path& p);
48 static bool is_html_file(const fs::path& p);
49 static bool is_jam_file(const fs::path& p);
50private:
51 //
52 // the following are the overridden virtuals from the base class:
53 //
54 void enable_list_mode();
55 void enable_summary_list_mode();
56 void enable_cvs_mode();
57 void enable_svn_mode();
58 void enable_unix_lines();
59 void enable_scan_mode();
60 void enable_license_mode();
61 void enable_bsl_convert_mode();
62 void enable_bsl_summary_mode();
63 void set_boost_path(const char* p);
64 void set_destination(const char* p);
65 void add_module(const char* p);
66 void set_namespace(const char* name);
67 void set_namespace_alias(bool);
68 void set_namespace_list(bool);
69
70 virtual int run();
71
72 // internal helper functions:
73 bool is_binary_file(const fs::path& p);
74 void scan_cvs_path(const fs::path& p);
75 void scan_svn_path(const fs::path& p);
76 void add_path(const fs::path& p);
77 void add_directory(const fs::path& p);
78 void add_file(const fs::path& p);
79 void copy_path(const fs::path& p);
80 void add_file_dependencies(const fs::path& p, bool scanfile);
81 void add_dependent_lib(const std::string& libname, const fs::path& p, const fileview& view);
82 void create_path(const fs::path& p);
83 // license code:
84 void scan_license(const fs::path& p, const fileview& v);
85 void output_license_info();
86
87 std::list<std::string> m_module_list; // the modules to process
88 bool m_list_mode; // list files only
89 bool m_list_summary_mode; // list file summary only
90 bool m_license_mode; // generate license information for files listed
91 bool m_cvs_mode; // check cvs for files
92 bool m_svn_mode; // check svn for files
93 bool m_unix_lines; // fix line endings
94 bool m_scan_mode; // scan non-boost files.
95 bool m_bsl_convert_mode; // try to convert to the BSL
96 bool m_bsl_summary_mode; // summarise BSL issues only
97 bool m_namespace_alias; // make "boost" a namespace alias when doing a namespace rename.
98 bool m_list_namespaces; // list all the top level namespaces found.
99 fs::path m_boost_path; // the path to the boost root
100 fs::path m_dest_path; // the path to copy to
101 std::map<fs::path, bool, path_less> m_cvs_paths; // valid files under cvs control
102 std::set<fs::path, path_less> m_copy_paths; // list of files to copy
103 std::map<int, license_data> m_license_data; // licenses in use
104 std::set<fs::path, path_less> m_unknown_licenses; // files with no known license
105 std::set<fs::path, path_less> m_unknown_authors; // files with no known copyright/author
106 std::set<fs::path, path_less> m_can_migrate_to_bsl; // files that can migrate to the BSL
107 std::set<fs::path, path_less> m_cannot_migrate_to_bsl; // files that cannot migrate to the BSL
108 std::set<std::string> m_bsl_authors; // authors giving blanket permission to use the BSL
109 std::set<std::string> m_authors_for_bsl_migration; // authors we need for BSL migration
110 std::map<fs::path, std::pair<std::string, std::string>, path_less>
111 m_converted_to_bsl;
112 std::map<std::string, std::set<fs::path, path_less> > m_author_data; // all the authors
113 std::map<fs::path, fs::path, path_less> m_dependencies; // dependency information
114 std::string m_namespace_name; // namespace rename.
115 std::set<std::string> m_lib_names; // List of library binary names
116 std::map<std::string, fs::path> m_top_namespaces; // List of top level namespace names
117};
118
119

source code of boost/tools/bcp/bcp_imp.hpp