Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSN GUI editor #32

Merged
merged 33 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
91bf4b3
add integration with the .net installer
bpintea Sep 27, 2018
ac5ca5f
add DSN config validation
bpintea Sep 28, 2018
88d0da9
add integration with the .net installer
bpintea Sep 27, 2018
785b366
add DSN config validation
bpintea Sep 28, 2018
035b115
Merge branch 'feature/gui_config' of github.com:bpintea/elasticsearch…
bpintea Oct 2, 2018
80880f6
Fix installer error reporing
bpintea Oct 3, 2018
3adba71
Add an initial "simplistic" DSN editor.
bpintea Oct 3, 2018
acb0cf1
fix the running of the unittests
bpintea Oct 4, 2018
bd781df
Update "simple" UI with "complex" UI
codebrain Oct 4, 2018
c61cdf1
Merge branch 'feature/gui_config' of github.com:bpintea/elasticsearch…
codebrain Oct 4, 2018
468a84f
Fix ESODBC_DSN_EXISTS_ERROR error handling
codebrain Oct 4, 2018
be4f4a8
b/f: conn str writer returned wrong chars count
bpintea Oct 4, 2018
980b34a
refactor DSN validation
bpintea Oct 6, 2018
548c303
further DSN validation and code deduplication
bpintea Oct 9, 2018
baee1b6
Add editor launcher (for rapid development!).
codebrain Oct 10, 2018
9c7aecf
Merge branch 'feature/gui_config' of github.com:bpintea/elasticsearch…
codebrain Oct 10, 2018
1bd7bd7
Set state of Save / Test buttons based on values being present in hos…
codebrain Oct 10, 2018
e2f5b51
Add logging information panel. Fixes #31.
codebrain Oct 10, 2018
8c5575d
change one file's encoding
bpintea Oct 11, 2018
542bfff
configure COM as STA
bpintea Oct 11, 2018
e8ee1af
Fixes #27
codebrain Oct 13, 2018
50c8481
Merge branch 'feature/gui_config' of github.com:bpintea/elasticsearch…
codebrain Oct 13, 2018
ca5f91d
Add TraceEnabled handling to UI. #31
codebrain Oct 13, 2018
48dca53
create thread if neutral/multi-threaded appart.
bpintea Oct 15, 2018
a38e80c
Swap cursor for a wait cursor on connection test, to give feedback to…
codebrain Oct 15, 2018
fd60f3e
Merge branch 'feature/gui_config' of github.com:bpintea/elasticsearch…
codebrain Oct 15, 2018
8230016
Remove [X] button, to force user into using the cancel button
codebrain Oct 15, 2018
4a81307
add a new conn str param, TraceEnabled
bpintea Oct 15, 2018
4a9aa1d
b/f: use the correct macro for DSN editor exports
bpintea Oct 16, 2018
463bc1d
add missing license headers
bpintea Oct 17, 2018
8425ff2
rename .cpp file to .cc to stay consistent
bpintea Oct 17, 2018
d93ffa2
detail one comment
bpintea Oct 23, 2018
aa709b8
Address PR comments
codebrain Oct 24, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
driver/*.swp
cscope.out
.vs
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 :
59 changes: 39 additions & 20 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,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 +354,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
Loading