]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Parameterize vendor prefix and PCI device id
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 8 Sep 2015 16:36:00 +0000 (17:36 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 8 Sep 2015 16:52:42 +0000 (17:52 +0100)
The XenServer PV vendor prefix ('XS') and PCI device (C000) are still
hard-coded into the XENVBD 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 xenvbd.inf
directly in build.py.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
MAINTAINERS
build.py
include/version.hx [deleted file]
src/xencrsh/xencrsh.rc
src/xendisk/xendisk.rc
src/xenvbd.inf
src/xenvbd/xenvbd.rc
vs2012/xencrsh/xencrsh.vcxproj
vs2013/xencrsh/xencrsh.vcxproj

index 09e9f6514819a9328e95733b649e213e6448221d..88cc97a0484cedd85dd41edfe85b584bc83c4fa7 100644 (file)
@@ -6,19 +6,34 @@ who will advise you on the precise procedure they wish to use.
 
 We also request you follow these basic guidelines:
 
-1.  Make sure you test your changes on both 32- and 64-bit versions of  Windows.
+1.  Make sure you test your changes on both a 32- and 64-bit version of Windows.
+    (The more versions of Windows you can test on the better).
 
 2.  Make sure your changes do not introduce any new prefast warnings.
 
-3.  All submissions must be made under the terms of the "Developer's Certificate
-    of Origin" (DC) and should include a Signed-off-by: line.
+3.  Make a patch available to the relevant maintainer in the list. Use 'diff -u'
+    to make the patch easy to merge. Be prepared to get your changes sent back
+    with seemingly silly requests about formatting and variable names. These
+    aren't as silly as they seem. One job the maintainers do is to keep things
+    looking the same.
 
-2.  All Submissions should use Unix line endings for consitency with the rest of
-    the XenServer project.
+    NOTE that all source should have Unix line endings.
 
-3.  Each patch should include a descriptive commit comment that helps understand
-    why the patch is necessary and why it works. This will be used both for
-    initial review and for new people to understand how the code works later
+    PLEASE see http://wiki.xen.org/wiki/Submitting_Xen_Patches for hints on how
+    to submit a patch in a suitable form. Whilst the PV driver source
+    repositories are distinct from the Xen Project hypervisor source, we will
+    follow the same general patch submission and review process.
+
+    PLEASE try to include any credit lines you want added with the  patch. It
+    avoids people being missed off by mistake and makes it easier to know who
+    wants adding and who doesn't.
+
+    PLEASE document known bugs. If it doesn't work for everything or does
+    something very odd once a month document it.
+
+    PLEASE remember that submissions must be made under the terms of the
+    "Developer's Certificate of Origin" (DCO) and should include a
+    Signed-off-by: line.
 
 4.  Make sure you have the right to submit any changes you make. If you do 
     changes at work you may find your employer owns the patches instead of 
index 75b9631986b3e7310790b1b84c88b88624a24ad0..18a3c5257488a95c30ee7a36aaf0a0ea31f4ad51 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -23,6 +23,76 @@ 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('@VENDOR_PREFIX@', os.environ['VENDOR_PREFIX'], 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')
 
@@ -329,11 +399,11 @@ if __name__ == '__main__':
     driver = 'xenvbd'
     vs = getVsVersion()
 
-    os.utime('include/version.hx', None)
-    os.utime('src/%s.inf' % driver, None)
+    if 'VENDOR_NAME' not in os.environ.keys():
+        os.environ['VENDOR_NAME'] = 'Xen Project'
 
-    if 'COMPANY_NAME' not in os.environ.keys():
-        os.environ['COMPANY_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'
@@ -345,13 +415,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 92b0a6b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) Citrix Systems Inc.\r
- * All rights reserved.\r
- * \r
- * Redistribution and use in source and binary forms, \r
- * with or without modification, are permitted provided \r
- * that the following conditions are met:\r
- * \r
- * *   Redistributions of source code must retain the above \r
- *     copyright notice, this list of conditions and the \r
- *     following disclaimer.\r
- * *   Redistributions in binary form must reproduce the above \r
- *     copyright notice, this list of conditions and the \r
- *     following disclaimer in the documentation and/or other \r
- *     materials provided with the distribution.\r
- * \r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, \r
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF \r
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \r
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR \r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR \r
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \r
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \r
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING \r
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF \r
- * SUCH DAMAGE.\r
- */\r
-\r
-#define COMPANY_NAME_STR       "@COMPANY_NAME@"\r
-#define PRODUCT_NAME_STR       "@PRODUCT_NAME@"\r
-\r
-#define MAJOR_VERSION  @MAJOR_VERSION@\r
-#define MAJOR_VERSION_STR      "@MAJOR_VERSION@"\r
-\r
-#define MINOR_VERSION  @MINOR_VERSION@\r
-#define MINOR_VERSION_STR      "@MINOR_VERSION@"\r
-\r
-#define MICRO_VERSION  @MICRO_VERSION@\r
-#define MICRO_VERSION_STR      "@MICRO_VERSION@"\r
-\r
-#define BUILD_NUMBER   @BUILD_NUMBER@\r
-#define BUILD_NUMBER_STR       "@BUILD_NUMBER@"\r
-\r
-#define YEAR   @YEAR@\r
-#define YEAR_STR       "@YEAR@"\r
-\r
-#define MONTH  @MONTH@\r
-#define MONTH_STR      "@MONTH@"\r
-\r
-#define DAY    @DAY@\r
-#define DAY_STR        "@DAY@"\r
-\r
index d09727099dc00333e7ad8d137852338893291715..65bbff9ec4a029abd2e1566a5e133b9e6f94596b 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         "XENCRSH"
index 5aa56a3315acefe7e9fb23bd88d9d0eb7b80ecc1..a74ce0c61b8da692bf0e4473d5ad5b4e85747032 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         "XENDISK"
index e92d3fbc489d04d6ae67176487f11387cf69ec7b..98ec3de7ae58cb083a13598273dbe67eb93cf48f 100644 (file)
@@ -32,7 +32,7 @@
 Signature="$Windows NT$" 
 Class=SCSIAdapter
 ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318} 
-Provider=%Company
+Provider=%Vendor
 CatalogFile=xenvbd.cat
 DriverVer=01/01/1900,0.0.0.0
 
@@ -50,12 +50,12 @@ xendisk.sys=0,,
 xenvbd_coinst.dll=0,,
 
 [Manufacturer] 
-%Company%=Inst,NT$ARCH$
+%Vendor%=Inst,NT$ARCH$
 
 [Inst.NT$ARCH$]
-%XenVbdDesc%=XenVbd_Inst,XENBUS\VEN_XSC000&DEV_VBD&REV_08000009
-%XenVbdDesc%=XenVbd_Inst,XENBUS\VEN_XS0001&DEV_VBD&REV_08000009
-%XenVbdDesc%=XenVbd_Inst,XENBUS\VEN_XS0002&DEV_VBD&REV_08000009
+%XenVbdDesc%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VBD&REV_08000009
+%XenVbdDesc%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VBD&REV_08000009
+%XenVbdDesc%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VBD&REV_08000009
 
 [XenVbd_Inst] 
 CopyFiles=XenVbd_Copyfiles
@@ -109,7 +109,7 @@ HKR,,CoInstallers32,0x00010000,"xenvbd_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@M
 
 [Strings] 
 
-Company = "@COMPANY_NAME@"
+Vendor = "@VENDOR_NAME@"
 DiskDesc = "@PRODUCT_NAME@ PV Storage Host Adapter Package" 
 XenVbdDesc= "@PRODUCT_NAME@ PV Storage Host Adapter"
 XenDiskDesc= "@PRODUCT_NAME@ PV Storage Filter"
index 6ac8c502003839454defac8ce1aa0ab543db8654..1b0148b5518a6ca2d183d57f535472fdf5ea5e4e 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         "XENVBD"
index c835b44f478f21e24cbe42f09ba65e6ded7745e4..23f469b469b6dec4e869454ab118bdcc96e0b137 100644 (file)
        <PropertyGroup>
                <IncludePath>..\..\include;$(IncludePath)</IncludePath>
                <RunCodeAnalysis>true</RunCodeAnalysis>
-        <EnableInf2cat>false</EnableInf2cat>
-        <CustomBuildBeforeTargets>ClCompile;StampInf</CustomBuildBeforeTargets>
+               <EnableInf2cat>false</EnableInf2cat>
                <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
                <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
        </PropertyGroup>
        
     <ItemDefinitionGroup>
-        <CustomBuildStep>
-            <Command>echo "Build Inf"
-                powershell -Command "(Get-Content ..\..\src\xenvbd.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\xenvbd.inf"
-                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>..\..\vs2012\xenvbd.inf;..\..\include\version.h</Outputs>
-            <Inputs>..\..\src\xenvbd.inf;..\..\include\version.hx</Inputs>
-        </CustomBuildStep>
                <ClCompile>
                        <PreprocessorDefinitions>__MODULE__="XENCRSH";%(PreprocessorDefinitions)</PreprocessorDefinitions>
                        <WarningLevel>EnableAllWarnings</WarningLevel>
index 668042611d06b9ba71bed9e884a9b43b2f05273e..90914d88afcf61c3c5bfe0a4a66f3381e85235c4 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
   <Import Project="..\configs.props" />\r
   <PropertyGroup Label="Globals">\r
     <IncludePath>..\..\include;$(IncludePath)</IncludePath>\r
     <RunCodeAnalysis>true</RunCodeAnalysis>\r
     <EnableInf2cat>false</EnableInf2cat>\r
-    <CustomBuildBeforeTargets>ClCompile;StampInf</CustomBuildBeforeTargets>\r
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>\r
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>\r
   </PropertyGroup>\r
   <ItemDefinitionGroup>\r
-    <CustomBuildStep>\r
-        <Command>echo "Build Inf"\r
-            powershell -Command "(Get-Content ..\..\src\xenvbd.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\xenvbd.inf"\r
-            echo "Build version header"\r
-            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"\r
-        </Command>\r
-        <Outputs>..\..\vs2013\xenvbd.inf;..\..\include\version.h</Outputs>\r
-        <Inputs>..\..\src\xenvbd.inf;..\..\include\version.hx</Inputs>\r
-    </CustomBuildStep>\r
     <ClCompile>\r
       <PreprocessorDefinitions>__MODULE__="XENCRSH";%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
       <WarningLevel>EnableAllWarnings</WarningLevel>\r