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

Structured inputs for Rust (and more languages in the future, probably) #8775

Closed

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented May 18, 2021

The fixed issue has most of the background on this, so I'm not going to repeat it, go look at #8725 for more info.

The goal of this series is to make it possible to use generated files with languages that do all of their compilation in one go (Rust, Cython, Zig), and rely on the layout of those files on disk for imports (Rust, Cython, Zig). For those languages we don't generate a single .o for each source file, the compilers and/or languages simply don't make that possible. Instead, we generate a singlle compilation target for all of those sources.

To that end this series introduces a new concept, the "structured input". This input is a dictionary mapping an arbitrary "root" to a directory tree (at the moment the target's private directory is used as the root), like so:

executable(
  'exe',
  {
    '': 'main.rs',
    'foo' : 'mod.rs',
    'bar': generated_mod.rs,
  }
)

Meson will ensure that at the root of the tree is main.rs, then a root/foo/mod.rs exists, as does root/bar/generated_mod.rs, it will do this before compiling mian.rs If necessary it will copy files (at build time) into the build tree. It does this at build time to avoid reconfiguring on file changes, and to ensure that the tree is always accurate. This is unnecessary if there are no generated sources, and simply passing executable('exe', 'main.rs') has not been changed.

Fixes #8725

dcbaker added 12 commits May 17, 2021 16:06
The build level shouldn't be deal with interpreter objects, by the time
they leave the intpreter they should be in the Meson middle layer
representaiton
Currently it's useless, but it can be passed in and assigned.
This allows for generating structured inputs for Rust targets, including
CustomTargets, ConfigurationFiles, and static files that need to be
copied/moved.
instead of opencoding what should be there in the rust compile rule
Rust is the only language the currently requires structured inputs, so
it's the only one I'm implementing.
This is hardly complete, but it's a start.
@dcbaker dcbaker requested review from jpakkane and mensinda as code owners May 18, 2021 00:00
@lgtm-com
Copy link

lgtm-com bot commented May 18, 2021

This pull request introduces 2 alerts when merging 9a0dd4c into be015a3 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Unused import

@jpakkane
Copy link
Member

executable(
  'exe',
  {
    '': 'main.rs',
    'foo' : 'mod.rs',
    'bar': generated_mod.rs,
  }
)

This is unacceptable as a syntax. It is completely unreadable with the magic dictionaries and all.

@lgtm-com
Copy link

lgtm-com bot commented May 18, 2021

This pull request introduces 2 alerts when merging f396f76 into be015a3 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Unused import

@dcbaker
Copy link
Member Author

dcbaker commented May 18, 2021

Then do you have another idea on what the syntax should be, @jpakkane?

@dcbaker
Copy link
Member Author

dcbaker commented Jun 22, 2021

@jpakkane, how would you feel about a new function instead?:

sources = structured_source(
  foo_gen_pyx, 'foo_static.pyx',
  sub : bar_gen_pyx, 'bar_static.pyx',
  ...
)

target = py.module('foo', sources)

@dcbaker dcbaker added this to the 0.59.0 milestone Jun 22, 2021
@jpakkane
Copy link
Member

Sure, something like that makes a lot more sense as it is its own isolated thing.

@dcbaker
Copy link
Member Author

dcbaker commented Oct 1, 2021

This is going to need enough rework that I'm just giong to open a new PR for this.

@dcbaker dcbaker removed this from the 0.59.0 milestone Oct 1, 2021
@dcbaker dcbaker mentioned this pull request Oct 1, 2021
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.

Filesystem significant languages and build directory implementation details
2 participants