+ rmake ruby script
[opsoft.git] / silentbob / plugins / plugin_xml_project.cxx
blob4dd07be4c996ff28a0689b426fd40daffc4380fb
1 /*
2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <gclib/gclib.h>
12 #include <gclib/gclib_c.h>
13 #include <mod.h>
14 #include <head.h>
15 #include <dbg.h>
17 extern "C" DArray * plugin_init (struct env_t *env);
18 struct env_t *ENV;
19 char * __xml_project_name;
20 char * __xml_type;
21 EHash * __compile_env;
23 char xml_project_opt (DArray * d_opts, int * pos)
25 int count;
26 char * S;
28 if (! d_opts || ! pos)
29 return 0;
31 count = d_opts->get_size ();
32 S = d_opts->get (*pos);
34 if (EQ (S, "--xml-bin") ||
35 EQ (S, "--xml-program")) {
36 if (++(*pos) >= count)
37 return 1;
38 __xml_type = "программа";
39 __xml_project_name = d_opts->get (*pos);
40 return 1;
43 if (EQ (S, "--xml-shared")) {
44 if (++(*pos) >= count)
45 return 1;
46 __xml_type = "шаровая_лайба";
47 __xml_project_name = d_opts->get (*pos);
48 return 1;
51 return 0;
54 void xmlDump ()
56 printf ("\t<модуль имя=\"%s\" тип=\"%s\">\n", __xml_project_name, __xml_type);
57 printf ("\t<свойство CC=\"%s\" />\n", (*__compile_env)["CC"]);
58 printf ("\t<свойство CXX=\"%s\" />\n", (*__compile_env)["CXX"]);
59 printf ("\t<свойство OPTS=\"%s\" />\n", (*__compile_env)["OPTS"]);
60 printf ("\t<свойство INCLUDE=\"%s\" />\n", (*__compile_env)["INCLUDE"]);
61 printf ("\t<свойство LIBS=\"%s\" />\n", (*__compile_env)["LIBS"]);
62 printf ("\t<свойство LDFLAGS=\"%s\" />\n", (*__compile_env)["LDFLAGS"]);
64 printf ("\t<исходники>\n");
65 for (int i = 0; i < ENV->d_files->get_size (); ++i)
66 printf ("\t\t<файл имя=\"%s\" />\n", ENV->d_files->get (i));
67 printf ("\t</исходники>\n");
68 printf ("\t</модуль>\n");
71 char xml_project_opt2 (DArray * d_opts, int * pos)
73 char * S;
75 if (! d_opts || ! pos)
76 return 0;
78 S = d_opts->get (*pos);
79 if (EQ (S, "--xml-bin") ||
80 EQ (S, "--xml-program") ||
81 EQ (S, "--xml-shared")) {
82 __compile_env = bob_init_compile_env ();
83 xmlDump ();
84 exit (0);
87 return 0;
90 void xml_project_short_info ()
92 printf ("XML Project.");
95 void xml_project_long_info ()
97 printf ("XML Project.\n");
98 printf ("Version: 1.0\n");
99 printf ("options: --xml-project --xml-bin --xml-shared\n");
102 DArray * plugin_init (struct env_t *env)
104 DArray * Ret;
105 struct mod_feature * pm;
107 ENV = env;
108 Ret = new DArray (1);
109 pm = CNEW (mod_feature, 1);
110 memset (pm, 0, sizeof (mod_feature));
111 pm->mod.Type = TYPE_FEATURE;
112 pm->mod.Version = strdup ("1.0");
113 pm->mod.short_info = xml_project_short_info;
114 pm->mod.long_info = xml_project_long_info;
115 pm->opt = xml_project_opt;
116 pm->opt2 = xml_project_opt2;
118 Ret->add (LPCHAR (pm));
119 return Ret;