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

std::filesystem support with polyfill #12104

Closed
5 tasks done
jwnimmer-tri opened this issue Sep 26, 2019 · 5 comments
Closed
5 tasks done

std::filesystem support with polyfill #12104

jwnimmer-tri opened this issue Sep 26, 2019 · 5 comments

Comments

@jwnimmer-tri
Copy link
Collaborator

jwnimmer-tri commented Sep 26, 2019

We'd like to use std::filesystem in lieu of spruce.

It looks like std::filesystem is still only std::experimental::filesystem in Ubuntu 18.04 (Bionic) and macOS Mojave (10.14), but will be non-experimental as of Ubuntu 20.04 and macOS Catalina (10.15).

Therefore, my plan would be to use https://github.com/gulrak/filesystem (aka ghc::filesystem) as polyfill for OS versions without standard library support, but to use the standard library when available (as we do with, e.g. std::optional).

Once we drop support for Mojave 10.14 (i.e., when 10.16 comes out) such that Bionic is the only straggler, we could image dropping ghc::filesystem and using std::experimental::filesystem with -lstdc++fs if we'd like to lose the extra dependency.

The questions for ghc::filesystem is whether we compile it as single-header vs separate, and whether we allow it as a public dependency (from h files) or only private like with spruce currently (only from cc files). My current thought is to start with private.

WIP at https://github.com/jwnimmer-tri/drake/commits/filesystem

\CC @jamiesnape @EricCousineau-TRI

@jamiesnape
Copy link
Contributor

jamiesnape commented Sep 26, 2019

single-header vs separate,

Separate, using the wrapper headers? I think I have a mild preference for separate, depending in part on whether the dependency is private (my preference is stronger if it is public).

My current thought is to start with private.

Agree.

@jwnimmer-tri
Copy link
Collaborator Author

jwnimmer-tri commented Sep 26, 2019

My WIP uses separate compilation, but without the wrapper headers. By rolling our own presence check, we can avoid all dependency on ghc for users who have a sufficiently new toolchain, which is nice for commercial users who have to separately vendor every source dependency of Drake (which includes both TRI and other companies).

@jamiesnape
Copy link
Contributor

That sounds good to me.

@jwnimmer-tri
Copy link
Collaborator Author

jwnimmer-tri commented Sep 26, 2019

In #12106 we'll add ghc::filesystem. Future PRs will work to remove @spruce. We should also upstream some old-style-cast warning fixups.

@jwnimmer-tri
Copy link
Collaborator Author

As of #12182, @spruce is never used internally in Drake, and is deprecated for use by downstream bazel projects. (It was never available downstream to CMake projects.) After the 3-month window, it will be removed from the source tree.

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

No branches or pull requests

2 participants