I hope you did read my previous mail of code dependancy -- if not, it's at the end of message. This here is not so much overthought thing, but a good starting point, maybe, if code deps are used.

Anyway, i give here the same idea in more complete form and good syntax (good, because it could be added to compilers, for example):

/* As compiler may give warnings or errors otherwise, portage code parses defines "portage-providers". */
#ifdef runasdaemon

#ifdef portage-providers
#provide interface customdaemon
/* if provided *as*, then does not actually provide anything before include clause */
#use interface daemonheaders 1.0.2 as <dhead.h>
/* when <test.h> is included, depends on dev-apps/test at least version 1.0.2 */
#provider-atom test set package=dev-apps/test
#provider-atom test set version>=1.0.2
/* require testflag to be set */
#provider-atom test need useflag testflag "Hello world!"
/* require testflag2 to be unset */
#provider-atom test hate useflag testflag2 "Testflag2 bad :("
/* have some good taste in warnings */
#provider-atom test warn useflag testflag3 "Test warning!"
#provider-atom test ask useflag testflag4 "Testflag4 good :)"
#use atom test as <test.h>
#provider-atom otheratom set package=dev-apps/otherpackage
/* if runasdaemon, otheratom will be required */
#use atom otheratom

#ifdef something

/* if runasdaemon and something, daemonheaders 1.0.2 is needed */
#include <dhead.h>
/* if runasdaemon and something, atom "test" is needed */
#include <test.h>

/* atoms could be provided as well; interface is a simple atom with few params; just <test.h> could be provided, also: */
#ifdef portage-providers
#provide header <welcome.h>
#use header <someheader.h>



2006/3/22, tvali <[EMAIL PROTECTED]>:
I was thinking about it, too, and found something i do like maybe more. It would be not binary, but code dependancy. This is limited to specific languages, then, but after all, there may also be different binary dependencies, too [for example, you may depend on fonts & images from another package].

Ok, my thought is like that. Lets imagine a simple c file:

#ifdef usepackagex
#include <packagex.h>

As it is simple to see, this file could be used to calculate non-binary dependency, inluding useflags. And there is a plus -- tool, which just reads those #ifdef's and #includes, could easily understand, which flags make up which dependancy, without building package again and again with different useflags. PS. i dont mean X by packagex, but rather a random pack. I write here as if #define always includes useflag name - i may be wrong, but it doesnt make a huge difference. Sure, there are #ifdef's in code, which should not read, so we must have an array for legal useflags - but this is also not important in my explanation.

Lets add some custom comment syntax (line numbers are given for explanation):

1. #ifdef usepackagex
2. /* Portage: packagex.h = abc-def/packagex => 1.0.2 */
3. /* Portage: use fonts/customfontpackage */
4. #include <packagex.h>
5. #endif

Now, what a parser does:

Start parse: setup empty array UseFlags = []

Line 1: #ifdef usepackagex
Add useflag name into useflags array:
UseFlags = ['usepackagex']
Line 2: /* Portage: packagex.h = abc-def/packagex => 1.0.2 */
This line maybe outside of any #ifdef's as well, but in our small application there is no external conf.c file ;)
Dictionary 'Links' will contain a notice that whenever packagex is included, it must be at least version 1.0.2 of package abc-def/packagex.
Line 3: /* Portage: use fonts/customfontpackage */
Dependancy on fonts/customfontpackage, therefore add to dependancies:
[['usepackagex'], 'fonts/customfontpackage']
Line 4: #include <packagex.h>
Dependancy on fonts/customfontpackage, therefore add to dependancies:
[['usepackagex'], 'abc-def/packagex => 1.0.2']
Line 5: #endif
Remove 'usepackagex' from useflags:
UseFlags = []


From a programmer's point of view, the user is a peripheral that types when you issue a read request.  -P. Williams

If you think your management doesn't know what it's doing or that your organisation turns out low-quality software crap that embarrasses you, then leave.  -Ed Yourdon

We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise. -Larry Wall

[ http://www.softwarequotes.com/ ] - http://www.softwarequotes.com/ShowQuotes.asp?ID=544&Name=Borenstein,_Nathaniel_S. - http://www.softwarequotes.com/ShowQuotes.asp?ID=571&Name=Boehm,_Barry

Reply via email to