summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-02-14 20:42:55 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-02-14 20:42:55 (GMT)
commit856bf9a4e962ec118bcbfc5150825b256f2b8e2e (patch)
tree6ccc4386886b82a558e7ace3d47a9ab3ff4749e3 /Tools
parentcffcfed1263a255386c0da50709d6abc18accaab (diff)
downloadcpython-856bf9a4e962ec118bcbfc5150825b256f2b8e2e.zip
cpython-856bf9a4e962ec118bcbfc5150825b256f2b8e2e.tar.gz
cpython-856bf9a4e962ec118bcbfc5150825b256f2b8e2e.tar.bz2
Add build support for AMD64.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/msi/msi.py15
-rw-r--r--Tools/msi/msilib.py40
-rw-r--r--Tools/msi/msisupport.mak13
3 files changed, 53 insertions, 15 deletions
diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py
index 839eb9d..52dfa22 100644
--- a/Tools/msi/msi.py
+++ b/Tools/msi/msi.py
@@ -8,8 +8,6 @@ from win32com.client import constants
from distutils.spawn import find_executable
# Settings can be overridden in config.py below
-# 1 for Itanium build
-msilib.Win64 = 0
# 0 for official python.org releases
# 1 for intermediate releases by anybody, with
# a new product code for every package.
@@ -129,7 +127,6 @@ pythondll_uuid = {
"25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}"
} [major+minor]
-
# Build the mingw import library, libpythonXY.a
# This requires 'nm' and 'dlltool' executables on your PATH
def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
@@ -176,6 +173,12 @@ mingw_lib = os.path.join(srcdir, "PCBuild", "libpython%s%s.a" % (major, minor))
have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
+# Determine the target architechture
+dll_path = os.path.join(srcdir, "PCBuild", dll_file)
+msilib.set_arch_from_file(dll_path)
+if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
+ raise SystemError, "msisupport.dll for incorrect architecture"
+
if testpackage:
ext = 'px'
testprefix = 'x'
@@ -205,11 +208,7 @@ def build_database():
# schema represents the installer 2.0 database schema.
# sequence is the set of standard sequences
# (ui/execute, admin/advt/install)
- if msilib.Win64:
- w64 = ".ia64"
- else:
- w64 = ""
- db = msilib.init_database("python-%s%s.msi" % (full_current_version, w64),
+ db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
schema, ProductName="Python "+full_current_version,
ProductCode=product_code,
ProductVersion=current_version,
diff --git a/Tools/msi/msilib.py b/Tools/msi/msilib.py
index 948099d..9011b0a 100644
--- a/Tools/msi/msilib.py
+++ b/Tools/msi/msilib.py
@@ -5,15 +5,13 @@ import win32com.client.gencache
import win32com.client
import pythoncom, pywintypes
from win32com.client import constants
-import re, string, os, sets, glob, popen2, sys, _winreg
+import re, string, os, sets, glob, popen2, sys, _winreg, struct
try:
basestring
except NameError:
basestring = (str, unicode)
-Win64 = 0
-
# Partially taken from Wine
datasizemask= 0x00ff
type_valid= 0x0100
@@ -311,10 +309,7 @@ def init_database(name, schema,
si.SetProperty(PID_TITLE, "Installation Database")
si.SetProperty(PID_SUBJECT, ProductName)
si.SetProperty(PID_AUTHOR, Manufacturer)
- if Win64:
- si.SetProperty(PID_TEMPLATE, "Intel64;1033")
- else:
- si.SetProperty(PID_TEMPLATE, "Intel;1033")
+ si.SetProperty(PID_TEMPLATE, msi_type)
si.SetProperty(PID_REVNUMBER, gen_uuid())
si.SetProperty(PID_WORDCOUNT, 2) # long file names, compressed, original media
si.SetProperty(PID_PAGECOUNT, 200)
@@ -647,3 +642,34 @@ class Dialog:
def checkbox(self, name, x, y, w, h, attr, prop, text, next):
return self.control(name, "CheckBox", x, y, w, h, attr, prop, text, next, None)
+
+def pe_type(path):
+ header = open(path).read(1000)
+ # offset of PE header is at offset 0x3c; 1-based
+ pe_offset = struct.unpack("<i", header[0x3c:0x40])[0]-1
+ assert header[pe_offset:pe_offset+4] == "PE\0\0"
+ machine = struct.unpack("<H", header[pe_offset+4:pe_offset+6])[0]
+ return machine
+
+def set_arch_from_file(path):
+ global msi_type, Win64, arch_ext
+ machine = pe_type(path)
+ if machine == 0x14c:
+ # i386
+ msi_type = "Intel"
+ Win64 = 0
+ arch_ext = ''
+ elif machine == 0x200:
+ # Itanium
+ msi_type = "Intel64"
+ Win64 = 1
+ arch_ext = '.ia64'
+ elif machine == 0x8664:
+ # AMD64
+ msi_type = "x64"
+ Win64 = 1
+ arch_ext = '.amd64'
+ else:
+ raise ValueError, "Unsupported architecture"
+ msi_type += ";1033"
+
diff --git a/Tools/msi/msisupport.mak b/Tools/msi/msisupport.mak
index 1047510..fb960c2 100644
--- a/Tools/msi/msisupport.mak
+++ b/Tools/msi/msisupport.mak
@@ -1,3 +1,6 @@
+!IF "$(CPU)" == ""
+# VS environment
+
# /OPT: REF and ICF are added by VS.NET by default
# NOWIN98 saves 7k of executable size, at the expense of some
# slowdown on Win98
@@ -10,3 +13,13 @@ msisupport.dll: msisupport.obj
msisupport.obj: msisupport.c
cl /O2 /D WIN32 /D NDEBUG /D _WINDOWS /MT /W3 /c msisupport.c
+!ELSE
+# SDK environment: assume all options are already correct
+
+msisupport.dll: msisupport.obj
+ link.exe /OUT:msisupport.dll /INCREMENTAL:NO /NOLOGO /DLL msisupport.obj msi.lib kernel32.lib
+
+msisupport.obj: msisupport.c
+ cl /O2 /D WIN32 /D NDEBUG /D _WINDOWS /MD /W3 /GS- /c msisupport.c
+!ENDIF
+