diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2022-09-30 15:43:36 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2022-10-05 01:24:36 +0200 |
commit | 21e26138b0ce179a5f8e87094ab5bc8e75fadcff (patch) | |
tree | 01ea6b9d42f26073a0605545ad15a33aed292655 | |
parent | 8759967d1c53603ee63b7e28bdf6c76b80635073 (diff) | |
download | mariadb-git-bb-10.11-wlad-MDEV-29251.tar.gz |
MDEV-29251 Set output directories during compilationbb-10.11-wlad-MDEV-29251
..to create s directory layout that closely resembles zip/tarball/MSI
install.
If we call ${CMAKE_BINARY_DIR} rsp CMAKE_BINARY_DIR/$<CONFIG>
$build_dir , then the compilation will place executables into
$build_dir/bin, and plugins into $build_dir/lib/plugins
Immediate benefits are
- searching, copying or symlinking of plugins in mtr is no more necessary
- searching for executables in mtr is simplified.
- Windows mariadbd.exe will to automatically set correct default
plugin directory (it had always been relative to location of the exe itself)
Other changes
"initial_database" target will create datadir $buildroot/data
directory, instead of $buildroot/sql/data, to still allow
server on Windows to start by just typing <path-to-mysqld> --console in
the shell.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | cmake/libutils.cmake | 30 | ||||
-rw-r--r-- | cmake/mariadb_connector_c.cmake | 19 | ||||
-rw-r--r-- | cmake/mysql_add_executable.cmake | 9 | ||||
-rw-r--r-- | cmake/plugin.cmake | 3 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess.pm | 20 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | mysql-test/mariadb-test-run.pl | 135 | ||||
-rw-r--r-- | sql/CMakeLists.txt | 4 | ||||
-rw-r--r-- | storage/connect/CMakeLists.txt | 2 |
10 files changed, 100 insertions, 127 deletions
diff --git a/.gitignore b/.gitignore index 93a132b3d83..ce19aad70cb 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ TAGS Testing/ tmp/ VERSION.dep +bin/ configure client/async_example client/mysql @@ -47,6 +48,7 @@ client/mysqlslap client/mysqltest client/mariadb-conv cmake_install.cmake +data/ dbug/*.r dbug/factorial dbug/tests @@ -79,6 +81,7 @@ include/probes_mysql_dtrace.h include/probes_mysql_nodtrace.h include/source_revision.h info_macros.cmake +lib/ libmysql*/libmysql*_exports_file.cc libmysql*/merge_archives_mysql*.cmake libmysql*/mysql*_depends.c diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 74853c36a74..69077fb4adc 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -381,3 +381,33 @@ FUNCTION (MAYBE_DISABLE_IPO target) INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL OFF) ENDIF() ENDFUNCTION() + +# The function is used to fix output directory during the build +# We try to use same relative location as installations do, i.e +# all executables in <build_dir>/bin, all plugins in +# <build_dir>/lib/plugin +FUNCTION (SET_TARGET_OUTPUT_DIRECTORY target) + GET_TARGET_PROPERTY(target_type ${target} TYPE) + IF(target MATCHES server) + SET(outdir_type RUNTIME_OUTPUT_DIRECTORY) + SET(outdir_location bin) + ELSEIF(target_type MATCHES EXECUTABLE) + SET(outdir_type RUNTIME_OUTPUT_DIRECTORY) + SET(outdir_location bin) + ELSEIF(target_type MATCHES MODULE_LIBRARY) + SET(outdir_type LIBRARY_OUTPUT_DIRECTORY) + SET(outdir_location lib/plugin) + ELSEIF(target_type MATCHES SHARED_LIBRARY) + SET(outdir_type LIBRARY_OUTPUT_DIRECTORY) + SET(outdir_location lib) + ENDIF() + IF(outdir_type) + FOREACH(c ${CMAKE_CONFIGURATION_TYPES}) + STRING(TOUPPER "${c}" c_upper) + SET_TARGET_PROPERTIES(${target} PROPERTIES ${outdir_type}_${c_upper} ${CMAKE_BINARY_DIR}/${c}/${outdir_location}) + ENDFOREACH() + IF(NOT "${CMAKE_CONFIGURATION_TYPES}") + SET_TARGET_PROPERTIES(${target} PROPERTIES ${outdir_type} ${CMAKE_BINARY_DIR}/${outdir_location}) + ENDIF() + ENDIF() +ENDFUNCTION() diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index a9b103345cd..4a54a80602c 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -38,8 +38,27 @@ SET(CLIENT_PLUGIN_PVIO_SHMEM STATIC) SET(CLIENT_PLUGIN_PVIO_SOCKET STATIC) MESSAGE("== Configuring MariaDB Connector/C") +# Fix output directory of the plugins to be the same as servers +FOREACH(c "" _DEBUG _RELEASE _RELWITHDEBINFO _MINSIZEREL) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY${c} ${CMAKE_BINARY_DIR}/lib/plugin) +ENDFOREACH() + +# Fix client's plugin output directory to be the same as server's +FOREACH(c ${CMAKE_CONFIGURATION_TYPES}) + STRING(TOUPPER "${c}" c_upper) + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${c_upper} ${CMAKE_BINARY_DIR}/${c}/lib/plugin) +ENDFOREACH() +IF(NOT "${CMAKE_CONFIGURATION_TYPES}") + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/plugin) +ENDIF() ADD_SUBDIRECTORY(libmariadb) +FOREACH(c "" ${CMAKE_CONFIGURATION_TYPES}) + STRING(TOUPPER "${c}" c_upper) + UNSET(CMAKE_LIBRARY_OUTPUT_DIRECTORY${c_upper}) +ENDFOREACH() +UNSET(CMAKE_LIBRARY_OUTPUT_DIRECTORY) + IF(UNIX) INSTALL(CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}) diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake index 06bdfce14de..8ab4a5de12f 100644 --- a/cmake/mysql_add_executable.cmake +++ b/cmake/mysql_add_executable.cmake @@ -64,7 +64,7 @@ FUNCTION (MYSQL_ADD_EXECUTABLE) ENDIF() ADD_EXECUTABLE(${target} ${WIN32} ${MACOSX_BUNDLE} ${EXCLUDE_FROM_ALL} ${sources}) - + SET_TARGET_OUTPUT_DIRECTORY(${target}) # tell CPack where to install IF(NOT ARG_EXCLUDE_FROM_ALL) IF(NOT ARG_DESTINATION) @@ -98,12 +98,11 @@ FUNCTION (MYSQL_ADD_EXECUTABLE) IF(link) IF(UNIX) ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink + COMMAND cmake -E chdir $<TARGET_FILE_DIR:${target}> ${CMAKE_COMMAND} -E create_symlink ${target} ${link} - COMMENT "Creating ${link} link" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) + COMMENT "Creating ${link} link") INSTALL(PROGRAMS - ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${link} + $<TARGET_FILE_DIR:${target}>/${link} DESTINATION ${ARG_DESTINATION} COMPONENT ${COMP}) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 813d8ef6e42..e1c2472a60c 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -203,7 +203,8 @@ MACRO(MYSQL_ADD_PLUGIN) AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS) ADD_VERSION_INFO(${target} MODULE SOURCES) - ADD_LIBRARY(${target} MODULE ${SOURCES}) + ADD_LIBRARY(${target} MODULE ${SOURCES}) + SET_TARGET_OUTPUT_DIRECTORY(${target}) DTRACE_INSTRUMENT(${target}) SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "") diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 69033649b46..2ce549a0f20 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -102,22 +102,14 @@ else # Find the safe process binary or script sub find_bin { - if (IS_WIN32PERL or IS_CYGWIN) + # Use my_safe_process + my $exe= my_find_bin($bindir, ["../$::multiconfig/bin", "lib/My/SafeProcess", "My/SafeProcess"], + "my_safe_process"); + push(@safe_process_cmd, $exe); + if (IS_WIN32PERL) { - # Use my_safe_process.exe - my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"], - "my_safe_process"); - push(@safe_process_cmd, $exe); - # Use my_safe_kill.exe - $safe_kill= my_find_bin($bindir, "lib/My/SafeProcess", "my_safe_kill"); - } - else - { - # Use my_safe_process - my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"], - "my_safe_process"); - push(@safe_process_cmd, $exe); + $safe_kill= my_find_bin($bindir, ["../$::multiconfig/bin", "lib/My/SafeProcess"], "my_safe_kill"); } } diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index 0004a44982d..9527cc07c08 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -21,6 +21,8 @@ IF (WIN32) ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc) TARGET_INCLUDE_DIRECTORIES(my_safe_kill PRIVATE ${CMAKE_SOURCE_DIR}/include) TARGET_LINK_LIBRARIES(my_safe_kill mysys psapi) + SET_TARGET_OUTPUT_DIRECTORY(my_safe_process) + SET_TARGET_OUTPUT_DIRECTORY(my_safe_kill) ELSE() ADD_EXECUTABLE(my_safe_process safe_process.cc) ENDIF() diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 16f4164061e..6c2dc8aa78b 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -1282,12 +1282,7 @@ sub command_line_setup { } else { - $path_client_bindir= mtr_path_exists("$bindir/client_release", - "$bindir/client_debug", - "$bindir/client/$multiconfig", - "$bindir/client$multiconfig", - "$bindir/client", - "$bindir/bin"); + $path_client_bindir= mtr_path_exists("$bindir/$multiconfig/bin"); } # Look for language files and charsetsdir, use same share @@ -1844,8 +1839,8 @@ sub find_mysqld { } return my_find_bin($bindir, - ["sql", "libexec", "sbin", "bin"], - [@mysqld_names]); + ["$multiconfig/bin", "libexec", "sbin", "bin"], + [@mysqld_names]); } @@ -1969,11 +1964,11 @@ sub mysql_client_test_arguments(){ # mysql_client_test executable may _not_ exist if ( $opt_embedded_server ) { $exe= mtr_exe_maybe_exists( - "$bindir/libmysqld/examples$multiconfig/mysql_client_test_embedded", - "$bindir/bin/mysql_client_test_embedded"); + "$bindir/bin/mysql_client_test_embedded", + "$bindir/$multiconfig/bin/mysql_client_test_embedded"); } else { - $exe= mtr_exe_maybe_exists("$bindir/tests$multiconfig/mysql_client_test", - "$bindir/bin/mysql_client_test"); + $exe= mtr_exe_maybe_exists("$bindir/$multiconfig/bin/mysql_client_test", + "$bindir/bin/mysql_client_test"); } my $args; @@ -1986,10 +1981,11 @@ sub mysql_client_test_arguments(){ return $ret; } + sub tool_arguments ($$) { my($sedir, $tool_name) = @_; my $exe= my_find_bin($bindir, - [$sedir, "bin"], + ["$multiconfig/bin",$sedir], $tool_name); my $args; @@ -2114,16 +2110,16 @@ sub environment_setup { else { $ENV{'SECURE_LOAD_PATH'}= $glob_mysql_test_dir."/std_data"; + # + # Some stupid^H^H^H^H^H^Hignorant network providers set up "wildcard DNS" + # servers that return some given web server address for any lookup of a + # non-existent host name. This confuses test cases that want to test the + # behaviour when connecting to a non-existing host, so we need to be able + # to disable those tests when DNS is broken. + $ENV{HAVE_BROKEN_DNS}= defined(gethostbyname('invalid_hostname')); } - # - # Some stupid^H^H^H^H^H^Hignorant network providers set up "wildcard DNS" - # servers that return some given web server address for any lookup of a - # non-existent host name. This confuses test cases that want to test the - # behaviour when connecting to a non-existing host, so we need to be able - # to disable those tests when DNS is broken. - # - $ENV{HAVE_BROKEN_DNS}= defined(gethostbyname('invalid_hostname')); + # ---------------------------------------------------- # mysql clients @@ -2146,14 +2142,13 @@ sub environment_setup { $ENV{'MARIADB_CONV'}= "$exe_mariadb_conv --character-sets-dir=$path_charsetsdir"; if(IS_WINDOWS) { - $ENV{'MYSQL_INSTALL_DB_EXE'}= mtr_exe_exists("$bindir/sql$multiconfig/mysql_install_db", - "$bindir/bin/mysql_install_db"); + $ENV{'MYSQL_INSTALL_DB_EXE'}= mtr_exe_exists("$bindir/$multiconfig/bin/mysql_install_db") } my $client_config_exe= mtr_exe_maybe_exists( "$bindir/libmariadb/mariadb_config$multiconfig/mariadb_config", - "$bindir/bin/mariadb_config"); + "$bindir/bin/$multiconfig/mariadb_config"); if ($client_config_exe) { my $tls_info= `$client_config_exe --tlsinfo`; @@ -2188,8 +2183,7 @@ sub environment_setup { # my_print_defaults # ---------------------------------------------------- my $exe_my_print_defaults= - mtr_exe_exists("$bindir/extra$multiconfig/my_print_defaults", - "$path_client_bindir/my_print_defaults"); + mtr_exe_exists("$path_client_bindir/my_print_defaults"); $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= native_path($exe_my_print_defaults); # ---------------------------------------------------- @@ -2223,47 +2217,36 @@ sub environment_setup { # ---------------------------------------------------- # perror # ---------------------------------------------------- - my $exe_perror= mtr_exe_exists("$bindir/extra$multiconfig/perror", - "$path_client_bindir/perror"); + my $exe_perror= mtr_exe_exists("$path_client_bindir/perror"); $ENV{'MY_PERROR'}= native_path($exe_perror); # ---------------------------------------------------- # mysql_tzinfo_to_sql # ---------------------------------------------------- - my $exe_mysql_tzinfo_to_sql= mtr_exe_exists("$basedir/sql$multiconfig/mysql_tzinfo_to_sql", - "$path_client_bindir/mysql_tzinfo_to_sql", - "$bindir/sql$multiconfig/mysql_tzinfo_to_sql"); + my $exe_mysql_tzinfo_to_sql= mtr_exe_exists("$path_client_bindir/mysql_tzinfo_to_sql"); $ENV{'MYSQL_TZINFO_TO_SQL'}= native_path($exe_mysql_tzinfo_to_sql); # ---------------------------------------------------- # replace # ---------------------------------------------------- - my $exe_replace= mtr_exe_exists(vs_config_dirs('extra', 'replace'), - "$basedir/extra/replace", - "$bindir/extra$multiconfig/replace", - "$path_client_bindir/replace"); + my $exe_replace= mtr_exe_exists("$path_client_bindir/replace"); $ENV{'REPLACE'}= native_path($exe_replace); # ---------------------------------------------------- # innochecksum # ---------------------------------------------------- my $exe_innochecksum= - mtr_exe_maybe_exists("$bindir/extra$multiconfig/innochecksum", - "$path_client_bindir/innochecksum"); + mtr_exe_maybe_exists("$path_client_bindir/innochecksum"); $ENV{'INNOCHECKSUM'}= native_path($exe_innochecksum) if $exe_innochecksum; # ---------------------------------------------------- # mariabackup # ---------------------------------------------------- - my $exe_mariabackup= mtr_exe_maybe_exists( - "$bindir/extra/mariabackup$multiconfig/mariabackup", - "$path_client_bindir/mariabackup"); + my $exe_mariabackup= mtr_exe_maybe_exists("$path_client_bindir/mariabackup"); $ENV{XTRABACKUP}= native_path($exe_mariabackup) if $exe_mariabackup; - my $exe_xbstream= mtr_exe_maybe_exists( - "$bindir/extra/mariabackup/$multiconfig/mbstream", - "$path_client_bindir/mbstream"); + my $exe_xbstream= mtr_exe_maybe_exists("$path_client_bindir/mbstream"); $ENV{XBSTREAM}= native_path($exe_xbstream) if $exe_xbstream; $ENV{INNOBACKUPEX}= "$exe_mariabackup --innobackupex"; @@ -2442,66 +2425,13 @@ sub setup_vardir() { unless($plugindir) { - # create a plugin dir and copy or symlink plugins into it - if ($source_dist) - { - $plugindir="$opt_vardir/plugins"; - # Source builds collect both client plugins and server plugins in the - # same directory. - $client_plugindir= $plugindir; - mkpath($plugindir); - if (IS_WINDOWS) - { - if (!$opt_embedded_server) - { - for (<$bindir/storage/*$multiconfig/*.dll>, - <$bindir/plugin/*$multiconfig/*.dll>, - <$bindir/libmariadb$multiconfig/*.dll>, - <$bindir/sql$multiconfig/*.dll>) - { - my $pname=basename($_); - copy rel2abs($_), "$plugindir/$pname"; - set_plugin_var($pname); - } - } - } - else - { - my $opt_use_copy= 1; - if (symlink "$opt_vardir/run", "$plugindir/symlink_test") - { - $opt_use_copy= 0; - unlink "$plugindir/symlink_test"; - } - - for (<$bindir/storage/*$multiconfig/*.so>, - <$bindir/plugin/*$multiconfig/*.so>, - <$bindir/libmariadb/plugins/*/*.so>, - <$bindir/libmariadb/$multiconfig/*.so>, - <$bindir/sql$multiconfig/*.so>) - { - my $pname=basename($_); - if ($opt_use_copy) - { - copy rel2abs($_), "$plugindir/$pname"; - } - else - { - symlink rel2abs($_), "$plugindir/$pname"; - } - set_plugin_var($pname); - } - } - } - else - { # hm, what paths work for debs and for rpms ? for (<$bindir/lib64/mysql/plugin/*.so>, <$bindir/lib/mysql/plugin/*.so>, <$bindir/lib64/mariadb/plugin/*.so>, <$bindir/lib/mariadb/plugin/*.so>, - <$bindir/lib/plugin/*.so>, # bintar - <$bindir/lib/plugin/*.dll>) + <$bindir/$multiconfig/lib/plugin/*.so>, # bintar + <$bindir/$multiconfig/lib/plugin/*.dll>) { my $pname= basename($_); set_plugin_var($pname); @@ -2515,7 +2445,6 @@ sub setup_vardir() { $client_plugindir= $_ if <$_/*.so>; } $client_plugindir= $plugindir unless $client_plugindir; - } } # Remove old log files @@ -2601,7 +2530,7 @@ sub check_debug_support { # Helper function to find the correct value for the multiconfig # if it was not set explicitly. # -# the configuration with the most recent build dir in sql/ is selected. +# the configuration with the most recent build dir is selected. # # note: looking for all BuildLog.htm files everywhere in the tree with the # help of File::Find would be possibly more precise, but it is also @@ -2615,13 +2544,13 @@ sub fix_vs_config_dir () { $multiconfig=""; - for (<$bindir/sql/*/mysqld.exe>, - <$bindir/sql/*/mysqld> + for (<$bindir/*/bin/mysqld.exe>, + <$bindir/*/bin/mysqld> ) { #/ if (-M $_ < $modified) { $modified = -M _; - $multiconfig = basename(dirname($_)); + $multiconfig = basename(dirname(dirname($_))); } } diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 4c52bc2858d..2f2a00c1bc5 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -277,6 +277,7 @@ IF(MSVC OR CMAKE_SYSTEM_NAME MATCHES AIX) ELSE() SET_TARGET_PROPERTIES(server PROPERTIES AIX_EXPORT_ALL_SYMBOLS TRUE) ENDIF() + SET_TARGET_OUTPUT_DIRECTORY(server) MYSQL_INSTALL_TARGETS(server DESTINATION ${INSTALL_BINDIR} COMPONENT Server) ENDIF() @@ -428,7 +429,6 @@ IF(TARGET mariadbd AND (NOT CMAKE_CROSSCOMPILING OR DEFINED CMAKE_CROSSCOMPILING IF(GENERATOR_IS_MULTI_CONFIG) SET (CONFIG_PARAM -DCONFIG=${CMAKE_CFG_INTDIR}) ENDIF() - MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) ADD_CUSTOM_COMMAND( OUTPUT initdb.dep COMMAND ${CMAKE_COMMAND} -E remove_directory data @@ -441,7 +441,7 @@ IF(TARGET mariadbd AND (NOT CMAKE_CROSSCOMPILING OR DEFINED CMAKE_CROSSCOMPILING -DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}" -P ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR} DEPENDS mariadbd ) IF(WIN32) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index bad7d916043..642da9b41bf 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -434,8 +434,6 @@ IF(MSVC) ENDIF() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") string(REPLACE "/permissive-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - INSTALL(FILES "$<TARGET_FILE_DIR:connect>/ha_connect.lib" - DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) ENDIF() |