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 | * This file implements the cpp_main entry point |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | #include <iostream> |
---|
13 | #include <cstring> |
---|
14 | #include <boost/filesystem/path.hpp> |
---|
15 | #include <boost/version.hpp> |
---|
16 | #include "bcp.hpp" |
---|
17 | |
---|
18 | #ifdef BOOST_NO_STDC_NAMESPACE |
---|
19 | namespace std{ |
---|
20 | using ::strcmp; |
---|
21 | using ::strncmp; |
---|
22 | } |
---|
23 | #endif |
---|
24 | |
---|
25 | void show_usage() |
---|
26 | { |
---|
27 | std::cout << |
---|
28 | "Usage:\n" |
---|
29 | " bcp --list [options] module-list\n" |
---|
30 | " bcp --report [options] module-list html-file\n" |
---|
31 | " bcp [options] module-list output-path\n" |
---|
32 | "\n" |
---|
33 | "Options:\n" |
---|
34 | " --boost=path sets the location of the boost tree to path\n" |
---|
35 | " --scan treat the module list as a list of (possibly non-boost)\n" |
---|
36 | " files to scan for boost dependencies\n" |
---|
37 | " --cvs only copy files under cvs version control\n" |
---|
38 | " --unix-lines make sure that all copied files use Unix style line endings\n" |
---|
39 | "\n" |
---|
40 | "module-list: a list of boost files or library names to copy\n" |
---|
41 | "html-file: the name of a html file to which the report will be written\n" |
---|
42 | "output-path: the path to which files will be copied\n"; |
---|
43 | } |
---|
44 | |
---|
45 | bool filesystem_name_check( const std::string & name ) |
---|
46 | { |
---|
47 | return true; |
---|
48 | } |
---|
49 | |
---|
50 | int cpp_main(int argc, char* argv[]) |
---|
51 | { |
---|
52 | // |
---|
53 | // Before anything else replace Boost.filesystem's file |
---|
54 | // name checker with one that does nothing (we only deal |
---|
55 | // with files that already exist, if they're not portable |
---|
56 | // names it's too late for us to do anything about it). |
---|
57 | // |
---|
58 | boost::filesystem::path::default_name_check(filesystem_name_check); |
---|
59 | // |
---|
60 | // without arguments just show help: |
---|
61 | // |
---|
62 | if(argc < 2) |
---|
63 | { |
---|
64 | show_usage(); |
---|
65 | return 0; |
---|
66 | } |
---|
67 | // |
---|
68 | // create the application object: |
---|
69 | // |
---|
70 | pbcp_application papp(bcp_application::create()); |
---|
71 | // |
---|
72 | // work through args, and tell the application |
---|
73 | // object what ir needs to do: |
---|
74 | // |
---|
75 | bool list_mode = false; |
---|
76 | for(int i = 1; i < argc; ++i) |
---|
77 | { |
---|
78 | if(0 == std::strcmp("-h", argv[i]) |
---|
79 | || 0 == std::strcmp("--help", argv[i])) |
---|
80 | { |
---|
81 | show_usage(); |
---|
82 | return 0; |
---|
83 | } |
---|
84 | if(0 == std::strcmp("-v", argv[i]) |
---|
85 | || 0 == std::strcmp("--version", argv[i])) |
---|
86 | { |
---|
87 | std::cout << "bcp " << (BOOST_VERSION / 100000) << "." << (BOOST_VERSION / 100 % 1000) << "." << (BOOST_VERSION % 100) << std::endl; |
---|
88 | std::cout << __DATE__ << std::endl; |
---|
89 | return 0; |
---|
90 | } |
---|
91 | else if(0 == std::strcmp("--list", argv[i])) |
---|
92 | { |
---|
93 | list_mode = true; |
---|
94 | papp->enable_list_mode(); |
---|
95 | } |
---|
96 | else if(0 == std::strcmp("--report", argv[i])) |
---|
97 | { |
---|
98 | papp->enable_license_mode(); |
---|
99 | } |
---|
100 | else if(0 == std::strcmp("--cvs", argv[i])) |
---|
101 | { |
---|
102 | papp->enable_cvs_mode(); |
---|
103 | } |
---|
104 | else if(0 == std::strcmp("--scan", argv[i])) |
---|
105 | { |
---|
106 | papp->enable_scan_mode(); |
---|
107 | } |
---|
108 | else if(0 == std::strcmp("--bsl-convert", argv[i])) |
---|
109 | { |
---|
110 | papp->enable_bsl_convert_mode(); |
---|
111 | } |
---|
112 | else if(0 == std::strcmp("--bsl-summary", argv[i])) |
---|
113 | { |
---|
114 | papp->enable_bsl_summary_mode(); |
---|
115 | } |
---|
116 | else if(0 == std::strcmp("--unix-lines", argv[i])) |
---|
117 | { |
---|
118 | papp->enable_unix_lines(); |
---|
119 | } |
---|
120 | else if(0 == std::strncmp("--boost=", argv[i], 8)) |
---|
121 | { |
---|
122 | papp->set_boost_path(argv[i] + 8); |
---|
123 | } |
---|
124 | else if(argv[i][0] == '-') |
---|
125 | { |
---|
126 | show_usage(); |
---|
127 | return 1; |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | if(!list_mode && (i == argc - 1)) |
---|
132 | papp->set_destination(argv[i]); |
---|
133 | else |
---|
134 | papp->add_module(argv[i]); |
---|
135 | } |
---|
136 | } |
---|
137 | // |
---|
138 | // run the application object: |
---|
139 | // |
---|
140 | return papp->run(); |
---|
141 | } |
---|
142 | |
---|
143 | |
---|
144 | |
---|