buildfile 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/buildfile.rb +142 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dc5d77be8cd277b7d1b1465f798ab5786c76d00c
4
+ data.tar.gz: 8637d2ad2327004cf698c6e511598229ea3ac620
5
+ SHA512:
6
+ metadata.gz: 16841aa476354fd3fd403edb6f477b8e6461acff0bd2873dac84ba52558e8f3ee7b78e210999d49692586d2d37f26ff6b1eff8dd62dcdb380237660e026454d6
7
+ data.tar.gz: 8c4288c3719104044f838a3148fbbbfc2baae73af9bbb35880361cc6bcda313d2d1f0d194954970283a78412dc0b6116392babf9420fb3c26ab70dbc2f7733af
data/lib/buildfile.rb ADDED
@@ -0,0 +1,142 @@
1
+ require 'yaml'
2
+
3
+ module Buildfile
4
+
5
+ class Project
6
+
7
+ attr_reader :project_yaml
8
+
9
+
10
+ def initialize(yaml)
11
+ @project_yaml = yaml["project"]
12
+ end
13
+
14
+
15
+ def get_project_name
16
+ @project_yaml["name"] || "a.out"
17
+ end
18
+
19
+ def get_output_name
20
+ @project_yaml["output_name"] || get_project_name()
21
+ end
22
+
23
+
24
+ def get_compiler
25
+ default_compiler = "clang++"
26
+ @project_yaml["compiler"] || default_compiler
27
+ end
28
+
29
+
30
+ def get_file_list
31
+ concat_list('', @project_yaml["source_files"])
32
+ end
33
+
34
+
35
+ def get_inc_dirs
36
+ concat_list('-I', @project_yaml["include_dirs"])
37
+ end
38
+
39
+
40
+ def get_lib_dirs
41
+ concat_list('-L', @project_yaml["library_dirs"])
42
+ end
43
+
44
+
45
+ def get_libs
46
+ concat_list('-', @project_yaml["libraries"])
47
+ end
48
+
49
+
50
+ def get_other_flags
51
+ concat_list('-', @project_yaml["other_flags"])
52
+ end
53
+
54
+
55
+ def get_pre_processor_defines
56
+ begin
57
+ @project_yaml["pre_processor_defines"].map {
58
+ |i| "-D" + i[0].to_s + (if i[1] then "=" + i[1].to_s else "" end)
59
+ }.flatten.join(' ') || ""
60
+ rescue
61
+ ""
62
+ end
63
+ end
64
+
65
+
66
+ def get_custom_flags
67
+
68
+ custom_flags = ""
69
+
70
+ begin
71
+ @project_yaml["custom_flags"].each do |i|
72
+ custom_flags += concat_list(i["prefix"],
73
+ i["list"],
74
+ (i["space"] || false))
75
+ custom_flags += ' '
76
+ end
77
+
78
+ custom_flags.strip!
79
+ rescue
80
+ ""
81
+ end
82
+
83
+ return custom_flags;
84
+ end
85
+
86
+ private
87
+ def concat_list(prefix, list, space_between_flag = false)
88
+
89
+ if(space_between_flag) then
90
+ space = " "
91
+ else
92
+ space = ""
93
+ end
94
+
95
+ begin
96
+ list.map{|i| prefix + space + i}.join(' ') || ""
97
+ rescue
98
+ ""
99
+ end
100
+ end
101
+
102
+ end # Project
103
+
104
+
105
+ def self.generate_project_build_string_from_buildfile(file_name)
106
+ generate_project_build_string_from_loaded_yaml(YAML.load_file(file_name))
107
+ end
108
+
109
+
110
+ def self.generate_project_build_string_from_loaded_yaml(yaml)
111
+
112
+ proj = Project.new(yaml)
113
+
114
+ compiler = proj.get_compiler()
115
+
116
+ output_name = proj.get_output_name()
117
+ # input files
118
+ files = proj.get_file_list()
119
+
120
+ # include dirs
121
+ inc_dirs = proj.get_inc_dirs()
122
+
123
+ # lib dirs
124
+ lib_dirs = proj.get_lib_dirs()
125
+
126
+ # libs
127
+ libs = proj.get_libs()
128
+
129
+ # other_flags
130
+ other_flags = proj.get_other_flags()
131
+
132
+ # pre processor
133
+ defines = proj.get_pre_processor_defines()
134
+
135
+ # custom_flag
136
+ custom_flags = proj.get_custom_flags()
137
+
138
+ # generate bulid string.
139
+ build_str = "#{compiler} #{files} #{inc_dirs} #{lib_dirs} #{libs} #{other_flags} #{defines} #{custom_flags} -o #{output_name}"
140
+ end
141
+
142
+ end # module
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildfile
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Phil CK
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A very early wip of having rake build C++ projects.
14
+ email: phil@cooperking.net
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/buildfile.rb
20
+ homepage: https://github.com/PhilCK/buildfile
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Cross platform C++ build helper.
44
+ test_files: []