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

Use DC env variable as the default compiler #2047

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

omerfirmak
Copy link
Contributor

@omerfirmak omerfirmak commented Nov 30, 2020

When DUB recursively invokes itself, it sets up the DC
env var with the compiler it is using. The callee dub should
use that compiler if it is not overriden with "--compiler".

DC=ldc2 dub build is equivalent to dub build --compiler=ldc2
DC=ldc2 dub build --compiler=dmd would use dmd

This addresses the issue 1 mentioned in #2012

@dlang-bot
Copy link
Collaborator

Thanks for your pull request and interest in making D better, @omerfirmak! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

@omerfirmak
Copy link
Contributor Author

Any ideas on how to unittest this?

@PetarKirov
Copy link
Member

Probably there are cleaner approaches, but the first thing that comes to my mind is this:

void main()
{
    version (LDC)
        return 1;
    else version (DigitalMars)
        return 2;
    // and so on.
}

Copy link
Member

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

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

Another way to test it is:

void main (string[] args)
{
    version (LDC)
        immutable expected = "ldc2";
    // ...
    assert(expected == args[1], format!"Expected '%s' but got '%s'"(expected, args[1]); 
}

source/dub/dub.d Show resolved Hide resolved
changelog/env-d-compiler.dd Outdated Show resolved Hide resolved
@omerfirmak omerfirmak force-pushed the agora-1323-env-dc branch 7 times, most recently from 9680c91 to 68f34d7 Compare November 30, 2020 16:36
@omerfirmak
Copy link
Contributor Author

omerfirmak commented Nov 30, 2020

Thanks for the reviews! Added the test.

changelog/env-d-compiler.dd Outdated Show resolved Hide resolved
@omerfirmak
Copy link
Contributor Author

Travis seems to be stuck.

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.

4 participants