[DO-981] qt package (!15)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
This commit is contained in:
18
recipes/odbc/all/conandata.yml
Normal file
18
recipes/odbc/all/conandata.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
sources:
|
||||
"2.3.11":
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-unixodbc_org/unixODBC-2.3.11.tar.gz"
|
||||
sha256: "d9e55c8e7118347e3c66c87338856dad1516b490fb7c756c1562a2c267c73b5c"
|
||||
"2.3.9":
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-unixodbc_org/unixODBC-2.3.9.tar.gz"
|
||||
sha256: "52833eac3d681c8b0c9a5a65f2ebd745b3a964f208fc748f977e44015a31b207"
|
||||
"2.3.7":
|
||||
url: "https://nexus.avroid.tech/repository/all-raw-proxy-unixodbc_org/unixODBC-2.3.7.tar.gz"
|
||||
sha256: "45f169ba1f454a72b8fcbb82abd832630a3bf93baa84731cf2949f449e1e3e77"
|
||||
patches:
|
||||
"2.3.11":
|
||||
- patch_file: "patches/0001-duplicated-get-connection.patch"
|
||||
"2.3.9":
|
||||
- patch_file: "patches/0001-duplicated-get-connection.patch"
|
||||
"2.3.7":
|
||||
- patch_file: "patches/0001-duplicated-get-connection.patch"
|
||||
- patch_file: "patches/0002-missing-declarations.patch"
|
||||
149
recipes/odbc/all/conanfile.py
Normal file
149
recipes/odbc/all/conanfile.py
Normal file
@@ -0,0 +1,149 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.apple import fix_apple_shared_install_name
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.layout import basic_layout
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class OdbcConan(ConanFile):
|
||||
name = "odbc"
|
||||
package_type = "library"
|
||||
description = "Package providing unixODBC"
|
||||
topics = ("odbc", "database", "dbms", "data-access")
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "http://www.unixodbc.org"
|
||||
license = ("LGPL-2.1", "GPL-2.1")
|
||||
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"with_libiconv": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"with_libiconv": True,
|
||||
}
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
#self.requires("libtool/2.4.7")
|
||||
if self.options.with_libiconv:
|
||||
self.requires("libiconv/1.17")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.os == "Windows":
|
||||
raise ConanInvalidConfiguration("odbc is a system lib on Windows")
|
||||
|
||||
# def build_requirements(self):
|
||||
# self.tool_requires("gnu-config/cci.20210814")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = AutotoolsToolchain(self)
|
||||
yes_no = lambda v: "yes" if v else "no"
|
||||
#libtool_cppinfo = self.dependencies["libtool"].cpp_info.aggregated_components()
|
||||
tc.configure_args.extend([
|
||||
#"--without-included-ltdl",
|
||||
#f"--with-ltdl-include={libtool_cppinfo.includedirs[0]}",
|
||||
#f"--with-ltdl-lib={libtool_cppinfo.libdirs[0]}",
|
||||
#"--disable-ltdl-install",
|
||||
f"--enable-iconv={yes_no(self.options.with_libiconv)}",
|
||||
"--sysconfdir=/etc",
|
||||
])
|
||||
if self.options.with_libiconv:
|
||||
libiconv_prefix = self.dependencies["libiconv"].package_folder
|
||||
tc.configure_args.append(f"--with-libiconv-prefix={libiconv_prefix}")
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
apply_conandata_patches(self)
|
||||
# support more triplets
|
||||
for gnu_config in [
|
||||
self.conf.get("user.gnu-config:config_guess", check_type=str),
|
||||
self.conf.get("user.gnu-config:config_sub", check_type=str),
|
||||
]:
|
||||
if gnu_config:
|
||||
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder)
|
||||
# allow external libtdl (in libtool recipe)
|
||||
replace_in_file(
|
||||
self,
|
||||
os.path.join(self.source_folder, "configure"),
|
||||
"if test -f \"$with_ltdl_lib/libltdl.la\";",
|
||||
"if true;",
|
||||
)
|
||||
#libtool_system_libs = self.dependencies["libtool"].cpp_info.aggregated_components().system_libs
|
||||
#if libtool_system_libs:
|
||||
# replace_in_file(
|
||||
# self,
|
||||
# os.path.join(self.source_folder, "configure"),
|
||||
# "-L$with_ltdl_lib -lltdl",
|
||||
# "-L$with_ltdl_lib -lltdl -l{}".format(" -l".join(libtool_system_libs)),
|
||||
# )
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
autotools = Autotools(self)
|
||||
autotools.configure()
|
||||
autotools.make()
|
||||
|
||||
def package(self):
|
||||
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
autotools = Autotools(self)
|
||||
autotools.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
rmdir(self, os.path.join(self.package_folder, "etc"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
|
||||
fix_apple_shared_install_name(self)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_file_name", "ODBC")
|
||||
self.cpp_info.set_property("cmake_target_name", "ODBC::ODBC")
|
||||
# to avoid conflict with pkgconfig file of _odbc component
|
||||
self.cpp_info.set_property("pkg_config_name", "odbc_full_package")
|
||||
|
||||
self.cpp_info.names["cmake_find_package"] = "ODBC"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "ODBC"
|
||||
|
||||
# odbc
|
||||
self.cpp_info.components["_odbc"].set_property("pkg_config_name", "odbc")
|
||||
self.cpp_info.components["_odbc"].libs = ["odbc"]
|
||||
#self.cpp_info.components["_odbc"].requires = ["libtool::libtool"]
|
||||
if self.options.with_libiconv:
|
||||
self.cpp_info.components["_odbc"].requires.append("libiconv::libiconv")
|
||||
|
||||
# odbcinst
|
||||
self.cpp_info.components["odbcinst"].set_property("pkg_config_name", "odbcinst")
|
||||
self.cpp_info.components["odbcinst"].libs = ["odbcinst"]
|
||||
#self.cpp_info.components["odbcinst"].requires = ["libtool::libtool"]
|
||||
|
||||
# odbccr
|
||||
self.cpp_info.components["odbccr"].set_property("pkg_config_name", "odbccr")
|
||||
self.cpp_info.components["odbccr"].libs = ["odbccr"]
|
||||
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.components["_odbc"].system_libs = ["pthread"]
|
||||
self.cpp_info.components["odbcinst"].system_libs = ["pthread"]
|
||||
|
||||
# TODO: to remove in conan v2
|
||||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/cur/SQLGetDiagRec.c
|
||||
+++ b/cur/SQLGetDiagRec.c
|
||||
@@ -101,8 +101,4 @@ SQLRETURN CLGetDiagRec( SQLSMALLINT handle_type,
|
||||
text_length_ptr);
|
||||
}
|
||||
|
||||
-DMHDBC __get_connection( EHEAD * head )
|
||||
-{
|
||||
- return 0;
|
||||
-}
|
||||
|
||||
53
recipes/odbc/all/patches/0002-missing-declarations.patch
Normal file
53
recipes/odbc/all/patches/0002-missing-declarations.patch
Normal file
@@ -0,0 +1,53 @@
|
||||
--- a/DriverManager/SQLError.c
|
||||
+++ b/DriverManager/SQLError.c
|
||||
@@ -184,7 +184,7 @@
|
||||
|
||||
static char const rcsid[]= "$RCSfile: SQLError.c,v $ $Revision: 1.11 $";
|
||||
|
||||
-static SQLRETURN extract_sql_error( EHEAD *head,
|
||||
+static SQLRETURN cci_extract_sql_error( EHEAD *head,
|
||||
SQLCHAR *sqlstate,
|
||||
SQLINTEGER *native_error,
|
||||
SQLCHAR *message_text,
|
||||
@@ -440,7 +440,7 @@ SQLRETURN SQLError( SQLHENV environment_handle,
|
||||
herror->ret_code_deferred = 0;
|
||||
}
|
||||
|
||||
- ret = extract_sql_error( herror,
|
||||
+ ret = cci_extract_sql_error( herror,
|
||||
sqlstate,
|
||||
native_error,
|
||||
message_text,
|
||||
--- a/DriverManager/SQLErrorW.c
|
||||
+++ b/DriverManager/SQLErrorW.c
|
||||
@@ -173,7 +173,7 @@ SQLRETURN extract_parent_handle_err( int handle_type,
|
||||
* unicode mapping function
|
||||
*/
|
||||
|
||||
-static SQLRETURN extract_sql_error_w( EHEAD *head,
|
||||
+static SQLRETURN cci_extract_sql_error_w( EHEAD *head,
|
||||
SQLWCHAR *sqlstate,
|
||||
SQLINTEGER *native_error,
|
||||
SQLWCHAR *message_text,
|
||||
@@ -391,7 +391,7 @@ SQLRETURN SQLErrorW( SQLHENV environment_handle,
|
||||
herror->ret_code_deferred = 0;
|
||||
}
|
||||
|
||||
- ret = extract_sql_error_w( herror,
|
||||
+ ret = cci_extract_sql_error_w( herror,
|
||||
sqlstate,
|
||||
native_error,
|
||||
message_text,
|
||||
--- a/DriverManager/drivermanager.h
|
||||
+++ b/DriverManager/drivermanager.h
|
||||
@@ -707,6 +707,10 @@ int function_return_ex( int level, void * handle, int ret_code, int save_to_diag
|
||||
void function_entry( void *handle );
|
||||
void setup_error_head( EHEAD *error_header, void *handle, int handle_type );
|
||||
void clear_error_head( EHEAD *error_header );
|
||||
+void extract_diag_error( int htype, DRV_SQLHANDLE handle, DMHDBC connection, EHEAD *head, int return_code, int save_to_diag );
|
||||
+void extract_sql_error( DRV_SQLHANDLE henv, DRV_SQLHANDLE hdbc, DRV_SQLHANDLE hstmt, DMHDBC connection, EHEAD *head, int return_code );
|
||||
+void extract_diag_error_w( int htype, DRV_SQLHANDLE handle, DMHDBC connection, EHEAD *head, int return_code, int save_to_diag );
|
||||
+void extract_sql_error_w( DRV_SQLHANDLE henv, DRV_SQLHANDLE hdbc, DRV_SQLHANDLE hstmt, DMHDBC connection, EHEAD *head, int return_code );
|
||||
SQLWCHAR *ansi_to_unicode_copy( SQLWCHAR * dest, char *src, SQLINTEGER buffer_len, DMHDBC connection, int *wlen );
|
||||
SQLWCHAR *ansi_to_unicode_alloc( SQLCHAR *str, SQLINTEGER len, DMHDBC connection, int *wlen );
|
||||
char *unicode_to_ansi_copy( char* dest, int dest_len, SQLWCHAR *src, SQLINTEGER len, DMHDBC connection, int *clen );
|
||||
7
recipes/odbc/all/test_package/CMakeLists.txt
Normal file
7
recipes/odbc/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(ODBC REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ODBC::ODBC)
|
||||
9
recipes/odbc/all/test_package/CMakeUserPresets.json
Normal file
9
recipes/odbc/all/test_package/CMakeUserPresets.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/gcc-12-x86_64-gnu17-release/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
27
recipes/odbc/all/test_package/conanfile.py
Normal file
27
recipes/odbc/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str, run=True)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
self.run("odbcinst --version", env="conanrun")
|
||||
17
recipes/odbc/all/test_package/test_package.c
Normal file
17
recipes/odbc/all/test_package/test_package.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Type of SQL_CHAR is %i\n", SQL_CHAR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQLRETURN driver_connect() {
|
||||
SQLHDBC dbc;
|
||||
SQLCHAR *connect_string = (unsigned char *)"DSN=mydsn;";
|
||||
|
||||
return SQLDriverConnect(dbc, NULL, connect_string, SQL_NTS,
|
||||
NULL, 0, NULL, SQL_DRIVER_COMPLETE);
|
||||
}
|
||||
7
recipes/odbc/config.yml
Normal file
7
recipes/odbc/config.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
versions:
|
||||
"2.3.11":
|
||||
folder: all
|
||||
"2.3.9":
|
||||
folder: all
|
||||
"2.3.7":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user