buildfile 0.0.1 → 0.0.2

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 +4 -4
  2. data/lib/buildfile.rb +40 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc5d77be8cd277b7d1b1465f798ab5786c76d00c
4
- data.tar.gz: 8637d2ad2327004cf698c6e511598229ea3ac620
3
+ metadata.gz: 37aacbf825e5097d3e842105da3c9f76089b9b6c
4
+ data.tar.gz: c67493435e97a2afae6759f1f16b2da0143605fc
5
5
  SHA512:
6
- metadata.gz: 16841aa476354fd3fd403edb6f477b8e6461acff0bd2873dac84ba52558e8f3ee7b78e210999d49692586d2d37f26ff6b1eff8dd62dcdb380237660e026454d6
7
- data.tar.gz: 8c4288c3719104044f838a3148fbbbfc2baae73af9bbb35880361cc6bcda313d2d1f0d194954970283a78412dc0b6116392babf9420fb3c26ab70dbc2f7733af
6
+ metadata.gz: 66643221d40afa38e07f86158007dfd763df4d815abb210321b266fa971c780c9153349db0c216c567ef012046587938f915efed2a0862a965d32abc11be1ebc
7
+ data.tar.gz: 287f84a71ace5d974333f55687cf08074bc73eb2280bee68d7183359cb22b04266dfa8e1cdbdc4981e74f49bfc0573f5b94fd3a9e8233de329fc41da05015526
@@ -1,5 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
+ # Buildfile
4
+ # The process a yaml file into a clang++ buildstring.
3
5
  module Buildfile
4
6
 
5
7
  class Project
@@ -11,9 +13,13 @@ module Buildfile
11
13
  @project_yaml = yaml["project"]
12
14
  end
13
15
 
16
+ def get_output_type
17
+ @project_yaml["type"]
18
+ end
14
19
 
15
20
  def get_project_name
16
- @project_yaml["name"] || "a.out"
21
+ default_type = if get_output_type == "static_lib" then "lib.a" else "a.out" end
22
+ @project_yaml["name"] || default_type
17
23
  end
18
24
 
19
25
  def get_output_name
@@ -102,41 +108,70 @@ module Buildfile
102
108
  end # Project
103
109
 
104
110
 
111
+ def self.generate_static_lib(proj)
112
+
113
+ compile_str = "#{proj.get_compiler} -c #{proj.get_file_list} #{proj.get_other_flags} #{proj.get_inc_dirs} && ar -rcs #{proj.get_output_name} *.o"
114
+
115
+ end
116
+
117
+
105
118
  def self.generate_project_build_string_from_buildfile(file_name)
106
119
  generate_project_build_string_from_loaded_yaml(YAML.load_file(file_name))
107
120
  end
108
121
 
109
122
 
110
123
  def self.generate_project_build_string_from_loaded_yaml(yaml)
124
+ proj = Project.new(yaml)
125
+
126
+ if(proj.get_output_type == "exe")
127
+ return Buildfile.generate_exe(proj)
128
+ elsif(proj.get_output_type == "static_lib")
129
+ return Buildfile.generate_static_lib(proj)
130
+ end
111
131
 
112
- proj = Project.new(yaml)
132
+ end
113
133
 
134
+
135
+ def self.generate_exe(proj)
136
+ build_str = ""
137
+
138
+ # Compiler name
114
139
  compiler = proj.get_compiler()
140
+ if(compiler) then build_str += compiler end
115
141
 
142
+ # Output name, or fallback to project name
116
143
  output_name = proj.get_output_name()
144
+ if(compiler) then build_str += output_name end
145
+
117
146
  # input files
118
147
  files = proj.get_file_list()
148
+ if(files) then build_str += files end
119
149
 
120
150
  # include dirs
121
151
  inc_dirs = proj.get_inc_dirs()
152
+ if(inc_dirs) then build_str += inc_dirs end
122
153
 
123
154
  # lib dirs
124
155
  lib_dirs = proj.get_lib_dirs()
156
+ if(lib_dirs) then build_str += lib_dirs end
125
157
 
126
158
  # libs
127
159
  libs = proj.get_libs()
160
+ if(libs) then build_str += libs end
128
161
 
129
162
  # other_flags
130
163
  other_flags = proj.get_other_flags()
164
+ if(other_flags) then build_str += other_flags end
131
165
 
132
166
  # pre processor
133
167
  defines = proj.get_pre_processor_defines()
168
+ if(defines) then build_str += defines end
134
169
 
135
170
  # custom_flag
136
171
  custom_flags = proj.get_custom_flags()
172
+ if(custom_flags) then build_str += custom_flags end
137
173
 
138
- # generate bulid string.
139
- build_str = "#{compiler} #{files} #{inc_dirs} #{lib_dirs} #{libs} #{other_flags} #{defines} #{custom_flags} -o #{output_name}"
174
+ #return build_str
140
175
  end
141
176
 
142
- end # module
177
+ end #Module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil CK