-
Notifications
You must be signed in to change notification settings - Fork 53
/
color_compile.c
52 lines (41 loc) · 893 Bytes
/
color_compile.c
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
/*
* color_compile.c - handle compile command
*
* Copyright (c) 2014-2015 Alan Wang <alan@wrcode.com>
*
* This file is released under the Apache Licene 2.0.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUF_SIZE 2048
#define CAT_SIZE 1024
int main(int argc, char const *argv[])
{
int i;
char buf[BUF_SIZE];
if (argc < 2 || 0 != strcmp(argv[0], "color_compile") )
{
fprintf(stderr, "[color_compile] bad argument...\n");
return 1;
}
// declude make menuconfig
if (3 == argc && 0 == strcmp(argv[1], "make") &&
0 == strcmp(argv[2], "menuconfig") )
{
system("make menuconfig");
return 0;
}
// copy cmd
buf[0] = '\0';
for (i = 1; i < argc; ++i)
{
strncat(buf, argv[i], CAT_SIZE);
strncat(buf, " ", CAT_SIZE);
}
// add out_color_info
strncat(buf, "2>&1 | out_color_info", CAT_SIZE);
// true exec
system(buf);
return 0;
}