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

Remove dependency on boost filesystem #679

Closed
wants to merge 1 commit into from
Closed

Remove dependency on boost filesystem #679

wants to merge 1 commit into from

Conversation

meshula
Copy link
Member

@meshula meshula commented Oct 30, 2018

Description of Change(s)

This change introduces an implementation of MkDir to Arch that functions similarly to boost::filesystem's mkdir - it recursively builds a path as necessary. A small test is included to demonstrate functionality.

Fixes Issue(s)

boost::filesystem is used only once, trivially, by the USD suite in the Houdini plug in to create a hierarchy of directories. It seems that retaining this boost dependency for such a simple function is unnecessary.

Linking against boost libraries in general poses continuing challenges especially in tracking compatibility between compiler and cmake versions. Removing this solitary dependency on boost::filesystem in favor of a function in Arch brings us one step closer to having only boost::python as a link dependency.

@marktucker
Copy link
Contributor

If boost::filesystem is only used to do a recursive mkdir, and that is only done from within the Houdini plugin, I'd suggest getting rid of the Arch implementation of the recursive mkdir, and using UT_FileUtil::makeDirs() from within the Houdini HDK instead. No need to pollute USD with code already implemented in Houdini...

@spitzak
Copy link

spitzak commented Oct 30, 2018

This sort of function is needed often enough that maybe it should be provided. I am greatly in favor of avoiding boost file functions due to their messing Unicode transformations into the filename object, which should be byte strings only.

This can be much shorter, just mkdir the string and check the error result. Only if it returns ENOENT do you recurse and try to create the parent directory. Other errors and success return ok.

@jtran56
Copy link

jtran56 commented Oct 30, 2018

Filed as internal issue #USD-4881.

@meshula
Copy link
Member Author

meshula commented Nov 2, 2018

Updated the PR.

boost::system is also unused, so I've elided it.

I extended the unit test to try to catch more expected behaviors of when creating a directory should or should not succeed.

@spitzak I attempted a mkdir/ENOENT variation as you suggested, but haven't found a cross platform pattern that passes the extended unit test. This simple stat method does pass though.

I added for windows only a preprocessor definition that suppresses a pragma lib in boost's headers from bringing in spurious boost link libraries. This one is particularly vexing because the boost name mangling that pragma does frequently mismatches boost libraries end users are attempting to link with.

I added parens to a print in the copy python script to allow that script to run if your build environment has python3 in the path.

@spitzak
Copy link

spitzak commented Nov 2, 2018

What error do you get on Windows if the stat fails? I would add it to the set. I would be interested in what the error is as this sort of code is everywhere. Also to make sure, what I was proposing is this:

Error myMkdir(x) {
   error = mkdir(x);
   if (error == ENOENT) {
       error = myMkdir(parent(x));
       if (not error)
           error = mkdir(x);
   }
   return error;
}

I think adding whatever Windows fails with to the error test would fix this.

The main deal is to get the most likely course to do as few system calls as possible.

@meshula
Copy link
Member Author

meshula commented Nov 3, 2018

Yes, that's roughly the pattern I attempted. If _mkdir returns -1, you should be able to return ENOENT from errno. I didn't observe that to always be true, and the simple loop was becoming spaghetti... Pretty much it was a case that seemed only resolvable by calling stat, which basically took me all the way around the bush to this implementation :) But I'm happy to revisit it; I can dig a bit and find out where it failed.

@spitzak
Copy link

spitzak commented Nov 4, 2018 via email

@spitzak
Copy link

spitzak commented Nov 5, 2018 via email

@meshula
Copy link
Member Author

meshula commented Nov 5, 2018

One possible simplifying semantic would be to return true indicating that a directory is created, and false indicating not. But then, the user will have to follow up with a stat to know if the desired directory exists and is a directory. Nothing's gained in terms of total system calls to accomplish the task. I prefer that the true indicates that a writeable directory exists/was made at the desired place, and false indicates that a writeable directory does not exist there. With my preference, naming the routine ArchMkDir gives a false equivalence to mkdir and _mkdir. Another possibility is to not call the routine ArchMkDir, or to go with the suggestion of not having the routine and using the Houdini routine instead. Writing a POSIX simulator is a slippery slope, as the faulty _mkdir shows.

@spitzak
Copy link

spitzak commented Nov 5, 2018 via email

@c64kernal
Copy link
Contributor

BTW, we've got a change coming to dev after the pending release that removes the boost::filesystem dependency in gusd and uses the Houdini UT method as @marktucker suggested.

@c64kernal
Copy link
Contributor

@meshula -- I've also verified that in build_usd.py we need to keep boost::filesystem around if you're building with OIIO -- I'll add a conditional for that one as well. I hope it's okay with you, but I'll be merging in this change piecemeal with the end goal of getting rid of the dependency on boost::filesystem and boost::system if you're not building with OIIO...

@meshula
Copy link
Member Author

meshula commented Dec 11, 2018

Sounds good. I'm trying to reproduce this issue. Which platform(s) require boost::filesystem when using OIIO? Also, this is when using the build_usd.py script, I assume?

@c64kernal
Copy link
Contributor

As far as I know, all platforms require boost::filesystem for OIIO, but I've been testing on Windows. And yeah this is with build_usd.py

I've landed several changes already that incorporate some of this PR. They should hit dev soon hopefully so that you can have a look.

Right now I'm working on removing more dependencies from build_usd.py and making them conditional on whether or not you build OIIO (we'll also have to test with the various plugins, e.g., Katana, Maya, etc.) and on the different platforms, but so far I haven't gotten to any of that -- I expect that we'll be able to do much better than we do today if you don't build all those plugins.

@meshula
Copy link
Member Author

meshula commented Dec 12, 2018

One more follow up - you've got BOOST_ALL_NO_LIB defined, when building the OIIO plugin for usd?

if(WIN32)
    # On Windows, boost automagic library linking via pragma lib is problematic, so suppress it
    add_definitions(-DBOOST_ALL_NO_LIB)
endif()

@c64kernal
Copy link
Contributor

I don't have that set! Though I get the same issue on linux, and the missing dependency is expressed in cmake (somewhere!) before it hits the boost build system, I think.

FWIW, what I've got so far (still testing) is build filesystem only when OIIO is requested and build date_time and thread only if either OIIO or Katana plugins are requested. And again, this logic only lives in build_usd.py.

pixar-oss pushed a commit that referenced this pull request Dec 16, 2018
Removes dependency on boost::filesystem from gusd and uses Houdini
supplied method instead.  This will allow us to get rid of one more
dependency on a non-header boost library.

See #679

(Internal change: 1923905)
pixar-oss pushed a commit that referenced this pull request Dec 16, 2018
pixar-oss pushed a commit that referenced this pull request Dec 16, 2018
We no longer rely on boost::filesystem and system, remove them
from our build scripts.

We do still need to build boost::filesystem if the build includes
OpenImageIO, so we make that dependency conditional.

See #679

(Internal change: 1924232)
pixar-oss pushed a commit that referenced this pull request Dec 16, 2018
boost::thread also brings along with it date_time and system.

See #679

(Internal change: 1924518)
@c64kernal
Copy link
Contributor

Hey @meshula -- the changes for this landed in dev. Have a look at them and let me know what you think. If you see something important that's missing, feel free to reopen or submit a new PR. Thanks so much!

@c64kernal c64kernal closed this Dec 20, 2018
@meshula
Copy link
Member Author

meshula commented Dec 20, 2018

Fantastic! I look forward to playing with it!

AdamFelt pushed a commit to autodesk-forks/USD that referenced this pull request Apr 16, 2024
…diateInfo. (PixarAnimationStudios#679)

### Description of Change(s)
Move the ScriptInfo and WordBreakIndexList into intermediateInfo.

### Fixes Issue(s)
-

<!--
Please follow the Contributing and Building guidelines to run tests against your
change. Place an X in the box if tests are run and are all tests passing.
-->
- [ ] I have verified that all unit tests pass with the proposed changes
<!--
Place an X in the box if you have submitted a signed Contributor License Agreement.
A signed CLA must be received before pull requests can be merged.
For instructions, see: http://openusd.org/release/contributing_to_usd.html
-->
- [ ] I have submitted a signed Contributor License Agreement

(cherry picked from commit 5fe87842f8b9569ec9ddb29a752ce48b2491742d)
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.

5 participants