new genPyCode, INSTALL_PYTHON_SOURCE

This commit is contained in:
David Rose 2004-06-03 17:26:32 +00:00
parent d5bff7418a
commit b9cb0516aa
14 changed files with 849 additions and 583 deletions

View File

@ -84,6 +84,19 @@
// itself (although this may be overridden).
#define INSTALL_DIR /usr/local/panda
// If you intend to use Panda only as a Python module, you may find
// the following define useful (but you should put in the correct path
// to site-packages within your own installed Python). This will
// install the Panda libraries into the standard Python search space
// so that they can be accessed as Python modules. (Also see the
// PYTHON_IPATH variable, below.)
// If you don't do this, you can still use Panda as a Python module,
// but you must put /usr/local/python/lib (or $INSTALL_DIR/lib) on
// your PYTHONPATH.
// #define INSTALL_LIB_DIR /usr/lib/python2.2/site-packages
// What level of compiler optimization/debug symbols should we build?
// The various optimize levels are defined as follows:
@ -142,14 +155,28 @@
#define INTERROGATE_MODULE interrogate_module
// Is Python installed, and should Python interfaces be generated? If
// Python is installed, which directory is it in? (If the directory
// is someplace standard like /usr/include, you may leave it blank.)
#define PYTHON_IPATH /usr/local/include/python1.6
// Python is installed, which directory is it in?
#define PYTHON_IPATH /usr/include/python2.2
#define PYTHON_LPATH
#define PYTHON_FPATH
#define PYTHON_FRAMEWORK
#defer HAVE_PYTHON $[isdir $[PYTHON_IPATH]]
// Define the default set of libraries to be instrumented by
// genPyCode. You may wish to add to this list to add your own
// libraries, or if you want to use some of the more obscure
// interfaces like libpandaegg and libpandafx.
#define GENPYCODE_LIBS libpandaexpress libpanda libpandaphysics libdirect
// Normally, Python source files are copied into the INSTALL_LIB_DIR
// defined above, along with the compiled C++ library objects, when
// you make install. If you prefer not to copy these Python source
// files, but would rather run them directly out of the source
// directory (presumably so you can develop them and make changes
// without having to reinstall), comment out this definition and put
// your source directory on your PYTHONPATH.
#define INSTALL_PYTHON_SOURCE 1
// Do you want to enable the "in_interpreter" global variable? This
// will enable some callbacks, particularly the MemoryUsage object, to
// know whether they were called from Python code (or other high-level

File diff suppressed because it is too large Load Diff

View File

@ -564,12 +564,14 @@ Warning: Variable $[upcase $[tree]]_INSTALL is not set!
#endif
#end tree
#define install_lib_dir $[install_dir]/lib
#define install_bin_dir $[install_dir]/bin
#define install_headers_dir $[install_dir]/include
#define install_data_dir $[install_dir]/shared
#define install_igatedb_dir $[install_dir]/etc
#define install_config_dir $[install_dir]/etc
#define install_lib_dir $[or $[INSTALL_LIB_DIR],$[install_dir]/lib]
#define install_bin_dir $[or $[INSTALL_BIN_DIR],$[install_dir]/bin]
#define install_headers_dir $[or $[INSTALL_HEADERS_DIR],$[install_dir]/include]
#define install_data_dir $[or $[INSTALL_DATA_DIR],$[install_dir]/shared]
#define install_igatedb_dir $[or $[INSTALL_IGATEDB_DIR],$[install_dir]/etc]
#define install_config_dir $[or $[INSTALL_CONFIG_DIR],$[install_dir]/etc]
#defer install_py_dir $[install_lib_dir]/$[PACKAGE]/$[DIRNAME]
#defer install_py_package_dir $[install_lib_dir]/$[PACKAGE]
#if $[ne $[DTOOL_INSTALL],]
#define install_parser_inc_dir $[DTOOL_INSTALL]/include/parser-inc

View File

@ -69,6 +69,14 @@
// freshen the cache file.
#define dep_sources $[sort $[filter %.c %.cxx %.yxx %.lxx %.h %.I %.T,$[dep_sources_1]]]
// If there is an __init__.py in the directory, then all Python
// files in the directory just get installed without having to be
// named.
#if $[and $[INSTALL_PYTHON_SOURCE],$[wildcard $[TOPDIR]/$[DIRPREFIX]__init__.py]]
#define py_sources $[wildcard $[TOPDIR]/$[DIRPREFIX]*.py]
#endif
#define install_py $[py_sources:$[TOPDIR]/$[DIRPREFIX]%=%]
#endif // $[build_directory]
@ -128,6 +136,7 @@
$[if $[install_data],$[install_data_dir]] \
$[if $[install_config],$[install_config_dir]] \
$[if $[install_igatedb],$[install_igatedb_dir]] \
$[if $[install_py],$[install_py_dir] $[install_py_package_dir]] \
]
// Similarly, we need to ensure that $[ODIR] exists. Trying to make
@ -189,7 +198,9 @@ $[TAB] rm -f $[patsubst %,$[%_obj],$[st_sources]]
#if $[lib_targets] $[static_lib_targets] $[bin_targets] $[test_bin_targets]
$[TAB] rm -f $[lib_targets] $[static_lib_targets] $[bin_targets] $[test_bin_targets]
#endif
#if $[py_sources]
$[TAB] rm -f *.pyc *.pyo // Also scrub out old generated Python code.
#endif
// 'cleanall' is intended to undo all the effects of running ppremake
// and building. It removes everything except the Makefile.
@ -232,7 +243,8 @@ $[TAB] rm -f $[igatemout] $[$[igatemout]_obj]
$[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
$[INSTALL_PARSER_INC:%=$[install_parser_inc_dir]/%] \
$[INSTALL_DATA:%=$[install_data_dir]/%] \
$[INSTALL_CONFIG:%=$[install_config_dir]/%]
$[INSTALL_CONFIG:%=$[install_config_dir]/%] \
$[if $[install_py],$[install_py:%=$[install_py_dir]/%] $[install_py_package_dir]/__init__.py]
#define installed_igate_files \
$[get_igatedb(metalib_target lib_target ss_lib_target):$[ODIR]/%=$[install_igatedb_dir]/%]
@ -707,6 +719,18 @@ $[install_config_dir]/$[file] : $[file]
$[TAB] $[INSTALL]
#end file
#foreach file $[install_py]
$[install_py_dir]/$[file] : $[file]
#define local $[file]
#define dest $[install_py_dir]
$[TAB] $[INSTALL]
#end file
#if $[install_py]
$[install_py_package_dir]/__init__.py :
$[TAB] touch $[install_py_package_dir]/__init__.py
#endif
// Finally, all the special targets. These are commands that just need
// to be invoked; we don't pretend to know what they are.
#forscopes special_target

View File

@ -255,12 +255,6 @@ make_wrapper_entry(FunctionIndex function_index) {
iwrapper._name = _wrapper_name;
iwrapper._unique_name = _unique_name;
if (true_wrapper_names) {
// If we're reporting "true" names, it means we set the
// wrapper's name to the name of the function it wraps.
iwrapper._name =
InterrogateBuilder::clean_identifier(_cppfunc->get_local_name(&parser));
}
if (output_function_names) {
// If we're keeping the function names, record that the wrapper is
// callable.

View File

@ -95,6 +95,7 @@ public:
string _function_signature;
string _hash;
string _unique_name;
string _reported_name;
string _wrapper_name;
FunctionWrapperIndex _wrapper_index;

View File

@ -377,6 +377,11 @@ make_function_remap(const InterrogateType &itype,
get_unique_prefix() + _def->library_hash_name + remap->_hash;
remap->_wrapper_name =
get_wrapper_prefix() + _def->library_hash_name + remap->_hash;
remap->_reported_name = remap->_wrapper_name;
if (true_wrapper_names) {
remap->_reported_name =
InterrogateBuilder::clean_identifier(remap->_cppfunc->get_local_name(&parser));
}
}
return remap;
}

View File

@ -103,7 +103,7 @@ write_module(ostream &out, InterrogateModuleDef *def) {
Function::Remaps::const_iterator ri;
for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) {
FunctionRemap *remap = (*ri);
out << " { \"" << remap->_unique_name << "\", &"
out << " { \"" << remap->_reported_name << "\", &"
<< remap->_wrapper_name << ", METH_VARARGS },\n";
}
}

View File

@ -69,7 +69,7 @@ ConfigureFn(config_interrogatedb) {
#endif
}
const DSearchPath &
DSearchPath &
get_interrogatedb_path() {
static DSearchPath *interrogatedb_path = NULL;
if (interrogatedb_path == (DSearchPath *)NULL) {

View File

@ -25,6 +25,6 @@
NotifyCategoryDecl(interrogatedb, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG);
const DSearchPath &get_interrogatedb_path();
DSearchPath &get_interrogatedb_path();
#endif

View File

@ -34,6 +34,7 @@ int InterrogateDatabase::_current_minor_version = 2;
////////////////////////////////////////////////////////////////////
InterrogateDatabase::
InterrogateDatabase() {
_error_flag = false;
_next_index = 1;
_lookups_fresh = 0;
}
@ -102,6 +103,19 @@ request_module(InterrogateModuleDef *def) {
}
}
////////////////////////////////////////////////////////////////////
// Function: InterrogateDatabase::get_error_flag
// Access: Public
// Description: Returns the global error flag. This will be set true
// if there was some problem importing the database
// (e.g. cannot find an .in file), or false if
// everything is ok.
////////////////////////////////////////////////////////////////////
bool InterrogateDatabase::
get_error_flag() {
return _error_flag;
}
////////////////////////////////////////////////////////////////////
// Function: InterrogateDatabase::get_num_global_types
// Access: Public
@ -481,6 +495,18 @@ get_current_minor_version() {
return _current_minor_version;
}
////////////////////////////////////////////////////////////////////
// Function: InterrogateDatabase::set_error_flag
// Access: Public
// Description: Sets the global error flag. This should be set true
// if there was some problem importing the database
// (e.g. cannot find an .in file).
////////////////////////////////////////////////////////////////////
void InterrogateDatabase::
set_error_flag(bool error_flag) {
_error_flag = error_flag;
}
////////////////////////////////////////////////////////////////////
// Function: InterrogateDatabase::get_next_index
// Access: Public
@ -885,12 +911,16 @@ load_latest() {
if (pathname.empty()) {
interrogatedb_cat->error()
<< "Unable to find " << filename << " on " << searchpath << "\n";
set_error_flag(true);
} else {
ifstream input;
pathname.set_text();
if (!pathname.open_read(input)) {
interrogatedb_cat->error() << "Unable to read " << pathname << ".\n";
set_error_flag(true);
} else {
int file_identifier;
input >> file_identifier
@ -902,6 +932,7 @@ load_latest() {
<< "Interrogate data in " << pathname
<< " is out of sync with the compiled-in data"
<< " (" << file_identifier << " != " << def->file_identifier << ").\n";
set_error_flag(true);
}
if (_file_major_version != _current_major_version ||
@ -912,6 +943,8 @@ load_latest() {
<< _file_minor_version << " while we are expecting "
<< _current_major_version << "." << _current_minor_version
<< ".\n";
set_error_flag(true);
} else {
if (interrogatedb_cat->is_debug()) {
interrogatedb_cat->debug()
@ -920,6 +953,7 @@ load_latest() {
if (!read(input, def)) {
interrogatedb_cat->error()
<< "Error reading " << pathname << ".\n";
set_error_flag(true);
}
}
}

View File

@ -48,6 +48,8 @@ public:
public:
// Functions to read the database.
bool get_error_flag();
int get_num_global_types();
TypeIndex get_global_type(int n);
int get_num_all_types();
@ -87,6 +89,8 @@ public:
public:
// Functions to build the database.
void set_error_flag(bool error_flag);
int get_next_index();
void add_type(TypeIndex index, const InterrogateType &type);
void add_function(FunctionIndex index, InterrogateFunction *function);
@ -157,6 +161,7 @@ private:
typedef vector<InterrogateModuleDef *> Requests;
Requests _requests;
bool _error_flag;
int _next_index;
enum LookupType {

View File

@ -21,6 +21,19 @@
#include "interrogateType.h"
#include "interrogateFunction.h"
// This function adds one more directory to the list of directories
// search for interrogate (*.in) files. In the past, this list has
// been defined the environment variable ETC_PATH, but now it is
// passed in by the code generator.
void
interrogate_add_search_directory(const char *dirname) {
get_interrogatedb_path().append_directory(Filename::from_os_specific(dirname));
}
bool interrogate_error_flag() {
return InterrogateDatabase::get_ptr()->get_error_flag();
}
int
interrogate_number_of_manifests() {
return InterrogateDatabase::get_ptr()->get_num_global_manifests();

View File

@ -88,6 +88,9 @@ enum AtomicToken {
AT_string = 7
};
EXPCL_DTOOLCONFIG void interrogate_add_search_directory(const char *dirname);
EXPCL_DTOOLCONFIG bool interrogate_error_flag();
//////////////////////////////////////////////////////////////////////////
//
// Manifest Symbols