/[jscoverage]/trunk/jscoverage.c
ViewVC logotype

Annotation of /trunk/jscoverage.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Wed Aug 1 13:51:53 2007 UTC (12 years, 1 month ago) by siliconforks
Original Path: trunk/main.c
File MIME type: text/plain
File size: 3254 byte(s)
Initial import.

1 siliconforks 2 /*
2     main.c - JSCoverage main routine
3     Copyright (C) 2007 siliconforks.com
4    
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18     */
19    
20     #include <stdio.h>
21     #include <stdlib.h>
22     #include <string.h>
23    
24     #include "instrument.h"
25     #include "instrument-js.h"
26     #include "resource-manager.h"
27     #include "util.h"
28    
29     int main(int argc, char ** argv) {
30     int verbose = 0;
31    
32     // program = argv[0];
33     program = "jscoverage";
34    
35     char * source = NULL;
36     char * destination = NULL;
37    
38     char ** no_instrument = xmalloc((argc - 1) * sizeof(char *));
39     int num_no_instrument = 0;
40    
41     char ** exclude = xmalloc((argc - 1) * sizeof(char *));
42     int num_exclude = 0;
43    
44     for (int i = 1; i < argc; i++) {
45     if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
46     copy_resource_to_stream("help.txt", stdout);
47     exit(EXIT_SUCCESS);
48     }
49     else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
50     printf("jscoverage %s\n", VERSION);
51     exit(EXIT_SUCCESS);
52     }
53     else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
54     verbose = 1;
55     }
56     else if (strcmp(argv[i], "--no-instrument") == 0) {
57     i++;
58     if (i == argc) {
59     fatal("--no-instrument: option requires an argument");
60     }
61     no_instrument[num_no_instrument] = argv[i];
62     num_no_instrument++;
63     }
64     else if (strncmp(argv[i], "--no-instrument=", 16) == 0) {
65     no_instrument[num_no_instrument] = argv[i] + 16;
66     num_no_instrument++;
67     }
68     else if (strcmp(argv[i], "--exclude") == 0) {
69     i++;
70     if (i == argc) {
71     fatal("--exclude: option requires an argument");
72     }
73     exclude[num_exclude] = argv[i];
74     num_exclude++;
75     }
76     else if (strncmp(argv[i], "--exclude=", 10) == 0) {
77     exclude[num_exclude] = argv[i] + 10;
78     num_exclude++;
79     }
80     else if (strncmp(argv[i], "-", 1) == 0) {
81     fatal("unrecognized option `%s'", argv[i]);
82     }
83     else if (source == NULL) {
84     source = argv[i];
85     }
86     else if (destination == NULL) {
87     destination = argv[i];
88     }
89     else {
90     fatal("too many arguments");
91     }
92     }
93    
94     if (source == NULL || destination == NULL) {
95     fatal("missing argument");
96     }
97    
98     source = make_canonical_path(source);
99     destination = make_canonical_path(destination);
100    
101     jscoverage_init();
102     jscoverage_instrument(source, destination, verbose, exclude, num_exclude, no_instrument, num_no_instrument);
103     jscoverage_copy_resources(destination);
104     jscoverage_cleanup();
105    
106     free(source);
107     free(destination);
108     free(exclude);
109     free(no_instrument);
110    
111     exit(EXIT_SUCCESS);
112     }

  ViewVC Help
Powered by ViewVC 1.1.24