February 25, 2014 Re: D alternative for C/C++ -Dfoo=42 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cherry | Just a few clarifications .... > For now maybe I could keep an empty/default config.d somewhere in the library source path. I am creating a DSL (Domain Specific Language) library. I am talking about the library src path of my DSL library. > And I could use that with multiple -J options. This way dmd configuration from the default path unless it finds the config file in the user path. > I figured that DMD will pick import file from the left-most -J path it finds the file in. So all I need is a wrapper over rdmd/dmd that adds a -J. and -J<default path> (in that order) to the user compile command. Regards - Cherry |
February 25, 2014 Re: D alternative for C/C++ -Dfoo=42 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | On Tuesday, 25 February 2014 at 13:26:20 UTC, Dejan Lekic wrote:
>>
>> I don't like it. I would prefer a CTFE-able counter part to boost::program_options that generates thouse enums from a config file.
>
> If you want a config file, you do not need -D args. You simply import() it. Right?
Yep, that would be a cleaner solution since it would avoid some pitfalls with the current flags proposal: Should those enums be fully qualified? What if I put all the source files into a single command line (which leads to faster compilation with dmd)? May that override enums by accident? Should every enum be overwriteable or only those that have a specific UDA etc. etc. ?
And in the end you are using a build tool anyway and you'll put your config flags into a makefile or something that then becomes an ugly config file.
|
February 25, 2014 Re: D alternative for C/C++ -Dfoo=42 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cherry | > Something like "static if(fileExists!"config.d") mixin(import("config.d")) else ...".
>
> Thoughts?
>
> Regards
> - Cherry
--
static if(__traits(compiles, import("config.d")))
{
// import/parse/mixin
}
else
{
// default here
}
--
May be wrapped into a template for more convenience.
|
February 25, 2014 Re: D alternative for C/C++ -Dfoo=42 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tobias Pankrath | On Tuesday, 25 February 2014 at 14:26:13 UTC, Tobias Pankrath wrote:
>> Something like "static if(fileExists!"config.d") mixin(import("config.d")) else ...".
>>
>> Thoughts?
>>
>> Regards
>> - Cherry
> --
> static if(__traits(compiles, import("config.d")))
> {
> // import/parse/mixin
> }
> else
> {
> // default here
> }
> --
>
> May be wrapped into a template for more convenience.
I thought that too... And then, when I tried, SURPRISE, it doesn't work :S
|
February 25, 2014 Re: D alternative for C/C++ -Dfoo=42 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Francesco Cattoglio | On Tuesday, 25 February 2014 at 14:30:23 UTC, Francesco Cattoglio wrote:
> On Tuesday, 25 February 2014 at 14:26:13 UTC, Tobias Pankrath wrote:
>>> Something like "static if(fileExists!"config.d") mixin(import("config.d")) else ...".
>>>
>>> Thoughts?
>>>
>>> Regards
>>> - Cherry
>> --
>> static if(__traits(compiles, import("config.d")))
>> {
>> // import/parse/mixin
>> }
>> else
>> {
>> // default here
>> }
>> --
>>
>> May be wrapped into a template for more convenience.
>
> I thought that too... And then, when I tried, SURPRISE, it doesn't work :S
Ok, MY BAD! It works, but I gave him a folder instead of a file. When you give it a folder instead of a file, it still works but also outputs an error:
read error, errno = 21
However the "else" branch is still taken. Well, this went better than expected!
|
February 26, 2014 Re: D alternative for C/C++ -Dfoo=42 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dejan Lekic | On Tuesday, 25 February 2014 at 13:26:20 UTC, Dejan Lekic wrote:
>>
>> I don't like it. I would prefer a CTFE-able counter part to boost::program_options that generates thouse enums from a config file.
>
> If you want a config file, you do not need -D args. You simply import() it. Right?
or import myconfig; and specify -I path to myconfig.d instead of -J path.
|
Copyright © 1999-2021 by the D Language Foundation