1 |
I hope you did read my previous mail of code dependancy -- if not, it's at |
2 |
the end of message. This here is not so much overthought thing, but a good |
3 |
starting point, maybe, if code deps are used. |
4 |
|
5 |
Anyway, i give here the same idea in more complete form and good syntax |
6 |
(good, because it could be added to compilers, for example): |
7 |
|
8 |
/* As compiler may give warnings or errors otherwise, portage code parses |
9 |
defines "portage-providers". */ |
10 |
#ifdef runasdaemon |
11 |
|
12 |
#ifdef portage-providers |
13 |
#provide interface customdaemon |
14 |
/* if provided *as*, then does not actually provide anything before include |
15 |
clause */ |
16 |
#use interface daemonheaders 1.0.2 as <dhead.h> |
17 |
/* when <test.h> is included, depends on dev-apps/test at least version |
18 |
1.0.2 */ |
19 |
#provider-atom test set package=dev-apps/test |
20 |
#provider-atom test set version>=1.0.2 |
21 |
/* require testflag to be set */ |
22 |
#provider-atom test need useflag testflag "Hello world!" |
23 |
/* require testflag2 to be unset */ |
24 |
#provider-atom test hate useflag testflag2 "Testflag2 bad :(" |
25 |
/* have some good taste in warnings */ |
26 |
#provider-atom test warn useflag testflag3 "Test warning!" |
27 |
#provider-atom test ask useflag testflag4 "Testflag4 good :)" |
28 |
#use atom test as <test.h> |
29 |
#provider-atom otheratom set package=dev-apps/otherpackage |
30 |
/* if runasdaemon, otheratom will be required */ |
31 |
#use atom otheratom |
32 |
#endif |
33 |
|
34 |
#ifdef something |
35 |
|
36 |
/* if runasdaemon and something, daemonheaders 1.0.2 is needed */ |
37 |
#include <dhead.h> |
38 |
/* if runasdaemon and something, atom "test" is needed */ |
39 |
#include <test.h> |
40 |
|
41 |
/* atoms could be provided as well; interface is a simple atom with few |
42 |
params; just <test.h> could be provided, also: */ |
43 |
#ifdef portage-providers |
44 |
#provide header <welcome.h> |
45 |
#use header <someheader.h> |
46 |
#endif |
47 |
|
48 |
#endif |
49 |
|
50 |
#endif |
51 |
|
52 |
2006/3/22, tvali <qtvali@×××××.com>: |
53 |
> |
54 |
> I was thinking about it, too, and found something i do like maybe more. It |
55 |
> would be not binary, but code dependancy. This is limited to specific |
56 |
> languages, then, but after all, there may also be different binary |
57 |
> dependencies, too [for example, you may depend on fonts & images from |
58 |
> another package]. |
59 |
> |
60 |
> Ok, my thought is like that. Lets imagine a simple c file: |
61 |
> |
62 |
> #ifdef usepackagex |
63 |
> #include <packagex.h> |
64 |
> #endif |
65 |
> |
66 |
> As it is simple to see, this file could be used to calculate non-binary |
67 |
> dependency, inluding useflags. And there is a plus -- tool, which just reads |
68 |
> those #ifdef's and #includes, could easily understand, which flags make up |
69 |
> which dependancy, without building package again and again with different |
70 |
> useflags. PS. i dont mean X by packagex, but rather a random pack. I write |
71 |
> here as if #define always includes useflag name - i may be wrong, but it |
72 |
> doesnt make a huge difference. Sure, there are #ifdef's in code, which |
73 |
> should not read, so we must have an array for legal useflags - but this is |
74 |
> also not important in my explanation. |
75 |
> |
76 |
> Lets add some custom comment syntax (line numbers are given for |
77 |
> explanation): |
78 |
> |
79 |
> 1. #ifdef usepackagex |
80 |
> 2. /* Portage: packagex.h = abc-def/packagex => 1.0.2 */ |
81 |
> 3. /* Portage: use fonts/customfontpackage */ |
82 |
> 4. #include <packagex.h> |
83 |
> 5. #endif |
84 |
> |
85 |
> Now, what a parser does: |
86 |
> |
87 |
> Start parse: setup empty array UseFlags = [] |
88 |
> |
89 |
> Line 1: #ifdef usepackagex |
90 |
> Add useflag name into useflags array: |
91 |
> UseFlags = ['usepackagex'] |
92 |
> Line 2: /* Portage: packagex.h = abc-def/packagex => 1.0.2 */ |
93 |
> This line maybe outside of any #ifdef's as well, but in our small |
94 |
> application there is no external conf.c file ;) |
95 |
> Dictionary 'Links' will contain a notice that whenever packagex is |
96 |
> included, it must be at least version 1.0.2 of package abc-def/packagex. |
97 |
> Line 3: /* Portage: use fonts/customfontpackage */ |
98 |
> Dependancy on fonts/customfontpackage, therefore add to dependancies: |
99 |
> [['usepackagex'], 'fonts/customfontpackage'] |
100 |
> Line 4: #include <packagex.h> |
101 |
> Dependancy on fonts/customfontpackage, therefore add to dependancies: |
102 |
> [['usepackagex'], 'abc-def/packagex => 1.0.2'] |
103 |
> Line 5: #endif |
104 |
> Remove 'usepackagex' from useflags: |
105 |
> UseFlags = [] |
106 |
> |
107 |
|
108 |
-- |
109 |
tvali |
110 |
|
111 |
>From a programmer's point of view, the user is a peripheral that types when |
112 |
you issue a read request. -P. Williams |
113 |
|
114 |
If you think your management doesn't know what it's doing or that your |
115 |
organisation turns out low-quality software crap that embarrasses you, then |
116 |
leave. -Ed Yourdon |
117 |
|
118 |
We all agree on the necessity of compromise. We just can't agree on when |
119 |
it's necessary to compromise. -Larry Wall |
120 |
|
121 |
[ http://www.softwarequotes.com/ ] - |
122 |
http://www.softwarequotes.com/ShowQuotes.asp?ID=544&Name=Borenstein,_Nathaniel_S. |
123 |
- http://www.softwarequotes.com/ShowQuotes.asp?ID=571&Name=Boehm,_Barry |