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