From: <ai...@us...> - 2009-03-11 17:20:00
|
Revision: 9721 http://plplot.svn.sourceforge.net/plplot/?rev=9721&view=rev Author: airwin Date: 2009-03-11 17:19:13 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Rename get-drv-info.c to test-drv-info.c. Implement a test_dyndrivers target that is only created if not cross building. Restore some file dependencies. Greatly simplify cross-build logic. Modified Paths: -------------- trunk/drivers/CMakeLists.txt Added Paths: ----------- trunk/drivers/test-drv-info.c Removed Paths: ------------- trunk/drivers/get-drv-info.c Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-11 17:16:40 UTC (rev 9720) +++ trunk/drivers/CMakeLists.txt 2009-03-11 17:19:13 UTC (rev 9721) @@ -41,43 +41,40 @@ ${CMAKE_BINARY_DIR}/include ) - option(TEST_DYNDRIVERS "Test dynamic drivers" OFF) - if(TEST_DYNDRIVERS) + option(TEST_DYNDRIVERS "Test dynamic drivers" ON) + if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir) + set_source_files_properties( - get-drv-info.c + test-drv-info.c PROPERTIES COMPILE_FLAGS "-I${LTDL_INCLUDE_DIR} -DUSINGDLL" ) - if(NOT CMAKE_CROSSCOMPILING) - add_executable(get-drv-info get-drv-info.c) - target_link_libraries(get-drv-info - plplot${LIB_TAG} - ${LTDL_LIBRARIES} - ) - set(get-drv-info_RPATH - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_BINARY_DIR}/lib/csa - ${CMAKE_BINARY_DIR}/lib/nn - ${CMAKE_BINARY_DIR}/lib/qsastime - ${libplplot${LIB_TAG}_RPATH} - ) - - set_target_properties( - get-drv-info - PROPERTIES - INSTALL_RPATH "${get-drv-info_RPATH}" - BUILD_WITH_INSTALL_RPATH ON - ) - else(NOT CMAKE_CROSSCOMPILING) - set(IMPORT_EXECUTABLES ${CMAKE_NATIVE_BINARY_DIR}/drivers/ImportExecutables.cmake) - include(${IMPORT_EXECUTABLES}) - endif(NOT CMAKE_CROSSCOMPILING) + add_executable(test-drv-info test-drv-info.c) + target_link_libraries(test-drv-info + plplot${LIB_TAG} + ${LTDL_LIBRARIES} + ) + set(test-drv-info_RPATH + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_BINARY_DIR}/lib/csa + ${CMAKE_BINARY_DIR}/lib/nn + ${CMAKE_BINARY_DIR}/lib/qsastime + ${libplplot${LIB_TAG}_RPATH} + ) + + set_target_properties( + test-drv-info + PROPERTIES + INSTALL_RPATH "${test-drv-info_RPATH}" + BUILD_WITH_INSTALL_RPATH ON + ) + get_target_property(test-drv-info_LOCATION test-drv-info LOCATION) + set(test_dyndrivers_FDEPENDS) + set(test_dyndrivers_TDEPENDS test-drv-info) - if(NOT CMAKE_CROSSCOMPILING) - export(TARGETS get-drv-info FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake ) - endif(NOT CMAKE_CROSSCOMPILING) - endif(TEST_DYNDRIVERS) + endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) #message("${SOURCE_ROOT_NAME}_SOURCE = ${${SOURCE_ROOT_NAME}_SOURCE}") @@ -166,28 +163,29 @@ SUFFIX ${DYNAMIC_SUFFIX} ) endif(USE_RPATH) - if(TEST_DYNDRIVERS) + if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) get_target_property( ${SOURCE_ROOT_NAME}_LOCATION ${SOURCE_ROOT_NAME} LOCATION ) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc - COMMAND get-drv-info + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc + COMMAND test-drv-info ${SOURCE_ROOT_NAME} - > ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc + > ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc + COMMAND ${CMAKE_COMMAND} -E compare_files + ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc + ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc DEPENDS ${${SOURCE_ROOT_NAME}_LOCATION} + ${test-drv-info_LOCATION} ) - add_custom_target( - ${SOURCE_ROOT_NAME}_CHECK ALL - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc + list(APPEND test_dyndrivers_FDEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/test_dyndrivers_dir/${SOURCE_ROOT_NAME}.rc ) - # Workaround CMake 2-level make recursion issue for parallel builds. - add_dependencies(${SOURCE_ROOT_NAME}_CHECK ${SOURCE_ROOT_NAME}) - endif(TEST_DYNDRIVERS) + list(APPEND test_dyndrivers_TDEPENDS ${SOURCE_ROOT_NAME}) + endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) install(TARGETS ${SOURCE_ROOT_NAME} DESTINATION ${DRV_DIR}) install( @@ -195,5 +193,11 @@ DESTINATION ${DRV_DIR} ) endforeach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) + if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) + add_custom_target(test_dyndrivers + DEPENDS ${test_dyndrivers_FDEPENDS} + ) + add_dependencies(test_dyndrivers ${test_dyndrivers_TDEPENDS}) + endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) endif(ENABLE_DYNDRIVERS) Deleted: trunk/drivers/get-drv-info.c =================================================================== --- trunk/drivers/get-drv-info.c 2009-03-11 17:16:40 UTC (rev 9720) +++ trunk/drivers/get-drv-info.c 2009-03-11 17:19:13 UTC (rev 9721) @@ -1,80 +0,0 @@ -/* Get device info from PLplot driver module - * - * Copyright (C) 2003 Rafael Laboissiere - * Copyright (C) 2004 Joao Cardoso - * - * This file is part of PLplot. - * - * PLplot is free software; you can redistribute it and/or modify it under - * the terms of the GNU Library General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * PLplot is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library - * General Public License for more details. - - * You should have received a copy of the GNU Library General Public License - * along with the GNU C Library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02110-1301, USA. - */ - -#include "plplotP.h" -#ifndef LTDL_WIN32 - #include <ltdl.h> -#else - #include "ltdl_win32.h" -#endif -#include <stdio.h> -#include <signal.h> -#include <stdlib.h> - -#define SYM_LEN 300 -#define DRVSPEC_LEN 400 - -/* SEGV signal handler */ -RETSIGTYPE -catch_segv (int sig) -{ - fprintf (stderr, "libltdl error: %s\n", lt_dlerror ()); - exit (1); -} - -int -main (int argc, char* argv[]) -{ - lt_dlhandle dlhand; - char sym[SYM_LEN]; - char* drvnam = argv[1]; - char drvspec[ DRVSPEC_LEN ]; - char** info; - - /* Establish a handler for SIGSEGV signals. */ - signal (SIGSEGV, catch_segv); - - lt_dlinit (); -#ifdef LTDL_WIN32 - snprintf( drvspec, DRVSPEC_LEN, "%s", drvnam ); -#else - snprintf( drvspec, DRVSPEC_LEN, "%s/%s", plGetDrvDir (), drvnam ); -#endif /* LTDL_WIN32 */ - dlhand = lt_dlopenext (drvspec); - if (dlhand == NULL) { - fprintf (stderr, "Could not open driver module %s\n" - "libltdl error: %s\n", drvspec, lt_dlerror ()); - return 1; - } - snprintf (sym, SYM_LEN, "plD_DEVICE_INFO_%s", drvnam); - info = (char **) lt_dlsym (dlhand, sym); - if (info != NULL) { - printf ("%s", *info); - return 0; - } - else { - fprintf (stderr, "Could not read symbol %s in driver module %s\n" - "libltdl error: %s\n", sym, drvspec, lt_dlerror ()); - return 1; - } -} Copied: trunk/drivers/test-drv-info.c (from rev 9717, trunk/drivers/get-drv-info.c) =================================================================== --- trunk/drivers/test-drv-info.c (rev 0) +++ trunk/drivers/test-drv-info.c 2009-03-11 17:19:13 UTC (rev 9721) @@ -0,0 +1,80 @@ +/* Get device info from PLplot driver module + * + * Copyright (C) 2003 Rafael Laboissiere + * Copyright (C) 2004 Joao Cardoso + * + * This file is part of PLplot. + * + * PLplot is free software; you can redistribute it and/or modify it under + * the terms of the GNU Library General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * PLplot is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library + * General Public License for more details. + + * You should have received a copy of the GNU Library General Public License + * along with the GNU C Library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02110-1301, USA. + */ + +#include "plplotP.h" +#ifndef LTDL_WIN32 + #include <ltdl.h> +#else + #include "ltdl_win32.h" +#endif +#include <stdio.h> +#include <signal.h> +#include <stdlib.h> + +#define SYM_LEN 300 +#define DRVSPEC_LEN 400 + +/* SEGV signal handler */ +RETSIGTYPE +catch_segv (int sig) +{ + fprintf (stderr, "libltdl error: %s\n", lt_dlerror ()); + exit (1); +} + +int +main (int argc, char* argv[]) +{ + lt_dlhandle dlhand; + char sym[SYM_LEN]; + char* drvnam = argv[1]; + char drvspec[ DRVSPEC_LEN ]; + char** info; + + /* Establish a handler for SIGSEGV signals. */ + signal (SIGSEGV, catch_segv); + + lt_dlinit (); +#ifdef LTDL_WIN32 + snprintf( drvspec, DRVSPEC_LEN, "%s", drvnam ); +#else + snprintf( drvspec, DRVSPEC_LEN, "%s/%s", plGetDrvDir (), drvnam ); +#endif /* LTDL_WIN32 */ + dlhand = lt_dlopenext (drvspec); + if (dlhand == NULL) { + fprintf (stderr, "Could not open driver module %s\n" + "libltdl error: %s\n", drvspec, lt_dlerror ()); + return 1; + } + snprintf (sym, SYM_LEN, "plD_DEVICE_INFO_%s", drvnam); + info = (char **) lt_dlsym (dlhand, sym); + if (info != NULL) { + printf ("%s", *info); + return 0; + } + else { + fprintf (stderr, "Could not read symbol %s in driver module %s\n" + "libltdl error: %s\n", sym, drvspec, lt_dlerror ()); + return 1; + } +} Property changes on: trunk/drivers/test-drv-info.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |