Skip to content

Fix issue 17392 - Add Dub file for the lexer and parser#6771

Merged
andralex merged 1 commit intodlang:masterfrom
jacob-carlborg:issue-17392-dub
Jul 16, 2017
Merged

Fix issue 17392 - Add Dub file for the lexer and parser#6771
andralex merged 1 commit intodlang:masterfrom
jacob-carlborg:issue-17392-dub

Conversation

@jacob-carlborg
Copy link
Contributor

@jacob-carlborg jacob-carlborg commented May 12, 2017

The Dub file is intended to make the the compiler available as a library through Dub.

Currently the Dub package is only tested in Travis CI. I don't know if Dub is available in the autotester or not.

@dlang-bot
Copy link
Contributor

dlang-bot commented May 12, 2017

Thanks for your pull request, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Auto-close Bugzilla Description
17392 Add Dub file for the lexer and parser

@jacob-carlborg jacob-carlborg changed the title [WIP] Fix issue 17392 - Add Dub file for the lexer and parser Fix issue 17392 - Add Dub file for the lexer and parser May 12, 2017
@jacob-carlborg
Copy link
Contributor Author

@andralex @RazvanN7 @MartinNowak ping.

@jacob-carlborg
Copy link
Contributor Author

Someone from the D foundation or the D core team would need to create an account on code.dlang.org to make the Dub package available.

dub.sdl Outdated
sourcePaths "docs"

// This is required because Dub needs to have at lease one source file
sourceFiles "src/ddmd/package.d"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there really no better solution here? Having to put hacks for our official package manager in our official compiler's package description is ... not great.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, changing to targetType "none" would allow dropping the sourcePaths and sourceFiles directives and should otherwise behave the same (except that it doesn't generate the extra dummy library).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's not possible to build the main package:

Main package must have a binary target type, not none. Cannot build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it seems like it can still be used as a dependency without any problems. But the natural dub build doesn't work anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, but not sure if it's correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, that's indeed a difference. But dub build would only build the dummy library. Dependencies are only built for dynamic library or executable targets. There is dlang/dub#97, which would solve this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I see. At some point an executable or dynamic library needs to be built for a library to be useful. So I guess it kind of solves itself.

@CyberShadow
Copy link
Member

CC @s-ludwig @wilzbach

dub.sdl Outdated
subPackage {
name "parser"
targetType "library"
sourcePaths "docs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-ludwig Thanks! Is there a similar solution here to avoid the dummy sourcePaths, where only two sourceFiles are needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourcePaths "docs" can be replaced by an empty sourcePaths. Defining an empty list of source paths is enough to inhibit the auto-detection of the "src" folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That worked, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@jacob-carlborg
Copy link
Contributor Author

Anything else that needs to be taken care of before this can be merged?

@andralex
Copy link
Member

Cool beans! I'm on board with this, though it's a bit early :o). @MartinNowak could you do the honors of merging if all looks good?

@jacob-carlborg
Copy link
Contributor Author

Cool beans! I'm on board with this, though it's a bit early :o)

Yes, but if we are very clear that we don't provide any stable API between release and use version 0.x.y, I don't think it's any problem. Semantic versioning says:

"Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable"

We can append the DMD version as metadata, i.e. 0.0.1+2.075.0. Hopefully this can speed up the process of making the frontend available as a library, since it will be more easily accessible. Two pull requests have already broken the separation between the parser and the rest of the frontend. The tests in this PR would catch that.

@yebblies
Copy link
Contributor

The problems with idgen really need to be fixed instead of hacked around. It looks like we can replace idgen with ctfe, since we don't need id.h any more. Any (LDC/GDC) glue uses could use idPool anyway.

@ibuclaw
Copy link
Member

ibuclaw commented May 21, 2017

This uses sdl :sadder:

@jacob-carlborg
Copy link
Contributor Author

The problems with idgen really need to be fixed instead of hacked around. It looks like we can replace idgen with ctfe, since we don't need id.h any more. Any (LDC/GDC) glue uses could use idPool anyway.

Can we wait with that for another pull request?

@yebblies
Copy link
Contributor

Can we wait with that for another pull request?

Why? This PR should wait for that PR IMO, since nobody is likely to actually use this until we have at least a working parser exposed. (See the existing dub package that exposes the lexer.) I don't want the idgen hacks in master.

@jacob-carlborg
Copy link
Contributor Author

Why?

Because I'm trying to keep the PR as small as possible. I've learned the hard way to not create too big PR's or change too much.

@yebblies
Copy link
Contributor

Yeah I'm not asking for that fix in this PR, I want it done in another PR first before this PR is merged. Which would end up making this PR smaller.

This was referenced May 23, 2017
@jacob-carlborg
Copy link
Contributor Author

Yeah I'm not asking for that fix in this PR, I want it done in another PR first before this PR is merged. Which would end up making this PR smaller.

@yebblies I created #6837 for this.

@UplinkCoder
Copy link
Member

UplinkCoder commented May 28, 2017

@jacob-carlborg idgen can be run as a prebuild step.
Or
we ship a pre-generated version of id.d
Which can be updated by idgen whenever idgen changes.

@jacob-carlborg
Copy link
Contributor Author

idgen can be run as a prebuild step.

@UplinkCoder it already is run as a prebuild step [1], but #6771 (comment). I don't care which approach we use, please just come to an agreement.

[1] https://github.com/dlang/dmd/pull/6771/files#diff-406ece895a5b70a272cd76a2ef902836R41

@jacob-carlborg
Copy link
Contributor Author

@yebblies So Walter didn't like that the a header file wasn't generated anymore #6837. Would you like to try convince him or is the solution in this PR acceptable?

@wilzbach
Copy link
Contributor

wilzbach commented Jun 5, 2017

@jacob-carlborg FYI: dlang/dlang.org#1671 will expose the documentation pages for dmd on dlang.org ;-)

The Dub file is intended to make the the compiler available as a
library through Dub.
@wilzbach
Copy link
Contributor

Btw the failure of gdc on Travis wasn't spurious

See also #6999 for using the built compiler to run the test instead of the host compiler as all other test in this file do.

@wilzbach
Copy link
Contributor

Btw @MartinNowak @CyberShadow (see private email for credentials) - I tried to add dlang/dmd to code.dlang.org, but I got this nice error:

image

So how about pushing v0.0.1 as long as SemVer is still WIP?

@ibuclaw
Copy link
Member

ibuclaw commented Jul 17, 2017

Btw the failure of gdc on Travis wasn't spurious.

Well you are using an older version of gdc. The failure itself is dmd frontend that doesn't have the same c++ support as more recent versions.

@jacob-carlborg jacob-carlborg deleted the issue-17392-dub branch July 17, 2017 06:35
@jacob-carlborg
Copy link
Contributor Author

So how about pushing v0.0.1 as long as SemVer is still WIP?

@wilzbach We could also set the version scheme that is currently used as metadata, i.e. v0.0.1+2.075.0.

@ibuclaw
Copy link
Member

ibuclaw commented Jul 17, 2017

By the way, doesn't the auto-merge label prevent broken PRs from being committed? FYI @andralex on why you should not use merge directly.

@CyberShadow
Copy link
Member

@ibuclaw See dlang/dlang-bot#69

@ibuclaw
Copy link
Member

ibuclaw commented Jul 17, 2017

Hmm, and I suppose the autotester only merges if all of its tests pass. So I guess I'm misremembering a time when this was not the case. ☺️

@ibuclaw
Copy link
Member

ibuclaw commented Jul 17, 2017

In the gdc repo, I protect master, and make it so that not even admins can force a merge if any required tests are failing.

Couldn't this be applied here too?

@CyberShadow
Copy link
Member

Yes, we do that too. Jenkins is not currently required because Dub/Vibe tests fail sporadically.

@jacob-carlborg
Copy link
Contributor Author

@CyberShadow but in this case the Jenkins tests passed but not Travis (gdc)

@CyberShadow
Copy link
Member

Oops, that's right.

Travis is not set as required here either. I don't know why, though.

@jacob-carlborg
Copy link
Contributor Author

IIRC, someone said that the macOS test on Travis were failing from time to time.

@jacob-carlborg
Copy link
Contributor Author

Not sure if it's possible to specify some of the tests from Travis to be required.

@ibuclaw
Copy link
Member

ibuclaw commented Jul 17, 2017

Travis has allow_failures or something akin to.

@wilzbach
Copy link
Contributor

IIRC, someone said that the macOS test on Travis were failing

It's not only that, we also have random failures due to

  • dlang.org being unreachable (it got a lot better since we use a second server as fallback, but it's still an issue sometimes
  • code.dlang.org being unreachable (the dub binary is fetched from there even though it's nowadays bundled with DMD and LDC)
  • random failures in the phobos testsuite
  • reaching maximum run time
  • failing to do any output on OSX
    ...

Just browse https://travis-ci.org/dlang/dmd/builds yourself.
So I think those were the reasons against setting it to required.

Travis has allow_failures or something akin to.

Yes, but allowing failures for all builds isn't very useful.

@jacob-carlborg
Copy link
Contributor Author

Just browse https://travis-ci.org/dlang/dmd/builds yourself.

Basically all of the ones I looked at was failing due to exceeding the time limit. One was failing due to code.dlang.org not being available.

@ibuclaw
Copy link
Member

ibuclaw commented Jul 17, 2017

I thought builds averaged 20 minutes. Is travisci that terrible now? Or is the CI tests just doing that much more.

@wilzbach
Copy link
Contributor

So how about pushing v0.0.1 as long as SemVer is still WIP?

Martin was a bit worried that this might jeopardize the plans to rectify SemVer at DMD and confuse users.

@s-ludwig would it be possible to add DMD manually, s.t. only its branches can be used? I guess ~master should be enough in the beginning to start testing this?

@s-ludwig
Copy link
Member

Easiest would be to add a dummy v0.0.1 tag, add it, and then remove the tag again. It will stay registered in that case.

@wilzbach
Copy link
Contributor

Easiest would be to add a dummy v0.0.1 tag, add it, and then remove the tag again. It will stay registered in that case.

OK temporarily added v0.0.1:

https://github.com/dlang/dmd/releases/tag/v0.0.1

But I am still getting the error message - do I need to wait until it the cache is emptied?

image

@s-ludwig
Copy link
Member

Hm, just looked at the source and the registry pick up only the last 100 tags (in lexicographical order). Will open a ticket. You can try with v3.0.0 for the time being.

@wilzbach
Copy link
Contributor

You can try with v3.0.0 for the time being.

Thanks - seems like this worked. Should be public soon:

image

@wilzbach
Copy link
Contributor

Basically all of the ones I looked at was failing due to exceeding the time limit. One was failing due to code.dlang.org not being available.

That's good. At least our previous work has shown some fruits :)
The DUB failures should be gone once dlang/dub#1190 and dlang/dub#1198 have been merged and deployed.
The timeout issues don't affect PRs that much as fewer arguments are used. So we actually could try to require Travis.

What do you think @CyberShadow?

I thought builds averaged 20 minutes. Is travisci that terrible now? Or is the CI tests just doing that much more.

I think it's a combination: performance of Travis is degrading over time due to more users and constantly new tests are added to the testsuite.

@wilzbach
Copy link
Contributor

Should be public soon:

-> http://code.dlang.org/packages/dmd

@jacob-carlborg's unittest modified to an example:

#!/usr/bin/env dub
/++ dub.sdl:
name "dmd_lexer_example"
dependency "dmd" version="~master"
+/
void main()
{
    import ddmd.lexer;
    import ddmd.tokens;
    import std.stdio;

    immutable sourceCode = "void test() {} // foobar";
    scope lexer = new Lexer("test", sourceCode.ptr, 0, sourceCode.length, 0, 0);
 
    while (lexer.nextToken != TOKeof)
        writeln(lexer.token.value);
}

@jacob-carlborg how about making an announcement of your great work?
@RazvanN7 how about using a DUB single file header for your examples?

@CyberShadow
Copy link
Member

What do you think @CyberShadow?

We can try it I guess. Stable too?

@jacob-carlborg
Copy link
Contributor Author

how about making an announcement of your great work?

Yes. That's a good idea 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants