From 4d5b3a6e821b7cae09d7f0e611dffc77ae37b154 Mon Sep 17 00:00:00 2001 From: Yves Boudreault Date: Mon, 2 Aug 2021 10:39:17 -0400 Subject: [PATCH] MAYA-112871 MayaUSD: VS Code setup Fix canonical path for script run-clang-format.py (fix only on Windows and when using Python 3.6 or higher). - reported file paths reported by Git and paths inclusion had different case making the test fail finding any files. Fix for forcing the use of old ABI on Linux same as done in Maya so that Maya-usd can be compiled with GCC 9.x or higher without error. --- .github/run-clang-format.py | 21 ++++++++++++++++----- cmake/compiler_config.cmake | 6 ++++++ cmake/googletest_download.txt.in | 4 ++++ cmake/googletest_src.txt.in | 4 ++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/run-clang-format.py b/.github/run-clang-format.py index 1301e67470..79592e4ad1 100755 --- a/.github/run-clang-format.py +++ b/.github/run-clang-format.py @@ -15,6 +15,7 @@ import re import stat import sys +import platform import time from subprocess import check_call, check_output @@ -71,11 +72,21 @@ def regex_from_file(path, glob=False): regex = '({})'.format('|'.join(patterns)) return re.compile(regex) - -def canonicalpath(path): - path = os.path.abspath(os.path.realpath(os.path.normpath(os.path.normcase(path)))) - return path.replace('\\', '/') - +if platform.system() == "Windows" and sys.version_info >= (3, 6): + import pathlib # Python 3.6 is required for pathlib.Path + def canonicalpath(path): + path = os.path.abspath(os.path.realpath(os.path.normpath(os.path.normcase(path)))) + realpath = str(pathlib.Path(path).resolve()) # To get a properly cased path ie: from r'C:\WiNdOwS\SyStEm32\DeSkToP.iNi' get r'C:\Windows\System32\desktop.ini' + if len(path) == len(realpath): # This is to avoid following symbolic links, there is still the possibility that they could be equal. + path = realpath + if os.path.isabs(path) and path[0].upper() != path[0]: + path = path[0].upper() +path[1:] # path.capitalize() + path = path.replace('\\', '/') + return path +else: + def canonicalpath(path): + path = os.path.abspath(os.path.realpath(os.path.normpath(os.path.normcase(path)))) + return path.replace('\\', '/') def run_clang_format(paths=(), verbose=False, commit=None): """Runs clang-format in-place on repo files diff --git a/cmake/compiler_config.cmake b/cmake/compiler_config.cmake index 91143d37ff..a40a0fcf5f 100644 --- a/cmake/compiler_config.cmake +++ b/cmake/compiler_config.cmake @@ -99,6 +99,12 @@ function(mayaUsd_compile_config TARGET) PRIVATE ${GNU_CLANG_FLAGS} ) + if(IS_LINUX) + target_compile_definitions(${TARGET} + PRIVATE + _GLIBCXX_USE_CXX11_ABI=0 # USD is built with old ABI + ) + endif() elseif(IS_MSVC) target_compile_options(${TARGET} PRIVATE diff --git a/cmake/googletest_download.txt.in b/cmake/googletest_download.txt.in index b77983e765..cf0e4614f8 100644 --- a/cmake/googletest_download.txt.in +++ b/cmake/googletest_download.txt.in @@ -15,8 +15,11 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(FORCE_SHARED_CRT "") +set(FORCE_OLD_ABI "") if(MSVC) set(FORCE_SHARED_CRT "-DFORCE_SHARED_CRT=OFF") +elseif(UNIX AND NOT APPLE) + set(FORCE_OLD_ABI "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") endif() ExternalProject_Add(googletest @@ -37,4 +40,5 @@ ExternalProject_Add(googletest "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}" "-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}" + "${FORCE_OLD_ABI}" ) diff --git a/cmake/googletest_src.txt.in b/cmake/googletest_src.txt.in index eae66654fd..1e8d6b1f4f 100644 --- a/cmake/googletest_src.txt.in +++ b/cmake/googletest_src.txt.in @@ -13,8 +13,11 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(FORCE_SHARED_CRT "") +set(FORCE_OLD_ABI "") if(MSVC) set(FORCE_SHARED_CRT "-DFORCE_SHARED_CRT=OFF") +elseif(UNIX AND NOT APPLE) + set(FORCE_OLD_ABI "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") endif() ExternalProject_Add(googletest @@ -34,4 +37,5 @@ ExternalProject_Add(googletest "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}" "-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}" + "${FORCE_OLD_ABI}" )