From 1ce0d7c63b33bd7970b6ab53884e726858cee92d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Apr 2007 15:41:24 -0400 Subject: [PATCH] Bug#24732 Executables do not include Vista manifests - Added script to generate application specific manifest. - Added new CMake MACRO to add customer build events which will first generate a manifest and then embeds that manifest into an executable. BitKeeper/etc/ignore: Bug#24732 Executables do not include Vista manifests - Revise ignore rules to disallow auto-generated cmake files but to allow custom macros defined in a .cmake file. CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Added logic for EMBED_MANIFESTS configuration option. client/CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Embed manifest with custom CMake MACRO for client executables. extra/CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Embed manifest with custom CMake MACRO for my_print_default executable. libmysql/CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Embed manifest with custom CMake MACRO for myTest executable. myisam/CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Embed manifest with custom CMake MACRO for myisam executables. server-tools/instance-manager/CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Embed manifest with custom CMake MACRO for mysqlmanager executable. sql/CMakeLists.txt: Bug#24732 Executables do not include Vista manifests - Embed manifest with custom CMake MACRO for mysqld executable. win/README: Bug#24732 Executables do not include Vista manifests - Added new configuration option documentation. win/configure.js: Bug#24732 Executables do not include Vista manifests - Added new EMBED_MANIFESTS configuration option. win/create_manifest.js: Bug#24732 Executables do not include Vista manifests - Manifest generator. This script generates a basic manifest. win/mysql_manifest.cmake: Bug#24732 Executables do not include Vista manifests - Define new CMake MACRO for adding Windows manifests to executables. --- .bzrignore | 3 +- CMakeLists.txt | 27 +++++++ client/CMakeLists.txt | 14 ++++ extra/CMakeLists.txt | 7 ++ libmysql/CMakeLists.txt | 5 ++ myisam/CMakeLists.txt | 8 ++ server-tools/instance-manager/CMakeLists.txt | 5 ++ sql/CMakeLists.txt | 5 ++ win/README | 2 + win/configure.js | 1 + win/create_manifest.js | 85 ++++++++++++++++++++ win/mysql_manifest.cmake | 20 +++++ 12 files changed, 181 insertions(+), 1 deletion(-) create mode 100755 win/create_manifest.js create mode 100755 win/mysql_manifest.cmake diff --git a/.bzrignore b/.bzrignore index 33552f5035c..d1de21857db 100644 --- a/.bzrignore +++ b/.bzrignore @@ -4,7 +4,8 @@ *.bb *.bbg *.bin -*.cmake +*.vcproj.cmake +cmake_install.cmake *.core *.d *.da diff --git a/CMakeLists.txt b/CMakeLists.txt index b7f7a7228bc..fcbd3f4e4bd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,33 @@ ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D _CRT_SECURE_NO_DEPRECATE") +IF(EMBED_MANIFESTS) + # Search for the Manifest tool. CMake will first search it's defaults + # (CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH, CMAKE_PROGRAM_PATH and + # the system PATH) followed by the listed paths which are the current + # possible defaults and should be updated when necessary. The custom + # manifests are designed to be compatible with all mt versions. + FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt + PATHS + "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin" + "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin" + "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin") + IF(HAVE_MANIFEST_TOOL) + MESSAGE(STATUS "Found Mainfest Tool. Embedding custom manifests.") + ELSE(HAVE_MANIFEST_TOOL) + MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.") + ENDIF(HAVE_MANIFEST_TOOL) + # Disable automatic manifest generation. + STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS + ${CMAKE_EXE_LINKER_FLAGS}) + # Set the processor architecture. + IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") + SET(PROCESSOR_ARCH "X64") + ELSE(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") + SET(PROCESSOR_ARCH "X86") + ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") +ENDIF(EMBED_MANIFESTS) + ADD_SUBDIRECTORY(vio) ADD_SUBDIRECTORY(dbug) ADD_SUBDIRECTORY(strings) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b598c77ddfc..6e37d02ecd8 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -12,6 +12,7 @@ # 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 +INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") @@ -98,3 +99,16 @@ TARGET_LINK_LIBRARIES(mysqladmin mysqlclient mysys dbug yassl taocrypt zlib wsoc ADD_EXECUTABLE(echo echo.c) +IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("mysql" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqltest" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqlcheck" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqldump" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqlimport" "asInvoker") + MYSQL_EMBED_MANIFEST("mysql_upgrade" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqlshow" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqlbinlog" "asInvoker") + MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker") + MYSQL_EMBED_MANIFEST("echo" "asInvoker") +ENDIF(EMBED_MANIFESTS) + diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index a7a5e3e7b66..8608e72127b 100755 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -12,6 +12,7 @@ # 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 +INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") @@ -45,3 +46,9 @@ TARGET_LINK_LIBRARIES(perror strings mysys dbug wsock32) ADD_EXECUTABLE(replace replace.c) TARGET_LINK_LIBRARIES(replace strings mysys dbug wsock32) + +IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("my_print_defaults" "asInvoker") + MYSQL_EMBED_MANIFEST("perror" "asInvoker") + MYSQL_EMBED_MANIFEST("replace" "asInvoker") +ENDIF(EMBED_MANIFESTS) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index db4368a3534..647f6bd5e33 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -12,6 +12,7 @@ # 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 +INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") # Need to set USE_TLS, since __declspec(thread) approach to thread local # storage does not work properly in DLLs. @@ -67,3 +68,7 @@ TARGET_LINK_LIBRARIES(libmysql mysys strings wsock32) ADD_EXECUTABLE(myTest mytest.c) TARGET_LINK_LIBRARIES(myTest libmysql) + +IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("myTest" "asInvoker") +ENDIF(EMBED_MANIFESTS) diff --git a/myisam/CMakeLists.txt b/myisam/CMakeLists.txt index 28d06254e8a..94a7ffc9952 100755 --- a/myisam/CMakeLists.txt +++ b/myisam/CMakeLists.txt @@ -12,6 +12,7 @@ # 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 +INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") @@ -39,3 +40,10 @@ TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib wsock32) ADD_EXECUTABLE(myisampack myisampack.c) TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib wsock32) + +IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker") + MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker") + MYSQL_EMBED_MANIFEST("myisamlog" "asInvoker") + MYSQL_EMBED_MANIFEST("myisampack" "asInvoker") +ENDIF(EMBED_MANIFESTS) diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt index 861c44e9f71..b7e2f08ff6e 100755 --- a/server-tools/instance-manager/CMakeLists.txt +++ b/server-tools/instance-manager/CMakeLists.txt @@ -12,6 +12,7 @@ # 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 +INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") @@ -30,3 +31,7 @@ ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instanc ADD_DEPENDENCIES(mysqlmanager GenError) TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32) + +IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("mysqlmanager" "asInvoker") +ENDIF(EMBED_MANIFESTS) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 7e26f62b5f7..e77b4c5765e 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -12,6 +12,7 @@ # 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 +INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX -DUSE_SYMDIR /Zi") @@ -84,6 +85,10 @@ ADD_EXECUTABLE(mysqld ../sql-common/client.c derror.cc des_key_file.cc TARGET_LINK_LIBRARIES(mysqld heap myisam myisammrg mysys yassl zlib dbug yassl taocrypt strings vio regex wsock32) +IF(EMBED_MANIFESTS) + MYSQL_EMBED_MANIFEST("mysqld" "requireAdministrator") +ENDIF(EMBED_MANIFESTS) + IF(WITH_EXAMPLE_STORAGE_ENGINE) TARGET_LINK_LIBRARIES(mysqld example) ENDIF(WITH_EXAMPLE_STORAGE_ENGINE) diff --git a/win/README b/win/README index 871ae4efee7..118d619226a 100644 --- a/win/README +++ b/win/README @@ -50,6 +50,8 @@ The options right now are MYSQL_TCP_PORT= Server port, default 3306 DISABLE_GRANT_OPTIONS Disables the use of --init-file and --skip-grant-tables options of mysqld.exe + EMBED_MANIFESTS Embed custom manifests into final exes, otherwise VS + default will be used. So the command line could look like: diff --git a/win/configure.js b/win/configure.js index 3488efacba3..a2502d96b80 100755 --- a/win/configure.js +++ b/win/configure.js @@ -47,6 +47,7 @@ try case "WITH_PARTITION_STORAGE_ENGINE": case "__NT__": case "DISABLE_GRANT_OPTIONS": + case "EMBED_MANIFESTS": configfile.WriteLine("SET (" + args.Item(i) + " TRUE)"); break; case "MYSQL_SERVER_SUFFIX": diff --git a/win/create_manifest.js b/win/create_manifest.js new file mode 100755 index 00000000000..5605f57ef74 --- /dev/null +++ b/win/create_manifest.js @@ -0,0 +1,85 @@ +/* + manifest.js - Writes a custom XML manifest for each executable/library + 6 command line options must be supplied: + name - Name of the executable/library into which the mainfest will be + embedded. + version - Version of the executable + arch - Architecture intended. + type - Application type. + exe_level - Application execution level. + [asInvoker|highestAvailable|requireAdministrator] + outfile - Final destination where mainfest will be written. + + Example: + cscript manifest.js name=mysql version=5.0.32 arch=X86 type=win32 + exe_level=asInvoker outfile=out.xml +*/ + +try +{ + var args = WScript.Arguments + for (i=0; i < args.Count(); i++) + { + var parts = args.Item(i).split('='); + switch (parts[0]) + { + case "name": + var app_name= parts[1]; + break; + case "version": + var app_version= parts[1]; + break; + case "arch": + var app_arch= parts[1]; + break; + case "type": + var app_type= parts[1]; + break; + case "exe_level": + var app_exe_level= parts[1]; + break; + case "outfile": + var manifest_file= parts[1]; + break; + default: + WScript.echo("Invalid argument supplied."); + } + } + if (i != 6) + throw new Error(1, "Incorrect number of arguments."); + + var manifest_xml= "\r\n"; + manifest_xml+= "\r\n"; + // Identify the application security requirements. + manifest_xml+= "\t\r\n"; + manifest_xml+= "\t\t\r\n\t\t\t\r\n\t\t\t\t"; + manifest_xml+= "