[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH] Parameterize vendor prefix and PCI device id
The XenServer PV vendor prefix ('XS') and PCI device (C000) are still hard-coded into the XENVIF 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 xenvif.inf directly in build.py. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- build.py | 91 +++++++++++++++++++++++++++++++++++++++++--- include/version.hx | 55 -------------------------- src/xenvif.inf | 12 +++--- src/xenvif/fdo.c | 4 +- src/xenvif/xenvif.rc | 2 +- vs2012/xenvif/xenvif.vcxproj | 10 ----- vs2013/xenvif/xenvif.vcxproj | 10 ----- 7 files changed, 95 insertions(+), 89 deletions(-) delete mode 100644 include/version.hx diff --git a/build.py b/build.py index 0945b1c..bdb0e3c 100755 --- a/build.py +++ b/build.py @@ -24,6 +24,75 @@ 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 +398,11 @@ if __name__ == '__main__': driver = 'xenvif' 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 +414,23 @@ 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']) + 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 index e3863f3..0000000 --- a/include/version.hx +++ /dev/null @@ -1,55 +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@" - diff --git a/src/xenvif.inf b/src/xenvif.inf index 727fbcc..3edd405 100644 --- a/src/xenvif.inf +++ b/src/xenvif.inf @@ -33,7 +33,7 @@ Signature="$Windows NT$" Class=System ClassGUID={4d36e97d-e325-11ce-bfc1-08002be10318} -Provider=%Company% +Provider=%Vendor% CatalogFile=xenvif.cat DriverVer=01/01/1900,0.0.0.0 @@ -52,15 +52,15 @@ xenvif_coinst.dll=0,, xenvif_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xenvif_coinst.dll [Manufacturer] -%Company%=Inst,NT$ARCH$ +%Vendor%=Inst,NT$ARCH$ [Inst.NT$ARCH$] ; DisplayName Section DeviceID ; ----------- ------- -------- -%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XSC000&DEV_VIF&REV_08000009 -%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XS0001&DEV_VIF&REV_08000009 -%XenVifDesc% =XenVif_Inst, XENBUS\VEN_XS0002&DEV_VIF&REV_08000009 +%XenVifDesc% =XenVif_Inst, XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_08000009 +%XenVifDesc% =XenVif_Inst, XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_08000009 +%XenVifDesc% =XenVif_Inst, XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_08000009 [XenVif_Inst] CopyFiles=XenVif_Copyfiles @@ -97,7 +97,7 @@ HKR,,CoInstallers32,0x00010000,"xenvif_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@M [Strings] -Company="@COMPANY_NAME@" +Vendor="@VENDOR_NAME@" DiskDesc="@PRODUCT_NAME@ PV Network Class Package" XenVifDesc="@PRODUCT_NAME@ PV Network Class" diff --git a/src/xenvif/fdo.c b/src/xenvif/fdo.c index c4c8052..67916d6 100644 --- a/src/xenvif/fdo.c +++ b/src/xenvif/fdo.c @@ -42,6 +42,7 @@ #include <gnttab_interface.h> #include <suspend_interface.h> #include <unplug_interface.h> +#include <version.h> #include "driver.h" #include "registry.h" @@ -419,7 +420,8 @@ __FdoSetVendorName( status = RtlStringCbPrintfA(Fdo->VendorName, MAXNAMELEN, - "XS%04X", + "%s%04X", + VENDOR_PREFIX_STR, DeviceID); ASSERT(NT_SUCCESS(status)); } diff --git a/src/xenvif/xenvif.rc b/src/xenvif/xenvif.rc index 6d8e820..55aedb1 100644 --- a/src/xenvif/xenvif.rc +++ b/src/xenvif/xenvif.rc @@ -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 "XENVIF" diff --git a/vs2012/xenvif/xenvif.vcxproj b/vs2012/xenvif/xenvif.vcxproj index 13be8a2..e3df309 100644 --- a/vs2012/xenvif/xenvif.vcxproj +++ b/vs2012/xenvif/xenvif.vcxproj @@ -21,20 +21,10 @@ <IncludePath>..\..\include;..\..\include\xen;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> - <CustomBuildBeforeTargets>ClCompile;StampInf</CustomBuildBeforeTargets> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir> </PropertyGroup> <ItemDefinitionGroup> - <CustomBuildStep> - <Command>echo "Build Inf" - powershell -Command "(Get-Content ..\..\src\xenvif.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 ..\xenvif.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>..\xenvif.inf;..\..\include\version.h</Outputs> - <Inputs>..\..\src\xenvif.inf;..\..\include\version.hx</Inputs> - </CustomBuildStep> <ClCompile> <PreprocessorDefinitions>__MODULE__="XENVIF";POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <WarningLevel>EnableAllWarnings</WarningLevel> diff --git a/vs2013/xenvif/xenvif.vcxproj b/vs2013/xenvif/xenvif.vcxproj index 19ac1ed..61265a2 100644 --- a/vs2013/xenvif/xenvif.vcxproj +++ b/vs2013/xenvif/xenvif.vcxproj @@ -20,20 +20,10 @@ <PropertyGroup> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> - <CustomBuildBeforeTargets>ClCompile;StampInf</CustomBuildBeforeTargets> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir> </PropertyGroup> <ItemDefinitionGroup> - <CustomBuildStep> - <Command>echo "Build Inf" - powershell -Command "(Get-Content ..\..\src\xenvif.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 ..\xenvif.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>..\xenvif.inf;..\..\include\version.h</Outputs> - <Inputs>..\..\src\xenvif.inf;..\..\include\version.hx</Inputs> - </CustomBuildStep> <ClCompile> <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\include\xen;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>__MODULE__="XENVIF";POOL_NX_OPTIN=1;NT_PROCESSOR_GROUPS;%(PreprocessorDefinitions)</PreprocessorDefinitions> -- 2.1.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |