libfreerdp-channels: refactoring of cmake static entry table generation

This commit is contained in:
Marc-André Moreau 2012-10-15 16:31:41 -04:00
parent 010761055e
commit d0314a569e
22 changed files with 124 additions and 118 deletions

View File

@ -24,6 +24,7 @@ macro(add_channel_client _channel_prefix _channel_name)
set(${_channel_prefix}_CLIENT_NAME ${_channel_name} PARENT_SCOPE)
set(${_channel_prefix}_CLIENT_CHANNEL ${${_channel_prefix}_CLIENT_CHANNEL} PARENT_SCOPE)
set(${_channel_prefix}_CLIENT_ENTRY ${${_channel_prefix}_CLIENT_ENTRY} PARENT_SCOPE)
set(CHANNEL_STATIC_CLIENT_ENTRIES ${CHANNEL_STATIC_CLIENT_ENTRIES} ${${_channel_prefix}_CLIENT_ENTRY} PARENT_SCOPE)
endif()
endmacro(add_channel_client)
@ -34,6 +35,7 @@ macro(add_channel_server _channel_prefix _channel_name)
set(${_channel_prefix}_SERVER_NAME ${_channel_name} PARENT_SCOPE)
set(${_channel_prefix}_SERVER_CHANNEL ${${_channel_prefix}_SERVER_CHANNEL} PARENT_SCOPE)
set(${_channel_prefix}_SERVER_ENTRY ${${_channel_prefix}_SERVER_ENTRY} PARENT_SCOPE)
set(CHANNEL_STATIC_SERVER_ENTRIES ${CHANNEL_STATIC_SERVER_ENTRIES} ${${_channel_prefix}_SERVER_ENTRY} PARENT_SCOPE)
endif()
endmacro(add_channel_server)

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "audin")
set(MODULE_PREFIX "CHANNEL_AUDIN_CLIENT")
set(CHANNEL_NAME "audin")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
audin_main.c

View File

@ -15,9 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(CHANNEL "audin")
set(MODULE_NAME "${CHANNEL}-server")
set(MODULE_PREFIX "CHANNEL_AUDIN_SERVER")
set(CHANNEL_NAME "audin")
set(MODULE_NAME "${CHANNEL_NAME}-server")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_SERVER" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
audin.c)

View File

@ -23,31 +23,40 @@ set(${MODULE_PREFIX}_SRCS
tables.h
channels.c)
foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
set(STATIC_MODULE_NAME ${${STATIC_MODULE}_CLIENT_NAME})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${STATIC_MODULE_NAME})
message(STATUS "StaticModuleName: ${STATIC_MODULE_NAME}")
if(${${STATIC_MODULE}_CLIENT_ENTRY} STREQUAL "VirtualChannelEntry")
set(ENTRY_POINT_NAME "${${STATIC_MODULE}_CLIENT_NAME}_${${STATIC_MODULE}_CLIENT_ENTRY}")
set(ENTRY_POINT_IMPORT "extern int ${ENTRY_POINT_NAME}(PCHANNEL_ENTRY_POINTS pEntryPoints);")
set(VIRTUAL_CHANNEL_ENTRY_IMPORTS "${VIRTUAL_CHANNEL_ENTRY_IMPORTS}\n${ENTRY_POINT_IMPORT}")
set(VIRTUAL_CHANNEL_ENTRY_TABLE "${VIRTUAL_CHANNEL_ENTRY_TABLE}\n\t{ \"${STATIC_MODULE_NAME}\", ${ENTRY_POINT_NAME} },")
endif()
if(${${STATIC_MODULE}_CLIENT_ENTRY} STREQUAL "DeviceServiceEntry")
set(ENTRY_POINT_NAME "${${STATIC_MODULE}_CLIENT_NAME}_${${STATIC_MODULE}_CLIENT_ENTRY}")
set(ENTRY_POINT_IMPORT "extern int ${ENTRY_POINT_NAME}(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints);")
set(DEVICE_SERVICE_ENTRY_IMPORTS "${DEVICE_SERVICE_ENTRY_IMPORTS}\n${ENTRY_POINT_IMPORT}")
set(DEVICE_SERVICE_ENTRY_TABLE "${DEVICE_SERVICE_ENTRY_TABLE}\n\t{ \"${STATIC_MODULE_NAME}\", ${ENTRY_POINT_NAME} },")
endif()
list(REMOVE_DUPLICATES CHANNEL_STATIC_CLIENT_ENTRIES)
foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES})
foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
if(${${STATIC_MODULE}_CLIENT_ENTRY} STREQUAL ${STATIC_ENTRY})
set(STATIC_MODULE_NAME ${${STATIC_MODULE}_CLIENT_NAME})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${STATIC_MODULE_NAME})
set(ENTRY_POINT_NAME "${${STATIC_MODULE}_CLIENT_NAME}_${${STATIC_MODULE}_CLIENT_ENTRY}")
set(ENTRY_POINT_IMPORT "extern void ${ENTRY_POINT_NAME}();")
set(${STATIC_ENTRY}_IMPORTS "${${STATIC_ENTRY}_IMPORTS}\n${ENTRY_POINT_IMPORT}")
set(${STATIC_ENTRY}_TABLE "${${STATIC_ENTRY}_TABLE}\n\t{ \"${STATIC_MODULE_NAME}\", ${ENTRY_POINT_NAME} },")
endif()
endforeach()
endforeach()
set(VIRTUAL_CHANNEL_ENTRY_TABLE "${VIRTUAL_CHANNEL_ENTRY_TABLE}\n\t{ \"\", NULL }")
set(DEVICE_SERVICE_ENTRY_TABLE "${DEVICE_SERVICE_ENTRY_TABLE}\n\t{ \"\", NULL }")
set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\nconst STATIC_ENTRY_TABLE CLIENT_STATIC_ENTRY_TABLES[] =\n{")
foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES})
set(CLIENT_STATIC_ENTRY_IMPORTS "${CLIENT_STATIC_ENTRY_IMPORTS}\n${${STATIC_ENTRY}_IMPORTS}")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\nconst STATIC_ENTRY CLIENT_${STATIC_ENTRY}_TABLE[] =\n{")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n${${STATIC_ENTRY}_TABLE}")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n\t{ \"\", NULL }\n};")
set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"${STATIC_ENTRY}\", CLIENT_${STATIC_ENTRY}_TABLE },")
endforeach()
set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"\", NULL }\n};")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tables.c.in ${CMAKE_CURRENT_SOURCE_DIR}/tables.c)

View File

@ -25,60 +25,54 @@
#include <freerdp/client/channels.h>
extern const VIRTUAL_CHANNEL_ENTRY VIRTUAL_CHANNEL_TABLE[];
extern const DEVICE_SERVICE_ENTRY DEVICE_SERVICE_TABLE[];
extern const STATIC_ENTRY_TABLE CLIENT_STATIC_ENTRY_TABLES[];
void* freerdp_channels_find_static_virtual_channel_entry(const char* name)
void* freerdp_channels_find_static_entry_in_table(const STATIC_ENTRY_TABLE* table, const char* entry)
{
int index = 0;
VIRTUAL_CHANNEL_ENTRY* pEntry;
STATIC_ENTRY* pEntry;
pEntry = (VIRTUAL_CHANNEL_ENTRY*) &VIRTUAL_CHANNEL_TABLE[index++];
pEntry = (STATIC_ENTRY*) &table->table[index++];
while (pEntry->entry != NULL)
{
if (strcmp(pEntry->name, name) == 0)
if (strcmp(pEntry->name, entry) == 0)
{
return (void*) pEntry->entry;
}
pEntry = (VIRTUAL_CHANNEL_ENTRY*) &VIRTUAL_CHANNEL_TABLE[index++];
pEntry = (STATIC_ENTRY*) &table->table[index++];
}
return NULL;
}
void* freerdp_channels_find_static_device_service_entry(const char* name)
{
int index = 0;
DEVICE_SERVICE_ENTRY* pEntry;
pEntry = (DEVICE_SERVICE_ENTRY*) &DEVICE_SERVICE_TABLE[index++];
while (pEntry->entry != NULL)
{
if (strcmp(pEntry->name, name) == 0)
{
return (void*) pEntry->entry;
}
pEntry = (DEVICE_SERVICE_ENTRY*) &DEVICE_SERVICE_TABLE[index++];
}
return NULL;
}
void* freerdp_channels_find_static_entry(const char* name, const char* entry)
{
if (strcmp(entry, "VirtualChannelEntry") == 0)
int index = 0;
STATIC_ENTRY_TABLE* pEntry;
pEntry = (STATIC_ENTRY_TABLE*) &CLIENT_STATIC_ENTRY_TABLES[index++];
while (pEntry->table != NULL)
{
return freerdp_channels_find_static_virtual_channel_entry(name);
}
else if (strcmp(entry, "DeviceServiceEntry") == 0)
{
return freerdp_channels_find_static_device_service_entry(name);
if (strcmp(pEntry->name, name) == 0)
{
return freerdp_channels_find_static_entry_in_table(pEntry, entry);
}
pEntry = (STATIC_ENTRY_TABLE*) &CLIENT_STATIC_ENTRY_TABLES[index++];
}
return NULL;
}
void* freerdp_channels_find_static_virtual_channel_entry(const char* name)
{
return freerdp_channels_find_static_entry("VirtualChannelEntry", name);
}
void* freerdp_channels_find_static_device_service_entry(const char* name)
{
return freerdp_channels_find_static_entry("DeviceServiceEntry", name);
}

View File

@ -18,14 +18,11 @@
*/
#include "tables.h"
${VIRTUAL_CHANNEL_ENTRY_IMPORTS}
${DEVICE_SERVICE_ENTRY_IMPORTS}
const VIRTUAL_CHANNEL_ENTRY VIRTUAL_CHANNEL_TABLE[] =
{${VIRTUAL_CHANNEL_ENTRY_TABLE}
};
${CLIENT_STATIC_ENTRY_IMPORTS}
${CLIENT_STATIC_ENTRY_TABLES}
${CLIENT_STATIC_ENTRY_TABLES_LIST}
const DEVICE_SERVICE_ENTRY DEVICE_SERVICE_TABLE[] =
{${DEVICE_SERVICE_ENTRY_TABLE}
};

View File

@ -19,24 +19,16 @@
#include <freerdp/svc.h>
#ifndef PDEVICE_SERVICE_ENTRY_POINTS
#define PDEVICE_SERVICE_ENTRY_POINTS void*
#endif
typedef int (*VIRTUAL_CHANNEL_ENTRY_FN)(PCHANNEL_ENTRY_POINTS pEntryPoints);
typedef int (*DEVICE_SERVICE_ENTRY_FN)(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints);
struct _VIRTUAL_CHANNEL_ENTRY
struct _STATIC_ENTRY
{
const char* name;
const VIRTUAL_CHANNEL_ENTRY_FN entry;
const void* entry;
};
typedef struct _VIRTUAL_CHANNEL_ENTRY VIRTUAL_CHANNEL_ENTRY;
typedef struct _STATIC_ENTRY STATIC_ENTRY;
struct _DEVICE_SERVICE_ENTRY
struct _STATIC_ENTRY_TABLE
{
const char* name;
const DEVICE_SERVICE_ENTRY_FN entry;
const STATIC_ENTRY* table;
};
typedef struct _DEVICE_SERVICE_ENTRY DEVICE_SERVICE_ENTRY;
typedef struct _STATIC_ENTRY_TABLE STATIC_ENTRY_TABLE;

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "cliprdr")
set(MODULE_PREFIX "CHANNEL_CLIPRDR_CLIENT")
set(CHANNEL_NAME "cliprdr")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
cliprdr_constants.h
@ -25,7 +26,7 @@ set(${MODULE_PREFIX}_SRCS
cliprdr_main.c
cliprdr_main.h)
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} FALSE "DVCPluginEntry")
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} FALSE "VirtualChannelEntry")
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")

View File

@ -22,4 +22,3 @@ string(TOUPPER "CHANNEL_${CHANNEL_NAME}" MODULE_PREFIX)
if(WITH_CLIENT_CHANNELS)
add_channel_client(${MODULE_PREFIX} ${CHANNEL_NAME})
endif()

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "disk")
set(MODULE_PREFIX "CHANNEL_RDPDR_DISK_CLIENT")
set(CHANNEL_NAME "disk")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
disk_file.c

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "drdynvc")
set(MODULE_PREFIX "CHANNEL_DRDYNVC_CLIENT")
set(CHANNEL_NAME "drdynvc")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
drdynvc_main.c
@ -25,7 +26,7 @@ set(${MODULE_PREFIX}_SRCS
dvcman.c
dvcman.h)
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} FALSE "DVCPluginEntry")
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} FALSE "VirtualChannelEntry")
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")

View File

@ -15,13 +15,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "parallel")
set(MODULE_PREFIX "CHANNEL_RDPDR_PARALLEL_CLIENT")
set(CHANNEL_NAME "parallel")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
parallel_main.c)
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} TRUE "DVCPluginEntry")
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} TRUE "DeviceServiceEntry")
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "printer")
set(MODULE_PREFIX "CHANNEL_RDPDR_PRINTER_CLIENT")
set(CHANNEL_NAME "printer")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
printer_main.c
@ -37,7 +38,7 @@ if(WIN32)
printer_win.h)
endif()
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} TRUE "DVCPluginEntry")
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} TRUE "DeviceServiceEntry")
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
@ -55,10 +56,10 @@ if(WITH_CUPS)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${CUPS_LIBRARIES})
endif()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
endif()
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${MODULE_NAME}/Client")

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "rail")
set(MODULE_PREFIX "CHANNEL_RAIL_CLIENT")
set(CHANNEL_NAME "rail")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
rail_main.c

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "rdpdr")
set(MODULE_PREFIX "CHANNEL_RDPDR_CLIENT")
set(CHANNEL_NAME "rdpdr")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
irp.c

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "rdpsnd")
set(MODULE_PREFIX "CHANNEL_RDPSND_CLIENT")
set(CHANNEL_NAME "rdpsnd")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
rdpsnd_main.c

View File

@ -15,9 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(CHANNEL "rdpsnd")
set(MODULE_NAME "${CHANNEL}-server")
set(MODULE_PREFIX "CHANNEL_RDPSND_SERVER")
set(CHANNEL_NAME "rdpsnd")
set(MODULE_NAME "${CHANNEL_NAME}-server")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_SERVER" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
rdpsnd.c)

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "sample")
set(MODULE_PREFIX "CHANNEL_SAMPLE_CLIENT")
set(CHANNEL_NAME "sample")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
skel_main.c

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "serial")
set(MODULE_PREFIX "CHANNEL_DEVICE_SERIAL_CLIENT")
set(CHANNEL_NAME "serial")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
serial_tty.c

View File

@ -16,8 +16,8 @@
# limitations under the License.
set(CHANNEL_NAME "smartcard")
set(MODULE_NAME ${CHANNEL_NAME})
string(TOUPPER "CHANNEL_${CHANNEL_NAME}" MODULE_PREFIX)
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
if(WITH_CLIENT_CHANNELS)
add_channel_client(${MODULE_PREFIX} ${CHANNEL_NAME})

View File

@ -16,8 +16,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "tsmf")
set(MODULE_PREFIX "CHANNEL_TSMF_CLIENT")
set(CHANNEL_NAME "tsmf")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
tsmf_audio.c

View File

@ -16,8 +16,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(MODULE_NAME "urbdrc")
set(MODULE_PREFIX "CHANNEL_URBDRC_CLIENT")
set(CHANNEL_NAME "urbdrc")
set(MODULE_NAME "${CHANNEL_NAME}")
string(TOUPPER "CHANNEL_${CHANNEL_NAME}_CLIENT" MODULE_PREFIX)
set(${MODULE_PREFIX}_SRCS
searchman.c