RosettaCommons/binder

binder generates almost nothing

Closed this issue · 7 comments

i have a qt based library that i try to bind in python.
i specified +class MainClass in binder.config and after running this command:

binder --config binder.cfg --root-module pyqapp --prefix bindings all_includes.hpp \
-- -std=c++11 -fPIC -Wno-c++11-narrowing -Ilibqapp/include -I/usr/include/x86_64-linux-gnu/qt5/ \
-I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5/QtGui \
-I/usr/include/x86_64-linux-gnu/qt5/Network -I/usr/include/x86_64-linux-gnu/qt5/QtMultimedia \
-I/usr/include/c++/6/ -I/usr/include/x86_64-linux-gnu/c++/6/

binder generates some empry folder and files, just the main source file contains this:

#include <map>
#include <memory>
#include <stdexcept>
#include <functional>

#include <pybind11/pybind11.h>

typedef std::function< pybind11::module & (std::string const &) > ModuleGetter;



PYBIND11_PLUGIN(pyqapp) {
	std::map <std::string, std::shared_ptr<pybind11::module> > modules;
	ModuleGetter M = [&](std::string const &namespace_) -> pybind11::module & {
		auto it = modules.find(namespace_);
		if( it == modules.end() ) throw std::runtime_error("Attempt to access pybind11::module for namespace " + namespace_ + " before it was created!!!");
		return * it->second;
	};

	modules[""] = std::make_shared<pybind11::module>("pyqapp", "pyqapp module");

	std::vector< std::pair<std::string, std::string> > sub_modules {
	};
	for(auto &p : sub_modules ) modules[p.first.size() ? p.first+"::"+p.second : p.second] = std::make_shared<pybind11::module>( modules[p.first]->def_submodule(p.second.c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() ) );


	return modules[""]->ptr();
}

I am guessing that this is due to an empty namespace list that was specified for bindings.

Does MainClass reside in any namespaces? If not, could you please try to add --bind "" into binder command line (before --) and see if that helps. And if this class reside in particular namespace then use --bind "my_namespace" instead.

Let me know if that helps,

adding --bind "", binder prints:

Generate bindings, pass №1...
Generate bindings, pass №2...
Generate bindings, pass №3...
Generate bindings, pass №4...
Sorting Binders...
Sorting Binders... Done.
Writing code...
Warning: file_name_for_decl could not determent file name for decl: class QObject * qt_qFindChild_helper(const class QObject *, const class QString &, const struct QMetaObject &, class QFlags<enum Qt::FindChildOption>), result is too short!
Warning: file_name_for_decl could not determent file name for decl: class QObject & QtPrivate::deref_for_methodcall(class QObject &), result is too short!
Warning: file_name_for_decl could not determent file name for decl: bool qMapLessThanKey<QString>(const class QString &, const class QString &), result is too short!
Warning: file_name_for_decl could not determent file name for decl: const struct QMetaObject * qt_getEnumMetaObject(enum QLocale::Language), result is too short!
Warning: file_name_for_decl could not determent file name for decl: QSettings, result is too short!
Warning: file_name_for_decl could not determent file name for decl: const class QLoggingCategory & TG_CORE_INBOUNDPKT(), result is too short!
Warning: file_name_for_decl could not determent file name for decl: QDataStream, result is too short!
.
.
.
.
Warning: file_name_for_decl could not determent file name for decl: const class QLoggingCategory & TG_LIB_API(), result is too short!
Warning: file_name_for_decl could not determent file name for decl: const char * Qt::qt_getEnumName(enum Qt::ArrowType), result is too short!
Warning: file_name_for_decl could not determent file name for decl: const struct QMetaObject * Qt::qt_getEnumMetaObject(enum Qt::TextElideMode), result is too short!
Warning: file_name_for_decl could not determent file name for decl: const char * Qt::qt_getEnumName(enum Qt::WindowModality), result is too short!
Writing code... Done.

with an empty bindings folder (actually it has four empty folders: QtCore, QtNetwork, std and unknown)
and this files:

bindingslibio.cpp.txt
bindingspyqapp.cpp.txt
bindingspyqapp.sources.txt
bindingspyqtapp.modules.txt

Hmm... how exactly is your classes declared? Are they inside some namespace? If so, have you added +namespace <my-class-namespace> in config?

Any chance you could post snippet of some of your classes (best to choose the simplest one) that suppose to get binded but did not?

Also, if you check content of bindingspyqapp.sources.txt that you posted it is clear that bindings generated a lot of source files, could you please double check generated folders is indeed empty? Could it be that you was looking at the different paths?

Also, from examining content of generated files it looks like all generated bindings is for Qt and std, i did not see any obvious signs of your library unless it all went into 'unknown' which only could happened if code used relative include notation (like #include "myfile.h" instead of #include <myfile.h>`, does this ring a bell?

@lyskov i'm trying to bind this library, which the main class is not in a namespace. i changed all relative include notations to #include <>. this time binder do not print any warning, but the output directory is empty yet.

There must be some simple path issue here, if i look at source flies that you posted i see that a lot files was generated:

% cat bindingspyqapp.sources.txt
pyqapp.cpp
std/stl_iterator_base_types.cpp
QtCore/qglobal.cpp
QtCore/qglobal_1.cpp
QtCore/qglobal_2.cpp
QtCore/qtypetraits.cpp
QtCore/qbytearraylist.cpp
QtCore/qlist.cpp
...

Could you please try to use --prefix option and provide it with absolute path ending with / (and make sure that this dir exists) and see if that make any difference? I am guessing that right now generated files got written but probably into different location...

Also, when/if you located the generated files: since C++ classes is not in the particular namespaces then bindings files for them will be located in <prefix>/unknown/ dir, so i guess try to grep for LIBQTELEGRAMSHARED_EXPORT to see if it there before trying to compile the code.

@mbande i have not heard back from you on this issue. So unless you can provide further input i will consider this is as solved and close this issue. Thanks,