Skip to content

Commit

Permalink
Bring support for Microsoft Windows nearly here.
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <devs@wabi.foundation>
  • Loading branch information
furby-tm committed Aug 28, 2024
1 parent c6f8395 commit 90faf23
Show file tree
Hide file tree
Showing 217 changed files with 668 additions and 876 deletions.
53 changes: 4 additions & 49 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,49 +1,13 @@
{
"originHash" : "f185df3d3c50c2e3f896f9a641d1efcb55956dcfff1daef529be75f505276ed8",
"originHash" : "ce1aee86fa5c8d9a7438ca07a0fd98efa7cca704d376c5db8983be8ed22dddbc",
"pins" : [
{
"identity" : "galah",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wabiverse/galah.git",
"state" : {
"revision" : "9d829bdd244676ef77b2bd219093c59a6315adaf",
"version" : "1.0.1"
}
},
{
"identity" : "metaversekit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wabiverse/MetaverseKit",
"state" : {
"revision" : "a93afc6413a829ef9c74f111128fb902677cf532",
"version" : "1.7.8"
}
},
{
"identity" : "metaversepythonframework",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wabiverse/MetaversePythonFramework",
"state" : {
"revision" : "e2f4ba867b7e287a283a27a0005ab64deef14279",
"version" : "3.11.7"
}
},
{
"identity" : "metaversevulkanframework",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wabiverse/MetaverseVulkanFramework",
"state" : {
"revision" : "13c7061599c61a4959c558d8ec1836e5b32b640b",
"version" : "1.26.2"
}
},
{
"identity" : "pythonkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pvieito/PythonKit.git",
"state" : {
"revision" : "43647b36cacb99558e57ef98e97ef598f91d1164",
"version" : "0.5.0"
"revision" : "73fcb0d3b3e83e9e1b83d54338cf1d58251053a4",
"version" : "1.8.1"
}
},
{
Expand Down Expand Up @@ -91,15 +55,6 @@
"version" : "1.6.1"
}
},
{
"identity" : "swift-macro-toolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/stackotter/swift-macro-toolkit",
"state" : {
"revision" : "687075e7bf976e121d083e922a07c7a9350ca85d",
"version" : "0.4.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
Expand All @@ -120,4 +75,4 @@
}
],
"version" : 3
}
}
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ let package = Package(
dependencies: [
// prepare for SwiftCrossUI, for a cross-platform UsdView.
// .package(url: "https://github.com/stackotter/swift-cross-ui", revision: "5c5d8c8"),
.package(url: "https://github.com/wabiverse/MetaverseKit", from: "1.7.8"),
.package(url: "https://github.com/wabiverse/MetaverseKit", from: "1.8.1"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "510.0.3"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.4.0"),
Expand Down Expand Up @@ -322,6 +322,7 @@ let package = Package(
.define("MFB_PACKAGE_MODULE", to: "Arch"),
.define("ARCH_EXPORTS", to: "1"),
.define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])),
.define("ARCH_COMPILER_MSVC", .when(platforms: [.windows])),
]
),

Expand Down Expand Up @@ -547,6 +548,7 @@ let package = Package(
.define("MFB_PACKAGE_MODULE", to: "Sdf"),
.define("SDF_EXPORTS", to: "1"),
.define("_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH", .when(platforms: [.windows])),
.define("YY_NO_UNISTD_H", .when(platforms: [.windows]))
]
),

Expand Down Expand Up @@ -1507,7 +1509,7 @@ let package = Package(
.target(name: "UsdShade"),
.target(name: "UsdLux"),
.target(name: "UsdHydra"),
.target(name: "UsdAbc"),
.target(name: "UsdAbc", condition: .when(platforms: Arch.OS.nix.platform)),
.target(name: "UsdDraco"),
.target(name: "UsdMedia"),
.target(name: "UsdMtlx"),
Expand Down
6 changes: 3 additions & 3 deletions Python/PyTf/wrapStringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ static long _StringToLong(char const *str)

static unsigned long _GetULongMax()
{
return std::numeric_limits<unsigned long>::max();
return (std::numeric_limits<unsigned long>::max)();
}

static long _GetLongMax()
{
return std::numeric_limits<long>::max();
return (std::numeric_limits<long>::max)();
}

static long _GetLongMin()
{
return std::numeric_limits<long>::min();
return (std::numeric_limits<long>::min)();
}

} // anonymous namespace
Expand Down
4 changes: 2 additions & 2 deletions Python/PyUsdUtils/wrapStitchClips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool _ConvertStitchClips(const SdfLayerHandle &resultLayer,
const object pyClipSet)
{
const auto clipSet = _ConvertWithDefault(pyClipSet, UsdClipsAPISetNames->default_);
constexpr double dmax = std::numeric_limits<double>::max();
constexpr double dmax = (std::numeric_limits<double>::max)();
return UsdUtilsStitchClips(resultLayer,
clipLayerFiles,
clipPath,
Expand Down Expand Up @@ -74,7 +74,7 @@ bool _ConvertStitchClipTemplate(const SdfLayerHandle &resultLayer,
{
const auto clipSet = _ConvertWithDefault(pyClipSet, UsdClipsAPISetNames->default_);
const auto activeOffset = _ConvertWithDefault(pyActiveOffset,
std::numeric_limits<double>::max());
(std::numeric_limits<double>::max)());
const auto interpolateMissingClipValues = _ConvertWithDefault(pyInterpolateMissingClipValues,
false);
return UsdUtilsStitchClipsTemplate(resultLayer,
Expand Down
6 changes: 3 additions & 3 deletions Python/PyVt/wrapValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ struct Vt_ValueFromPython {
// long or unsigned long long or fail, depending on range.
long long val = PyLong_AsLongLong(obj_ptr);
if (!PyErr_Occurred()) {
if (std::numeric_limits<int>::min() <= val && val <= std::numeric_limits<int>::max()) {
if ((std::numeric_limits<int>::min)() <= val && val <= (std::numeric_limits<int>::max)()) {
new (storage) VtValue(int(val));
}
else if (std::numeric_limits<long>::min() <= val &&
val <= std::numeric_limits<long>::max())
else if ((std::numeric_limits<long>::min)() <= val &&
val <= (std::numeric_limits<long>::max)())
{
new (storage) VtValue(long(val));
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Ar/include/Ar/resolverContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include "Tf/hash.h"
#include "Tf/safeTypeCompare.h"

#ifdef PXR_PYTHON_SUPPORT_ENABLED
#if defined(PXR_PYTHON_SUPPORT_ENABLED) && PXR_PYTHON_SUPPORT_ENABLED
// XXX: This include is a hack to avoid build errors due to
// incompatible macro definitions in pyport.h on macOS.
# include "Tf/pyLock.h"
# include <locale>
#endif
#endif // defined(PXR_PYTHON_SUPPORT_ENABLED) && PXR_PYTHON_SUPPORT_ENABLED

#include "Tf/pyObjWrapper.h"

Expand Down Expand Up @@ -266,7 +266,7 @@ class ArResolverContext {

virtual TfPyObjWrapper GetPythonObj() const
{
#ifdef PXR_PYTHON_SUPPORT_ENABLED
#if defined(PXR_PYTHON_SUPPORT_ENABLED) && PXR_PYTHON_SUPPORT_ENABLED
TfPyLock lock;
return boost::python::object(_context);
#else
Expand All @@ -283,7 +283,7 @@ class ArResolverContext {
h.Append(context->Hash());
}

#ifdef PXR_PYTHON_SUPPORT_ENABLED
#if defined(PXR_PYTHON_SUPPORT_ENABLED) && PXR_PYTHON_SUPPORT_ENABLED
friend class Ar_ResolverContextPythonAccess;
#endif

Expand Down
4 changes: 2 additions & 2 deletions Sources/Ar/resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ class _DispatchingResolver final : public ArResolver {
std::make_shared<_Resolver>(resolverInfo);

for (std::string &uriScheme : uriSchemes) {
maxSchemeLength = std::max(uriScheme.length(), maxSchemeLength);
maxSchemeLength = (std::max)(uriScheme.length(), maxSchemeLength);
uriResolvers.emplace(std::move(uriScheme), uriResolver);
};
}
Expand Down Expand Up @@ -1210,7 +1210,7 @@ class _DispatchingResolver final : public ArResolver {
// Search for the first ":" character delimiting a URI/IRI scheme in
// the given asset path. As an optimization, we only search the
// first _maxURISchemeLength + 1 (to accommodate the ":") characters.
const size_t numSearchChars = std::min(assetPath.length(), _maxURISchemeLength + 1);
const size_t numSearchChars = (std::min)(assetPath.length(), _maxURISchemeLength + 1);

auto endIt = assetPath.begin() + numSearchChars;
auto delimIt = std::find(assetPath.begin(), endIt, ':');
Expand Down
1 change: 1 addition & 0 deletions Sources/Arch/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://openusd.org/license.
//

#include "Arch/defines.h"
#include "Arch/attributes.h"
#include "Arch/error.h"
#include "pxr/pxrns.h"
Expand Down
6 changes: 3 additions & 3 deletions Sources/Arch/demangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using std::string;
# define _AT_LEAST_GCC_THREE_ONE_OR_CLANG
#endif

#if defined(_AT_LEAST_GCC_THREE_ONE_OR_CLANG)
#if defined(_AT_LEAST_GCC_THREE_ONE_OR_CLANG) && !defined(ARCH_OS_WINDOWS)
# include <cxxabi.h>
#endif

Expand Down Expand Up @@ -124,7 +124,7 @@ static void _StripPxrInternalNamespace(string *name)

#endif

#if defined(_AT_LEAST_GCC_THREE_ONE_OR_CLANG)
#if defined(_AT_LEAST_GCC_THREE_ONE_OR_CLANG) && !defined(ARCH_OS_WINDOWS)

/*
* This routine doesn't work when you get to gcc3.4.
Expand Down Expand Up @@ -256,7 +256,7 @@ void Arch_DemangleFunctionName(string *mangledFunctionName)
ArchDemangle(mangledFunctionName);
}

#endif // _AT_LEAST_GCC_THREE_ONE_OR_CLANG
#endif // _AT_LEAST_GCC_THREE_ONE_OR_CLANG && !defined(ARCH_OS_WINDOWS)

string ArchGetDemangled(const string &typeName)
{
Expand Down
9 changes: 6 additions & 3 deletions Sources/Arch/include/Arch/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
/// This file allows you to define architecture-specific or compiler-specific
/// options to be used outside lib/arch.

#include "Arch/defines.h"
#include "Arch/export.h"
#include "pxr/pxrns.h"

#if defined(ARCH_OS_WINDOWS)
# include "Arch/api.h"
#endif // defined(ARCH_OS_WINDOWS)

PXR_NAMESPACE_OPEN_SCOPE

#if defined(doxygen)
Expand Down Expand Up @@ -257,8 +262,6 @@ struct Arch_ConstructorEntry {

#elif defined(ARCH_OS_WINDOWS)

# include "Arch/api.h"

// Entry for a constructor/destructor in the custom section.
__declspec(align(16)) struct Arch_ConstructorEntry {
typedef void(__cdecl *Type)(void);
Expand All @@ -267,7 +270,7 @@ __declspec(align(16)) struct Arch_ConstructorEntry {
unsigned int priority : 8; // Priority of function
};

// Declare the special sections.
// // Declare the special sections.
# pragma section(".pxrctor", read)
# pragma section(".pxrdtor", read)

Expand Down
2 changes: 1 addition & 1 deletion Sources/Arch/include/Arch/fileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# include <unistd.h>
#elif defined(ARCH_OS_WINDOWS)
# include <io.h>
# include <stringapiset.h>
// # include <stringapiset.h>
# include <windows.h>
#endif

Expand Down
6 changes: 3 additions & 3 deletions Sources/Arch/stackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ static void _ArchLogProcessStateHelper(bool isFatal,

const char *haltMsg = " terminated";
int labelSize = strlen(progname) + strlen(haltMsg);
int bannerSize = std::max<int>(80, labelSize + strlen("-- ") * 2);
int bannerSize = (std::max<int>)(80, labelSize + strlen("-- ") * 2);

fputs("\n", stderr);
int numLeadingDashes = (bannerSize - labelSize) / 2 - 1;
Expand Down Expand Up @@ -1219,7 +1219,7 @@ void ArchPrintStackTrace(ostream &oss, const std::string &programName, const std
#if defined(ARCH_OS_DARWIN)

_LogStackTraceToOutputIterator(
ostream_iterator<string>(oss), numeric_limits<size_t>::max(), true);
ostream_iterator<string>(oss), (numeric_limits<size_t>::max)(), true);

#else

Expand Down Expand Up @@ -1304,7 +1304,7 @@ size_t ArchGetStackFrames(size_t maxdepth, size_t skip, uintptr_t *frames)
{
void *stack[MAX_STACK_DEPTH];
size_t frameCount = CaptureStackBackTrace(skip, MAX_STACK_DEPTH, stack, NULL);
frameCount = std::min(frameCount, maxdepth);
frameCount = (std::min)(frameCount, maxdepth);
for (size_t frame = 0; frame != frameCount; ++frame) {
frames[frame] = reinterpret_cast<uintptr_t>(stack[frame]);
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Arch/systemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static std::string _DynamicSizedRead(size_t initialSize,
// Repeatedly invoke the callback with our buffer until it's big enough.
size_t size = initialSize;
while (!callback(buffer.get(), &size)) {
if (size == std::numeric_limits<size_t>::max()) {
if (size == (std::numeric_limits<size_t>::max)()) {
// callback is never going to succeed.
return std::string();
}
Expand All @@ -102,7 +102,7 @@ std::string ArchGetExecutablePath()
ARCH_WARNING(
"Unable to read /proc/self/exe to obtain "
"executable path");
*size = std::numeric_limits<size_t>::max();
*size = (std::numeric_limits<size_t>::max)();
return false;
}
else if (static_cast<size_t>(n) >= *size) {
Expand Down Expand Up @@ -148,7 +148,7 @@ std::string ArchGetExecutablePath()
ARCH_WARNING(
"Unable to read GetModuleFileName() to obtain "
"executable path");
*size = std::numeric_limits<size_t>::max();
*size = (std::numeric_limits<size_t>::max)();
return false;
}
else if (n >= nSize) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/Arch/timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int64_t Arch_ComputeTickQuantum()
for (int i = 0; i != std::extent<decltype(times)>::value - 1; ++i) {
times[i] = times[i + 1] - times[i];
}
currMin = std::min(currMin, *std::min_element(std::begin(times), std::prev(std::end(times))));
currMin = (std::min)(currMin, *std::min_element(std::begin(times), std::prev(std::end(times))));
}
return static_cast<int64_t>(currMin);
}
Expand Down Expand Up @@ -230,7 +230,7 @@ uint64_t Arch_MeasureExecutionTime(uint64_t maxTicks,
// Run 10 times upfront to estimate how many runs to include in each sample.
uint64_t estTicksPer = ~0;
for (int i = 10; i--;) {
estTicksPer = std::min(estTicksPer, measureN(1));
estTicksPer = (std::min)(estTicksPer, measureN(1));
}

// We want the tick quantum noise to -> 0.1% or less of the total time.
Expand Down Expand Up @@ -279,7 +279,7 @@ uint64_t Arch_MeasureExecutionTime(uint64_t maxTicks,
break;
}
// Otherwise update best median, and resample.
bestMedian = std::min(bestMedian, sampleTimes[NumSamples / 2]);
bestMedian = (std::min)(bestMedian, sampleTimes[NumSamples / 2]);
// Replace the slowest 1/3...
for (int i = (NumSamples - NumSamples / 3); i != NumSamples; ++i) {
sampleTimes[i] = measureSample();
Expand Down
2 changes: 1 addition & 1 deletion Sources/Arch/virtualMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <cstdint>
#if defined(ARCH_OS_WINDOWS)
# include <Memoryapi.h>
// # include <Memoryapi.h>
# include <Windows.h>
#else // Assume POSIX
# include <sys/mman.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct _Params {
extractor.Extract(UsdRecursivePayloadsExampleFileFormatTokens->Depth, &depth);
// Treat negative values as zero so we have consistent parameter values
// when there's no recursive layer content to generate.
depth = std::max(0, depth);
depth = (std::max)(0, depth);
if (depth < 1) {
return;
}
Expand All @@ -89,7 +89,7 @@ struct _Params {
// depth. We clamp this value to be positive so there's always at least
// one prim generated at each depth.
extractor.Extract(UsdRecursivePayloadsExampleFileFormatTokens->Num, &num);
num = std::max(1, num);
num = (std::max)(1, num);

// Radius and height are only needed when depth is 2 or higher as they
// are used to layout the recursively generated prims and depth 1 just
Expand Down
Loading

0 comments on commit 90faf23

Please sign in to comment.