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.
- checksums.yaml +4 -4
- data/lib/buildfile.rb +40 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37aacbf825e5097d3e842105da3c9f76089b9b6c
|
|
4
|
+
data.tar.gz: c67493435e97a2afae6759f1f16b2da0143605fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66643221d40afa38e07f86158007dfd763df4d815abb210321b266fa971c780c9153349db0c216c567ef012046587938f915efed2a0862a965d32abc11be1ebc
|
|
7
|
+
data.tar.gz: 287f84a71ace5d974333f55687cf08074bc73eb2280bee68d7183359cb22b04266dfa8e1cdbdc4981e74f49bfc0573f5b94fd3a9e8233de329fc41da05015526
|
data/lib/buildfile.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
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 #
|
|
177
|
+
end #Module
|