ckick 0.1.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/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE +373 -0
- data/README.md +20 -0
- data/Rakefile +6 -0
- data/bin/ckick +84 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ckick.gemspec +27 -0
- data/lib/ckick.rb +54 -0
- data/lib/ckick/array.rb +19 -0
- data/lib/ckick/cflag.rb +15 -0
- data/lib/ckick/ckickfile.rb +11 -0
- data/lib/ckick/compiler_flag.rb +39 -0
- data/lib/ckick/cxxflag.rb +15 -0
- data/lib/ckick/dependencies.rb +72 -0
- data/lib/ckick/executable.rb +23 -0
- data/lib/ckick/find_plugin.rb +25 -0
- data/lib/ckick/hash.rb +33 -0
- data/lib/ckick/hash_elements.rb +51 -0
- data/lib/ckick/hashable.rb +44 -0
- data/lib/ckick/include_path.rb +19 -0
- data/lib/ckick/library.rb +37 -0
- data/lib/ckick/library_link.rb +32 -0
- data/lib/ckick/library_path.rb +19 -0
- data/lib/ckick/nil_class.rb +8 -0
- data/lib/ckick/path.rb +26 -0
- data/lib/ckick/path_delegate.rb +29 -0
- data/lib/ckick/plugin.rb +47 -0
- data/lib/ckick/plugin/clang_complete.rb +19 -0
- data/lib/ckick/plugin/gtest.rb +44 -0
- data/lib/ckick/plugin/resource/build-gtest.cmake +17 -0
- data/lib/ckick/plugin_delegate.rb +15 -0
- data/lib/ckick/project.rb +173 -0
- data/lib/ckick/sub_directory.rb +121 -0
- data/lib/ckick/target.rb +81 -0
- data/lib/ckick/version.rb +7 -0
- data/resource/default_cxx_project.json +40 -0
- metadata +129 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
3
|
+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
4
|
+
|
5
|
+
require "ckick/nil_class"
|
6
|
+
require "ckick/executable"
|
7
|
+
require "ckick/library"
|
8
|
+
require "fileutils"
|
9
|
+
require "ckick/hashable"
|
10
|
+
require "ckick/path_delegate"
|
11
|
+
|
12
|
+
module CKick
|
13
|
+
|
14
|
+
class SubDirectory
|
15
|
+
include Hashable
|
16
|
+
|
17
|
+
attr_reader :name, :parent_dir, :has_cmake
|
18
|
+
|
19
|
+
def initialize args={}
|
20
|
+
name = args[:name]
|
21
|
+
raise IllegalInitializationError, "no name provided to sub directory" unless name.is_a?(String) && !name.empty?
|
22
|
+
libs = args[:libraries]
|
23
|
+
raise IllegalInitializationError, ":libraries argument is not an Array" unless libs.is_a?(Array) || libs.nil?
|
24
|
+
exes = args[:executables]
|
25
|
+
raise IllegalInitializationError, ":executables argument is not an Array" unless exes.is_a?(Array) || exes.nil?
|
26
|
+
subdirs = args[:subdirs]
|
27
|
+
raise IllegalInitializationError, ":subdirs is not an Array" unless subdirs.is_a?(Array) || subdirs.nil?
|
28
|
+
|
29
|
+
has_cmake = args[:has_cmake].nil? || args[:has_cmake]
|
30
|
+
|
31
|
+
if (!exes.nil? || !libs.nil?) && !has_cmake
|
32
|
+
raise BadSubDirectoryError, "A subdirectory not containing a CMakeLists cannot contain targets."
|
33
|
+
end
|
34
|
+
|
35
|
+
@name = name
|
36
|
+
@has_cmake = has_cmake
|
37
|
+
|
38
|
+
@libraries = []
|
39
|
+
libs.each do |lib|
|
40
|
+
@libraries << Library.new(lib)
|
41
|
+
end
|
42
|
+
@executables = []
|
43
|
+
exes.each do |exe|
|
44
|
+
@executables << Executable.new(exe)
|
45
|
+
end
|
46
|
+
|
47
|
+
@subdirs = []
|
48
|
+
subdirs.each do |subdir|
|
49
|
+
@subdirs << SubDirectory.new(subdir)
|
50
|
+
end
|
51
|
+
|
52
|
+
@parent_dir = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_s
|
56
|
+
@name
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_hash
|
60
|
+
if !@has_cmake
|
61
|
+
return to_no_empty_value_hash.without(:parent_dir)
|
62
|
+
end
|
63
|
+
to_no_empty_value_hash.without(:parent_dir, :has_cmake)
|
64
|
+
end
|
65
|
+
|
66
|
+
def path
|
67
|
+
raise NoParentDirError, "sub directory #{@name} has no parent set" unless @parent_dir
|
68
|
+
File.join(@parent_dir, @name)
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_structure
|
72
|
+
PathDelegate.create_directory(path)
|
73
|
+
|
74
|
+
if @has_cmake
|
75
|
+
PathDelegate.write_file(path, "CMakeLists.txt", cmake)
|
76
|
+
|
77
|
+
targets.each do |t|
|
78
|
+
t.create_structure
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
@subdirs.each do |subdir|
|
83
|
+
subdir.create_structure
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def cmake
|
88
|
+
res = ''
|
89
|
+
|
90
|
+
res << targets.collect { |t| t.cmake }.join("\n")
|
91
|
+
|
92
|
+
unless @subdirs.empty?
|
93
|
+
res << "\n"
|
94
|
+
res << @subdirs.collect do |subdir|
|
95
|
+
"add_subdirectory(#{subdir.name})"
|
96
|
+
end.join("\n")
|
97
|
+
end
|
98
|
+
|
99
|
+
res
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def targets
|
105
|
+
@executables + @libraries
|
106
|
+
end
|
107
|
+
|
108
|
+
def set_parent(parent_dir)
|
109
|
+
@parent_dir = parent_dir
|
110
|
+
|
111
|
+
targets.each do |t|
|
112
|
+
t.__send__ :set_parent, path
|
113
|
+
end
|
114
|
+
|
115
|
+
@subdirs.each do |subdir|
|
116
|
+
subdir.__send__ :set_parent, path
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
data/lib/ckick/target.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
3
|
+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
4
|
+
|
5
|
+
require "ckick/nil_class"
|
6
|
+
require "ckick/library_link"
|
7
|
+
require "ckick/path_delegate"
|
8
|
+
require "ckick/hashable"
|
9
|
+
|
10
|
+
module CKick
|
11
|
+
|
12
|
+
class Target
|
13
|
+
include Hashable
|
14
|
+
|
15
|
+
def initialize args={}
|
16
|
+
raise IllegalInitializationError unless args.is_a?(Hash) && !args.empty?
|
17
|
+
|
18
|
+
name = args[:name] || ""
|
19
|
+
raise NoNameError, "No target name given for target" unless name.is_a?(String) && !name.empty?
|
20
|
+
@name = name
|
21
|
+
|
22
|
+
source = args[:source] || []
|
23
|
+
if source.is_a? Array
|
24
|
+
raise NoSourceError, "No source file provided for target #{@name}" if source.empty?
|
25
|
+
raise BadSourceError, "Bad source file names provided for target #{@name}: #{source}" unless source.select { |el| !el.is_a?(String) }.empty?
|
26
|
+
@source = source
|
27
|
+
elsif source.is_a? String
|
28
|
+
@source = [source]
|
29
|
+
else
|
30
|
+
raise BadSourceError, "Bad source file name provided for target #{@name}"
|
31
|
+
end
|
32
|
+
|
33
|
+
@libs = []
|
34
|
+
libs = args[:libs] || []
|
35
|
+
if libs.is_a?(Array)
|
36
|
+
raise BadLibError, "Bad library name provided for target #{@name}: #{libs}" unless libs.select { |el| !el.is_a?(String) }.empty?
|
37
|
+
libs.each do |lib|
|
38
|
+
@libs << LibraryLink.new(name: lib)
|
39
|
+
end
|
40
|
+
elsif libs.is_a?(String)
|
41
|
+
@libs << LibraryLink.new(name: libs)
|
42
|
+
else
|
43
|
+
raise BadLibError, "Bad library name provided for target #{@name}: #{libs}"
|
44
|
+
end
|
45
|
+
|
46
|
+
@parent_dir = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_hash
|
50
|
+
to_no_empty_value_hash.without(:parent_dir)
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_s
|
54
|
+
@name
|
55
|
+
end
|
56
|
+
|
57
|
+
def paths
|
58
|
+
raise NoParentDirError, "No parent directory has been set for target #{@name}" unless @parent_dir
|
59
|
+
res = []
|
60
|
+
@source.each do |source_file|
|
61
|
+
res << File.join(@parent_dir, source_file)
|
62
|
+
end
|
63
|
+
res
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_structure
|
67
|
+
paths.each do |path|
|
68
|
+
unless File.exist? path
|
69
|
+
PathDelegate.touch_file(path)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def set_parent(parent_dir)
|
77
|
+
@parent_dir = parent_dir
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "new_cxx_project",
|
3
|
+
"cmake_min_version": "3.0",
|
4
|
+
|
5
|
+
"root": ".",
|
6
|
+
|
7
|
+
"build_dir": "build",
|
8
|
+
|
9
|
+
"dependencies": {
|
10
|
+
"cxxflags": ["-std=c++11", "-O3"]
|
11
|
+
},
|
12
|
+
|
13
|
+
"plugins": [
|
14
|
+
{
|
15
|
+
"name": "ClangComplete"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"name": "GTest"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
|
22
|
+
"subdirs": [
|
23
|
+
{
|
24
|
+
"name": "include",
|
25
|
+
"has_cmake": false
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"name": "src",
|
29
|
+
"executables": [
|
30
|
+
{
|
31
|
+
"name": "main",
|
32
|
+
"source": "main.cc"
|
33
|
+
}
|
34
|
+
]
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"name": "test"
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ckick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Gingras
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-30 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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: CKick is a simple gem that helps to kick start a C/C++ project using
|
56
|
+
CMake with an arbitrary structure. Using a CKickfile (a simple JSON), ckick is able
|
57
|
+
to generate an whole project structure without having to write any CMakeLists.txt
|
58
|
+
by your own.
|
59
|
+
email:
|
60
|
+
- jonathan.gingras.1@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- .rspec
|
67
|
+
- .travis.yml
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/ckick
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- ckick.gemspec
|
76
|
+
- lib/ckick.rb
|
77
|
+
- lib/ckick/array.rb
|
78
|
+
- lib/ckick/cflag.rb
|
79
|
+
- lib/ckick/ckickfile.rb
|
80
|
+
- lib/ckick/compiler_flag.rb
|
81
|
+
- lib/ckick/cxxflag.rb
|
82
|
+
- lib/ckick/dependencies.rb
|
83
|
+
- lib/ckick/executable.rb
|
84
|
+
- lib/ckick/find_plugin.rb
|
85
|
+
- lib/ckick/hash.rb
|
86
|
+
- lib/ckick/hash_elements.rb
|
87
|
+
- lib/ckick/hashable.rb
|
88
|
+
- lib/ckick/include_path.rb
|
89
|
+
- lib/ckick/library.rb
|
90
|
+
- lib/ckick/library_link.rb
|
91
|
+
- lib/ckick/library_path.rb
|
92
|
+
- lib/ckick/nil_class.rb
|
93
|
+
- lib/ckick/path.rb
|
94
|
+
- lib/ckick/path_delegate.rb
|
95
|
+
- lib/ckick/plugin.rb
|
96
|
+
- lib/ckick/plugin/clang_complete.rb
|
97
|
+
- lib/ckick/plugin/gtest.rb
|
98
|
+
- lib/ckick/plugin/resource/build-gtest.cmake
|
99
|
+
- lib/ckick/plugin_delegate.rb
|
100
|
+
- lib/ckick/project.rb
|
101
|
+
- lib/ckick/sub_directory.rb
|
102
|
+
- lib/ckick/target.rb
|
103
|
+
- lib/ckick/version.rb
|
104
|
+
- resource/default_cxx_project.json
|
105
|
+
homepage: https://github.com/jonathangingras/ckick
|
106
|
+
licenses:
|
107
|
+
- MPL-2.0
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.0.14.1
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Kick start a C/C++ CMake project structure from a single JSON file
|
129
|
+
test_files: []
|