]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Parameterize vendor prefix and PCI device id
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 8 Sep 2015 15:21:25 +0000 (16:21 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 9 Sep 2015 15:47:32 +0000 (16:47 +0100)
The XenServer PV vendor prefix ('XS') and PCI device (C000) are still
hard-coded into the XENBUS package. These need to be stripped out and
replaced by values that can be customized at build time. This patch does
that.

The patch also reverts to building version.h and customizing xenbus.inf
directly in build.py.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
12 files changed:
build.py
include/version.hx [deleted file]
src/coinst/coinst.c
src/xen/xen.rc
src/xenbus.inf
src/xenbus/fdo.c
src/xenbus/xenbus.rc
src/xenfilt/xenfilt.rc
vs2012/xen/xen.vcxproj
vs2012/xenbus/xenbus.vcxproj
vs2013/xen/xen.vcxproj
vs2013/xenbus/xenbus.vcxproj

index b4768fef820fe9d597d9e184b17aeb4ba4c95e7e..b7e35bf384e559be825cd77555bed12a8bf9eaa3 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -24,6 +24,74 @@ def next_build_number():
     return build_number
 
 
+def make_header():
+    now = datetime.datetime.now()
+
+    file = open('include\\version.h', 'w')
+
+    file.write('#define VENDOR_NAME_STR\t\t"' + os.environ['VENDOR_NAME'] + '"\n')
+    file.write('#define VENDOR_PREFIX_STR\t"' + os.environ['VENDOR_PREFIX'] + '"\n')
+
+    if 'VENDOR_DEVICE_ID' in os.environ.keys():
+        file.write('#define VENDOR_DEVICE_ID_STR\t"' + os.environ['VENDOR_DEVICE_ID'] + '"\n')
+
+    file.write('#define PRODUCT_NAME_STR\t"' + os.environ['PRODUCT_NAME'] + '"\n')
+    file.write('\n')
+
+    file.write('#define MAJOR_VERSION\t\t' + os.environ['MAJOR_VERSION'] + '\n')
+    file.write('#define MAJOR_VERSION_STR\t"' + os.environ['MAJOR_VERSION'] + '"\n')
+    file.write('\n')
+
+    file.write('#define MINOR_VERSION\t\t' + os.environ['MINOR_VERSION'] + '\n')
+    file.write('#define MINOR_VERSION_STR\t"' + os.environ['MINOR_VERSION'] + '"\n')
+    file.write('\n')
+
+    file.write('#define MICRO_VERSION\t\t' + os.environ['MICRO_VERSION'] + '\n')
+    file.write('#define MICRO_VERSION_STR\t"' + os.environ['MICRO_VERSION'] + '"\n')
+    file.write('\n')
+
+    file.write('#define BUILD_NUMBER\t\t' + os.environ['BUILD_NUMBER'] + '\n')
+    file.write('#define BUILD_NUMBER_STR\t"' + os.environ['BUILD_NUMBER'] + '"\n')
+    file.write('\n')
+
+    file.write('#define YEAR\t\t\t' + str(now.year) + '\n')
+    file.write('#define YEAR_STR\t\t"' + str(now.year) + '"\n')
+    file.write('\n')
+
+    file.write('#define MONTH\t\t\t' + str(now.month) + '\n')
+    file.write('#define MONTH_STR\t\t"' + str(now.month) + '"\n')
+    file.write('\n')
+
+    file.write('#define DAY\t\t\t' + str(now.day) + '\n')
+    file.write('#define DAY_STR\t\t\t"' + str(now.day) + '"\n')
+    file.write('\n')
+
+    file.close()
+
+
+def copy_inf(vs, name):
+    src = open('src\\%s.inf' % name, 'r')
+    dst = open('%s\\%s.inf' % (vs, name), 'w')
+
+    for line in src:
+        line = re.sub('@MAJOR_VERSION@', os.environ['MAJOR_VERSION'], line)
+        line = re.sub('@MINOR_VERSION@', os.environ['MINOR_VERSION'], line)
+        line = re.sub('@MICRO_VERSION@', os.environ['MICRO_VERSION'], line)
+        line = re.sub('@BUILD_NUMBER@', os.environ['BUILD_NUMBER'], line)
+        line = re.sub('@VENDOR_NAME@', os.environ['VENDOR_NAME'], line)
+        line = re.sub('@PRODUCT_NAME@', os.environ['PRODUCT_NAME'], line)
+
+        if re.search('@VENDOR_DEVICE_ID@', line):
+            if 'VENDOR_DEVICE_ID' not in os.environ.keys():
+                continue
+            line = re.sub('@VENDOR_DEVICE_ID@', os.environ['VENDOR_DEVICE_ID'], line)
+
+        dst.write(line)
+
+    dst.close()
+    src.close()
+
+
 def get_expired_symbols(name, age = 30):
     path = os.path.join(os.environ['SYMBOL_SERVER'], '000Admin\\history.txt')
 
@@ -330,11 +398,11 @@ if __name__ == '__main__':
     driver = 'xenbus'
     vs = getVsVersion()
 
-    os.utime('include/version.hx', None)
-    os.utime('src/%s.inf' % driver, None)
-    
-    if 'COMPANY_NAME' not in os.environ.keys():
-        os.environ['COMPANY_NAME'] = 'Xen Project'
+    if 'VENDOR_NAME' not in os.environ.keys():
+        os.environ['VENDOR_NAME'] = 'Xen Project'
+
+    if 'VENDOR_PREFIX' not in os.environ.keys():
+        os.environ['VENDOR_PREFIX'] = 'XP'
 
     if 'PRODUCT_NAME' not in os.environ.keys():
         os.environ['PRODUCT_NAME'] = 'Xen'
@@ -346,13 +414,27 @@ if __name__ == '__main__':
     if 'BUILD_NUMBER' not in os.environ.keys():
         os.environ['BUILD_NUMBER'] = next_build_number()
 
-    print("BUILD_NUMBER=%s" % os.environ['BUILD_NUMBER'])
-
     if 'GIT_REVISION' in os.environ.keys():
         revision = open('revision', 'w')
         print(os.environ['GIT_REVISION'], file=revision)
         revision.close()
 
+    print("VENDOR_NAME\t\t'%s'" % os.environ['VENDOR_NAME'])
+    print("VENDOR_PREFIX\t\t'%s'" % os.environ['VENDOR_PREFIX'])
+
+    if 'VENDOR_DEVICE_ID' in os.environ.keys():
+        print("VENDOR_DEVICE_ID\t'%s'" % os.environ['VENDOR_DEVICE_ID'])
+
+    print("PRODUCT_NAME\t\t'%s'" % os.environ['PRODUCT_NAME'])
+    print("MAJOR_VERSION\t\t%s" % os.environ['MAJOR_VERSION'])
+    print("MINOR_VERSION\t\t%s" % os.environ['MINOR_VERSION'])
+    print("MICRO_VERSION\t\t%s" % os.environ['MICRO_VERSION'])
+    print("BUILD_NUMBER\t\t%s" % os.environ['BUILD_NUMBER'])
+    print()
+
+    make_header()
+    copy_inf(vs, driver)
+
     symstore_del(driver, 30)
 
     if vs=='vs2012':
diff --git a/include/version.hx b/include/version.hx
deleted file mode 100644 (file)
index 4b7351d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * *   Redistributions of source code must retain the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the
- *     following disclaimer in the documentation and/or other
- *     materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define COMPANY_NAME_STR       "@COMPANY_NAME@"
-#define PRODUCT_NAME_STR       "@PRODUCT_NAME@"
-
-#define MAJOR_VERSION  @MAJOR_VERSION@
-#define MAJOR_VERSION_STR      "@MAJOR_VERSION@"
-
-#define MINOR_VERSION  @MINOR_VERSION@
-#define MINOR_VERSION_STR      "@MINOR_VERSION@"
-
-#define MICRO_VERSION  @MICRO_VERSION@
-#define MICRO_VERSION_STR      "@MICRO_VERSION@"
-
-#define BUILD_NUMBER   @BUILD_NUMBER@
-#define BUILD_NUMBER_STR       "@BUILD_NUMBER@"
-
-#define YEAR   @YEAR@
-#define YEAR_STR       "@YEAR@"
-
-#define MONTH  @MONTH@
-#define MONTH_STR      "@MONTH@"
-
-#define DAY    @DAY@
-#define DAY_STR        "@DAY@"
index 09ef84780fe5049d44a3090e50987dc7f8a46dda..5cdd060baef9320952c186ffb5bda78a42f4a9ca 100644 (file)
@@ -365,10 +365,8 @@ fail1:
     return FALSE;
 }
 
-#define PLATFORM_DEVICE_0001_NAME       "VEN_5853&DEV_0001"
-#define PLATFORM_DEVICE_0002_NAME       "VEN_5853&DEV_0002"
-
-#define XENSERVER_VENDOR_DEVICE_NAME    "VEN_5853&DEV_C000"
+#define XEN_PLATFORM_PCI_DEVICE_STR         "VEN_5853&DEV_0001"
+#define XENSERVER_PLATFORM_PCI_DEVICE_STR   "VEN_5853&DEV_0002"
 
 static BOOLEAN
 OpenDeviceKey(
@@ -669,7 +667,7 @@ MatchExistingDriver(
 
     // Look for a legacy platform device
     Success = GetDeviceKeyName("PCI",
-                               PLATFORM_DEVICE_0001_NAME,
+                               XEN_PLATFORM_PCI_DEVICE_STR,
                                &DeviceKeyName);
     if (!Success)
         goto fail1;
@@ -678,7 +676,7 @@ MatchExistingDriver(
         goto found;
 
     Success = GetDeviceKeyName("PCI",
-                               PLATFORM_DEVICE_0002_NAME,
+                               XENSERVER_PLATFORM_PCI_DEVICE_STR,
                                &DeviceKeyName);
     if (!Success)
         goto fail2;
index 51db47ab179a622d392acf02cc481ecb550bca41..95d94b633d7f805da985a2602918255422b59c24 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <version.h>
 
-#define        VER_COMPANYNAME_STR         COMPANY_NAME_STR
+#define        VER_COMPANYNAME_STR         VENDOR_NAME_STR
 #define VER_LEGALCOPYRIGHT_STR      "Copyright (c) Citrix Systems Inc."
 
 #define VER_PRODUCTNAME_STR         "XEN"
index 7f9370fa71e28949815563907bbea15446a10758..7ece951ffadaf5b56f4ff97a44189adcc85f3287 100644 (file)
@@ -32,7 +32,7 @@
 Signature="$Windows NT$" 
 Class=System
 ClassGUID={4d36e97d-e325-11ce-bfc1-08002be10318}
-Provider=%Company
+Provider=%Vendor
 CatalogFile=xenbus.cat
 DriverVer=01/01/1900,0.0.0.0
 
@@ -58,13 +58,13 @@ xenfilt.sys
 xenbus_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xenbus_coinst.dll
 
 [Manufacturer] 
-%Company%=Inst,NT$ARCH$
+%Vendor%=Inst,NT$ARCH$
 
 [Inst.NT$ARCH$]
 ; DisplayName          Section         DeviceID
 ; -----------          -------         --------
 
-%XenBusDesc%           =XenBus_Inst,   PCI\VEN_5853&DEV_C000&SUBSYS_C0005853&REV_01
+%XenBusDesc%           =XenBus_Inst,   PCI\VEN_5853&DEV_@VENDOR_DEVICE_ID@&SUBSYS_@VENDOR_DEVICE_ID@5853&REV_01
 %XenBusDesc%           =XenBus_Inst,   PCI\VEN_5853&DEV_0002
 %XenBusDesc%           =XenBus_Inst,   PCI\VEN_5853&DEV_0001
 
@@ -118,7 +118,7 @@ HKR,,CoInstallers32,0x00010000,"xenbus_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@M
 
 [Strings] 
 
-Company="@COMPANY_NAME@" 
+Vendor="@VENDOR_NAME@" 
 DiskDesc="@PRODUCT_NAME@ PV Bus Package" 
 XenBusDesc="@PRODUCT_NAME@ PV Bus"
 XenFiltDesc="@PRODUCT_NAME@ Generic Bus Filter"
index 0a516a47242d87ae06cc266ed2a09e2a3d2d1403..354438f446d47e9cebccc760ff55316a6908b347 100644 (file)
@@ -39,6 +39,7 @@
 #include <xen.h>
 
 #include <pvdevice_interface.h>
+#include <version.h>
 
 #include "names.h"
 #include "registry.h"
@@ -479,7 +480,8 @@ __FdoSetVendorName(
 
     status = RtlStringCbPrintfA(Fdo->VendorName,
                                 MAXNAMELEN,
-                                "XS%04X",
+                                "%s%04X",
+                                VENDOR_PREFIX_STR,
                                 DeviceID);
     ASSERT(NT_SUCCESS(status));
 
index c3ec266d6f08de7ffe6aa55cea69af45595d536e..9248d87bf3bd0ffc475d4a72c8cd08507255018e 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <version.h>
 
-#define        VER_COMPANYNAME_STR         COMPANY_NAME_STR
+#define        VER_COMPANYNAME_STR         VENDOR_NAME_STR
 #define VER_LEGALCOPYRIGHT_STR      "Copyright (c) Citrix Systems Inc."
 
 #define VER_PRODUCTNAME_STR         "XENBUS"
index 69077d09d9810cffc4518a2efccf5a94dda24eef..49494923233888d6ce120017f9f8f5b70fb3aa34 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <version.h>
 
-#define        VER_COMPANYNAME_STR         COMPANY_NAME_STR
+#define        VER_COMPANYNAME_STR         VENDOR_NAME_STR
 #define VER_LEGALCOPYRIGHT_STR      "Copyright (c) Citrix Systems Inc."
 
 #define VER_PRODUCTNAME_STR         "XENFILT"
index 0ffb844a4e8c1aea6abc76539cc8d8e633e582ac..c5f34d62431ed0796272ae4d9a124e7ae7c2aa45 100644 (file)
     <IncludePath>..\..\include;..\..\include\xen;..\..\src\common;$(IncludePath)</IncludePath>
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
-    <CustomBuildBeforeTargets>ClCompile</CustomBuildBeforeTargets>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
   </PropertyGroup>
   <ItemDefinitionGroup>
-    <CustomBuildStep>
-      <Command> echo "Build version header"
-      powershell -Command "(Get-Content ..\..\include\version.hx) -replace '@MAJOR_VERSION@', '$(MAJOR_VERSION)' -replace '@MINOR_VERSION@', '$(MINOR_VERSION)' -replace '@MICRO_VERSION@','$(MICRO_VERSION)' -replace '@BUILD_NUMBER@','$(BUILD_NUMBER)' -replace '@COMPANY_NAME@','$(COMPANY_NAME)' -replace '@PRODUCT_NAME@','$(PRODUCT_NAME)' -replace '@DAY@',%24(Get-Date -format %25%25d) -replace '@MONTH@',%24(Get-Date -format %25%25M) -replace '@YEAR@',%24(Get-Date -format yyyy) | Set-Content ..\..\include\version.h"
-      </Command>
-      <Outputs>..\..\include\version.h</Outputs>
-      <Inputs>..\..\include\version.hx</Inputs>
-    </CustomBuildStep>
     <ClCompile>
       <PreprocessorDefinitions>__MODULE__="XEN";POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <WarningLevel>EnableAllWarnings</WarningLevel>
index b4fe9921ebaacaa2c4d2e24692d6a1578a4405e9..f5692eba1d3a8a9f3850812437867d52459f7069 100644 (file)
     <IncludePath>..\..\include;..\..\include\xen;..\..\src\common;$(IncludePath)</IncludePath>
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
-    <CustomBuildBeforeTargets>StampInf</CustomBuildBeforeTargets>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
   </PropertyGroup>
   <ItemDefinitionGroup>
-    <CustomBuildStep>
-      <Command>echo "Build Inf"
-      powershell -Command "(Get-Content ..\..\src\xenbus.inf) -replace '@MAJOR_VERSION@', '$(MAJOR_VERSION)' -replace '@MINOR_VERSION@', '$(MINOR_VERSION)' -replace '@MICRO_VERSION@','$(MICRO_VERSION)' -replace '@BUILD_NUMBER@','$(BUILD_NUMBER)' -replace '@COMPANY_NAME@','$(COMPANY_NAME)' -replace '@PRODUCT_NAME@','$(PRODUCT_NAME)' | Set-Content ..\..\vs2012\xenbus.inf"
-      </Command>
-      <Outputs>..\..\vs2012\xenbus.inf</Outputs>
-      <Inputs>..\..\src\xenbus.inf</Inputs>
-    </CustomBuildStep>
     <ClCompile>
       <PreprocessorDefinitions>__MODULE__="XENBUS";POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <WarningLevel>EnableAllWarnings</WarningLevel>
index 9330d8d53237d6551e890069e98cea7b34100a47..fd5a471ad5c2b4e95fd61f83b9e1e16c7e57f61b 100644 (file)
     <EnableInf2cat>false</EnableInf2cat>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
-    <CustomBuildBeforeTargets>ClCompile</CustomBuildBeforeTargets>
   </PropertyGroup>
   <ItemDefinitionGroup>
-      <CustomBuildStep>
-        <Command> echo "Build version header"
-            powershell -Command "(Get-Content ..\..\include\version.hx) -replace '@MAJOR_VERSION@', '$(MAJOR_VERSION)' -replace '@MINOR_VERSION@', '$(MINOR_VERSION)' -replace '@MICRO_VERSION@','$(MICRO_VERSION)' -replace '@BUILD_NUMBER@','$(BUILD_NUMBER)' -replace '@COMPANY_NAME@','$(COMPANY_NAME)' -replace '@PRODUCT_NAME@','$(PRODUCT_NAME)' -replace '@DAY@',%24(Get-Date -format %25%25d) -replace '@MONTH@',%24(Get-Date -format %25%25M) -replace '@YEAR@',%24(Get-Date -format yyyy) | Set-Content ..\..\include\version.h"
-        </Command>
-        <Outputs>..\..\include\version.h</Outputs>
-        <Inputs>..\..\include\version.hx</Inputs>
-      </CustomBuildStep>
     <ClCompile>
       <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>__MODULE__="XEN";POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
index f6e057568ae805a996ca2794be3d3ca37c1b8a39..d53ce0ed7b076a834b295058e8059b19df727273 100644 (file)
     <EnableInf2cat>false</EnableInf2cat>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
-    <CustomBuildBeforeTargets>StampInf</CustomBuildBeforeTargets>
   </PropertyGroup>
   <ItemDefinitionGroup>
-    <CustomBuildStep>
-        <Command>echo "Build Inf"
-            powershell -Command "(Get-Content ..\..\src\xenbus.inf) -replace '@MAJOR_VERSION@', '$(MAJOR_VERSION)' -replace '@MINOR_VERSION@', '$(MINOR_VERSION)' -replace '@MICRO_VERSION@','$(MICRO_VERSION)' -replace '@BUILD_NUMBER@','$(BUILD_NUMBER)' -replace '@COMPANY_NAME@','$(COMPANY_NAME)' -replace '@PRODUCT_NAME@','$(PRODUCT_NAME)' | Set-Content ..\..\vs2013\xenbus.inf"
-        </Command>
-        <Outputs>..\..\vs2013\xenbus.inf</Outputs>
-        <Inputs>..\..\src\xenbus.inf</Inputs>
-    </CustomBuildStep>
     <ClCompile>
       <PreprocessorDefinitions>__MODULE__="XENBUS";POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;..\..\src\common;</AdditionalIncludeDirectories>