11cb0ef41Sopenharmony_cifrom __future__ import print_function 21cb0ef41Sopenharmony_ciimport os 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cidef get_major_minor_patch(text): 61cb0ef41Sopenharmony_ci for line in text.splitlines(): 71cb0ef41Sopenharmony_ci if line.startswith('#define NODE_MAJOR_VERSION'): 81cb0ef41Sopenharmony_ci major = line.split()[2] 91cb0ef41Sopenharmony_ci elif line.startswith('#define NODE_MINOR_VERSION'): 101cb0ef41Sopenharmony_ci minor = line.split()[2] 111cb0ef41Sopenharmony_ci elif line.startswith('#define NODE_PATCH_VERSION'): 121cb0ef41Sopenharmony_ci patch = line.split()[2] 131cb0ef41Sopenharmony_ci return major, minor, patch 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_cinode_version_h = os.path.join(os.path.dirname(__file__), 171cb0ef41Sopenharmony_ci '..', 181cb0ef41Sopenharmony_ci 'src', 191cb0ef41Sopenharmony_ci 'node_version.h') 201cb0ef41Sopenharmony_ciwith open(node_version_h) as in_file: 211cb0ef41Sopenharmony_ci print('.'.join(get_major_minor_patch(in_file.read()))) 22