This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v4] Added file properties to windows gdb executable for all mingw32 builds.


On Windows OS it is custom that executables and DLL's show file properties.
These contain product name/version, file name/version, company/copyright info.
File properties are visible by right-click on the file, selecting properties \ details.
This patch adds file properties to the gdb executable for all mingw builds.

2013-08-14  Bernd Bunk  <bernd.bunk@intel.com>

	* Makefile.in (windows_exe_properties.h): Add rule to create
	windows_exe_properties.h header file with file property information.
	(windows_exe_properties.o): Added rule to build the resource file.
	* configure: Add windows_exe_properties.o to mingw32 specific
	objects.
	* configure: Rebuild.
	* common/create-windows_exe_properties.sh: New file.
	* windows_exe_properties.rc: New file.

Signed-off-by: Bernd Bunk <bernd.bunk@intel.com>
---
 gdb/Makefile.in                             |    7 ++
 gdb/common/create-windows_exe_properties.sh |  114 +++++++++++++++++++++++++++
 gdb/configure                               |    8 ++
 gdb/configure.ac                            |    8 ++
 gdb/windows_exe_properties.rc               |   61 ++++++++++++++
 5 files changed, 198 insertions(+), 0 deletions(-)
 create mode 100644 gdb/common/create-windows_exe_properties.sh
 create mode 100644 gdb/windows_exe_properties.rc

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 45cddaf..0a9dbd2 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1426,6 +1426,13 @@ $(srcdir)/copying.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/../COPYING3 $(srcdir)/copy
 		< $(srcdir)/../COPYING3 > $(srcdir)/copying.tmp
 	mv $(srcdir)/copying.tmp $(srcdir)/copying.c
 
+windows_exe_properties.h: Makefile version.in common/create-windows_exe_properties.sh
+	$(SHELL) $(srcdir)/common/create-windows_exe_properties.sh $(srcdir) \
+		"$(host_alias)" "$(target_alias)" windows_exe_properties.h
+
+windows_exe_properties.o: windows_exe_properties.h windows_exe_properties.rc
+	$(WINDRES) $(srcdir)/windows_exe_properties.rc -I. windows_exe_properties.o
+
 version.c: Makefile version.in $(srcdir)/../bfd/version.h $(srcdir)/common/create-version.sh
 	$(SHELL) $(srcdir)/common/create-version.sh $(srcdir) \
 	    $(host_alias) $(target_alias) version.c
diff --git a/gdb/common/create-windows_exe_properties.sh b/gdb/common/create-windows_exe_properties.sh
new file mode 100644
index 0000000..cf15965
--- /dev/null
+++ b/gdb/common/create-windows_exe_properties.sh
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+# Create windows executable file properties for GDB on Windows.
+# These are visible in context menu Properties / Details on the GDB
+# executable on Windows.
+#
+# Copyright (C) 2013 Free Software Foundation, Inc.
+#
+# Contributed by Intel Corporation
+#
+# This file is part of GDB.
+#
+# 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; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
+# Create windows_exe_properties.h from given parameters
+# Usage:
+#    create-windows_exe_properties.sh PATH-TO-GDB-SRCDIR HOST_ALIAS \
+#        TARGET_ALIAS OUTPUT-FILE-NAME OPTIONS
+#
+#    See also environment variables below to customize some of the
+#    description fields.
+#
+
+# Shell parameters.
+srcdir="$1"
+host_alias="$2"
+target_alias="$3"
+output="$4"
+
+if [ $# -ne 4 ] ; then
+  echo "usage: $0 PATH-TO-GDB-SRCDIR HOST_ALIAS TARGET_ALIAS OUTPUT-FILE-NAME" >&2
+  exit 1
+fi
+
+# Default option values for the file property text fields.
+version=`cat $srcdir/version.in`
+company_name="Free Software Foundation, Inc."
+file_description="gdb"
+product_name="gdb"
+configured=""
+if [ -n "$host_alias" ] ; then
+  file_description="gdb for $host_alias"
+  product_name="gdb for $host_alias"
+  configured="This GDB was configured as \"\"$host_alias\"\"."
+fi
+internal_name="gdb.exe"
+original_filename="gdb.exe"
+copyright="Copyright (C) 2013 Free Software Foundation, Inc."
+  license=\
+"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+Type \"\"show copying\"\" and \"\"show warranty\"\" for details."
+support="For bug reporting instructions, please see:
+<http://www.gnu.org/software/gdb/bugs/>."
+
+# Check for environment variables to replace certain file properties.
+[ -n "$WINDOWS_EXE_VERSION" ] && version=$WINDOWS_EXE_VERSION
+[ -n "$WINDOWS_EXE_COMPANY_NAME" ] && company_name=$WINDOWS_EXE_COMPANY_NAME
+[ -n "$WINDOWS_EXE_FILE_DESCRIPTION" ] && file_description=$WINDOWS_EXE_FILE_DESCRIPTION
+[ -n "$WINDOWS_EXE_PRODUCT_NAME" ] && product_name=$WINDOWS_EXE_PRODUCT_NAME
+[ -n "$WINDOWS_EXE_INTERNAL_NAME" ] && internal_name=$WINDOWS_EXE_INTERNAL_NAME
+[ -n "$WINDOWS_EXE_ORIGINAL_FILENAME" ] && original_filename=$WINDOWS_EXE_ORIGINAL_FILENAME
+[ -n "$WINDOWS_EXE_COPYRIGHT" ] && copyright=$WINDOWS_EXE_COPYRIGHT
+[ -n "$WINDOWS_EXE_LICENSE" ] && license=$WINDOWS_EXE_LICENSE
+[ -n "$WINDOWS_EXE_CONFIGURED" ] && configured=$WINDOWS_EXE_CONFIGURED
+[ -n "$WINDOWS_EXE_SUPPORT" ] && support=$WINDOWS_EXE_SUPPORT
+
+# Combine complete copyright message.  Windows file property dialog only
+# shows ONE line (with scrollbar).  So do not separate with newlines but
+# use spaces instead.
+copyright_all=`echo $copyright $license $configured $support`
+
+# Remove "#" at the beginning and internal version at the end.
+version=`echo ${version%-*} | sed -e "s/#//"`
+
+# Split version.
+IFS_BAK="$IFS"
+IFS='.'
+array=($version)
+version_major=${array[0]}
+version_minor=${array[1]}
+version_build=${array[2]}
+IFS="$IFS_BAK"
+[ -z "$version_major" ] && version_major=0
+[ -z "$version_minor" ] && version_minor=0
+[ -z "$version_build" ] && version_build=0
+
+# Write version into output file.
+echo "#define FP_VERSION_MAJOR $version_major"  > $output
+echo "#define FP_VERSION_MINOR $version_minor" >> $output
+echo "#define FP_VERSION_BUILD $version_build" >> $output
+echo "#define FP_VERSION_ALL   \"$version_major.$version_minor.$version_build\"" >> $output
+
+echo "" >> $output
+
+# Write other file properties into output file.
+echo "#define FP_COMPANY_NAME      \"$company_name\""      >> $output
+echo "#define FP_FILE_DESCRIPTION  \"$file_description\""  >> $output
+echo "#define FP_INTERNAL_NAME     \"$internal_name\""     >> $output
+echo "#define FP_COPYRIGHT         \"$copyright_all\""     >> $output
+echo "#define FP_ORIGINAL_FILENAME \"$original_filename\"" >> $output
+echo "#define FP_PRODUCT_NAME      \"$product_name\""      >> $output
diff --git a/gdb/configure b/gdb/configure
index 8067825..5a90025 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -7073,6 +7073,14 @@ fi
 
 
 
+# If we build for mingw32/Windows, then also build file properties
+# for GDB executable.
+case $host_os in
+  *mingw32*)
+    CONFIG_OBS="$CONFIG_OBS windows_exe_properties.o"
+    ;;
+esac
+
 # Generate jit-reader.h
 
 # This is typedeffed to GDB_CORE_ADDR in jit-reader.h
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 667821f..70d0272 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -658,6 +658,14 @@ AC_SUBST(READLINE_DEPS)
 AC_SUBST(READLINE_CFLAGS)
 AC_SUBST(READLINE_TEXI_INCFLAG)
 
+# If we build for mingw32/Windows, then also build file properties
+# for GDB executable.
+case $host_os in
+  *mingw32*)
+    CONFIG_OBS="$CONFIG_OBS windows_exe_properties.o"
+    ;;
+esac
+
 # Generate jit-reader.h
 
 # This is typedeffed to GDB_CORE_ADDR in jit-reader.h
diff --git a/gdb/windows_exe_properties.rc b/gdb/windows_exe_properties.rc
new file mode 100644
index 0000000..2fc1342
--- /dev/null
+++ b/gdb/windows_exe_properties.rc
@@ -0,0 +1,61 @@
+/* Windows executable properties for GDB on Windows.
+   These are visible in context menu Properties / Details on the GDB
+   executable on Windows.
+
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+   Contributed by Intel Corporation.
+
+   This file is part of GDB.
+
+   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; either version 3 of the License, or
+   (at your option) any later version.
+
+   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, see <http://www.gnu.org/licenses/>.  */
+
+/* Value defines for windows executable file properties of GDB on Windows.
+   Patch this header file using create-windows_exe_properties.sh during gdb
+   build to customize the file properties. */
+#include "windows_exe_properties.h"
+
+#include "windows.h"
+VS_VERSION_INFO VERSIONINFO
+  FILEVERSION FP_VERSION_MAJOR,FP_VERSION_MINOR,FP_VERSION_BUILD,0
+  PRODUCTVERSION FP_VERSION_MAJOR,FP_VERSION_MINOR,FP_VERSION_BUILD,0
+  FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+  FILEFLAGS 0x1L
+#else
+  FILEFLAGS 0x0L
+#endif
+  FILEOS 0x40004L
+  FILETYPE 0x1L
+  FILESUBTYPE 0x0L
+BEGIN
+  BLOCK "StringFileInfo"
+  BEGIN
+    BLOCK "040904b0"
+    BEGIN
+      VALUE "CompanyName", FP_COMPANY_NAME
+      VALUE "FileDescription", FP_FILE_DESCRIPTION
+      VALUE "FileVersion", FP_VERSION_ALL
+      VALUE "InternalName", FP_INTERNAL_NAME
+      VALUE "LegalCopyright", FP_COPYRIGHT
+      VALUE "OriginalFilename", FP_ORIGINAL_FILENAME
+      VALUE "ProductName", FP_PRODUCT_NAME
+      VALUE "ProductVersion", FP_VERSION_ALL
+    END
+  END
+  BLOCK "VarFileInfo"
+  BEGIN
+    VALUE "Translation", 0x409, 1200
+  END
+END
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]