dub icon indicating copy to clipboard operation
dub copied to clipboard

Support building projects with alternative druntime implementations

Open w0rp opened this issue 10 years ago • 3 comments

I was just experimenting with using DUB to build a project which uses a minimal druntime. I had the idea of creating a minimal druntime as a sourceLibrary, and creating another project which uses a cross compiler and which uses the minimal druntime as a dependency.

I ran into a snag in that DUB compiles a file with the compiler in order to determine the build environment. However, if the compiler has no druntime of its own, then the step where the build environment is determined fails. I suppose the 'dflags' setting could be changed in the dub.json file to include the PATH to the alternate runtime, but that's not so attractive.

Is it possible to support this kind of build with DUB? Is there some way a package can be configured currently to support this that I missed? It would be kind of cool to build minimal D projects with DUB. I really hate setting import paths and writing Makefiles...

w0rp avatar May 04 '15 20:05 w0rp

I think should handle that in dmd.conf by specifying suitable import paths for the compiler.

MartinNowak avatar May 04 '15 21:05 MartinNowak

@etcimon : How do you currently do this ?

Geod24 avatar Jan 17 '24 23:01 Geod24

In ldc2.conf you have this:

{
[..]
    // default switches appended after all explicit command-line switches
    post-switches = [
        "-I%%ldcbinarypath%%/../import",
    ];
        // default switches injected before all explicit command-line switches
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
    ];
[..]
};

So basically you need to replace this with post-switches = [ ], and remove -defaultlib switch, and then in dub.sdl/dub.json you will have

    sourcePaths "druntime/core" "druntime/rt"
    sourceFiles "druntime/object.d"
    importPaths "druntime"

Where druntime is the folder containing your version of std/core/rt folders, and every subproject needs to have importPaths manually set to this folder too. Unfortunately you don't have any way of setting importPaths: "$dependency:name/druntime" so it only works if you clone and setup your project relatively. Also dub doesn't handle setting up the ldc2/dmd configurations for it :)

etcimon avatar Jan 17 '24 23:01 etcimon