Navigation



Ignore:
Timestamp:
Dec 9, 2010, 5:14:24 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Finally got the proxy aka shadow class to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_interactive/CMakeLists.txt

    r618 r624  
    1111FIND_PACKAGE(SWIG REQUIRED)
    1212INCLUDE(${SWIG_USE_FILE})
    13 SET(CMAKE_SWIG_FLAGS "")
     13SET(CMAKE_SWIG_FLAGS -castmode -threads)
    1414
    1515# Add the dependencies for re-swig-ing the file
    16 SET(SWIG_MODULE_diwrap_EXTRA_DEPS
     16SET(SWIG_MODULE_fDpy_EXTRA_DEPS
    1717        ${CMAKE_BINARY_DIR}/include/freeDiameter/freeDiameter-host.h
    1818        ${CMAKE_SOURCE_DIR}/include/freeDiameter/libfreeDiameter.h
    1919        ${CMAKE_SOURCE_DIR}/include/freeDiameter/freeDiameter.h)
     20SET_SOURCE_FILES_PROPERTIES(dbg_interactive.i PROPERTIES SWIG_MODULE_NAME fDpy)
    2021
    21 # We create the module even if we don't use it, so that intermediate values are defined (OK, this is stupid...)
    22 SWIG_ADD_MODULE(diwrap python diwrap.i)
     22# The following code is inspired from SWIG_ADD_MODULE, but we do only what we need
     23SWIG_MODULE_INITIALIZE(fDpy python)
     24SWIG_ADD_SOURCE_TO_MODULE(fDpy swig_generated_sources "dbg_interactive.i")
     25       
     26# In order to avoid shipping the python file that contains the shadow class definitions,
     27# we transform this file in a C-style string and compile it within our software.
     28# We use for this purpose xxd tool provided with vim package.
     29FIND_PROGRAM(XXD_EXECUTABLE xxd)
     30# To avoid the dependency, simply compile it if not provided
     31if (NOT XXD_EXECUTABLE)
     32   SET_SOURCE_FILES_PROPERTIES(helper/xxd.c PROPERTIES COMPILE_DEFINITIONS UNIX)
     33   ADD_EXECUTABLE(xxd helper/xxd.c)
     34   SET(XXD_EXECUTABLE xxd)
     35endif (NOT XXD_EXECUTABLE)
     36# And now the magic command
     37ADD_CUSTOM_COMMAND(
     38    OUTPUT "fDpy-inc.c"
     39    COMMAND "${XXD_EXECUTABLE}"
     40    ARGS "-i"
     41    "fDpy.py"
     42    "fDpy-inc.c"
     43    MAIN_DEPENDENCY "${swig_extra_generated_files}"
     44    COMMENT "Converting swig proxy class to C string")
     45
     46# Ensure that the generated source files are removed
     47GET_DIRECTORY_PROPERTY(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
     48SET_DIRECTORY_PROPERTIES(PROPERTIES
     49        ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources};fDpy-inc.c")
     50
    2351
    2452#####
    2553# Extension that embeds the python interpreter
    26 FD_ADD_EXTENSION(dbg_interactive dbg_interactive.c ${swig_generated_sources} ${swig_other_sources})
     54FD_ADD_EXTENSION(dbg_interactive dbg_interactive.c ${swig_generated_sources} fDpy-inc.c)
    2755TARGET_LINK_LIBRARIES(dbg_interactive ${PYTHON_LIBRARIES})
    2856
Note: See TracChangeset for help on using the changeset viewer.