File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,16 +5,23 @@ set(PXR_PREFIX pxr/base)
55set (PXR_PACKAGE arch)
66
77if (NOT EMSCRIPTEN)
8- set (PLATFORM_LIBS ${M_LIB} )
8+ set (ARCH_PLATFORM_LIBS ${M_LIB} )
9+ set (ARCH_PLATFORM_HEADERS "" )
10+ set (ARCH_PLATFORM_CPPFILES "" )
911endif ()
12+
1013if (WIN32 )
11- set (PLATFORM_LIBS Ws2_32.lib Dbghelp.lib ${PLATFORM_LIBS} )
14+ set (ARCH_PLATFORM_LIBS Ws2_32.lib Dbghelp.lib ${ARCH_PLATFORM_LIBS} )
15+ elseif (APPLE )
16+ set (ARCH_PLATFORM_HEADERS darwin.h)
17+ set (ARCH_PLATFORM_CPPFILES darwin.mm)
18+ set (ARCH_PLATFORM_LIBS "-framework Foundation" ${ARCH_PLATFORM_LIBS} )
1219endif ()
1320
1421pxr_library (arch
1522 LIBRARIES
1623 ${CMAKE_DL_LIBS}
17- ${PLATFORM_LIBS }
24+ ${ARCH_PLATFORM_LIBS }
1825
1926 PUBLIC_CLASSES
2027 align
@@ -53,10 +60,12 @@ pxr_library(arch
5360 PRIVATE_HEADERS
5461 testArchAbi.h
5562 testArchUtil.h
63+ ${ARCH_PLATFORM_HEADERS}
5664
5765 CPPFILES
5866 assumptions.cpp
5967 initConfig.cpp
68+ ${ARCH_PLATFORM_CPPFILES}
6069
6170 DOXYGEN_FILES
6271 overview.dox
Original file line number Diff line number Diff line change 1+ //
2+ // Copyright 2025 Apple
3+ //
4+ // Licensed under the terms set forth in the LICENSE.txt file available at
5+ // https://openusd.org/license.
6+ //
7+ #ifndef PXR_ARCH_DARWIN_H
8+ #define PXR_ARCH_DARWIN_H
9+ #include "pxr/pxr.h"
10+
11+ PXR_NAMESPACE_OPEN_SCOPE
12+
13+ const char * Arch_DarwinGetTemporaryDirectory ();
14+
15+ PXR_NAMESPACE_CLOSE_SCOPE
16+ #endif // PXR_ARCH_DARWIN_H
Original file line number Diff line number Diff line change 1+ //
2+ // Copyright 2025 Apple
3+ //
4+ // Licensed under the terms set forth in the LICENSE.txt file available at
5+ // https://openusd.org/license.
6+ //
7+
8+ #include " pxr/base/arch/darwin.h"
9+ #import < Foundation/Foundation.h>
10+
11+ PXR_NAMESPACE_OPEN_SCOPE
12+
13+
14+ const char * Arch_DarwinGetTemporaryDirectory () {
15+ return [NSTemporaryDirectory () UTF8String ];
16+ }
17+
18+ PXR_NAMESPACE_CLOSE_SCOPE
Original file line number Diff line number Diff line change 4141#include < unistd.h>
4242#endif
4343
44+ #if defined(ARCH_OS_DARWIN)
45+ #include " pxr/base/arch/darwin.h"
46+ #endif
47+
4448PXR_NAMESPACE_OPEN_SCOPE
4549
4650using std::pair;
@@ -727,6 +731,9 @@ Arch_InitTmpDir()
727731 // Strip the trailing slash
728732 tmpPath[sizeOfPath-1 ] = 0 ;
729733 _TmpDir = _strdup (ArchWindowsUtf16ToUtf8 (tmpPath).c_str ());
734+ #elif defined(ARCH_OS_DARWIN)
735+ // On Apple platforms, we use the system APIs to get the designated temp directory
736+ _TmpDir = strdup (Arch_DarwinGetTemporaryDirectory ());
730737#else
731738 const std::string tmpdir = ArchGetEnv (" TMPDIR" );
732739 if (!tmpdir.empty ()) {
@@ -735,9 +742,7 @@ Arch_InitTmpDir()
735742 // set, the following call will leak a string.
736743 _TmpDir = strdup (tmpdir.c_str ());
737744 } else {
738- #if defined(ARCH_OS_DARWIN)
739- _TmpDir = " /tmp" ;
740- #elif defined(ARCH_OS_WASM_VM)
745+ #if defined(ARCH_OS_WASM_VM)
741746 // Note: WASM will always create /tmp as part of its in memory
742747 // filesystem. All data will be lost when the VM is shut down.
743748 _TmpDir = " /tmp" ;
You can’t perform that action at this time.
0 commit comments