www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How can I restrict a library to be only included under a certain OS?

reply solidstate1991 <laszloszeremi outlook.com> writes:
I added this line to my SDLang formatted dub build file:

```
dependency "libx11" version="0.0.1" platform="posix"
```

Yet it's included even on Windows, even if I change it to "linux".

Since there's a fatal bug in the library that disallows it to be 
built, I'll be leaving it out for now, and instead move onto 
something else, or try to issue a correction.
Mar 28 2023
parent ryuukk_ <ryuukk.dev gmail.com> writes:
On Tuesday, 28 March 2023 at 21:10:08 UTC, solidstate1991 wrote:
 I added this line to my SDLang formatted dub build file:

 ```
 dependency "libx11" version="0.0.1" platform="posix"
 ```

 Yet it's included even on Windows, even if I change it to 
 "linux".

 Since there's a fatal bug in the library that disallows it to 
 be built, I'll be leaving it out for now, and instead move onto 
 something else, or try to issue a correction.
I think the way to go is with configuration ``dub build`` // will default to config "posix" since it's the 1st one ``dub build -c windows`` // will use "windows" config, without the dependency https://dub.pm/package-format-sdl.html#configurations ``` configuration "posix" { dependency "libx11" version="0.0.1" } configuration "windows" { platforms "windows" } ``` My dub knowledge is pretty limited, maybe there is a better way?
Mar 28 2023