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

EMSUSD-917 : Add a stable library as a subset of MayaUSD LIbrary call… #3555

Merged
merged 11 commits into from
Jan 31, 2024
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ project(maya-usd)
# options
#------------------------------------------------------------------------------
option(BUILD_MAYAUSD_LIBRARY "Build Core USD libraries." ON)
option(BUILD_MAYAUSDAPI_LIBRARY "Build the mayaUsdAPI subset library that provides a stable versioned interface to mayaUsd for external plugins." ON)
option(BUILD_ADSK_PLUGIN "Build Autodesk USD plugin." ON)
option(BUILD_PXR_PLUGIN "Build the Pixar USD plugin and libraries." ON)
option(BUILD_AL_PLUGIN "Build the Animal Logic USD plugin and libraries." ON)
Expand Down Expand Up @@ -93,6 +94,12 @@ if (BUILD_MAYAUSD_LIBRARY)
set(MAYAUSD_VERSION "${MAYAUSD_MAJOR_VERSION}.${MAYAUSD_MINOR_VERSION}.${MAYAUSD_PATCH_LEVEL}")
endif()

if (BUILD_MAYAUSDAPI_LIBRARY)
include(cmake/mayausdapi_version.info)
set(MAYAUSDAPI_VERSION "${MAYAUSDAPI_MAJOR_VERSION}.${MAYAUSDAPI_MINOR_VERSION}.${MAYAUSDAPI_PATCH_LEVEL}")
endif()


if (DEFINED PYTHON_INCLUDE_DIR AND DEFINED PYTHON_LIBRARIES AND DEFINED Python_EXECUTABLE)
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
SET(PYTHONLIBS_FOUND TRUE)
Expand Down Expand Up @@ -225,6 +232,14 @@ if (BUILD_PXR_PLUGIN OR BUILD_AL_PLUGIN OR BUILD_ADSK_PLUGIN)
endif()
endif()

if (BUILD_MAYAUSDAPI_LIBRARY)
if (NOT BUILD_MAYAUSD_LIBRARY)
message(FATAL_ERROR "Building mayaUsdAPI library requires MayaUsd core libraries to be built, please enable BUILD_MAYAUSD_LIBRARY.")
endif()
endif()



if (BUILD_PXR_PLUGIN)
add_subdirectory(plugin/pxr)
endif()
Expand Down
3 changes: 3 additions & 0 deletions cmake/mayausdapi_version.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(MAYAUSDAPI_MAJOR_VERSION 0)
set(MAYAUSDAPI_MINOR_VERSION 0)
set(MAYAUSDAPI_PATCH_LEVEL 1)
3 changes: 3 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ if (BUILD_MAYAUSD_LIBRARY)
add_subdirectory(mayaUsd)
add_subdirectory(usd)
endif()
if (BUILD_MAYAUSDAPI_LIBRARY)
add_subdirectory(mayaUsdAPI)
endif()
16 changes: 13 additions & 3 deletions lib/mayaUsd/listeners/proxyShapeNotice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@

PXR_NAMESPACE_OPEN_SCOPE

TF_INSTANTIATE_TYPE(MayaUsdProxyStageSetNotice, TfType::CONCRETE, TF_1_PARENT(TfNotice));
TF_INSTANTIATE_TYPE(MayaUsdProxyStageInvalidateNotice, TfType::CONCRETE, TF_1_PARENT(TfNotice));
TF_INSTANTIATE_TYPE(MayaUsdProxyStageObjectsChangedNotice, TfType::CONCRETE, TF_1_PARENT(TfNotice));
TF_INSTANTIATE_TYPE(MayaUsdProxyStageBaseNotice, TfType::CONCRETE, TF_1_PARENT(TfNotice));
TF_INSTANTIATE_TYPE(
MayaUsdProxyStageSetNotice,
TfType::CONCRETE,
TF_1_PARENT(MayaUsdProxyStageBaseNotice));
TF_INSTANTIATE_TYPE(
MayaUsdProxyStageInvalidateNotice,
TfType::CONCRETE,
TF_1_PARENT(MayaUsdProxyStageBaseNotice));
TF_INSTANTIATE_TYPE(
MayaUsdProxyStageObjectsChangedNotice,
TfType::CONCRETE,
TF_1_PARENT(MayaUsdProxyStageBaseNotice));

MayaUsdProxyStageBaseNotice::MayaUsdProxyStageBaseNotice(const MayaUsdProxyShapeBase& proxy)
: _proxy(proxy)
Expand Down
11 changes: 9 additions & 2 deletions lib/mayaUsd/ufe/wrapNotice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@

namespace {

TF_INSTANTIATE_NOTICE_WRAPPER(MayaUsdProxyStageSetNotice, TfNotice);
TF_INSTANTIATE_NOTICE_WRAPPER(MayaUsdProxyStageInvalidateNotice, TfNotice);
TF_INSTANTIATE_NOTICE_WRAPPER(MayaUsdProxyStageBaseNotice, TfNotice);
TF_INSTANTIATE_NOTICE_WRAPPER(MayaUsdProxyStageSetNotice, MayaUsdProxyStageBaseNotice);
TF_INSTANTIATE_NOTICE_WRAPPER(MayaUsdProxyStageInvalidateNotice, MayaUsdProxyStageBaseNotice);

} // namespace

void wrapNotice()
{
{
typedef MayaUsdProxyStageBaseNotice This;
TfPyNoticeWrapper<This, TfNotice>::Wrap()
.add_property("shapePath", &This::GetShapePath)
.add_property("stage", &This::GetStage);
}
{
typedef MayaUsdProxyStageSetNotice This;
TfPyNoticeWrapper<This, TfNotice>::Wrap()
Expand Down
153 changes: 153 additions & 0 deletions lib/mayaUsdAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#
# Copyright 2023 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
project(mayaUsdAPI)

add_library(${PROJECT_NAME} SHARED)

# -----------------------------------------------------------------------------
# sources
# -----------------------------------------------------------------------------
target_sources(${PROJECT_NAME}
PRIVATE
proxyStage.cpp
proxyShapeNotice.cpp
)

set(HEADERS
api.h
proxyStage.h
proxyShapeNotice.h
)

#------------------------------------------------------------------------------
# modules and definitions
#------------------------------------------------------------------------------
if(NOT DEFINED ENV{BOOST_ROOT})
set(ENV{BOOST_ROOT} ${PXR_USD_LOCATION})
endif()
if(MAYAUSD_DEFINE_BOOST_DEBUG_PYTHON_FLAG)
set(Boost_USE_DEBUG_PYTHON ON)
endif()

# -----------------------------------------------------------------------------
# compiler configuration
# -----------------------------------------------------------------------------
target_compile_definitions(${PROJECT_NAME}
PUBLIC
$<$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>:BOOST_DEBUG_PYTHON>
$<$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>:BOOST_LINKING_PYTHON>
PRIVATE
MAYAUSD_API_EXPORT
MFB_PACKAGE_NAME="${PROJECT_NAME}"
MFB_ALT_PACKAGE_NAME="${PROJECT_NAME}"
MFB_PACKAGE_MODULE="${PROJECT_NAME}"
$<$<BOOL:${IS_MACOSX}>:OSMac_>
$<$<BOOL:${IS_LINUX}>:LINUX>
# this flag is needed when building for Maya
$<$<BOOL:${IS_WINDOWS}>:WIN32>
)

set(SRCFILE ${CMAKE_CURRENT_SOURCE_DIR}/mayaUsdAPI.h.src)
set(DSTFILE ${CMAKE_BINARY_DIR}/include/mayaUsdAPI/mayaUsdAPI.h)
if (NOT EXISTS ${DSTFILE})
message(STATUS "promoting: " ${SRCFILE})
endif()
configure_file(${SRCFILE} ${DSTFILE})

mayaUsd_compile_config(${PROJECT_NAME})

mayaUsd_promoteHeaderList(
HEADERS
${HEADERS}
BASEDIR
${PROJECT_NAME}
)

# -----------------------------------------------------------------------------
# include directories
# -----------------------------------------------------------------------------
target_include_directories(${PROJECT_NAME}
PRIVATE
${MAYA_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/include
)

# -----------------------------------------------------------------------------
# link libraries
# -----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME}
PUBLIC
tf
PRIVATE
sdf
mayaUsd
)

# -----------------------------------------------------------------------------
# run-time search paths
# -----------------------------------------------------------------------------
if(IS_MACOSX OR IS_LINUX)
mayaUsd_init_rpath(rpath "lib")
mayaUsd_add_rpath(rpath "${CMAKE_INSTALL_PREFIX}/lib")
if(DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib")
elseif(DEFINED PXR_USD_LOCATION)
mayaUsd_add_rpath(rpath "${PXR_USD_LOCATION}/lib")
endif()
if(IS_LINUX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../${MAYAUSD_TO_USD_RELATIVE_PATH}/lib64")
endif()
if(IS_MACOSX AND DEFINED MAYAUSD_TO_USD_RELATIVE_PATH)
mayaUsd_add_rpath(rpath "../../../Maya.app/Contents/MacOS")
endif()
mayaUsd_install_rpath(rpath ${PROJECT_NAME})
endif()

#------------------------------------------------------------------------------
# install
#------------------------------------------------------------------------------
install(FILES ${HEADERS}
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}
)

set(LIBRARY_INSTALL_PATH
${CMAKE_INSTALL_PREFIX}/lib
)

install(
TARGETS ${PROJECT_NAME}
LIBRARY
DESTINATION ${LIBRARY_INSTALL_PATH}
ARCHIVE
DESTINATION ${LIBRARY_INSTALL_PATH}
RUNTIME
DESTINATION ${LIBRARY_INSTALL_PATH}
)

if(IS_WINDOWS)
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}>
DESTINATION ${LIBRARY_INSTALL_PATH} OPTIONAL
)
endif()

# We need an empty __init__.py file in each subfolder so it is considered a python module.
install(FILES __init__.py DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/python/${PROJECT_NAME})
install(FILES ${CMAKE_BINARY_DIR}/include/${PROJECT_NAME}/mayaUsdAPI.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})


add_subdirectory(python)
1 change: 1 addition & 0 deletions lib/mayaUsdAPI/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#is needed for python2 to be able to run tests.
64 changes: 64 additions & 0 deletions lib/mayaUsdAPI/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Copyright 2023 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#ifndef MAYAUSD_API_H
#define MAYAUSD_API_H

#include <pxr/base/arch/export.h>
#include <pxr/pxr.h>

// clang-format off
#if defined _WIN32 || defined __CYGWIN__

// The main export symbol used for the mayaUSDAPI library.
#ifdef MAYAUSD_API_EXPORT
#ifdef __GNUC__
#define MAYAUSD_API_PUBLIC __attribute__ ((dllexport))
#else
#define MAYAUSD_API_PUBLIC __declspec(dllexport)
#endif
#else
#ifdef __GNUC__
#define MAYAUSD_API_PUBLIC __attribute__ ((dllimport))
#else
#define MAYAUSD_API_PUBLIC __declspec(dllimport)
#endif
#endif
#define MAYAUSD_API_LOCAL
#else
#if __GNUC__ >= 4
#define MAYAUSD_API_PUBLIC __attribute__ ((visibility ("default")))
#define MAYAUSD_API_LOCAL __attribute__ ((visibility ("hidden")))
#else
#define MAYAUSD_API_PUBLIC
#define MAYAUSD_API_LOCAL
#endif
#endif

#ifdef MAYAUSD_API_EXPORT
#define MAYAUSD_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
#define MAYAUSD_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
#else
#define MAYAUSD_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
#define MAYAUSD_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
#endif
// clang-format on

// Convenience symbol versioning include: because api.h is widely
// included, this reduces the need to explicitly include mayaUsdAPI.h.
#include <mayaUsdAPI/mayaUsdAPI.h>

#endif // MAYAUSD_API_H
47 changes: 47 additions & 0 deletions lib/mayaUsdAPI/mayaUsdAPI.h.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Copyright 2023 Autodesk, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#pragma once

#define MAYAUSDAPI_MAJOR_VERSION ${MAYAUSDAPI_MAJOR_VERSION}
#define MAYAUSDAPI_MINOR_VERSION ${MAYAUSDAPI_MINOR_VERSION}
#define MAYAUSDAPI_PATCH_LEVEL ${MAYAUSDAPI_PATCH_LEVEL}
#define MAYAUSDAPI_API_VERSION (MAYAUSDAPI_MAJOR_VERSION * 10000 + MAYAUSDAPI_MINOR_VERSION * 100 + MAYAUSDAPI_PATCH_LEVEL)

// mayaUsdAPI viewport public namespace string will never change.
#define MAYAUSDAPI_NS MayaUsdAPI
// C preprocessor trickery to expand arguments.
#define MAYAUSDAPI_CONCAT(A, B) MAYAUSDAPI_CONCAT_IMPL(A, B)
#define MAYAUSDAPI_CONCAT_IMPL(A, B) A##B
// Versioned namespace includes the major version number.
#define MAYAUSDAPI_VERSIONED_NS MAYAUSDAPI_CONCAT(MAYAUSDAPI_NS, _v${MAYAUSDAPI_MAJOR_VERSION})

namespace MAYAUSDAPI_VERSIONED_NS {}

// With a using namespace declaration, pull in the versioned namespace into the
// mayaUsdAPI public namespace, to allow client code to use the plain mayaUsdAPI
// namespace, e.g. MayaUsdAPI::Class.
namespace MAYAUSDAPI_NS {
using namespace MAYAUSDAPI_VERSIONED_NS;
}

// Macro to place the mayaUsdAPI symbols in the versioned namespace, which
// is how they will appear in the shared library, e.g. MayaUsdAPI_v1::Class.
#ifdef DOXYGEN
#define MAYAUSDAPI_NS_DEF MAYAUSDAPI_NS
#else
#define MAYAUSDAPI_NS_DEF MAYAUSDAPI_VERSIONED_NS
#endif
Loading