www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to specify a default configuration in a library's dub.json? (i.e

reply mw <mingwu gmail.com> writes:
Hi,

I just did a build fix, and added two configurations to thrift's 
dub.json (whose   "targetType": "library")

https://github.com/apache/thrift/pull/2397/files

I want to know how to specify a default configuration in the 
library's dub.json? (i.e if the use doesn't not have 
subConfigurations).

Then the existing library user does not have to change his app's 
dub.json when he do `dub upgrade`.

Thanks.
May 25
parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 26 May 2021 at 00:19:23 UTC, mw wrote:
 Hi,

 I just did a build fix, and added two configurations to 
 thrift's dub.json (whose   "targetType": "library")

 https://github.com/apache/thrift/pull/2397/files

 I want to know how to specify a default configuration in the 
 library's dub.json? (i.e if the use doesn't not have 
 subConfigurations).

 Then the existing library user does not have to change his 
 app's dub.json when he do `dub upgrade`.

 Thanks.
The first configuration in the file is the default.
May 25
next sibling parent mw <mingwu gmail.com> writes:
On Wednesday, 26 May 2021 at 00:25:17 UTC, Mike Parker wrote:
 On Wednesday, 26 May 2021 at 00:19:23 UTC, mw wrote:
 Hi,

 I just did a build fix, and added two configurations to 
 thrift's dub.json (whose   "targetType": "library")

 https://github.com/apache/thrift/pull/2397/files

 I want to know how to specify a default configuration in the 
 library's dub.json? (i.e if the use doesn't not have 
 subConfigurations).

 Then the existing library user does not have to change his 
 app's dub.json when he do `dub upgrade`.

 Thanks.
The first configuration in the file is the default.
OK, that's great. Just find it here (for future reference): https://dub.pm/package-format-json.html#configurations By default, the first configuration that matches the target type and build platform is selected automatically.
May 25
prev sibling parent reply mw <mingwu gmail.com> writes:
On Wednesday, 26 May 2021 at 00:25:17 UTC, Mike Parker wrote:
 On Wednesday, 26 May 2021 at 00:19:23 UTC, mw wrote:
 Hi,

 I just did a build fix, and added two configurations to 
 thrift's dub.json (whose   "targetType": "library")

 https://github.com/apache/thrift/pull/2397/files

 I want to know how to specify a default configuration in the 
 library's dub.json? (i.e if the use doesn't not have 
 subConfigurations).

 Then the existing library user does not have to change his 
 app's dub.json when he do `dub upgrade`.

 Thanks.
The first configuration in the file is the default.
Hi, I'm having trouble with this PR right now. https://github.com/apache/thrift/pull/2397#issuecomment-849103620 """ src/thrift/internal/ssl.d(100): Error: static assert: "Must have version either use_openssl_1_0_x or use_openssl_1_1_x defined, e.g. "subConfigurations": { "apache-thrift": "use_openssl_1_0" }" Makefile:1292: recipe for target 'libthriftd-ssl.a' failed make[4]: *** [libthriftd-ssl.a] Error 1 make[4]: *** Waiting for unfinished jobs.... make[4]: Leaving directory '/thrift/src/lib/d' Makefile:895: recipe for target 'all-recursive' failed """ The default configuration is not picked up in the build process, https://github.com/apache/thrift/pull/2397/files#diff-1b617af56e869773e32ce59329f25b2db5d8b3c5151519919c7c10266b4d78fcR15 ``` "configurations": [ { "name": "use_openssl_1_0", "versions": ["use_openssl_1_0_x"], "dependencies": { "openssl": { "version": "~>1.1.6" } } }, ``` i.e. the version use_openssl_1_0_x is not defined. Anyone know how I can fix this? BTW, is the version string quote causing the problem: "use_openssl_1_0_x" is defined as a version string in the dub.json, but in the code: https://github.com/apache/thrift/pull/2397/files#diff-731671345667ab400d85c10e38fb33ed0c39b1e4d6b38456949284e4e1f47b66R93 I'm checking it as: ``` version(use_openssl_1_0_x) { // without the quote "", should I have string quote here? } ``` Thanks!
May 26
parent reply mw <mingwu gmail.com> writes:
 BTW, is the version string quote causing the problem: 
 "use_openssl_1_0_x" is defined as a version string in the 
 dub.json, but in the code:

 https://github.com/apache/thrift/pull/2397/files#diff-731671345667ab400d85c10e38fb33ed0c39b1e4d6b38456949284e4e1f47b66R93

 I'm checking it as:

     ```
       version(use_openssl_1_0_x) {  // without the quote "", 
 should I have string quote here?
       }
     ```
I'm following pyd's example: https://github.com/ariovistus/pyd/blob/master/dub.json#L35 ``` "versions": [ "Python_2_4_Or_Later", "Python_2_5_Or_Later", "Python_2_6_Or_Later", "Python_2_7_Or_Later" ] ``` `"Python_2_7_Or_Later"` is introduced as quoted string in dub.json, and later: https://github.com/ariovistus/pyd/blob/master/infrastructure/deimos/python/dictobject.d#L118 ``` version(Python_2_7_Or_Later) { } ``` `Python_2_7_Or_Later` is directly used as version label, without being quoted. So how to fix the problem?
May 26
parent mw <mingwu gmail.com> writes:
I think the reason for the library build failure is, it directly 
calls dmd instead of dub to build the library:

dmd -oflibthriftd-ssl.a -w -wi -Isrc -lib src/thrift/async/ssl.d 
src/thrift/internal/ssl.d ...


So my next question is what should be the correct dmd equivalent 
of the dub command?
May 26