Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dub assertion failure #149

Closed
vinesworth opened this issue Oct 30, 2013 · 3 comments
Closed

dub assertion failure #149

vinesworth opened this issue Oct 30, 2013 · 3 comments

Comments

@vinesworth
Copy link

My intent is to make an import-only library, thus the source paths are kept empty. I try the following package.json:

{
    "name": "ae",
    "targetType": "sourceLibrary",
    "importPaths": [""],
    "dependencies": {
        "ae:net" : "~master",
    },
    "subPackages": [
        {
            "name": "net",
            "targetType": "sourceLibrary",
            "sourcePaths": [""],
            "importPaths": ["net"],
        }
    ]
}

And it asserts on 'dub describe'. Removing 'ae:net' line allows dub to produce a description, but then the subpackage source files are not found in projects that depend on 'ae', and dub asserts again if they depend on 'ae:net' instead.

@s-ludwig
Copy link
Member

s-ludwig commented Nov 1, 2013

The problem is the empty path in "sourcePaths" - DUB now outputs a proper error message in this case. This is how it probably should look like instead:

{
    "name": "ae",
    "targetType": "sourceLibrary",
    "importPaths": [],
    "dependencies": {
        "ae:net" : "~master",
    },
    "subPackages": [
        {
            "name": "net",
            "targetType": "sourceLibrary",
            "sourcePaths": [],
            "importPaths": ["net"],
        }
    ]
}

However, if "ae" is the same as this, the directory structure needs to be adjusted before it can be used like this. Ideally, all top-level folders ("net", "sys" etc.) should be moved to "source/ae/" and then the package.json looks just like this:

{
    "name": "ae",
    "targetType": "sourceLibrary",
    "sourcePaths": []
}

Due to the way import paths work in D, it doesn't really make sense to use sub-packages here. To really separate those parts, it would be necessary to put them into different directory hierarchies, e.g.:

net-source/ae/net/*
sys-source/ae/sys/*
...

and then:

{
    "name": "ae",
    "targetType": "none",
    "dependencies": {
        "ae:net" : "~master",
    },
    "subPackages": [
        {
            "name": "net",
            "targetType": "sourceLibrary",
            "importPaths": ["net-source"],
        }
    ]
}

@s-ludwig s-ludwig closed this as completed Nov 1, 2013
@vinesworth
Copy link
Author

Oh, thanks for the hints ) Initially I've contacted the author of ae, and he said that there are multiple projects depending on the current directory structure, thus he will only accept a package.json if it doesn't require that change. What I'm doing is trying to workaround that issue. Do you think it's worthwhile, btw?

@s-ludwig
Copy link
Member

s-ludwig commented Nov 1, 2013

Hm, the only workaround that I see is to use "importPaths": [".."] and require that "ae" is checked out in a folder named "ae". But that won't be the case when it's automatically downloaded by DUB.

The other alternative would be to make it a normal source library (instead of header only) and not define any "importPaths", but rely on the module declarations in the source files:

{
    "name": "ae",
    "targetType": "sourceLibrary",
    "sourcePaths": ["net", "sys", ...]
}

I didn't test it, but I think it should be possible to make it work like this, but only if all source files are compiled at once - it will break e.g. in VisualD's single file compilation mode.

Finally, a fork with an adjusted directory structure that is synchronized regularly could of course be used as a last resort. At least git should be able to handle the moved files nicely when rebasing on the latest upstream changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants