ccfg 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/ccfg +32 -0
- data/lib/ccfg.rb +10 -0
- data/lib/ccfg/application.rb +22 -0
- data/lib/ccfg/handler.rb +85 -0
- data/lib/ccfg/version.rb +3 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 358aaebc4c2d05c10b88f286d8b653118b941cb0e1dd20ccb025fb0e2dd495ec
|
4
|
+
data.tar.gz: 5f9864093f301d8385723b08766be2853e8f3226f3c8a8eaeaf868258bf48f11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63d870f0ae8cbc95b89a0ce38d67a86dd3085b7f76b3f512a055aa445518288531716e315517c6c5c6281665038c22964dd8f4196e752e62bd79faf30bf6cb41
|
7
|
+
data.tar.gz: 0b78e55f2bac47f6ee9ca2adf2fecc988b9213497d842558b6cbddaa32883c72e8ecded15ddf97454d8a197e46356646420c7a71dfe8b3a873a223b9ea38233a
|
data/bin/ccfg
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2018 Anton S. Gerasimov (gera-gas)
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to
|
8
|
+
# deal in the Software without restriction, including without limitation the
|
9
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
22
|
+
# IN THE SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
=begin
|
26
|
+
require 'rubygems'
|
27
|
+
gem 'ccfg'
|
28
|
+
rescue LoadError
|
29
|
+
=end
|
30
|
+
|
31
|
+
require 'ccfg'
|
32
|
+
Ccfg::Application.new
|
data/lib/ccfg.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Ccfg
|
2
|
+
|
3
|
+
# Class for application control methods.
|
4
|
+
class Application
|
5
|
+
include Ccfg
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
# Create application.
|
9
|
+
@app = Cmdlib::App.new( 'ccfg' )
|
10
|
+
@app.about << 'Command line tool to generate C/C++ configure files.'
|
11
|
+
@app.usage << 'ccfg <input file> -o <output file> [DEFINITION LIST...].'
|
12
|
+
# Add options to application.
|
13
|
+
@app.addopt Cmdlib::Option.new( 'o', 'output', 'Option set output file (default STDOUT).', true )
|
14
|
+
# Add commands to application.
|
15
|
+
@app.default Handler.new
|
16
|
+
# Start application.
|
17
|
+
@app.run
|
18
|
+
end
|
19
|
+
|
20
|
+
end # class Application
|
21
|
+
|
22
|
+
end # module Ccfg
|
data/lib/ccfg/handler.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
module Ccfg
|
2
|
+
|
3
|
+
# CLI command handler.
|
4
|
+
class Handler < Cmdlib::Command
|
5
|
+
include Ccfg
|
6
|
+
|
7
|
+
def parse_line(line, deflist)
|
8
|
+
if line.length > 0 then
|
9
|
+
if line.include? Ccfg::CCONFIGURE_DEFINE_DIRECTIVE then
|
10
|
+
line.strip!
|
11
|
+
lineary = line.split(' ')
|
12
|
+
if lineary.size >=2 and lineary[0] == Ccfg::CCONFIGURE_DEFINE_DIRECTIVE then
|
13
|
+
deflist.each do |defname, defval|
|
14
|
+
if defname == lineary[1] then
|
15
|
+
line = "#define #{defname} #{defval}"
|
16
|
+
if lineary.size > 2 then
|
17
|
+
comment = ''
|
18
|
+
tail = ''
|
19
|
+
lineary.each do |e|
|
20
|
+
tail += "#{e} "
|
21
|
+
end
|
22
|
+
if tail.include? "//" then
|
23
|
+
comment = tail[tail.index("//") + "//".length, tail.length]
|
24
|
+
comment.strip!
|
25
|
+
comment = " //#{comment}"
|
26
|
+
elsif tail.include? "/*" then
|
27
|
+
start_index = tail.index("/*") + "/*".length
|
28
|
+
len = tail.index("*/") - start_index
|
29
|
+
comment = tail[start_index, len]
|
30
|
+
comment.strip!
|
31
|
+
comment = " /*#{comment} */"
|
32
|
+
end
|
33
|
+
line += comment
|
34
|
+
end
|
35
|
+
return line
|
36
|
+
end
|
37
|
+
end
|
38
|
+
line = "/* #undef #{lineary[1]} */"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
return line
|
43
|
+
end
|
44
|
+
|
45
|
+
def handler ( global_options, args )
|
46
|
+
if args.size == 0 then
|
47
|
+
puts "Error: to few arguments for command."
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
input = args[0]
|
51
|
+
args.delete_at(0)
|
52
|
+
cconfigure_definition_list = {}
|
53
|
+
# Get options from STDIN.
|
54
|
+
args.each do |a|
|
55
|
+
keyval = []
|
56
|
+
if a.include? '=' then
|
57
|
+
keyval = a.split('=')
|
58
|
+
else
|
59
|
+
keyval << a
|
60
|
+
keyval << ""
|
61
|
+
end
|
62
|
+
cconfigure_definition_list[keyval[0]] = keyval[1]
|
63
|
+
end
|
64
|
+
# Set output file from option or STDOUT.
|
65
|
+
if global_options[:output].value != nil then
|
66
|
+
fout = File.new( global_options[:output].value, 'w' )
|
67
|
+
end
|
68
|
+
# Start to parse lines.
|
69
|
+
File.open( input, 'r' ).readlines.each do |line|
|
70
|
+
line = parse_line line, cconfigure_definition_list
|
71
|
+
if global_options[:output].value != nil
|
72
|
+
fout.puts line
|
73
|
+
else
|
74
|
+
puts line
|
75
|
+
end
|
76
|
+
end
|
77
|
+
# Close file if option will be set.
|
78
|
+
if global_options[:output].value != nil then
|
79
|
+
fout.close
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end # class Handler
|
84
|
+
|
85
|
+
end # module Ccfg
|
data/lib/ccfg/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ccfg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton S.Gerasimov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cmdlib
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- gera_box@mail.ru
|
58
|
+
executables:
|
59
|
+
- ccfg
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- bin/ccfg
|
64
|
+
- lib/ccfg.rb
|
65
|
+
- lib/ccfg/application.rb
|
66
|
+
- lib/ccfg/handler.rb
|
67
|
+
- lib/ccfg/version.rb
|
68
|
+
homepage: https://github.com/gera-gas/ccfg
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.7.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Command line tool to generate C/C++ configure files (config.h.in => config.h).
|
92
|
+
test_files: []
|