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

Rsp support #32

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Rsp support #32

wants to merge 12 commits into from

Conversation

John-Colvin
Copy link
Contributor

@John-Colvin John-Colvin commented Apr 9, 2018

For compatibilities sake I just took dmd's implementation and did the bare minimum to make it work.

There aren't any tests so far, I haven't properly navigated the test setup you're using here yet.

This is all that's necessary to work with https://github.com/John-Colvin/dub/tree/dpp_support

if(!options.keepDlangFiles) {
foreach(fileName; options.dFileNames)
remove(fileName);
}
enforce(status == 0, "Executing `" ~ args.join(" ") ~ "` failed with exit code\n" ~ status.text);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved this to the end so files get cleaned up even if things fail (user can obviously specify to keep the files if they want to inspect them)

filter!(a => a.extension == ".dpp" || a.extension == ".d")
.front
.stripExtension
~ exeExtension;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no need to handle this here, if we don't mess with file ordering then we get dmd's behaviour for free.

~ exeExtension;
dlangCompilerArgs = args[1..$]
.map!(a => a.extension == ".dpp" ? toDFileName(a) : a)
.array;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

avoiding re-ordering files on the command line.

// ported from dmd's function of the same name.
// only modifications are to use builtin arrays
// and phobos in place of dmd's bespoke types
bool response_expand(ref const(char)*[] args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was gonna port some dmd tests for this function as well, but..... I couldn't find them. I suspect they don't exist


foreach(dppFileName; options.dppFileNames)
preprocess!File(options, dppFileName, options.toDFileName(dppFileName));

if(options.preprocessOnly) return;

const args = options.dlangCompiler ~ options.dlangCompilerArgs;
const res = execute(args);
enforce(res.status == 0, "Could not execute `" ~ args.join(" ") ~ "`:\n" ~ res.output);
const status = spawnProcess(args).wait();
Copy link
Owner

Choose a reason for hiding this comment

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

Why spawnProcess.wait instad of execute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that the compiler output gets out regardless of what d++ thinks. pragma(msg,...) needs to get out even on success, as do warnings. Also, you want to see whatever output you might have got before (or during) an infinite loop in the compiler or ctfe, so we can't wait for the compiler to finish before printing, might as well let it do its own printing to std{out/err}.

Copy link
Owner

Choose a reason for hiding this comment

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

Makes sense.


foreach(dppFileName; options.dppFileNames)
preprocess!File(options, dppFileName, options.toDFileName(dppFileName));

if(options.preprocessOnly) return;

const args = options.dlangCompiler ~ options.dlangCompilerArgs;
const res = execute(args);
enforce(res.status == 0, "Could not execute `" ~ args.join(" ") ~ "`:\n" ~ res.output);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to have this, if the target compiler can handle what's been given then we just pass it through.

Copy link
Owner

Choose a reason for hiding this comment

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

It's needed or else the compiler failing would cause d++ to return 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I commented in the wrong place. This line is still there, just moved down a bit.

@atilaneves
Copy link
Owner

Merging this without a test gives me the heebie jeebies, especially when the codecov check says -13% coverage.

You said that this is needed to work with your dub work - I assume that means you tested it manually? How so?

dppFileNames = args.filter!(a => a.extension == ".dpp").array;
enforce(dppFileNames.length != 0, "No .dpp input file specified\n" ~ usage);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where I meant to write this:

no need to have this, if the target compiler can handle what's been given then we just pass it through.

@John-Colvin
Copy link
Contributor Author

Things that should be tested:

  • You can see the d compiler output when compilation fails (ideally even in infinite loop - e.g. ctfe loop forever - case, could be tested but probably not worth it)

  • make sure that any mixture of dpp and d files end up in the order they were originally passed when they hit the d compiler.

  • should be able to do compilation of .d files without any .dpp files (because it should be a drop-in replacement)

  • .rsp file, passed on command line as e.g. dpp someDFile.d @myArgs.rsp someDppFile.dpp -blahImAFlag -release with any possible ordering of those arguments. .rsp extension is not required. Contents of .rsp file is just command line arguments, arguments are separated by spaces, tabs, or newlines. Obviously arguments that contain spaces have to have quotes around them.

  • less important as dub doesn't use it, but still strictly needed to be transparent drop-in for dmd/ldc/gdc: flags in an environment variable. Contents rules are exactly the same as the file-based case. E.g. this, note no $

      export EXTRA_ARGS=-O -inline blah.dpp
      dpp < ... some args ... > @EXTRA_ARGS < ... some more args ... >
    

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

Successfully merging this pull request may close these issues.

2 participants