1 |
/* |
/* |
2 |
main.c - JSCoverage main routine |
main.c - JSCoverage main routine |
3 |
Copyright (C) 2007 siliconforks.com |
Copyright (C) 2007, 2008 siliconforks.com |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
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 |
it under the terms of the GNU General Public License as published by |
17 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include <config.h> |
21 |
|
|
22 |
#include <stdio.h> |
#include <stdio.h> |
23 |
#include <stdlib.h> |
#include <stdlib.h> |
24 |
#include <string.h> |
#include <string.h> |
25 |
|
|
26 |
|
#include "global.h" |
27 |
#include "instrument.h" |
#include "instrument.h" |
28 |
#include "instrument-js.h" |
#include "instrument-js.h" |
29 |
#include "resource-manager.h" |
#include "resource-manager.h" |
30 |
#include "util.h" |
#include "util.h" |
31 |
|
|
32 |
|
const char * jscoverage_encoding = "ISO-8859-1"; |
33 |
|
|
34 |
int main(int argc, char ** argv) { |
int main(int argc, char ** argv) { |
35 |
int verbose = 0; |
int verbose = 0; |
36 |
|
|
40 |
char * source = NULL; |
char * source = NULL; |
41 |
char * destination = NULL; |
char * destination = NULL; |
42 |
|
|
43 |
char ** no_instrument = xmalloc((argc - 1) * sizeof(char *)); |
char ** no_instrument = xnew(char *, argc - 1); |
44 |
int num_no_instrument = 0; |
int num_no_instrument = 0; |
45 |
|
|
46 |
char ** exclude = xmalloc((argc - 1) * sizeof(char *)); |
char ** exclude = xnew(char *, argc - 1); |
47 |
int num_exclude = 0; |
int num_exclude = 0; |
48 |
|
|
49 |
for (int i = 1; i < argc; i++) { |
for (int i = 1; i < argc; i++) { |
82 |
exclude[num_exclude] = argv[i] + 10; |
exclude[num_exclude] = argv[i] + 10; |
83 |
num_exclude++; |
num_exclude++; |
84 |
} |
} |
85 |
|
else if (strcmp(argv[i], "--encoding") == 0) { |
86 |
|
i++; |
87 |
|
if (i == argc) { |
88 |
|
fatal("--encoding: option requires an argument"); |
89 |
|
} |
90 |
|
jscoverage_encoding = argv[i]; |
91 |
|
} |
92 |
|
else if (strncmp(argv[i], "--encoding=", 11) == 0) { |
93 |
|
jscoverage_encoding = argv[i] + 11; |
94 |
|
} |
95 |
else if (strncmp(argv[i], "-", 1) == 0) { |
else if (strncmp(argv[i], "-", 1) == 0) { |
96 |
fatal("unrecognized option `%s'", argv[i]); |
fatal("unrecognized option `%s'", argv[i]); |
97 |
} |
} |
115 |
|
|
116 |
jscoverage_init(); |
jscoverage_init(); |
117 |
jscoverage_instrument(source, destination, verbose, exclude, num_exclude, no_instrument, num_no_instrument); |
jscoverage_instrument(source, destination, verbose, exclude, num_exclude, no_instrument, num_no_instrument); |
|
jscoverage_copy_resources(destination); |
|
118 |
jscoverage_cleanup(); |
jscoverage_cleanup(); |
119 |
|
|
120 |
free(source); |
free(source); |