def write_svn_header(header, version): """ Creates the header file for the current revision and Chrome version information if the information has changed or if the file doesn't already exist. """ if not path_exists(version): raise Exception('Version file '+version+' does not exist.') # Read and parse the version file (key=value pairs, one per line) chrome = {} lines = read_file(version).split("\n") for line in lines: parts = line.split('=', 1) if len(parts) == 2: chrome[parts[0]] = parts[1] if path_exists(header): oldcontents = read_file(header) else: oldcontents = '' year = get_year() try: revision = svn.get_revision() except: revision = git.get_svn_revision() newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\ '//\n'+\ '// Redistribution and use in source and binary forms, with or without\n'+\ '// modification, are permitted provided that the following conditions are\n'+\ '// met:\n'+\ '//\n'+\ '// * Redistributions of source code must retain the above copyright\n'+\ '// notice, this list of conditions and the following disclaimer.\n'+\ '// * Redistributions in binary form must reproduce the above\n'+\ '// copyright notice, this list of conditions and the following disclaimer\n'+\ '// in the documentation and/or other materials provided with the\n'+\ '// distribution.\n'+\ '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\ '// Framework nor the names of its contributors may be used to endorse\n'+\ '// or promote products derived from this software without specific prior\n'+\ '// written permission.\n'+\ '//\n'+\ '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ '//\n'+\ '// ---------------------------------------------------------------------------\n'+\ '//\n'+\ '// This file is generated by the make_version_header.py tool.\n'+\ '//\n\n'+\ '#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\ '#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\ '#define CEF_REVISION ' + revision + '\n'+\ '#define COPYRIGHT_YEAR ' + year + '\n\n'+\ '#define CHROME_VERSION_MAJOR ' + chrome['MAJOR'] + '\n'+\ '#define CHROME_VERSION_MINOR ' + chrome['MINOR'] + '\n'+\ '#define CHROME_VERSION_BUILD ' + chrome['BUILD'] + '\n'+\ '#define CHROME_VERSION_PATCH ' + chrome['PATCH'] + '\n\n'+\ '#define DO_MAKE_STRING(p) #p\n'+\ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ '#ifdef __cplusplus\n'+\ 'extern "C" {\n'+\ '#endif\n\n'+\ '#include "internal/cef_export.h"\n\n'+\ '///\n'+\ '// Returns the CEF build revision of the libcef library.\n'+\ '///\n'+\ 'CEF_EXPORT int cef_build_revision();\n\n'+\ '#ifdef __cplusplus\n'+\ '}\n'+\ '#endif\n\n'+\ '#endif // APSTUDIO_HIDDEN_SYMBOLS\n\n'+\ '#endif // CEF_INCLUDE_CEF_VERSION_H_\n' if newcontents != oldcontents: write_file(header, newcontents) return True return False
def write_svn_header(header, chrome_version, cef_version, cpp_header_dir): """ Creates the header file for the current revision and Chrome version information if the information has changed or if the file doesn't already exist. """ if not path_exists(chrome_version): raise Exception('Chrome version file ' + chrome_version + ' does not exist.') if not path_exists(cef_version): raise Exception('CEF version file ' + cef_version + ' does not exist.') args = {} read_version_file(chrome_version, args) read_version_file(cef_version, args) if path_exists(header): oldcontents = read_file(header) else: oldcontents = '' year = get_year() if os.path.exists(os.path.join('.', '.svn')): revision = svn.get_revision() elif os.path.exists(os.path.join('.', '.git')): revision = git.get_svn_revision() else: raise Exception('Not a valid checkout') # calculate api hashes api_hash_calculator = cef_api_hash(cpp_header_dir, verbose=False) api_hashes = api_hash_calculator.calculate() newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\ '//\n'+\ '// Redistribution and use in source and binary forms, with or without\n'+\ '// modification, are permitted provided that the following conditions are\n'+\ '// met:\n'+\ '//\n'+\ '// * Redistributions of source code must retain the above copyright\n'+\ '// notice, this list of conditions and the following disclaimer.\n'+\ '// * Redistributions in binary form must reproduce the above\n'+\ '// copyright notice, this list of conditions and the following disclaimer\n'+\ '// in the documentation and/or other materials provided with the\n'+\ '// distribution.\n'+\ '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\ '// Framework nor the names of its contributors may be used to endorse\n'+\ '// or promote products derived from this software without specific prior\n'+\ '// written permission.\n'+\ '//\n'+\ '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ '//\n'+\ '// ---------------------------------------------------------------------------\n'+\ '//\n'+\ '// This file is generated by the make_version_header.py tool.\n'+\ '//\n\n'+\ '#ifndef CEF_INCLUDE_CEF_VERSION_H_\n'+\ '#define CEF_INCLUDE_CEF_VERSION_H_\n\n'+\ '#define CEF_VERSION_MAJOR ' + args['CEF_MAJOR'] + '\n'+\ '#define CEF_REVISION ' + revision + '\n'+\ '#define COPYRIGHT_YEAR ' + year + '\n\n'+\ '#define CHROME_VERSION_MAJOR ' + args['MAJOR'] + '\n'+\ '#define CHROME_VERSION_MINOR ' + args['MINOR'] + '\n'+\ '#define CHROME_VERSION_BUILD ' + args['BUILD'] + '\n'+\ '#define CHROME_VERSION_PATCH ' + args['PATCH'] + '\n\n'+\ '#define DO_MAKE_STRING(p) #p\n'+\ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ '#ifdef __cplusplus\n'+\ 'extern "C" {\n'+\ '#endif\n\n'+\ '#include "internal/cef_export.h"\n\n'+\ '// The API hash is created by analyzing CEF header files for C API type\n'+\ '// definitions. The hash value will change when header files are modified\n'+\ '// in a way that may cause binary incompatibility with other builds. The\n'+\ '// universal hash value will change if any platform is affected whereas the\n'+\ '// platform hash values will change only if that particular platform is\n'+\ '// affected.\n'+\ '#define CEF_API_HASH_UNIVERSAL "' + api_hashes['universal'] + '"\n'+\ '#if defined(OS_WIN)\n'+\ '#define CEF_API_HASH_PLATFORM "' + api_hashes['windows'] + '"\n'+\ '#elif defined(OS_MACOSX)\n'+\ '#define CEF_API_HASH_PLATFORM "' + api_hashes['macosx'] + '"\n'+\ '#elif defined(OS_LINUX)\n'+\ '#define CEF_API_HASH_PLATFORM "' + api_hashes['linux'] + '"\n'+\ '#endif\n\n'+\ '///\n'+\ '// Returns the CEF build revision for the libcef library.\n'+\ '///\n'+\ 'CEF_EXPORT int cef_build_revision();\n\n'+\ '///\n'+\ '// Returns CEF version information for the libcef library. The |entry|\n'+\ '// parameter describes which version component will be returned:\n'+\ '// 0 - CEF_VERSION_MAJOR\n'+\ '// 1 - CEF_REVISION\n'+\ '// 2 - CHROME_VERSION_MAJOR\n'+\ '// 3 - CHROME_VERSION_MINOR\n'+\ '// 4 - CHROME_VERSION_BUILD\n'+\ '// 5 - CHROME_VERSION_PATCH\n'+\ '///\n'+\ 'CEF_EXPORT int cef_version_info(int entry);\n\n'+\ '///\n'+\ '// Returns CEF API hashes for the libcef library. The returned string is owned\n'+\ '// by the library and should not be freed. The |entry| parameter describes which\n'+\ '// hash value will be returned:\n'+\ '// 0 - CEF_API_HASH_PLATFORM\n'+\ '// 1 - CEF_API_HASH_UNIVERSAL\n'+\ '///\n'+\ 'CEF_EXPORT const char* cef_api_hash(int entry);\n\n'+\ '#ifdef __cplusplus\n'+\ '}\n'+\ '#endif\n\n'+\ '#endif // APSTUDIO_HIDDEN_SYMBOLS\n\n'+\ '#endif // CEF_INCLUDE_CEF_VERSION_H_\n' if newcontents != oldcontents: write_file(header, newcontents) return True return False
# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. import svn_util as svn import git_util as git import sys # cannot be loaded as a module if __name__ != "__main__": sys.stderr.write("This file cannot be loaded as a module!") sys.exit() try: sys.stdout.write(svn.get_revision()) except: sys.stdout.write(git.get_svn_revision())
# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. import svn_util as svn import git_util as git import sys # cannot be loaded as a module if __name__ != "__main__": sys.stderr.write('This file cannot be loaded as a module!') sys.exit() try: sys.stdout.write(svn.get_revision()) except: sys.stdout.write(git.get_svn_revision())
# Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. import svn_util as svn import git_util as git import os import sys # cannot be loaded as a module if __name__ != "__main__": sys.stderr.write('This file cannot be loaded as a module!') sys.exit() if os.path.exists(os.path.join('../hex', '.svn')): sys.stdout.write(svn.get_revision(os.path.join('../hex'))) elif os.path.exists(os.path.join('../hex', '.git')): sys.stdout.write(git.get_svn_revision(os.path.join('../hex'))) else: sys.stdout.write("0") # raise Exception('Not a valid checkout')
# script directory script_dir = os.path.dirname(__file__) # heX root directory hex_dir = os.path.abspath(os.curdir) # CEF root directory cef_dir = os.path.abspath(os.path.join(script_dir, os.pardir, os.pardir, 'cef')) # src directory src_dir = os.path.abspath(os.path.join(cef_dir, os.pardir)) # retieve heX's url, revision and date information if os.path.exists(os.path.join(hex_dir, '.svn')): hex_rev = svn.get_revision() elif os.path.exists(os.path.join(hex_dir, '.git')): hex_rev = git.get_svn_revision() else: hex_rev = '"unknown"' hex_info = svn.get_svn_info(hex_dir) hex_url = hex_info['url'] # retrieve url, revision and date information cef_info = svn.get_svn_info(cef_dir) cef_url = cef_info['url'] cef_rev = cef_info['revision'] chromium_info = svn.get_svn_info(os.path.join(cef_dir, os.pardir)) chromium_url = chromium_info['url'] chromium_rev = chromium_info['revision']
def write_svn_header(header, chrome_version, cef_version, cpp_header_dir): """ Creates the header file for the current revision and Chrome version information if the information has changed or if the file doesn't already exist. """ if not path_exists(chrome_version): raise Exception("Chrome version file " + chrome_version + " does not exist.") if not path_exists(cef_version): raise Exception("CEF version file " + cef_version + " does not exist.") args = {} read_version_file(chrome_version, args) read_version_file(cef_version, args) if path_exists(header): oldcontents = read_file(header) else: oldcontents = "" year = get_year() if svn.is_checkout("."): revision = svn.get_revision() elif git.is_checkout("."): revision = git.get_svn_revision() else: raise Exception("Not a valid checkout") # calculate api hashes api_hash_calculator = cef_api_hash(cpp_header_dir, verbose=False) api_hashes = api_hash_calculator.calculate() newcontents = ( "// Copyright (c) " + year + " Marshall A. Greenblatt. All rights reserved.\n" + "//\n" + "// Redistribution and use in source and binary forms, with or without\n" + "// modification, are permitted provided that the following conditions are\n" + "// met:\n" + "//\n" + "// * Redistributions of source code must retain the above copyright\n" + "// notice, this list of conditions and the following disclaimer.\n" + "// * Redistributions in binary form must reproduce the above\n" + "// copyright notice, this list of conditions and the following disclaimer\n" + "// in the documentation and/or other materials provided with the\n" + "// distribution.\n" + "// * Neither the name of Google Inc. nor the name Chromium Embedded\n" + "// Framework nor the names of its contributors may be used to endorse\n" + "// or promote products derived from this software without specific prior\n" + "// written permission.\n" + "//\n" + "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n" + '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n' + "// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n" + "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n" + "// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n" + "// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n" + "// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" + "// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" + "// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" + "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n" + "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + "//\n" + "// ---------------------------------------------------------------------------\n" + "//\n" + "// This file is generated by the make_version_header.py tool.\n" + "//\n\n" + "#ifndef CEF_INCLUDE_CEF_VERSION_H_\n" + "#define CEF_INCLUDE_CEF_VERSION_H_\n\n" + "#define CEF_VERSION_MAJOR " + args["CEF_MAJOR"] + "\n" + "#define CEF_REVISION " + revision + "\n" + "#define COPYRIGHT_YEAR " + year + "\n\n" + "#define CHROME_VERSION_MAJOR " + args["MAJOR"] + "\n" + "#define CHROME_VERSION_MINOR " + args["MINOR"] + "\n" + "#define CHROME_VERSION_BUILD " + args["BUILD"] + "\n" + "#define CHROME_VERSION_PATCH " + args["PATCH"] + "\n\n" + "#define DO_MAKE_STRING(p) #p\n" + "#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n" + "#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n" '#include "include/internal/cef_export.h"\n\n' + "#ifdef __cplusplus\n" + 'extern "C" {\n' + "#endif\n\n" + "// The API hash is created by analyzing CEF header files for C API type\n" + "// definitions. The hash value will change when header files are modified\n" + "// in a way that may cause binary incompatibility with other builds. The\n" + "// universal hash value will change if any platform is affected whereas the\n" + "// platform hash values will change only if that particular platform is\n" + "// affected.\n" + '#define CEF_API_HASH_UNIVERSAL "' + api_hashes["universal"] + '"\n' + "#if defined(OS_WIN)\n" + '#define CEF_API_HASH_PLATFORM "' + api_hashes["windows"] + '"\n' + "#elif defined(OS_MACOSX)\n" + '#define CEF_API_HASH_PLATFORM "' + api_hashes["macosx"] + '"\n' + "#elif defined(OS_LINUX)\n" + '#define CEF_API_HASH_PLATFORM "' + api_hashes["linux"] + '"\n' + "#endif\n\n" + "///\n" + "// Returns the CEF build revision for the libcef library.\n" + "///\n" + "CEF_EXPORT int cef_build_revision();\n\n" + "///\n" + "// Returns CEF version information for the libcef library. The |entry|\n" + "// parameter describes which version component will be returned:\n" + "// 0 - CEF_VERSION_MAJOR\n" + "// 1 - CEF_REVISION\n" + "// 2 - CHROME_VERSION_MAJOR\n" + "// 3 - CHROME_VERSION_MINOR\n" + "// 4 - CHROME_VERSION_BUILD\n" + "// 5 - CHROME_VERSION_PATCH\n" + "///\n" + "CEF_EXPORT int cef_version_info(int entry);\n\n" + "///\n" + "// Returns CEF API hashes for the libcef library. The returned string is owned\n" + "// by the library and should not be freed. The |entry| parameter describes which\n" + "// hash value will be returned:\n" + "// 0 - CEF_API_HASH_PLATFORM\n" + "// 1 - CEF_API_HASH_UNIVERSAL\n" + "///\n" + "CEF_EXPORT const char* cef_api_hash(int entry);\n\n" + "#ifdef __cplusplus\n" + "}\n" + "#endif\n\n" + "#endif // APSTUDIO_HIDDEN_SYMBOLS\n\n" + "#endif // CEF_INCLUDE_CEF_VERSION_H_\n" ) if newcontents != oldcontents: write_file(header, newcontents) return True return False
def write_svn_header(header, chrome_version, hex_version, cpp_header_dir): """ Creates the header file for the current revision and Chrome version information if the information has changed or if the file doesn't already exist. """ if not path_exists(chrome_version): raise Exception('Chrome version file '+chrome_version+' does not exist.') if not path_exists(hex_version): raise Exception('heX version file '+hex_version+' does not exist.') args = {} read_version_file(chrome_version, args) read_version_file(hex_version, args) if path_exists(header): oldcontents = read_file(header) else: oldcontents = '' year = get_year() if os.path.exists(os.path.join('.', '.svn')): revision = svn.get_revision() elif os.path.exists(os.path.join('.', '.git')): revision = git.get_svn_revision() else: revision = '"unknown"' newcontents = '// Copyright (c) '+year+' NetEase Youdao Inc. and other heX contributors.\n'+\ '// Portions Copyright (c) 2008-2013 Marshall A.Greenblatt, 2006-2009\n'+\ '// Google Inc., and Joyent, Inc. All rights reserved.\n'+\ '//\n'+\ '// Redistribution and use in source and binary forms, with or without\n'+\ '// modification, are permitted provided that the following conditions are\n'+\ '// met:\n'+\ '//\n'+\ '// * Redistributions of source code must retain the above copyright notice,\n'+\ '// this list of conditions and the following disclaimer.\n'+\ '// * Redistributions in binary form must reproduce the above copyright\n'+\ '// notice, this list of conditions and the following disclaimer in the\n'+\ '// documentation and/or other materials provided with the distribution.\n'+\ '// * Neither the name of Google Inc. nor the name Chromium Embedded Framework\n'+\ '// nor the name of Joyent, Inc. nor the name of NetEase Youdao Inc. nor\n'+\ '// the name heX nor the names of its contributors may be used to endorse\n'+\ '// or promote products derived from this software without specific prior\n'+\ '// written permission.\n'+\ '//\n'+\ '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ '//\n'+\ '// ---------------------------------------------------------------------------\n'+\ '//\n'+\ '// This file is generated by the make_version_header.py tool.\n'+\ '//\n\n'+\ '#ifndef HEX_INCLUDE_HEX_VERSION_H_\n'+\ '#define HEX_INCLUDE_HEX_VERSION_H_\n\n'+\ '#define HEX_VERSION_MAJOR ' + args['HEX_MAJOR'] + '\n'+\ '#define HEX_VERSION_MINOR ' + args['HEX_MINOR'] + '\n'+\ '#define HEX_VERSION_BUILD ' + args['HEX_BUILD'] + '\n'+\ '#define HEX_REVISION ' + revision[0:9] + '\n'+\ '#endif // HEX_INCLUDE_HEX_VERSION_H_\n' if newcontents != oldcontents: write_file(header, newcontents) return True return False
def write_svn_header(header): """ Creates the header file for the current revision if the information has changed or if the file doesn't already exist. """ if path_exists(header): oldcontents = read_file(header) else: oldcontents = '' year = get_year() if svn.is_checkout('.') or svn.is_checkout('..'): revision = svn.get_revision() elif git.is_checkout('.') or git.is_checkout('..'): revision = git.get_svn_revision() else: raise Exception('Not a valid checkout') newcontents = '// Copyright (c) '+year+' The Chromium Embedded Framework Authors. All rights\n'+\ '// reserved. Use of this source code is governed by a BSD-style license that\n'+\ '// can be found in the LICENSE file.\n'+\ '//\n'+\ '// Redistribution and use in source and binary forms, with or without\n'+\ '// modification, are permitted provided that the following conditions are\n'+\ '// met:\n'+\ '//\n'+\ '// * Redistributions of source code must retain the above copyright\n'+\ '// notice, this list of conditions and the following disclaimer.\n'+\ '// * Redistributions in binary form must reproduce the above\n'+\ '// copyright notice, this list of conditions and the following disclaimer\n'+\ '// in the documentation and/or other materials provided with the\n'+\ '// distribution.\n'+\ '// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\ '// Framework nor the names of its contributors may be used to endorse\n'+\ '// or promote products derived from this software without specific prior\n'+\ '// written permission.\n'+\ '//\n'+\ '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ '//\n'+\ '// ---------------------------------------------------------------------------\n'+\ '//\n'+\ '// This file is generated by the make_version_header.py tool.\n'+\ '//\n\n'+\ '#ifndef JCEF_INCLUDE_JCEF_VERSION_H_\n'+\ '#define JCEF_INCLUDE_JCEF_VERSION_H_\n\n'+\ '#define JCEF_REVISION ' + revision + '\n'+\ '#define JCEF_COPYRIGHT_YEAR ' + year + '\n\n'+\ '#define DO_MAKE_STRING(p) #p\n'+\ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ '#endif // JCEF_INCLUDE_JCEF_VERSION_H_\n' if newcontents != oldcontents: write_file(header, newcontents) return True return False
def write_svn_header(header, chrome_version, hex_version, cpp_header_dir): """ Creates the header file for the current revision and Chrome version information if the information has changed or if the file doesn't already exist. """ if not path_exists(chrome_version): raise Exception('Chrome version file ' + chrome_version + ' does not exist.') if not path_exists(hex_version): raise Exception('heX version file ' + hex_version + ' does not exist.') args = {} read_version_file(chrome_version, args) read_version_file(hex_version, args) if path_exists(header): oldcontents = read_file(header) else: oldcontents = '' year = get_year() if os.path.exists(os.path.join('.', '.svn')): revision = svn.get_revision() elif os.path.exists(os.path.join('.', '.git')): revision = git.get_svn_revision() else: revision = '"unknown"' newcontents = '// Copyright (c) '+year+' NetEase Youdao Inc. and other heX contributors.\n'+\ '// Portions Copyright (c) 2008-2013 Marshall A.Greenblatt, 2006-2009\n'+\ '// Google Inc., and Joyent, Inc. All rights reserved.\n'+\ '//\n'+\ '// Redistribution and use in source and binary forms, with or without\n'+\ '// modification, are permitted provided that the following conditions are\n'+\ '// met:\n'+\ '//\n'+\ '// * Redistributions of source code must retain the above copyright notice,\n'+\ '// this list of conditions and the following disclaimer.\n'+\ '// * Redistributions in binary form must reproduce the above copyright\n'+\ '// notice, this list of conditions and the following disclaimer in the\n'+\ '// documentation and/or other materials provided with the distribution.\n'+\ '// * Neither the name of Google Inc. nor the name Chromium Embedded Framework\n'+\ '// nor the name of Joyent, Inc. nor the name of NetEase Youdao Inc. nor\n'+\ '// the name heX nor the names of its contributors may be used to endorse\n'+\ '// or promote products derived from this software without specific prior\n'+\ '// written permission.\n'+\ '//\n'+\ '// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\ '// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\ '// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\ '// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\ '// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\ '// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\ '// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\ '// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\ '// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\ '// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\ '// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\ '//\n'+\ '// ---------------------------------------------------------------------------\n'+\ '//\n'+\ '// This file is generated by the make_version_header.py tool.\n'+\ '//\n\n'+\ '#ifndef HEX_INCLUDE_HEX_VERSION_H_\n'+\ '#define HEX_INCLUDE_HEX_VERSION_H_\n\n'+\ '#define HEX_VERSION_MAJOR ' + args['HEX_MAJOR'] + '\n'+\ '#define HEX_VERSION_MINOR ' + args['HEX_MINOR'] + '\n'+\ '#define HEX_VERSION_BUILD ' + args['HEX_BUILD'] + '\n'+\ '#define HEX_REVISION ' + revision[0:9] + '\n'+\ '#endif // HEX_INCLUDE_HEX_VERSION_H_\n' if newcontents != oldcontents: write_file(header, newcontents) return True return False