summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorVladislav Vaintroub <vvaintroub@mysql.com>2009-06-10 10:59:49 +0200
committerVladislav Vaintroub <vvaintroub@mysql.com>2009-06-10 10:59:49 +0200
commit768bbae90eb116349940821a1fb48920291ddd97 (patch)
tree41fa2696a71a46f4885a21cf7c58dc438a600d7a /win
parentb6312995f1eb1478c8af30452c99e9b94b5f8185 (diff)
downloadmariadb-git-768bbae90eb116349940821a1fb48920291ddd97.tar.gz
Backport WL#3653 to 5.1 to enable bundled innodb plugin.
Remove custom DLL loader code from innodb plugin code, use symbols exported from mysqld. storage/innodb_plugin/handler/ha_innodb.cc: Remove a Win32 workaround for current_thd. The original problem that innodb plugin used value of TLS variable across DLL boundaries is solved in MySQL server (current_thd is a function not TLS variable now) storage/innodb_plugin/handler/handler0alter.cc: Remove custom delay loader storage/innodb_plugin/handler/handler0vars.h: Remove custom delay loader storage/innodb_plugin/handler/i_s.cc: Remove custom delay loader storage/innodb_plugin/handler/win_delay_loader.cc: Remove custom delay loader storage/innodb_plugin/plug.in: Remove commented out MYSQL_PLUGIN_STATIC, CMake would not parse that correctly
Diffstat (limited to 'win')
-rw-r--r--win/Makefile.am1
-rw-r--r--win/configure.js151
-rw-r--r--win/create_def_file.js220
3 files changed, 364 insertions, 8 deletions
diff --git a/win/Makefile.am b/win/Makefile.am
index 5dc637ae8a3..b7721264025 100644
--- a/win/Makefile.am
+++ b/win/Makefile.am
@@ -20,3 +20,4 @@ EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat build-vs9.bat \
# Don't update the files from bitkeeper
%::SCCS/s.%
+ mysql_manifest.cmake create_manifest.js create_def_file.js
diff --git a/win/configure.js b/win/configure.js
index ac51b15b9f0..fc5c548c983 100644
--- a/win/configure.js
+++ b/win/configure.js
@@ -39,17 +39,11 @@ try
var parts = args.Item(i).split('=');
switch (parts[0])
{
- case "WITH_ARCHIVE_STORAGE_ENGINE":
- case "WITH_BLACKHOLE_STORAGE_ENGINE":
- case "WITH_EXAMPLE_STORAGE_ENGINE":
- case "WITH_FEDERATED_STORAGE_ENGINE":
- case "WITH_INNOBASE_STORAGE_ENGINE":
- case "WITH_PARTITION_STORAGE_ENGINE":
- case "__NT__":
case "CYBOZU":
case "EMBED_MANIFESTS":
case "EXTRA_DEBUG":
case "WITH_EMBEDDED_SERVER":
+ case "WITHOUT_MARIA_TEMP_TABLES":
configfile.WriteLine("SET (" + args.Item(i) + " TRUE)");
break;
case "MYSQL_SERVER_SUFFIX":
@@ -65,6 +59,7 @@ try
break;
}
}
+
if (actual_port == 0)
{
// if we actually defaulted (as opposed to the pathological case of
@@ -114,7 +109,11 @@ try
GetBaseVersion(version) + "\")");
configfile.WriteLine("SET (MYSQL_VERSION_ID \"" +
GetVersionId(version) + "\")");
-
+ var engineOptions = ParsePlugins();
+ for (option in engineOptions)
+ {
+ configfile.WriteLine("SET(" + engineOptions[option] + " TRUE)");
+ }
configfile.Close();
fso = null;
@@ -184,3 +183,139 @@ function GetVersionId(version)
id += build;
return id;
}
+
+function PluginConfig(isGroup, include)
+{
+ this.isGroup = isGroup;
+ this.include = include;
+}
+
+
+// Parse command line arguments specific to plugins (aka storage engines).
+//
+// --with-plugin-PLUGIN, --with-plugins=group, --with-plugins=PLUGIN[,PLUGIN...]
+// --without-plugin-PLUGIN is supported.
+//
+// Legacy option WITH_<PLUGIN>_STORAGE_ENGINE is supported as well.
+// The function returns string array with elements like WITH_SOME_STORAGE_ENGINE
+// or WITHOUT_SOME_STORAGE_ENGINE.
+//
+// This function handles groups, for example effect of specifying --with-plugins=max
+// is the same as --with-plugins==archive,federated,falcon,innobase...
+
+function ParsePlugins()
+{
+
+ var config = new Array();
+
+ config["DEFAULT"] = new PluginConfig(true,true);
+
+ // Parse command line parameters
+ for (i=0; i< WScript.Arguments.length;i++)
+ {
+ var option = WScript.Arguments.Item(i);
+ var match = /WITH_(\w+)_STORAGE_ENGINE/.exec(option);
+ if (match == null)
+ match = /--with-plugin-(\w+)/.exec(option);
+ if (match != null)
+ {
+ config[match[1].toUpperCase()] = new PluginConfig(false,true);
+ continue;
+ }
+
+ match = /WITHOUT_(\w+)_STORAGE_ENGINE/.exec(option);
+ if (match == null)
+ match = /--without-plugin-(\w+)/.exec(option);
+
+ if (match != null)
+ {
+ config[match[1].toUpperCase()] =
+ new PluginConfig(false,false);
+ continue;
+ }
+
+ match = /--with-plugins=([\w,\-_]+)/.exec(option);
+ if(match != null)
+ {
+
+ var plugins = match[1].split(",");
+ for(var key in plugins)
+ {
+ config[plugins[key].toUpperCase()] =
+ new PluginConfig(null,true);
+ }
+ continue;
+ }
+ match = /--without-plugins=([\w,\-_]+)/.exec(option);
+ if(match != null)
+ {
+ var plugins = match[1].split(",");
+ for(var key in plugins)
+ config[plugins[key].toUpperCase()] =
+ new PluginConfig(null, false);
+ continue;
+ }
+ }
+
+ // Read plugin definitions, find out groups plugins belong to.
+ var fc = new Enumerator(fso.GetFolder("storage").SubFolders);
+ for (;!fc.atEnd(); fc.moveNext())
+ {
+ var subfolder = fc.item();
+ var name = subfolder.name.toUpperCase();
+
+ // Handle case where storage engine was already specified by name in
+ // --with-plugins or --without-plugins.
+ if (config[name] != undefined)
+ {
+ config[name].isGroup = false;
+ continue;
+ }
+ config[name] = new PluginConfig(false,null);
+
+ // Handle groups. For each plugin, find out which group it belongs to
+ // If this group was specified on command line for inclusion/exclusion,
+ // then include/exclude the plugin.
+ filename = subfolder +"\\plug.in";
+ if (fso.FileExists(filename))
+ {
+ var content = fso.OpenTextFile(filename, ForReading).ReadAll();
+ var match =
+ /MYSQL_STORAGE_ENGINE([ ]*)[\(]([^\)]+)[\)]/.exec(content);
+ if (match== null)
+ continue;
+ match = /\[[\w,\-_]+\][\s]?\)/.exec(match[0]);
+ if (match == null)
+ continue;
+ groups = match[0].split(/[\,\(\)\[\] ]/);
+ for (var key in groups)
+ {
+ var group = groups[key].toUpperCase();
+ if (config[group] != undefined)
+ {
+ config[group].isGroup = true;
+ if (config[group].include != null)
+ {
+ config[name].include = config[group].include;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ var arr = new Array();
+ for(key in config)
+ {
+ var eng = config[key];
+ if(eng.isGroup != undefined && !eng.isGroup && eng.include != undefined)
+ {
+ if (fso.FolderExists("storage\\"+key) || key=="PARTITION")
+ {
+ arr[arr.length] = eng.include?
+ "WITH_"+key+"_STORAGE_ENGINE":"WITHOUT_"+key+"_STORAGE_ENGINE";
+ }
+ }
+ }
+ return arr;
+}
diff --git a/win/create_def_file.js b/win/create_def_file.js
new file mode 100644
index 00000000000..aaaf4659736
--- /dev/null
+++ b/win/create_def_file.js
@@ -0,0 +1,220 @@
+// create_def_file.js
+//
+// Copyright (C) 2009 Sun Microsystems
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+/*
+ This script extracts names and types of globally defined symbols from
+ COFF object files, and writes this information to stdout using .DEF
+ file format (module definition file used by Microsoft linker)
+
+ In MySQL this script is used to export symbols from mysqld.exe for use by
+ storage engine DLLs.
+
+ Usage:
+ cscript create_def_file.js [x86|x64] [object|static_lib|directory ...]
+
+ If directory is passed as a parameter, script will process all object files
+ and static libraries in this directory and recursively in all subdrectories.
+
+ Note :The script does not work properly if /GL (global optimization)
+ compiler option was used to produce object files or libraries. This is a
+ limitation of the dumpbin tool that is used by the script.
+*/
+
+ForReading = 1;
+ForWriting = 2;
+ForAppending = 8;
+
+
+var args = WScript.Arguments;
+
+// check that we got proper arguments
+if (args.length < 2)
+{
+ echo("Usage: create_def_file <X86|X64> [static_library|objectfile|objectdirectory ...] ");
+ WScript.Quit(1);
+}
+
+
+var is64 = args.Item(0).toLowerCase() == "x64";
+var shell = new ActiveXObject("WScript.Shell");
+var fso = new ActiveXObject("Scripting.FileSystemObject");
+
+OutputSymbols(CollectSymbols());
+
+
+// takes the array that has been built up and writes out mysqld.def
+function OutputSymbols(symbols)
+{
+ var out = WScript.StdOut;
+ out.WriteLine("EXPORTS");
+ for (var sym in symbols)
+ out.WriteLine(sym);
+}
+
+function echo(message)
+{
+ WScript.StdErr.WriteLine(message);
+}
+
+// Extract global symbol names and type from objects
+function CollectSymbols()
+{
+ var uniqueSymbols = new Array();
+
+ try
+ {
+ /*
+ Compiler tools use VS_UNICODE_OUTPUT env. variable as indicator
+ that they run within IDE, so they can communicate with IDE via
+ pipes instead of usual stdout/stderr. Refer to
+ http://blogs.msdn.com/freik/archive/2006/04/05/569025.aspx
+ for more info.
+ Unset this environment variable.
+ */
+ shell.Environment("PROCESS").Remove("VS_UNICODE_OUTPUT");
+ }
+ catch(e){}
+
+ var rspfilename = "dumpsymbols.rsp";
+ CreateResponseFile(rspfilename);
+ var commandline="dumpbin @"+rspfilename;
+
+ echo("Executing "+commandline);
+ var oExec = shell.Exec(commandline);
+
+ while(!oExec.StdOut.AtEndOfStream)
+ {
+ var line = oExec.StdOut.ReadLine();
+ if (line.indexOf("External") == -1) continue;
+ var columns = line.split(" ");
+ var index = 0;
+ if (columns.length < 3)
+ continue;
+
+ /*
+ If the third column of dumpbin output contains SECTx,
+ the symbol is defined in that section of the object file.
+ If UNDEF appears, it is not defined in that object and must
+ be resolved elsewhere. BSS symbols (like uninitialized arrays)
+ appear to have non-zero second column.
+ */
+ if (columns[2].substring(0,4)!="SECT")
+ {
+ if (columns[2] == "UNDEF" && parseInt(columns[1])==0 )
+ continue;
+ }
+
+ /*
+ Extract undecorated symbol names
+ between "|" and next whitespace after it.
+ */
+ for (; index < columns.length; index++)
+ if (columns[index] == "|")
+ break;
+
+ var symbol = columns[index + 1];
+ var firstSpace = symbol.indexOf(" ");
+ if (firstSpace != -1)
+ symbol = symbol.substring(0, firstSpace-1);
+
+ // Don't export compiler defined stuff
+ if (IsCompilerDefinedSymbol(symbol))
+ continue;
+
+ // Correct symbol name for cdecl calling convention on x86
+ symbol = ScrubSymbol(symbol);
+
+ // Check if we have function or data
+ if (line.indexOf("notype () ") == -1)
+ symbol = symbol + " DATA";
+
+ uniqueSymbols[symbol] = 1;
+ }
+ fso.DeleteFile(rspfilename);
+ return uniqueSymbols;
+}
+
+// performs necessary cleanup on the symbol name
+function ScrubSymbol(symbol)
+{
+ if (is64) return symbol;
+ if (symbol.charAt(0) != "_")
+ return symbol;
+
+ var atSign = symbol.indexOf("@");
+ if (atSign != -1)
+ {
+ var paramSize = symbol.substring(atSign+1, symbol.Length);
+ if (paramSize.match("[0-9]+$")) return symbol;
+ }
+ return symbol.substring(1, symbol.length);
+}
+
+// returns true if the symbol is compiler defined
+function IsCompilerDefinedSymbol(symbol)
+{
+ return ((symbol.indexOf("__real@") != -1) ||
+ (symbol.indexOf("_RTC_") != -1) ||
+ (symbol.indexOf("??_C@_") != -1) ||
+ (symbol.indexOf("??_R") != -1) ||
+ (symbol.indexOf("??_7") != -1) ||
+ (symbol.indexOf("?_G") != -1) || // scalar deleting destructor
+ (symbol.indexOf("?_E") != -1)); // vector deleting destructor
+}
+
+// Creates response file for dumpbin
+function CreateResponseFile(filename)
+{
+ var responseFile = fso.CreateTextFile(filename,true);
+ responseFile.WriteLine("/SYMBOLS");
+
+ var index = 1;
+ for (; index < args.length; index++)
+ {
+ addToResponseFile(args.Item(index),responseFile);
+ }
+ responseFile.Close();
+}
+
+// Add object file/library to the dumpbin response file.
+// If filename parameter is directory, all objects and libs under
+// this directory or subdirectories are added.
+function addToResponseFile(filename, responseFile)
+{
+ if (fso.FolderExists(filename))
+ {
+ var folder = fso.getFolder(filename);
+ var enumerator = new Enumerator(folder.files);
+ for (; !enumerator.atEnd(); enumerator.moveNext())
+ {
+ addToResponseFile(enumerator.item().Path, responseFile);
+ }
+ enumerator = new Enumerator(folder.subFolders);
+ for (; !enumerator.atEnd(); enumerator.moveNext())
+ {
+ addToResponseFile(enumerator.item().Path, responseFile);
+ }
+ }
+ else if (fso.FileExists(filename))
+ {
+ var extension = filename.substr(filename.length -3).toLowerCase();
+ if(extension == "lib" || extension == "obj")
+ {
+ responseFile.WriteLine("\""+fso.GetFile(filename).Path+"\"");
+ }
+ }
+}