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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ if(PXR_ENABLE_PYTHON_SUPPORT)
# --Boost
find_package(Boost
COMPONENTS
filesystem
program_options
python
system
REQUIRED
)

Expand All @@ -60,13 +58,16 @@ else()
# --Boost
find_package(Boost
COMPONENTS
filesystem
program_options
system
REQUIRED
)
endif()

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

# --TBB
find_package(TBB REQUIRED COMPONENTS tbb)
add_definitions(${TBB_DEFINITIONS})
Expand Down
2 changes: 1 addition & 1 deletion cmake/macros/copyHeaderForBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import os, sys

if len(sys.argv) != 3:
print "Usage: {0} src dst".format(sys.argv[0])
print ("Usage: {0} src dst".format(sys.argv[0]))
sys.exit(1)

srcFile = sys.argv[1]
Expand Down
40 changes: 40 additions & 0 deletions pxr/base/lib/arch/fileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <cerrno>
#include <memory>
#include <utility>
#include <vector>

#include <fcntl.h>
#include <sys/types.h>
Expand Down Expand Up @@ -84,6 +85,45 @@ int ArchRmDir(const char* path)
}
#endif

bool ArchMkDir(const char* full_path)
{
if (!full_path)
return true;

size_t sz = strlen(full_path);
if (!sz)
return true;

std::string path(full_path);
path = ArchNormPath(path, false);

// test the full path for existence
ArchStatType st;
#if defined(ARCH_OS_WINDOWS)
if ((_stat64(path.c_str(), &st) == 0) && (((st.st_mode & _S_IFDIR) == _S_IFDIR)))
return true;
#else
if ((stat(path.c_str(), &st) == 0) && (S_ISDIR(st.st_mode)))
return true;
#endif

size_t sep = path.rfind('/');
if (sep != string::npos)
{
std::string sub_path = path.substr(0, sep);
if (!ArchMkDir(sub_path.c_str()))
return false; // propagate failures
}

int result;
#if defined(ARCH_OS_WINDOWS)
result = _mkdir(path.c_str());
#else
result = mkdir(path.c_str(), 0777);
#endif
return result == 0;
}

bool
ArchStatIsWritable(const ArchStatType *st)
{
Expand Down
2 changes: 2 additions & 0 deletions pxr/base/lib/arch/fileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ ArchOpenFile(char const* fileName, char const* mode);
# define ArchRmDir(path) rmdir(path)
#endif

ARCH_API bool ArchMkDir(const char* path);

/// Return the length of a file in bytes.
///
/// Returns -1 if the file cannot be opened/read.
Expand Down
27 changes: 26 additions & 1 deletion pxr/base/lib/arch/testenv/testFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,34 @@ int main()
// create and remove a tmp subdir
std::string retpath;
retpath = ArchMakeTmpSubdir(ArchGetTmpDir(), "myprefix");
ARCH_AXIOM (retpath != "");
ARCH_AXIOM(retpath != "");
ArchRmDir(retpath.c_str());

// create a temp subdir again
retpath = ArchMakeTmpSubdir(ArchGetTmpDir(), "myprefix");
ARCH_AXIOM(retpath != "");

// ensure that MkDir on an existing directory returns true
ARCH_AXIOM(ArchMkDir(retpath.c_str()));

// make a nested subdir
std::string nestedpath = retpath + "/sub/dir/test";
ARCH_AXIOM(ArchMkDir(nestedpath.c_str()));

// create a file in that directory
std::string filename = nestedpath + "/dummy.test";
ARCH_AXIOM((firstFile = ArchOpenFile(filename.c_str(), "wb")) != NULL);
fputs(testContent, firstFile);
fclose(firstFile);

// ensure mkdir returns false if trying to create a directory where it can't
ARCH_AXIOM(!ArchMkDir(filename.c_str()));

// remove
ArchRmDir(nestedpath.c_str());

printf("YAY\n");

// Test other utilities
TestArchNormPath();
TestArchAbsPath();
Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/lib/garch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pxr_library(garch
LIBRARIES
arch
tf
${Boost_SYSTEM_LIBRARY}
${OPENGL_gl_LIBRARY}
${APPKIT_LIBRARY}

Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/lib/glf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pxr_library(glf
trace
sdf
${Boost_PYTHON_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${GLEW_LIBRARY}
Expand Down
2 changes: 0 additions & 2 deletions third_party/houdini/lib/gusd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pxr_shared_library(${PXR_PACKAGE}
usdRi
usdShade
usdUtils
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${HOUDINI_LIB_NAMES}

INCLUDE_DIRS
Expand Down
7 changes: 2 additions & 5 deletions third_party/houdini/lib/gusd/shaderWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <pxr/usd/usdShade/connectableAPI.h>

#include <pxr/usd/usdRi/materialAPI.h>
#include <pxr/base/arch/filesystem.h>

#include <DEP/DEP_MicroNode.h>
#include <PRM/PRM_ParmList.h>
Expand All @@ -40,8 +41,6 @@
#include <UT/UT_Version.h>
#include <UT/UT_EnvControl.h>

#include <boost/filesystem.hpp>

#include <iostream>
#include <fstream>

Expand Down Expand Up @@ -74,9 +73,7 @@ _buildCustomOslNode(const VOP_Node* vopNode,
shaderName.prepend(shaderOutDir.c_str());

// Create shaderOutDir path directories, if they don't exist.
try {
boost::filesystem::create_directories(shaderOutDir);
} catch (boost::filesystem::filesystem_error &e) {
if (!ArchMkDir(shaderOutDir.c_str()) {
TF_CODING_ERROR("Failed to create dir '%s': %s", shaderOutDir.c_str(),
e.what());
return false;
Expand Down
1 change: 0 additions & 1 deletion third_party/katana/lib/usdKatana/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pxr_shared_library(${PXR_PACKAGE}
usdUtils
cameraUtil
katanaAttrfncApi
${Boost_SYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}

PUBLIC_CLASSES
Expand Down