Extract version from header file
This commit is contained in:
		
							
								
								
									
										17
									
								
								extract_version.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								extract_version.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					base_path = os.path.abspath(os.path.dirname(__file__))
 | 
				
			||||||
 | 
					config_h  = os.path.join(base_path, 'include', 'spdlog', 'version.h')
 | 
				
			||||||
 | 
					data      = {'MAJOR': 0, 'MINOR': 0, 'PATCH': 0}
 | 
				
			||||||
 | 
					reg       = re.compile(r'^\s*#define\s+SPDLOG_VER_([A-Z]+)\s+([0-9]+).*$')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					with open(config_h, 'r') as fp:
 | 
				
			||||||
 | 
					  for l in fp:
 | 
				
			||||||
 | 
					    m = reg.match(l)
 | 
				
			||||||
 | 
					    if m:
 | 
				
			||||||
 | 
					      data[m.group(1)] = int(m.group(2))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					print('{}.{}.{}'.format(data['MAJOR'], data['MINOR'], data['PATCH']))
 | 
				
			||||||
							
								
								
									
										10
									
								
								meson.build
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								meson.build
									
									
									
									
									
								
							@@ -1,7 +1,13 @@
 | 
				
			|||||||
project('spdlog', ['cpp'],
 | 
					project('spdlog', ['cpp'],
 | 
				
			||||||
  license         : 'MIT',
 | 
					  license         : 'MIT',
 | 
				
			||||||
  version         : '1.3.1',
 | 
					  version         : run_command(find_program('extract_version.py')).stdout().strip(),
 | 
				
			||||||
  default_options : ['warning_level=3', 'cpp_std=c++11', 'default_library=static'],
 | 
					  default_options : [
 | 
				
			||||||
 | 
					    'warning_level=3',
 | 
				
			||||||
 | 
					    'cpp_std=c++11',
 | 
				
			||||||
 | 
					    'default_library=static',
 | 
				
			||||||
 | 
					    'buildtype=release',
 | 
				
			||||||
 | 
					    'b_colorout=always',
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ------------------------
 | 
					# ------------------------
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user