May be a simple dub answer if my question even makes sense?

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 24 17:52:26 PDT 2016


On Saturday, 24 September 2016 at 16:51:47 UTC, WhatMeWorry wrote:

>
> My app.d has:
>
> module app;
> import common.derelict_libraries;
>
> and derelict_libraries.d has:
>
> module derelict_libraries;
> import derelict.glfw3.glfw3;
> import derelict.opengl3.gl3;
>
>
> It's fine to import other imports, Right?

As long as they're public. Imports are private by default, 
meaning their symbols are only visible locally. Change it to:

module derelict_libraries;
public import derelict.glfw3.glfw3;
public import derelict.opengl3.gl3;

>
> I am trying to make a portable dub/dmd build environment on a 
> flash drive for PC
> So the dub project is currently on a flash drive that is 
> assigned the letter E:
> Naturally, this could change if the flash drive were moved to 
> another PC.  did have to write a little shim code to add 
> environment["DFLAGS"] = r"-I..\";  so that the app.d import 
> could find the derelict_libraries.d relative to the project 
> directory. Like so:
>
> E:\projects\01_01_hello_window
> E:\projects\01_01_hello_window\source\app.d
> E:\projects\common\derelict_libraries.d
>

You can do that with dub without resorting to environment 
variables. Then you don't need to set it every time you move your 
flash drive to a different system. See the importPaths directive 
in the 'Build Settings' section of the documentation ([1] for 
JSON and [2] for SDLang).

>
> So to summarize things, the derelict imports are fine.
>
> But how does dub tell dmd that it should looking for opengl 
> imports at:
>
> C:\Users\Kyle\AppData\Roaming\dub\packages\derelict-gl3-1.0.15\source\derelict\opengl3
>
> and glfw3's imports at:
>
> C:\Users\Kyle\AppData\Roaming\dub\packages\derelict-glfw3-3.1.0\derelict-glfw3\source\derelict\glfw3

Because dub created those paths and downloaded the source for 
those packages into those paths, it knows where everything is. 
When it invokes DMD, it uses the -I command line switch just like 
anyone else would.

>
> I'm desperately trying to avoid hard coding these paths. 
> Because I want to use a lot more dub packages in the future.

Well, good, because you don't need to hardcode them.

[1] https://code.dlang.org/package-format?lang=json#build-settings
[2] https://code.dlang.org/package-format?lang=sdl#build-settings



More information about the Digitalmars-d-learn mailing list