Working towards gemifying and automatically reporting version.

This commit is contained in:
Mark VanderVoord
2024-08-01 11:47:58 -04:00
parent 119f6607d9
commit c83f8bddf2
4 changed files with 63 additions and 7 deletions
+6
View File
@@ -1,3 +1,4 @@
#!/bin/ruby
# ==========================================
# CMock Project - Automatic Mock Generation for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
@@ -95,6 +96,11 @@ if $0 == __FILE__
opt_flag = true
when '--skeleton'
options[:skeleton] = true
when '--version'
require 'cmock_version'
include CMockVersion
puts CMOCK_VERSION
exit(0)
when /^--strippables="?(.*)"?/
# --strippables are dealt with separately since the user is allowed to
# enter any valid regular expression as argument
+23
View File
@@ -0,0 +1,23 @@
module CMockVersion
# Where is the header file from here?
path = File.expand_path( File.join(File.dirname(__FILE__),"..","src","cmock.h") )
# Actually look up the version in the header file
a = [0,0,0]
begin
File.readlines(path).each do |line|
["VERSION_MAJOR", "VERSION_MINOR", "VERSION_BUILD"].each_with_index do |field, i|
m = line.match(/CMOCK_#{field}\s+(\d+)/)
a[i] = m[1] unless (m.nil?)
end
end
rescue
abort("Can't find my header file.")
end
# splat it to return the final value
CMOCK_VERSION = "#{a.join(".")}"
GEM = "0.32.0"
end