diff --git a/cmake/ToLua.cmake b/cmake/ToLua.cmake index 0cd1eae8..3bd9a51d 100644 --- a/cmake/ToLua.cmake +++ b/cmake/ToLua.cmake @@ -20,26 +20,34 @@ # along with this program. If not, see . # -function(wrap_tolua VAR) -if(NOT ARGN) - message(SEND_ERROR "Error: wrap_tolua called without any files") - return() -endif(NOT ARGN) - +function(wrap_tolua VAR FIL) SET(INCL) SET(${VAR}) -FOREACH(FIL ${ARGN}) - GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE) - GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE) - LIST(APPEND ${VAR} "${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c") - ADD_CUSTOM_COMMAND( OUTPUT ${${VAR}} ${INCL} COMMAND ${APP_TOLUA} -n - ${FIL_WE} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c ${ABS_FIL} DEPENDS - ${ABS_FIL} COMMENT "Running tolua++ on ${FIL}" - VERBATIM ) +GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE) +GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE) +LIST(APPEND ${VAR} "${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c") + +if(DEFINED ARGV2) + GET_FILENAME_COMPONENT(PATCH ${ARGV2} ABSOLUTE) + SET(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}-orig.c) + ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c + COMMAND patch -s ${TOLUA_OUT} ${PATCH} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c + DEPENDS ${TOLUA_OUT} ${PATCH} + COMMENT "Patching lib${FIL_WE}-orig.c" + VERBATIM) + SET_SOURCE_FILES_PROPERTIES(${TOLUA_OUT} PROPERTIES GENERATED TRUE) +else() + SET(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c) +endif(DEFINED ARGV2) + +ADD_CUSTOM_COMMAND( OUTPUT ${TOLUA_OUT} ${INCL} COMMAND ${APP_TOLUA} -n + ${FIL_WE} -o ${TOLUA_OUT} ${ABS_FIL} DEPENDS + ${ABS_FIL} COMMENT "Running tolua++ on ${FIL}" + VERBATIM ) + +SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE) - SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE) -ENDFOREACH(FIL) SET(${VAR} ${${VAR}} PARENT_SCOPE) diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt index bde5a679..3ff7e958 100644 --- a/lua/CMakeLists.txt +++ b/lua/CMakeLists.txt @@ -30,7 +30,9 @@ set(CMAKE_CXX_FLAGS_DEBUG "-ggdb") if(BUILD_LUA_CAIRO) include_directories(${luacairo_includes} ${CMAKE_CURRENT_SOURCE_DIR}) - wrap_tolua(luacairo_src cairo.pkg) + # cairo_set_dash() needs this special hack to work properly + # if you have a better solution, please let me know + wrap_tolua(luacairo_src cairo.pkg libcairo.patch) add_library(cairo SHARED ${luacairo_src}) diff --git a/lua/cairo.pkg b/lua/cairo.pkg index 65019bc2..6acf113a 100644 --- a/lua/cairo.pkg +++ b/lua/cairo.pkg @@ -240,7 +240,7 @@ typedef enum _cairo_line_join { void cairo_set_line_join(cairo_t * cr, cairo_line_join_t line_join); -void cairo_set_dash(cairo_t * cr, const double *dashes, int num_dashes, double offset); +void cairo_set_dash(cairo_t * cr, const double dashes[num_dashes], int num_dashes, double offset); void cairo_set_miter_limit(cairo_t * cr, double limit); diff --git a/lua/libcairo.patch b/lua/libcairo.patch new file mode 100644 index 00000000..037eb17a --- /dev/null +++ b/lua/libcairo.patch @@ -0,0 +1,16 @@ +--- lua/libcairo.c~ 2010-06-11 23:14:43.000000000 +0200 ++++ lua/libcairo.c 2010-06-12 10:47:51.000000000 +0200 +@@ -1452,12 +1452,12 @@ + #endif + { + struct _cairo* cr = (( struct _cairo*) tolua_tousertype(tolua_S,1,0)); ++ int num_dashes = ((int) tolua_tonumber(tolua_S,3,0)); + #ifdef __cplusplus + double* dashes = Mtolua_new_dim(double, num_dashes); + #else + double* dashes = (double*) malloc((num_dashes)*sizeof(double)); + #endif +- int num_dashes = ((int) tolua_tonumber(tolua_S,3,0)); + double offset = ((double) tolua_tonumber(tolua_S,4,0)); + { + #ifndef TOLUA_RELEASE