summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-01-29 18:51:12 +0100
committerVladislav Vaintroub <wlad@montyprogram.com>2011-01-29 18:51:12 +0100
commitb19e99865ccf3e946ebe59bf09add8e0452904ac (patch)
tree23cb9e8176ef9d0e276b47d197e11d195b2ecafb /scripts
parent3edf4dcd5a36be8d5acc94e0c5e29e77e47cd15b (diff)
downloadmariadb-git-b19e99865ccf3e946ebe59bf09add8e0452904ac.tar.gz
MWL#55 : cherrypick MySQL 5.5 CMake/build improvements in order
to be able to build MSI based installer
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/CMakeLists.txt39
-rw-r--r--scripts/comp_sql.c111
-rw-r--r--scripts/mysql_install_db.pl.in6
3 files changed, 100 insertions, 56 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index eee70fdf776..a62569843db 100755
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -14,10 +14,12 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Build mysql_fix_privilege_tables.sql
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql
- COMMAND copy /b
- mysql_system_tables.sql + mysql_system_tables_fix.sql
- mysql_fix_privilege_tables.sql
+FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql
+ native_outfile )
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables.sql
+ COMMAND COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR}
+ cmd /c copy /b mysql_system_tables.sql + mysql_system_tables_fix.sql
+ ${native_outfile}
DEPENDS
${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables.sql
${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables_fix.sql)
@@ -29,24 +31,26 @@ TARGET_LINK_LIBRARIES(comp_sql debug dbug mysys strings)
# Use comp_sql to build mysql_fix_privilege_tables_sql.c
GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables_sql.c
COMMAND ${COMP_SQL_EXE}
mysql_fix_privilege_tables
- mysql_fix_privilege_tables.sql
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql
mysql_fix_privilege_tables_sql.c
- DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql)
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS comp_sql
+ ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables.sql)
# Add dummy target for the above to be built
ADD_CUSTOM_TARGET(GenFixPrivs
ALL
- DEPENDS ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c)
+ DEPENDS ${CMAKE_BINARY_DIR}/scripts/mysql_fix_privilege_tables_sql.c)
# ----------------------------------------------------------------------
# Replace some variables @foo@ in the .in/.sh file, and write the new script
# ----------------------------------------------------------------------
SET(CFLAGS "-D_WINDOWS ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
-SET(prefix "${CMAKE_INSTALL_PREFIX}/MySQL Server ${MYSQL_BASE_VERSION}")
+SET(prefix "${CMAKE_INSTALL_PREFIX}")
SET(sysconfdir ${prefix})
SET(bindir ${prefix}/bin)
SET(libexecdir ${prefix}/bin)
@@ -76,11 +80,14 @@ CONFIGURE_FILE(mysqldumpslow.sh
CONFIGURE_FILE(mysqlhotcopy.sh
${CMAKE_BINARY_DIR}/scripts/mysqlhotcopy.pl ESCAPE_QUOTES @ONLY)
-INSTALL(FILES mysqldumpslow.pl mysqlhotcopy.pl mysql_config.pl
+FOREACH(f mysqldumpslow.pl mysqlhotcopy.pl mysql_config.pl
mysql_convert_table_format.pl mysql_install_db.pl
- mysql_secure_installation.pl mysqld_multi.pl
- DESTINATION scripts COMPONENT scripts)
-
-INSTALL(FILES fill_help_tables.sql mysql_fix_privilege_tables.sql mysql_system_tables.sql
- mysql_system_tables_data.sql mysql_system_tables_fix.sql mysql_test_data_timezone.sql
- DESTINATION share COMPONENT scripts)
+ mysql_secure_installation.pl mysqld_multi.pl)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${f}
+ DESTINATION scripts COMPONENT Server_Scripts)
+ENDFOREACH()
+
+INSTALL(FILES fill_help_tables.sql mysql_system_tables.sql
+ mysql_system_tables_data.sql mysql_system_tables_fix.sql mysql_test_data_timezone.sql
+ DESTINATION share COMPONENT Server)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql DESTINATION share COMPONENT Server) \ No newline at end of file
diff --git a/scripts/comp_sql.c b/scripts/comp_sql.c
index 88e88e632b6..f65517ccf19 100644
--- a/scripts/comp_sql.c
+++ b/scripts/comp_sql.c
@@ -25,6 +25,10 @@
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
+#include <sys/stat.h>
+
+/* Compiler-dependent constant for maximum string constant */
+#define MAX_STRING_CONSTANT_LENGTH 65535
FILE *in, *out;
@@ -58,64 +62,99 @@ static void die(const char *fmt, ...)
int main(int argc, char *argv[])
{
char buff[512];
+ struct stat st;
char* struct_name= argv[1];
char* infile_name= argv[2];
char* outfile_name= argv[3];
+
if (argc != 4)
die("Usage: comp_sql <struct_name> <sql_filename> <c_filename>");
/* Open input and output file */
if (!(in= fopen(infile_name, "r")))
die("Failed to open SQL file '%s'", infile_name);
+
+
if (!(out= fopen(outfile_name, "w")))
die("Failed to open output file '%s'", outfile_name);
+ fprintf(out, "const char %s[]={\n",struct_name);
+
+ /*
+ Some compilers have limitations how long a string constant can be.
+ We'll output very long strings as hexadecimal arrays, and short ones
+ as strings (prettier)
+ */
+ stat(infile_name, &st);
+ if (st.st_size > MAX_STRING_CONSTANT_LENGTH)
+ {
+ int cnt=0;
+ int c;
+ int first_char= 1;
+ for(cnt=0;;cnt++)
+ {
+ c= fgetc(in);
+ if (c== -1)
+ break;
+
+ if(cnt != 0)
+ fputc(',', out);
- fprintf(out, "const char* %s={\n\"", struct_name);
+ /* Put line break after each 16 hex characters */
+ if(cnt && (cnt%16 == 0))
+ fputc('\n', out);
- while (fgets(buff, sizeof(buff), in))
+ fprintf(out,"0x%02x",c);
+ }
+ fprintf(out,",0x00",c);
+ }
+ else
{
- char *curr= buff;
- while (*curr)
+ fprintf(out,"\"");
+ while (fgets(buff, sizeof(buff), in))
{
- if (*curr == '\n')
- {
- /*
- Reached end of line, add escaped newline, escaped
- backslash and a newline to outfile
- */
- fprintf(out, "\\n \"\n\"");
- curr++;
- }
- else if (*curr == '\r')
- {
- curr++; /* Skip */
- }
- else
+ char *curr= buff;
+ while (*curr)
{
- if (*curr == '"')
+ if (*curr == '\n')
{
- /* Needs escape */
- fputc('\\', out);
+ /*
+ Reached end of line, add escaped newline, escaped
+ backslash and a newline to outfile
+ */
+ fprintf(out, "\\n \"\n\"");
+ curr++;
+ }
+ else if (*curr == '\r')
+ {
+ curr++; /* Skip */
+ }
+ else
+ {
+ if (*curr == '"')
+ {
+ /* Needs escape */
+ fputc('\\', out);
+ }
+
+ fputc(*curr, out);
+ curr++;
}
-
- fputc(*curr, out);
- curr++;
+ }
+ if (*(curr-1) != '\n')
+ {
+ /*
+ Some compilers have a max string length,
+ insert a newline at every 512th char in long
+ strings
+ */
+ fprintf(out, "\"\n\"");
}
}
- if (*(curr-1) != '\n')
- {
- /*
- Some compilers have a max string length,
- insert a newline at every 512th char in long
- strings
- */
- fprintf(out, "\"\n\"");
- }
+ fprintf(out, "\\\n\"");
}
-
- fprintf(out, "\\\n\"};\n");
-
+
+ fprintf(out, "};\n");
fclose(in);
fclose(out);
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
index 18bd713c041..0985c27f0ec 100644
--- a/scripts/mysql_install_db.pl.in
+++ b/scripts/mysql_install_db.pl.in
@@ -360,7 +360,7 @@ my $hostname = hostname();
my $resolved;
if ( !$opt->{'cross-bootstrap'} and !$opt->{rpm} and !$opt->{force} )
{
- my $resolveip;
+ my $resolveip = $bindir/resolveip;
$resolved = `$resolveip $hostname 2>&1`;
if ( $? != 0 )
@@ -418,9 +418,7 @@ my $mysqld_install_cmd_line = quote_options($mysqld_bootstrap,
"--bootstrap",
"--basedir=$opt->{basedir}",
"--datadir=$opt->{ldata}",
- "--skip-innodb",
- "--skip-bdb",
- "--skip-ndbcluster",
+ "--loose-skip-innodb",
"--max_allowed_packet=8M",
"--net_buffer_length=16K",
@args,