Skip to content

Commit

Permalink
Merge branch 'master' into msi-installer
Browse files Browse the repository at this point in the history
  • Loading branch information
bpintea authored Oct 26, 2018
2 parents 11dd759 + b6670de commit ae6845e
Show file tree
Hide file tree
Showing 57 changed files with 8,326 additions and 1,576 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ driver/*.swp
cscope.out
.vs
installer/src/Installer/driver/
dsneditor/EsOdbcDsnEditor/Debug/
dsneditor/EsOdbcDsnEditorLauncher/bin/
dsneditor/EsOdbcDsnEditorLauncher/obj/
105 changes: 78 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ set(IS_UNICODE 1)
#include(GenerateExportHeader)

if (${WIN32})
if (${CMAKE_GENERATOR_PLATFORM} MATCHES x64)
# or: CMAKE_SIZEOF_VOID_P EQUAL 8
if (${CMAKE_GENERATOR_PLATFORM} MATCHES [Xx]64)
set(TARCH x64) # target arch
set(BARCH ) # bits architecture (64 is the default, silent)
set(PLAT_ARCH windows-x86_64)
else (${CMAKE_GENERATOR_PLATFORM} MATCHES x64)
else (${CMAKE_GENERATOR_PLATFORM} MATCHES [Xx]64)
set(TARCH x86)
set(BARCH 32)
set(PLAT_ARCH windows-x86)
endif (${CMAKE_GENERATOR_PLATFORM} MATCHES x64)
endif (${CMAKE_GENERATOR_PLATFORM} MATCHES [Xx]64)
message("Building for Windows, ${TARCH}.")
else (${WIN32})
message(FATAL_ERROR "No support for current platform yet")
Expand Down Expand Up @@ -175,18 +176,20 @@ aux_source_directory(${CTIMESTAMP_PATH_SRC}/ DRV_SRC)
#
set(LIBCURL_PATH_SRC ${CMAKE_SOURCE_DIR}/libs/curl CACHE PATH
"Lib curl source path")
set(LIBCURL_BUILD_TYPE debug CACHE STRING
"Lib curl build type: debug (default) or release")
set(LIBCURL_LINK_MODE static CACHE STRING
"Lib curl linking mode: static (default) or dll")
set(LIBCURL_BUILD_TYPE debug CACHE STRING
"Lib curl build type: debug (default) or release")

if (${LIBCURL_BUILD_TYPE} MATCHES debug)
if (${LIBCURL_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg])
set(LIBCURL_DEBUG_ENABLED yes)
set(LIBCURL_BUILD_TYPE debug)
set(LIBCURL_BUILD_SUFFIX _debug)
else (${LIBCURL_BUILD_TYPE} MATCHES debug)
else (${LIBCURL_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg])
set(LIBCURL_DEBUG_ENABLED no)
set(LIBCURL_BUILD_TYPE release)
# empty LIBCURL_BUILD_SUFFIX
endif (${LIBCURL_BUILD_TYPE} MATCHES debug)
endif (${LIBCURL_BUILD_TYPE} MATCHES [Dd][Ee][Bb][Uu][Gg])

set(LIBCURL_LD_PATH
# Curl "installs" the .dll and .lib in different directories -> use the
Expand All @@ -201,7 +204,12 @@ set(LIBCURL_INC_PATH ${LIBCURL_PATH_SRC}/include CACHE PATH

# Build libcurl.
# Note: this happens at config time as a pre-requisite, for now. This might
# be changed to a build target later (possibly as a CMake subproject).
# be changed to a build target later (possibly as a CMake subproject: re-link
# only if out-of-date, skip building the .exe, allow disabling non-HTTP
# protos, || build, setting output destination).
# Building as a pre-requisite has however the disadvantage of making the
# entire build "single-config", since the build type (rel/dbg) is decided at
# CMake-generation, not along the MSBuild invocation.
if (NOT IS_DIRECTORY ${LIBCURL_LD_PATH})
execute_process(COMMAND buildconf.bat
RESULT_VARIABLE CMD_RETURN
Expand Down Expand Up @@ -231,22 +239,22 @@ endif(NOT IS_DIRECTORY ${LIBCURL_LD_PATH})

# add libcurl as dependency
if (${WIN32})
if (${LIBCURL_LINK_MODE} MATCHES dll)
if (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll])
add_library(libcurl SHARED IMPORTED)
set_property(TARGET libcurl PROPERTY IMPORTED_LOCATION
${LIBCURL_LD_PATH}/libcurl${LIBCURL_BUILD_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
set_property(TARGET libcurl PROPERTY IMPORTED_IMPLIB
${LIBCURL_LD_PATH}/libcurl${LIBCURL_BUILD_SUFFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX})
# empty LIBCURL_WIN_LIBS
else (${LIBCURL_LINK_MODE} MATCHES dll)
else (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll])
add_library(libcurl STATIC IMPORTED)
set_property(TARGET libcurl PROPERTY IMPORTED_LOCATION
${LIBCURL_LD_PATH}/libcurl_a${LIBCURL_BUILD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DCURL_STATICLIB")
# Libraries that libcurl/WinSSL links against.
# Removed: wldap32 advapi32 gdi32 user32 (wth current config unused)
set(LIBCURL_WIN_LIBS ws2_32 crypt32 normaliz)
endif (${LIBCURL_LINK_MODE} MATCHES dll)
endif (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll])
else (${WIN32})
set_property(TARGET libcurl PROPERTY IMPORTED_LOCATION
${LIBCURL_LD_PATH}/libcurl${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand All @@ -258,41 +266,58 @@ add_custom_target(curlclean
WORKING_DIRECTORY "${LIBCURL_PATH_SRC}/winbuild"
)

#
# DSN Config GUI
#
set(DSNBND_LIB_BIN_DIR_BASE ${CMAKE_BINARY_DIR}/dsneditor-${TARCH})
set(DSNEDITOR_INC_PATH ${CMAKE_SOURCE_DIR}/dsneditor/EsOdbcDsnBinding/)
add_custom_target(dsneditor
COMMAND MSBuild ${CMAKE_SOURCE_DIR}/dsneditor/EsOdbcDsnBinding/EsOdbcDsnBinding.vcxproj
# place all the build items (by- & products) into a single dir
/p:OutputPath=${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/
/p:IntermediateOutputPath=${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/
/p:OutDir=${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/
/p:IntDir=${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/
/p:Configuration=$<CONFIG>
/p:Platform=${TARCH} # make it explicit, for x-arch builds
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Building the DSN editor libraries.")

message("C flags: ${CMAKE_C_FLAGS} .")
message("Driver source files: ${DRV_SRC} .")
message("Driver include paths: " ${ODBC_INC} ${DRV_SRC_DIR}
${LIBCURL_INC_PATH} ${UJSON4C_INC} ${CTIMESTAMP_PATH_SRC})

# generate resource file
configure_file(${DRV_SRC_DIR}/driver.rc.cmake ${CMAKE_BINARY_DIR}/driver.rc)

#
# finally, set destination library
#
# generate resource file
configure_file(${DRV_SRC_DIR}/driver.rc.cmake ${CMAKE_BINARY_DIR}/driver.rc)
add_library(${DRV_NAME} SHARED ${DRV_SRC} ${CMAKE_BINARY_DIR}/${DRV_NAME}.def
${CMAKE_BINARY_DIR}/driver.rc)
#generate_export_header(${DRV_NAME})
target_compile_definitions(${DRV_NAME} PRIVATE "DRIVER_BUILD")

add_dependencies(${DRV_NAME} dsneditor)
include_directories(${ODBC_INC} ${DRV_SRC_DIR} ${LIBCURL_INC_PATH}
${UJSON4C_INC} ${CTIMESTAMP_PATH_SRC})
${UJSON4C_INC} ${CTIMESTAMP_PATH_SRC} ${DSNEDITOR_INC_PATH})
target_link_libraries(${DRV_NAME} odbccp32 legacy_stdio_definitions
${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/esdsnbnd${CMAKE_IMPORT_LIBRARY_SUFFIX}
libcurl ${LIBCURL_WIN_LIBS})

target_link_libraries(${DRV_NAME} odbccp32 legacy_stdio_definitions libcurl
${LIBCURL_WIN_LIBS})

# add testing project/target
#
# Set up the testing project/target
#
enable_testing()
# ... and testing directory to build
add_subdirectory(test)


#
# Set up the instalation
#
set(INSTALL_DIR
${DRIVER_BASE_NAME}-${DRV_VERSION}${VERSION_QUALIFIER}-${PLAT_ARCH}
# this must remain a STRING (i.e not PATH), otherwise CPACK won't work
CACHE STRING
"Directory to install the driver files into")

message("Install target: ${INSTALL_DIR}.")
# this will cause the 'install' to no longer depend on 'all', which avoids
# building the tests, but this also means that the library must be built
# before building the 'install' target.
Expand All @@ -301,20 +326,46 @@ set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
install(FILES
LICENSE.rtf LICENSE.txt
DESTINATION ${INSTALL_DIR})
if (${LIBCURL_LINK_MODE} MATCHES dll)
# add libcurl if build dynamically
if (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll])
install(FILES
# need to use FILE : https://public.kitware.com/Bug/view.php?id=14311
${LIBCURL_LD_PATH}/libcurl${LIBCURL_BUILD_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${INSTALL_DIR})
endif (${LIBCURL_LINK_MODE} MATCHES dll)
endif (${LIBCURL_LINK_MODE} MATCHES [Dd][Ll][Ll])
# add editor DLLs
install(FILES
${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/esdsnedt.dll
${DSNBND_LIB_BIN_DIR_BASE}-$<CONFIG>/esdsnbnd.dll
DESTINATION ${INSTALL_DIR})
install(TARGETS ${DRV_NAME}
DESTINATION ${INSTALL_DIR})

#
# Set up the packaing
#
set(CPACK_GENERATOR "ZIP")
# don't build ALL (but see CMAKE_SKIP_INSTALL_ALL_DEPENDENCY comment)
set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY TRUE)
set(CPACK_PACKAGE_FILE_NAME
${DRIVER_BASE_NAME}-${DRV_VERSION}${VERSION_QUALIFIER}-${PLAT_ARCH})
include(CPack)


#
# Generation summary
#
message(" ***** <Generation summary>")
message("Driver source files: ${DRV_SRC}")
message("Driver compile flags: ${CMAKE_C_FLAGS}")
message("Driver include paths: ${ODBC_INC} ${DRV_SRC_DIR}"
"${LIBCURL_INC_PATH} ${UJSON4C_INC} ${CTIMESTAMP_PATH_SRC}"
"${DSNEDITOR_INC_PATH}")
# there's no var for this
message("Driver link libraries: odbccp32 legacy_stdio_definitions esdsnbnd"
"libcurl ${LIBCURL_WIN_LIBS}")
message("Driver install target: ${INSTALL_DIR}.")
message("Driver packaging target: ${CPACK_PACKAGE_FILE_NAME}.")
message(" ***** </Generation summary>")

# vim: set noet fenc=utf-8 ff=dos sts=0 sw=4 ts=4 :
61 changes: 39 additions & 22 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ set DRIVER_BASE_NAME=esodbc
set ARG="%*"
set SRC_PATH=%~dp0

REM "funny" fact: removing 'REM X' from above label definition makes 'cmd'
REM no longer find the label -- why? (check with "> build nobuild")
call:SET_ARCH
call:SET_CMAKE

Expand Down Expand Up @@ -204,8 +202,7 @@ REM USAGE function: output a usage message
echo building (requires 2017 version or later^).
echo clean : remove all the files in the build dir.
echo proper : clean libs, builds, project dirs and exit.
echo type:T : selects the build type, T, among one of:
echo Debug/Release/RelWithDebInfo/MinSizeRel.
echo type:T : selects the build type, T: Debug or Release.
echo tests : run all the defined tests.
echo suites : run all the defined tests, individually.
echo suite:S : run one test, S.
Expand Down Expand Up @@ -355,50 +352,70 @@ REM injected into the project files generated by cmake

REM BUILDTYPE function: set the build config to feed MSBuild
:BUILDTYPE
if /i not [%ARG:type=%] == [%ARG%] (
REM cycle through the args, look for 'type:' token and use the
REM follow-up token
for %%a in (%ARG:"=%) do (
set crr=%%a
if /i ["!crr:~0,5!"] == ["type:"] (
set BUILD_TYPE=!crr:~5!
if not exist ALL_BUILD.vcxproj (
if /i not [%ARG:type=%] == [%ARG%] (
REM cycle through the args, look for 'type:' token and use the
REM follow-up token
for %%a in (%ARG:"=%) do (
set crr=%%a
if /i ["!crr:~0,5!"] == ["type:"] (
set BUILD_TYPE=!crr:~5!
)
)
REM no check against empty val (type:) here
)
REM no check against empty val (type:) here
)
if [%BUILD_TYPE%] == [] (
set BUILD_TYPE=Debug
if [!BUILD_TYPE!] == [] (
set BUILD_TYPE=Debug
)
echo %~nx0: setting the build type to: !BUILD_TYPE!.
) else if exist %BUILD_DIR%/Release (
set BUILD_TYPE=Release
echo %~nx0: previously build type set: !BUILD_TYPE!.
) else if exist %BUILD_DIR%/Debug (
set BUILD_TYPE=Debug
echo %~nx0: previously build type set: !BUILD_TYPE!.
) else (
REM DSN editor libs only support Debug and Release
echo %~nx0: ERROR: unknown previously set build type.
set ERRORLEVEL=1
goto END
)
set MSBUILD_ARGS=/p:Configuration=!BUILD_TYPE!
echo %~nx0: setting the build type to: !BUILD_TYPE!.

goto:eof

REM BUILD function: build various targets
:BUILD
REM set the wanted or previously set build type.
call:BUILDTYPE
if ERRORLEVEL 1 (
goto END
)
if not exist ALL_BUILD.vcxproj (
echo %~nx0: generating the project files.

REM set the wanted build type.
call:BUILDTYPE
rem call:BUILDTYPE

set CMAKE_ARGS=-DDRIVER_BASE_NAME=%DRIVER_BASE_NAME%
REM no explicit x86 generator and is the default (MSVC2017 only?).
set CMAKE_ARGS=!CMAKE_ARGS! -DCMAKE_GENERATOR_PLATFORM=%TARCH:x86=%

if /i not [%ARG:curldll=%] == [%ARG%] (
set CMAKE_ARGS=!CMAKE_ARGS! -DLIBCURL_LINK_MODE=dll
)
if /i [!BUILD_TYPE!] == [Debug] (
set CMAKE_ARGS=!CMAKE_ARGS! -DLIBCURL_BUILD_TYPE=debug
) else (
set CMAKE_ARGS=!CMAKE_ARGS! -DLIBCURL_BUILD_TYPE=release
)

if not [!INSTALL_DIR!] == [] (
set CMAKE_ARGS=!CMAKE_ARGS! -DINSTALL_DIR=!INSTALL_DIR!
)
if not [!PACKAGE_VER!] == [] (
set CMAKE_ARGS=!CMAKE_ARGS! -DVERSION_QUALIFIER=!PACKAGE_VER!
)
if /i [!BUILD_TYPE!] == [Debug] (
set CMAKE_ARGS=!CMAKE_ARGS! -DLIBCURL_BUILD_TYPE=debug
) else (
set CMAKE_ARGS=!CMAKE_ARGS! -DLIBCURL_BUILD_TYPE=release
)

echo %~nx0: cmake params: !CMAKE_ARGS!.
%CMAKE% !CMAKE_ARGS! !SRC_PATH!
Expand Down
15 changes: 9 additions & 6 deletions driver/catalogue.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@
#define SQL_TABLES \
"SYS TABLES"
#define SQL_TABLES_CAT \
" CATALOG LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM
" CATALOG LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM \
" ESCAPE '" ESODBC_PATTERN_ESCAPE "'"
#define SQL_TABLES_TAB \
" LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM
" LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM \
" ESCAPE '" ESODBC_PATTERN_ESCAPE "'"
#define SQL_TABLES_TYP \
" TYPE " WPFWP_LDESC

// TODO add schema, when supported
#define SQL_COLUMNS(...) "SYS COLUMNS" __VA_ARGS__ \
" TABLE LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM \
" ESCAPE '" ESODBC_PATTERN_ESCAPE "' " \
" LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM
" ESCAPE '" ESODBC_PATTERN_ESCAPE "'" \
" LIKE " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM \
" ESCAPE '" ESODBC_PATTERN_ESCAPE "'"
#define SQL_COL_CAT \
" CATALOG " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM \
" CATALOG " ESODBC_STRING_DELIM WPFWP_LDESC ESODBC_STRING_DELIM


/* writes into 'dest', of size 'room', the current catalog of 'dbc'.
Expand Down Expand Up @@ -500,7 +503,7 @@ SQLRETURN EsSQLPrimaryKeysW(
_In_reads_opt_(cchTableName) SQLWCHAR *szTableName,
SQLSMALLINT cchTableName)
{
WARNH(hstmt, "no primary keys supported.");
INFOH(hstmt, "no primary keys supported.");
STMT_FORCE_NODATA(STMH(hstmt));
return SQL_SUCCESS;
}
Expand Down
Loading

0 comments on commit ae6845e

Please sign in to comment.