def generate_code(): # messages.disable( # # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X # messages.W1020 # , messages.W1021 # , messages.W1022 # , messages.W1023 # , messages.W1024 # , messages.W1025 # , messages.W1026 # , messages.W1027 # , messages.W1028 # , messages.W1029 # , messages.W1030 # , messages.W1031 # , messages.W1035 # , messages.W1040 # , messages.W1038 # , messages.W1041 # , messages.W1036 # pointer to Python immutable member # , messages.W1033 # unnamed variables # , messages.W1018 # expose unnamed classes # , messages.W1049 # returns reference to local variable # , messages.W1014 # unsupported '=' operator # ) # # Use GCCXML to create the controlling XML file. # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded # NOTE: If you update the source library code you need to manually delete the cache .XML file # xml_cached_fc = parser.create_cached_source_fc( os.path.join( environment.ogrenewt2.root_dir, "python_ogrenewt2.h" ) , environment.ogrenewt2.cache_file ) defined_symbols = environment.defined_symbols defined_symbols.append ('_OGRENEWT_DYNAMIC') defined_symbols.append ('OIS_NONCLIENT_BUILD') defined_symbols.append( 'VERSION_' + environment.ogrenewt2.version ) if environment.isWindows(): defined_symbols.append ('WIN32') # # build the core Py++ system from the GCCXML created source # mb = module_builder.module_builder_t( [ xml_cached_fc ] , gccxml_path=environment.gccxml_bin , working_directory=environment.root_dir , include_paths=environment.ogrenewt2.include_dirs , define_symbols=defined_symbols , indexing_suite_version=2 , cflags=environment.ogrenewt2.cflags ) # if this module depends on another set it here mb.register_module_dependency ( environment.ogre.generated_dir ) # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off mb.constructors().allow_implicit_conversion = False mb.BOOST_PYTHON_MAX_ARITY = 25 mb.classes().always_expose_using_scope = True # # We filter (both include and exclude) specific classes and functions that we want to wrap # global_ns = mb.global_ns global_ns.exclude() main_ns = global_ns.namespace( MAIN_NAMESPACE ) main_ns.include() common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) ManualExclude ( mb ) common_utils.AutoInclude ( mb, MAIN_NAMESPACE ) ManualInclude ( mb ) # here we fixup functions that expect to modifiy their 'passed' variables ManualTransformations ( mb ) AutoFixes ( mb, MAIN_NAMESPACE ) ManualFixes ( mb ) common_utils.Auto_Functional_Transformation ( main_ns ) #, special_vars=[] ) # # We need to tell boost how to handle calling (and returning from) certain functions # common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) ) # # the manual stuff all done here !!! # hand_made_wrappers.apply( mb ) NoPropClasses = [""] for cls in main_ns.classes(): if cls.name not in NoPropClasses: cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) # THIS MUST BE AFTER Auto_Functional_Transformation common_utils.Auto_Document( mb, MAIN_NAMESPACE ) ## add additional version information to the module to help identify it correctly common_utils.addDetailVersion ( mb, environment, environment.ogrenewt2 ) ########################################################################################## # # Creating the code. After this step you should not modify/customize declarations. # ########################################################################################## extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing mb.build_code_creator (module_name='_ogrenewt2_' , doc_extractor= extractor ) for inc in environment.ogrenewt2.include_dirs: mb.code_creator.user_defined_directories.append(inc ) mb.code_creator.user_defined_directories.append( environment.ogrenewt2.generated_dir ) mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogrenewt2.version ) ) huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogrenewt2.version ) ) mb.split_module(environment.ogrenewt2.generated_dir, huge_classes, use_files_sum_repository=False)
def spawnTask ( task, cwdin = '', getoutput=None ): """Execute a command line task and manage the return code etc """ global ENV_SET PREFIX = environment.PREFIX PATH = os.environ["PATH"] env = os.environ env["USESYSTEM"] = str(environment.UseSystem) if not ENV_SET: # this actually changes the environment so we shouldn't do it more than once env["PKG_CONFIG_PATH"]=os.path.join(PREFIX,"lib/pkgconfig") env["LD_LIBRARY_PATH"]=os.path.join(PREFIX,"lib") if environment.isMac(): env["CFLAGS"]="-I"+PREFIX+"/include -L"+PREFIX+"/lib" env["CXXFLAGS"]="-I"+PREFIX+"/include -L"+PREFIX+"/lib" ##env["LDFLAGS"]="-Wl,-rpath='\$\$ORIGIN/../../lib' -Wl,-rpath='\$\$ORIGIN' -Wl,-z,origin" ### Mac GCC 4.0.1 doesn't support rpath env["PYTHONPATH"]=PREFIX+"/lib/python"+environment.PythonVersionString+"/site-packages" env["CCFLAGS"]=" "+env["CFLAGS"] else: for FLAGS in "CFLAGS", "CXXFLAGS", "CCFLAGS", "LDFLAGS": if not FLAGS in env: env[FLAGS] = "" if environment.isWindows(): env["CFLAGS"]+=" "+"-I"+os.path.join(PREFIX,"include") else: env["CFLAGS"]+=" "+"-I"+os.path.join(PREFIX,"include")+ " -L"+os.path.join(PREFIX,"lib") if environment.is64(): env["CFLAGS"]+=" -L"+os.path.join(PREFIX,"lib64") if hasattr(environment, 'cxx_compiler'): env['CXX'] = environment.cxx_compiler # We need to tell gccxml about this change if not hasattr(environment, 'gccxml_compiler'): env['GCCXML_COMPILER'] = environment.cxx_compiler if hasattr(environment, 'cc_compiler'): env['CC'] = environment.cc_compiler if hasattr(environment, 'gccxml_compiler'): _env['GCCXML_COMPILER'] = environment.cxx_compiler env["CXXFLAGS"]+=" "+env["CFLAGS"] env["CCFLAGS"]+=" "+env["CFLAGS"] env["LDFLAGS"]+="-Wl,-rpath='$$ORIGIN/../../lib' -Wl,-rpath='$$ORIGIN' -Wl,-z,origin" env["PYTHONPATH"]=PREFIX+"/lib/python"+environment.PythonVersionString+"/site-packages" if environment.is64(): env["PYTHONPATH"]=env["PYTHONPATH"]+":"+PREFIX+"/lib64/python"+environment.PythonVersionString+"/site-packages" env["ZZIPLIB_LIBS"]="-lzzip" if environment.isWindows(): ## Make sure the right python interpreter is in the path so scons gets called correctly... PATH_Python = os.path.dirname( sys.executable ) env["PATH"]=PATH_Python+';'+PREFIX+"\\bin;" + PATH else: env["PATH"]=PREFIX+"/bin:" + PATH ENV_SET=True logger.debug ( "Spawning '%s' in '%s'" % (task,cwdin) ) if VERBOSE: out, err = "", "" process = subprocess.Popen (task, shell=True, cwd = cwdin, env=env) returncode = process.wait() else: process = subprocess.Popen (task, shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd = cwdin, env=env) try: out,err = process.communicate() returncode = process.returncode except: returncode = -1 if getoutput is not None: if returncode != -1: getoutput.write(out) getoutput.write(err) if returncode != 0: logger.warning ( "Task Failed" ) logger.debug ( out ) logger.debug ( err ) elif FULL_LOGGING: logger.warning ( "Full Logging ON" ) logger.debug ( out ) logger.debug ( err ) if returncode != 0 and FAILHARD: exit(" The following command failed %s" % task) return returncode
def generate_code(): if 0: messages.disable( # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X messages.W1020 , messages.W1021 , messages.W1022 , messages.W1023 , messages.W1024 , messages.W1025 , messages.W1026 , messages.W1027 , messages.W1028 , messages.W1029 , messages.W1030 , messages.W1031 , messages.W1035 , messages.W1040 , messages.W1038 , messages.W1041 , messages.W1036 # pointer to Python immutable member , messages.W1033 # unnamed variables , messages.W1018 # expose unnamed classes , messages.W1049 # returns reference to local variable , messages.W1014 # unsupported '=' operator ) # # Use GCCXML to create the controlling XML file. # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded # NOTE: If you update the source library code you need to manually delete the cache .XML file # xml_cached_fc = parser.create_cached_source_fc( os.path.join( environment.ogresdksample.root_dir, "python_ogresdksample.h" ) , environment.ogresdksample.cache_file ) defined_symbols = environment.defined_symbols defined_symbols.append( 'VERSION_' + environment.ogresdksample.version ) print environment.ogresdksample.include_dirs # # build the core Py++ system from the GCCXML created source # mb = module_builder.module_builder_t( [ xml_cached_fc ] , gccxml_path=environment.gccxml_bin , working_directory=environment.root_dir , include_paths=environment.ogresdksample.include_dirs , define_symbols=defined_symbols , indexing_suite_version=2 , cflags=environment.ogresdksample.cflags ) # if this module depends on another set it here mb.register_module_dependency ( environment.ogre.generated_dir ) # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off mb.constructors().allow_implicit_conversion = False mb.BOOST_PYTHON_MAX_ARITY = 25 mb.classes().always_expose_using_scope = True # # We filter (both include and exclude) specific classes and functions that we want to wrap # global_ns = mb.global_ns global_ns.exclude() main_ns = global_ns.namespace( MAIN_NAMESPACE ) main_ns.include() common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) ManualExclude ( mb ) common_utils.AutoInclude ( mb, MAIN_NAMESPACE ) ManualInclude ( mb ) # here we fixup functions that expect to modifiy their 'passed' variables ManualTransformations ( mb ) AutoFixes ( mb, MAIN_NAMESPACE ) ManualFixes ( mb ) common_utils.Auto_Functional_Transformation ( main_ns ) #, special_vars=[] ) FindProtectedVars ( mb ) # # We need to tell boost how to handle calling (and returning from) certain functions # common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) ) # # the manual stuff all done here !!! # hand_made_wrappers.apply( mb ) NoPropClasses = [""] for cls in main_ns.classes(): if cls.name not in NoPropClasses: cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) # THIS MUST BE AFTER Auto_Functional_Transformation common_utils.Auto_Document( mb, MAIN_NAMESPACE ) ## add additional version information to the module to help identify it correctly common_utils.addDetailVersion ( mb, environment, environment.ogresdksample ) ########################################################################################## # # Creating the code. After this step you should not modify/customize declarations. # ########################################################################################## extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing mb.build_code_creator (module_name='_ogresdksample_' , doc_extractor= extractor ) for inc in environment.ogresdksample.include_dirs: mb.code_creator.user_defined_directories.append(inc ) mb.code_creator.user_defined_directories.append( environment.ogresdksample.generated_dir ) mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogresdksample.version ) ) huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogresdksample.version ) ) mb.split_module(environment.ogresdksample.generated_dir, huge_classes, use_files_sum_repository=False) ## now we need to ensure a series of headers and additional source files are ## copied to the generated directory.. # files = os.listdir( environment.Config.PATH_INCLUDE_sdksample ) # files_filtered = [] # for f in files: # if f.startswith ("Sample") or f.startswith ("FileSystem"): # files_filtered.append (f) # print files_filtered common_utils.copyTree ( sourcePath = environment.Config.PATH_INCLUDE_sdksample, destPath = environment.ogresdksample.generated_dir, recursive=False, extensions=['h'] ) # need the actual implementation file if environment.isWindows(): fileToCopy = ['FileSystemLayerImpl_WIN32.cpp'] elif environment.isLinux(): fileToCopy = ['FileSystemLayerImpl_Unix.cpp'] common_utils.copyTree ( sourcePath = environment.Config.PATH_INCLUDE_sdksample, destPath = environment.ogresdksample.generated_dir, recursive=False, files_in= fileToCopy ) if environment.ogre.version.startswith("1.7"): ## have a code generation issue that needs resolving... filesToFix=['SdkTrayManager.pypp.cpp'] for filename in filesToFix: fname = os.path.join( environment.ogresdksample.generated_dir, filename) try: f = open(fname, 'r') buf = f.read() f.close() if (" MEMCATEGORY_GENERAL" in buf) or ("<MEMCATEGORY_GENERAL" in buf): buf = buf.replace ( " MEMCATEGORY_GENERAL", " Ogre::MEMCATEGORY_GENERAL") buf = buf.replace ( "<MEMCATEGORY_GENERAL", "<Ogre::MEMCATEGORY_GENERAL") f = open ( fname, 'w+') f.write ( buf ) f.close() print "UGLY FIX OK:", fname except: print "ERROR: Unable to fix:", fname
def generate_code(): # messages.disable( # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X # messages.W1020 # , messages.W1021 # , messages.W1022 # , messages.W1023 # , messages.W1024 # , messages.W1025 # , messages.W1026 # , messages.W1027 # , messages.W1028 # , messages.W1029 # , messages.W1030 # , messages.W1031 # , messages.W1035 # , messages.W1040 # , messages.W1038 # , messages.W1041 # , messages.W1036 # pointer to Python immutable member # , messages.W1033 # unnamed variables # , messages.W1018 # expose unnamed classes # , messages.W1049 # returns reference to local variable # , messages.W1014 # unsupported '=' operator # ) # # Use GCCXML to create the controlling XML file. # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded # NOTE: If you update the source library code you need to manually delete the cache .XML file # print os.path.join( environment.mygui.root_dir, "python_mygui.h" ) xml_cached_fc = parser.create_cached_source_fc( os.path.join( environment.mygui.root_dir, "python_mygui.h" ) , environment.mygui.cache_file ) defined_symbols = ['OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY', #'BOOST_PYTHON_NO_PY_SIGNATURES', '__PYTHONOGRE_BUILD_CODE', 'MYGUI_NONCLIENT_BUILD', 'MYGUI_DONT_USE_OBSOLETE'] #MYGUI_NO_OIS defined_symbols.append( 'VERSION_' + environment.mygui.version ) if environment._USE_THREADS: defined_symbols.append('BOOST_HAS_THREADS') if environment.isWindows(): defined_symbols.append('BOOST_HAS_WINTHREADS') # # build the core Py++ system from the GCCXML created source # mb = module_builder.module_builder_t( [ xml_cached_fc ] , gccxml_path=environment.gccxml_bin , working_directory=environment.root_dir , include_paths=environment.mygui.include_dirs , define_symbols=defined_symbols , indexing_suite_version=2 , cflags=environment.mygui.cflags ) filter_declarations(mb) # if this module depends on another set it here mb.constructors().allow_implicit_conversion = False mb.register_module_dependency ( environment.ogre.generated_dir ) print environment.ogre.generated_dir # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off mb.constructors().allow_implicit_conversion = False mb.BOOST_PYTHON_MAX_ARITY = 25 mb.classes().always_expose_using_scope = True # # We filter (both include and exclude) specific classes and functions that we want to wrap # global_ns = mb.global_ns global_ns.exclude() main_ns = global_ns.namespace( MAIN_NAMESPACE ) main_ns.include() common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) ManualExclude ( mb ) common_utils.AutoInclude ( mb, MAIN_NAMESPACE ) ManualInclude ( mb ) # here we fixup functions that expect to modifiy their 'passed' variables ManualTransformations ( mb ) AutoFixes ( mb, MAIN_NAMESPACE ) ManualFixes ( mb ) common_utils.Auto_Functional_Transformation ( main_ns, special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &'] ) # # We need to tell boost how to handle calling (and returning from) certain functions # common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) ) #global_ns.namespace( 'MyGUI' ).class_('Widget').include(already_exposed=True) # # the manual stuff all done here !!! # hand_made_wrappers.apply( mb ) set_call_policies (mb) NoPropClasses = [""] for cls in main_ns.classes(): if cls.name not in NoPropClasses: cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() ) ## add additional version information to the module to help identify it correctly common_utils.addDetailVersion ( mb, environment, environment.mygui ) ########################################################################################## # # Creating the code. After this step you should not modify/customize declarations. # ########################################################################################## extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing mb.build_code_creator (module_name='_mygui_' , doc_extractor= extractor ) for inc in environment.mygui.include_dirs: mb.code_creator.user_defined_directories.append(inc ) mb.code_creator.user_defined_directories.append( environment.mygui.generated_dir ) mb.code_creator.replace_included_headers( customization_data.header_files( environment.mygui.version ) ) huge_classes = map( mb.class_, customization_data.huge_classes( environment.mygui.version ) ) mb.split_module(environment.mygui.generated_dir, huge_classes, use_files_sum_repository=False) ## now we need to ensure a series of headers and additional source files are ## copied to the generated directory.. additional_files= os.listdir(environment.Config.PATH_INCLUDE_mygui) additional_files = [] for f in additional_files: if f.endswith('cpp') or f.endswith('.h'): sourcefile = os.path.join(environment.Config.PATH_INCLUDE_mygui, f) destfile = os.path.join(environment.mygui.generated_dir, f ) if not common_utils.samefile( sourcefile ,destfile ): shutil.copy( sourcefile, environment.mygui.generated_dir ) print "Updated ", f, "as it was missing or out of date" # copying event callback header file print "Copying 'python_mygui_callback.h'" shutil.copy2(os.path.join( environment.mygui.root_dir, "python_mygui_callback.h" ), os.path.join(environment.mygui.generated_dir, "python_mygui_callback.h"))