Skip to content
Permalink
Browse files

Merge branch 'cmake' into temp/cmake-ghci

  • Loading branch information
CFSworks committed Nov 6, 2019
2 parents b359848 + 0e0b218 commit f3c63e20c4d819f6e2c82503ef7e08c89ef221f3
Showing with 4,273 additions and 3,934 deletions.
  1. +4 −4 direct/src/stdpy/file.py
  2. +1 −2 dtool/CMakeLists.txt
  3. +7 −2 dtool/CompilerFlags.cmake
  4. +0 −11 dtool/metalibs/dtoolconfig/CMakeLists.txt
  5. +3,837 −3,776 dtool/src/cppparser/cppBison.cxx.prebuilt
  6. +29 −0 dtool/src/cppparser/cppBison.yxx
  7. +16 −1 dtool/src/cppparser/cppPreprocessor.cxx
  8. +16 −3 dtool/src/interrogate/CMakeLists.txt
  9. +4 −3 dtool/src/interrogate/functionRemap.cxx
  10. +10 −11 dtool/src/interrogatedb/CMakeLists.txt
  11. +64 −9 dtool/src/prc/CMakeLists.txt
  12. +15 −9 dtool/src/prc/streamReader.cxx
  13. +13 −7 dtool/src/prc/streamReader_ext.cxx
  14. +2 −2 panda/src/audiotraits/CMakeLists.txt
  15. +9 −1 panda/src/collide/collisionTraverser.cxx
  16. +4 −1 panda/src/collide/collisionTraverser.h
  17. +1 −5 panda/src/collide/collisionVisualizer.h
  18. +8 −6 panda/src/display/graphicsStateGuardian.cxx
  19. +3 −1 panda/src/display/graphicsStateGuardian.h
  20. +1 −1 panda/src/express/CMakeLists.txt
  21. +0 −2 panda/src/express/pStatCollectorForwardBase.cxx
  22. +4 −1 panda/src/express/pStatCollectorForwardBase.h
  23. +1 −1 panda/src/ffmpeg/CMakeLists.txt
  24. +3 −3 panda/src/gobj/geomVertexReader.cxx
  25. +1 −1 panda/src/gobj/geomVertexReader.h
  26. +0 −8 panda/src/particlesystem/config_particlesystem.h
  27. +0 −6 panda/src/particlesystem/particleSystem.h
  28. +5 −0 panda/src/pgraph/CMakeLists.txt
  29. +1 −3 panda/src/pgraph/cullResult.h
  30. +2 −8 panda/src/pgraph/pandaNode.cxx
  31. +1 −3 panda/src/pgraph/pandaNode.h
  32. +0 −7 panda/src/physics/config_physics.h
  33. +9 −11 panda/src/physics/physicsObject.h
  34. +109 −0 panda/src/pstatclient/pStatClient.cxx
  35. +35 −11 panda/src/pstatclient/pStatClient.h
  36. +2 −2 panda/src/pstatclient/pStatCollectorForward.cxx
  37. +1 −1 panda/src/pstatclient/pStatCollectorForward.h
  38. +0 −4 panda/src/putil/uniqueIdAllocator.cxx
  39. +12 −4 panda/src/tform/mouseWatcherBase.cxx
  40. +8 −3 panda/src/tform/mouseWatcherBase.h
  41. +35 −0 tests/prc/test_stream_reader.py
@@ -247,13 +247,13 @@ def read(self, size=-1):
self.__stream.clear() # clear eof flag
self.__lastWrite = False
if size is not None and size >= 0:
result = self.__reader.extractBytes(size)
return self.__reader.extractBytes(size)
else:
# Read to end-of-file.
result = b''
result = bytearray()
while not self.__stream.eof():
result += self.__reader.extractBytes(512)
return result
result += self.__reader.extractBytes(4096)
return bytes(result)

read1 = read

@@ -10,6 +10,5 @@ add_subdirectory(src/interrogate)
add_subdirectory(src/interrogatedb)
add_subdirectory(src/prc)

# Include dtool metalibs
# Include dtool metalib
add_subdirectory(metalibs/dtool)
add_subdirectory(metalibs/dtoolconfig)
@@ -10,8 +10,13 @@ include(CheckCXXCompilerFlag)

# These are flags for the custom configurations we add
# Standard
set(CMAKE_C_FLAGS_STANDARD "-O3")
set(CMAKE_CXX_FLAGS_STANDARD "-O3")
if(MSVC)
set(CMAKE_C_FLAGS_STANDARD "/Ox")
set(CMAKE_CXX_FLAGS_STANDARD "/Ox")
else()
set(CMAKE_C_FLAGS_STANDARD "-O3")
set(CMAKE_CXX_FLAGS_STANDARD "-O3")
endif()
set(CMAKE_SHARED_LINKER_FLAGS_STANDARD "")
set(CMAKE_MODULE_LINKER_FLAGS_STANDARD "")
set(CMAKE_EXE_LINKER_FLAGS_STANDARD "")

This file was deleted.

Large diffs are not rendered by default.

@@ -1218,6 +1218,35 @@ constructor_prototype:
CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($1);
ii->add_func_modifier($4, $6);

$$ = new CPPInstance(type, ii, 0, @1.file);
}
/* This is a hack to support functions with the identifier enveloped by a
pair of parentheses. */
| TYPENAME_IDENTIFIER '(' IDENTIFIER ')' '('
{
// Create a scope for this function.
CPPScope *scope = new CPPScope($3->get_scope(current_scope, global_scope),
$3->_names.back(), V_private);

// It still needs to be able to pick up any template arguments, if this is
// a definition for a method template. Add a fake "using" declaration to
// accomplish this.
scope->_using.insert(current_scope);

push_scope(scope);
}
function_parameter_list ')' function_post
{
pop_scope();
CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer);
if (type == nullptr) {
yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1);
}
assert(type != nullptr);

CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($3);
ii->add_func_modifier($7, $9);

$$ = new CPPInstance(type, ii, 0, @1.file);
}
| TYPENAME_IDENTIFIER '('
@@ -1942,7 +1942,22 @@ get_identifier(int c) {
// Is it a manifest?
Manifests::const_iterator mi = _manifests.find(name);
if (mi != _manifests.end() && !should_ignore_manifest((*mi).second)) {
return expand_manifest((*mi).second);
// If the manifest is expecting arguments, we don't expand it unless the
// the next token is an open-parenthesis.
CPPManifest *manifest = (*mi).second;
if (manifest->_has_parameters) {
while (c != EOF && isspace(c)) {
get();
c = peek();
}
if (c == '(') {
// It is followed by a parenthesis, so we can expand this.
return expand_manifest(manifest);
}
} else {
// Non-function-like macros are always expanded.
return expand_manifest(manifest);
}
}
if (name == "__FILE__") {
return get_literal(SIMPLE_STRING, loc, loc.file._filename_as_referenced);
@@ -60,23 +60,36 @@ set(INTERROGATE_PREAMBLE_PYTHON_NATIVE

composite_sources(interrogate INTERROGATE_SOURCES)
add_executable(interrogate ${INTERROGATE_HEADERS} ${INTERROGATE_SOURCES})
target_link_libraries(interrogate p3cppParser p3dtoolconfig
target_link_libraries(interrogate p3cppParser p3interrogatedb
PKG::OPENSSL)

# Python preamble for interrogate_module
set(_preamble_files)
foreach(_file ${INTERROGATE_PREAMBLE_PYTHON_NATIVE})
# Resolve symlinks, use absolute path, and add a `#line 1 ...` directive
get_filename_component(_file "${_file}" REALPATH)

string(SHA1 _hash "${_file}")
set(_line_file "${CMAKE_CURRENT_BINARY_DIR}/.${_hash}.h")
file(WRITE "${_line_file}" "#line 1 \"${_file}\"\n")

list(APPEND _preamble_files "${_line_file}")
list(APPEND _preamble_files "${_file}")
endforeach(_file)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/interrogate_preamble_python_native.cxx
COMMAND ${CMAKE_COMMAND}
-D OUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/interrogate_preamble_python_native.cxx"
-D INPUT_FILES="${INTERROGATE_PREAMBLE_PYTHON_NATIVE}"
-D INPUT_FILES="${_preamble_files}"
-D SYMBOL_NAME="interrogate_preamble_python_native"
-P ${PROJECT_SOURCE_DIR}/cmake/scripts/ConcatenateToCXX.cmake
DEPENDS ${INTERROGATE_PREAMBLE_PYTHON_NATIVE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

add_executable(interrogate_module interrogate_module.cxx
${CMAKE_CURRENT_BINARY_DIR}/interrogate_preamble_python_native.cxx)
target_link_libraries(interrogate_module p3cppParser p3dtoolconfig
target_link_libraries(interrogate_module p3cppParser p3interrogatedb
PKG::OPENSSL)

if(NOT CMAKE_CROSSCOMPILING)
@@ -445,15 +445,16 @@ get_call_str(const string &container, const vector_string &pexprs) const {
} else if (_has_this && !container.empty()) {
// If we have a "this" parameter, the calling convention is also a bit
// different.
call << "(";
call << "((";
_parameters[0]._remap->pass_parameter(call, container);
call << ")." << _cppfunc->get_local_name();
call << ")." << _cppfunc->get_local_name() << ")";

} else {
call << "(";
if (_cpptype != nullptr) {
call << _cpptype->get_local_name(&parser);
}
call << "::" << _cppfunc->get_local_name();
call << "::" << _cppfunc->get_local_name() << ")";
}
}
call << "(";
@@ -34,18 +34,17 @@ set(P3IGATERUNTIME_HEADERS
)

composite_sources(p3interrogatedb P3INTERROGATEDB_SOURCES)
add_component_library(p3interrogatedb NOINIT SYMBOL BUILDING_INTERROGATEDB
add_library(p3interrogatedb
${P3INTERROGATEDB_HEADERS} ${P3INTERROGATEDB_SOURCES})
target_link_libraries(p3interrogatedb p3prc p3dconfig p3dtool)
set_target_properties(p3interrogatedb PROPERTIES DEFINE_SYMBOL BUILDING_INTERROGATEDB)
target_link_libraries(p3interrogatedb p3dconfig p3prc)

if(NOT BUILD_METALIBS)
install(TARGETS p3interrogatedb
EXPORT Core COMPONENT Core
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
ARCHIVE COMPONENT CoreDevel)
endif()
install(TARGETS p3interrogatedb
EXPORT Core COMPONENT Core
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
ARCHIVE COMPONENT CoreDevel)
install(FILES ${P3INTERROGATEDB_HEADERS} COMPONENT CoreDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)
install(FILES ${P3IGATERUNTIME_HEADERS} COMPONENT CoreDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)

@@ -74,4 +73,4 @@ add_custom_command(

add_python_target(panda3d.interrogatedb
"${CMAKE_CURRENT_BINARY_DIR}/interrogatedb_module.cxx")
target_link_libraries(panda3d.interrogatedb p3dtoolconfig)
target_link_libraries(panda3d.interrogatedb p3interrogatedb)
@@ -81,8 +81,9 @@ set(P3PRC_IGATEEXT
)

composite_sources(p3prc P3PRC_SOURCES)
add_component_library(p3prc NOINIT SYMBOL BUILDING_DTOOL_PRC
add_library(p3prc
${P3PRC_HEADERS} ${P3PRC_SOURCES})
set_target_properties(p3prc PROPERTIES DEFINE_SYMBOL BUILDING_DTOOL_PRC)
target_include_directories(p3prc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
target_link_libraries(p3prc p3dtool PKG::OPENSSL)
target_interrogate(p3prc ALL EXTENSIONS ${P3PRC_IGATEEXT})
@@ -91,12 +92,66 @@ if(ANDROID)
target_link_libraries(p3prc log)
endif()

if(NOT BUILD_METALIBS)
install(TARGETS p3prc
EXPORT Core COMPONENT Core
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
ARCHIVE COMPONENT CoreDevel)
endif()
install(TARGETS p3prc
EXPORT Core COMPONENT Core
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
ARCHIVE COMPONENT CoreDevel)

install(FILES ${P3PRC_HEADERS} COMPONENT CoreDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)

# Also install under the old name "p3dtoolconfig"
# TODO: Remove this once "p3dtoolconfig" is deprecated
if(WIN32)
# Symlinks aren't pretty under WIN32
set(_symlink "copy")
else()
set(_symlink "create_symlink")
endif()

get_target_property(_type p3prc TYPE)
if(_type STREQUAL "SHARED_LIBRARY")

set(_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(UNIX)
get_target_property(_soversion p3prc SOVERSION)
if(APPLE)
set(_suffix ".${_soversion}${_suffix}")
else()
set(_suffix "${_suffix}.${_soversion}")
endif()

set(_file_genex "TARGET_SONAME_FILE")
set(_install_dir "${CMAKE_INSTALL_LIBDIR}")

else()
# Win32?
set(_file_genex "TARGET_FILE")
set(_install_dir "${CMAKE_INSTALL_BINDIR}")

endif()

set(_soname "${CMAKE_SHARED_LIBRARY_PREFIX}p3dtoolconfig${_suffix}")

add_custom_command(TARGET p3prc POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E chdir "$<${_file_genex}_DIR:p3prc>"
"${CMAKE_COMMAND}" -E "${_symlink}"
"$<${_file_genex}_NAME:p3prc>" "${_soname}"
)
install(FILES "$<${_file_genex}_DIR:p3prc>/${_soname}"
DESTINATION "${_install_dir}")
endif()

if(WIN32)
set(_libname "${CMAKE_IMPORT_LIBRARY_PREFIX}p3dtoolconfig${CMAKE_IMPORT_LIBRARY_SUFFIX}")
else()
set(_libname "${CMAKE_${_type}_PREFIX}p3dtoolconfig${CMAKE_${_type}_SUFFIX}")
endif()
add_custom_command(TARGET p3prc POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E chdir "$<TARGET_LINKER_FILE_DIR:p3prc>"
"${CMAKE_COMMAND}" -E "${_symlink}"
"$<TARGET_LINKER_FILE_NAME:p3prc>" "${_libname}"
)
install(FILES "$<TARGET_LINKER_FILE_DIR:p3prc>/${_libname}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
@@ -26,14 +26,20 @@ get_string() {

// First, get the length of the string
size_t size = get_uint16();

std::string result(size, 0);
if (size == 0) {
return string();
return result;
}

char *buffer = (char *)alloca(size);
_in->read(buffer, size);
_in->read(&result[0], size);
size_t read_bytes = _in->gcount();
return string(buffer, read_bytes);

if (read_bytes == size) {
return result;
} else {
return result.substr(0, read_bytes);
}
}

/**
@@ -82,17 +88,17 @@ string StreamReader::
get_fixed_string(size_t size) {
nassertr(!_in->eof() && !_in->fail(), string());

std::string result(size, 0);
if (size == 0) {
return string();
return result;
}

char *buffer = (char *)alloca(size);
_in->read(buffer, size);
_in->read(&result[0], size);
size_t read_bytes = _in->gcount();
string result(buffer, read_bytes);
result.resize(read_bytes);

size_t zero_byte = result.find('\0');
return result.substr(0, zero_byte);
return result.substr(0, std::min(zero_byte, read_bytes));
}

/**
@@ -21,14 +21,20 @@
*/
PyObject *Extension<StreamReader>::
extract_bytes(size_t size) {
unsigned char *buffer = (unsigned char *)alloca(size);
size_t read_bytes = _this->extract_bytes(buffer, size);
std::istream *in = _this->get_istream();
if (in->eof() || in->fail() || size == 0) {
return PyBytes_FromStringAndSize(nullptr, 0);
}

#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)buffer, read_bytes);
#else
return PyString_FromStringAndSize((char *)buffer, read_bytes);
#endif
PyObject *bytes = PyBytes_FromStringAndSize(nullptr, size);
in->read(PyBytes_AS_STRING(bytes), size);
size_t read_bytes = in->gcount();

if (read_bytes == size || _PyBytes_Resize(&bytes, read_bytes) == 0) {
return bytes;
} else {
return nullptr;
}
}

/**
@@ -17,7 +17,7 @@ if(HAVE_FMODEX)
)

composite_sources(p3fmod_audio P3FMOD_SOURCES)
add_library(p3fmod_audio ${P3FMOD_HEADERS} ${P3FMOD_SOURCES})
add_library(p3fmod_audio ${MODULE_TYPE} ${P3FMOD_HEADERS} ${P3FMOD_SOURCES})
set_target_properties(p3fmod_audio PROPERTIES DEFINE_SYMBOL BUILDING_FMOD_AUDIO)
target_link_libraries(p3fmod_audio panda PKG::FMODEX)

@@ -45,7 +45,7 @@ if(HAVE_OPENAL)


composite_sources(p3openal_audio P3OPENAL_SOURCES)
add_library(p3openal_audio ${P3OPENAL_HEADERS} ${P3OPENAL_SOURCES})
add_library(p3openal_audio ${MODULE_TYPE} ${P3OPENAL_HEADERS} ${P3OPENAL_SOURCES})
set_target_properties(p3openal_audio PROPERTIES DEFINE_SYMBOL BUILDING_OPENAL_AUDIO)
target_link_libraries(p3openal_audio panda PKG::OPENAL)

0 comments on commit f3c63e2

Please sign in to comment.
You can’t perform that action at this time.