-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cc
More file actions
83 lines (70 loc) · 2.01 KB
/
main.cc
File metadata and controls
83 lines (70 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdexcept>
#include <iostream>
#include <string>
#include "find.h"
#include "parse.h"
#include "argpc.h"
#include "build.h"
#include "plotter.h"
#include "debug.h"
#include "dependencies.h"
#include "argpcoption.h"
using namespace std;
bool makefile_specified = false;
string plotfile = "";
std::string makefile;
extern std::string depfile;
void set_makefile( std::string file )
{
makefile_specified = true;
makefile = file;
}
void set_depfile( std::string file )
{
depfile = file;
}
void plot( std::string file )
{
plotfile = file;
}
int main(int argc, char *argv[])
{
Plotter p;
int ret;
try {
Argpc *options = Argpc::getInstance( );
// Set up the standard argument options
options->addHelp( );
options->addUsage( );
options->addVersion( );
options->setVersion( "0.1" );
options->setBugAddress( "Aaron Small <a.small@unb.ca>" );
options->setDoc( "Yet another make clone" );
options->setArgumentDescription( "..." );
options->addOption( ArgpcOption( "file", 'f', "file", "Read FILE as a makefile.", set_makefile ) );
options->addOption( ArgpcOption( "depfile", 'b', "depfile", "Use specified file as dependency database.", set_depfile ) );
options->addOption( ArgpcOption( "plot", 'p', "graphfile", "Draw the cached dependency information", plot ) );
debug_init( );
options->parse( &argc, argv );
dependencies_init();
if( !makefile_specified ) {
makefile = find_makefile( );
}
parse_makefile( makefile );
for( int i = 1; i < argc; i ++ ) {
set_target( argv[i] );
}
set_default_target();
if( plotfile != "" ) {
p.open( plotfile );
set_plotter( &p );
}
ret = build_targets();
} catch ( const std::exception &e ) {
cerr << "make: " << e.what() << endl;
dependencies_deinit();
return 1;
}
dependencies_deinit();
return ret;
}