Skip to content

Commit

Permalink
MAYA-112871 MayaUSD: VS Code setup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
boudrey committed Aug 2, 2021
1 parent 4a14b56 commit 4d5b3a6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
21 changes: 16 additions & 5 deletions .github/run-clang-format.py
Expand Up @@ -15,6 +15,7 @@
import re
import stat
import sys
import platform
import time

from subprocess import check_call, check_output
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions cmake/compiler_config.cmake
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cmake/googletest_download.txt.in
Expand Up @@ -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
Expand All @@ -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}"
)
4 changes: 4 additions & 0 deletions cmake/googletest_src.txt.in
Expand Up @@ -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
Expand All @@ -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}"
)

0 comments on commit 4d5b3a6

Please sign in to comment.