macb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/macb +116 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f03439849e5b27333afadad20de9014fcfc17baf
|
4
|
+
data.tar.gz: 7e00a4620895e5f150f0ad902d159871f1b69d9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 679971d4607993bf1af949893895f6adfb5ae997d255c2a97cb10c22dc50cb0c51f9b9e521667b67607254454e59762ca1f4936c52e318fe4b4be83a283750d1
|
7
|
+
data.tar.gz: 421a76f47f616140b204b5e376d7d77eee1622593b6fdfff0c59f0f5cf272bc6f5bd10f46a3aa8c9aa420614d701d931c53c5375702ba5c59972f0ed02cc0f69
|
data/bin/macb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# BSD v2
|
3
|
+
# Copyright 2015 Wojciech A. Koszek <wojciech@koszek.com>
|
4
|
+
|
5
|
+
$g_debug = 1
|
6
|
+
$g_files = []
|
7
|
+
$g_flags = []
|
8
|
+
$g_f_out = nil
|
9
|
+
|
10
|
+
def usage
|
11
|
+
print "Usage:\n"
|
12
|
+
print "\tmacb <files>\n"
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def dbg(*args)
|
17
|
+
if $g_debug == 0 then
|
18
|
+
return
|
19
|
+
end
|
20
|
+
print "# ", *args, "\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
def obj_make
|
24
|
+
if File.exist?("obj") then
|
25
|
+
system("rm -rf obj")
|
26
|
+
end
|
27
|
+
Dir.mkdir("obj")
|
28
|
+
end
|
29
|
+
|
30
|
+
def cmake_create(f_out, f_inputs, f_flags)
|
31
|
+
# flatten the array and make it string
|
32
|
+
str_f_flags = f_flags.map { |s| "#{s}" }.join(' ')
|
33
|
+
str_f_inputs = f_inputs.map { |s| "#{s}" }.join(' ')
|
34
|
+
|
35
|
+
f_sources = ""
|
36
|
+
f_inputs.each do |i|
|
37
|
+
f_sources += " ../#{i}"
|
38
|
+
end
|
39
|
+
print "f_sources=#{f_sources}\n";
|
40
|
+
|
41
|
+
f = File.open("obj/CMakeLists.txt", "w")
|
42
|
+
f.write("cmake_minimum_required (VERSION 2.6)\n");
|
43
|
+
f.write("project (#{f_out})\n");
|
44
|
+
f.write("add_executable(#{f_out} #{f_sources})\n");
|
45
|
+
f.close()
|
46
|
+
|
47
|
+
if !File.exist?("makefile")
|
48
|
+
f = File.open("makefile", "w")
|
49
|
+
f.write("all:\n");
|
50
|
+
f.write("\tmacb #{str_f_flags} #{str_f_inputs}\n");
|
51
|
+
f.write("clean:\n");
|
52
|
+
f.write("\trm -rf #{f_out} obj\n");
|
53
|
+
f.close()
|
54
|
+
else
|
55
|
+
print "# makefile exists. not rewriting"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def tools_run(f_out, f_flags)
|
60
|
+
# flatten the array and make it string
|
61
|
+
str_f_flags = f_flags.map { |s| "#{s}" }.join(' ')
|
62
|
+
|
63
|
+
dbg "tools_run: #{str_f_flags}"
|
64
|
+
|
65
|
+
child = fork {
|
66
|
+
Dir.chdir("obj");
|
67
|
+
system({"CFLAGS" => str_f_flags}, "cmake", "-GXcode")
|
68
|
+
system({"CFLAGS" => str_f_flags}, "xcodebuild")
|
69
|
+
}
|
70
|
+
Process.waitpid(child)
|
71
|
+
|
72
|
+
obj_fn = "./obj/Debug/#{f_out}"
|
73
|
+
dbg "tools_run, checking #{obj_fn}"
|
74
|
+
if File.exist?(obj_fn) then
|
75
|
+
dbg "Rename f_out: #{f_out}"
|
76
|
+
File.rename(obj_fn, f_out)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
#-------------------------------------------------------------------------------
|
81
|
+
|
82
|
+
if ARGV.length <= 0 then
|
83
|
+
usage
|
84
|
+
end
|
85
|
+
|
86
|
+
$g_f_out = false
|
87
|
+
#print ARGV.length , "\n"
|
88
|
+
ARGV.each_with_index do |arg, _idx|
|
89
|
+
print ">", arg, "\n"
|
90
|
+
if (arg =~ /\.c$/) or (arg =~ /\.h$/) or (arg =~ /\.m$/) or
|
91
|
+
(arg =~ /\.swift$/) then
|
92
|
+
dbg "Parsing file: #{arg}"
|
93
|
+
if $g_f_out == false then
|
94
|
+
fn_ext = arg.split('.')
|
95
|
+
$g_f_out = fn_ext[0]
|
96
|
+
dbg "Will build '#{$g_f_out}' program"
|
97
|
+
end
|
98
|
+
dbg "Supported file #{arg}"
|
99
|
+
$g_files.push(arg)
|
100
|
+
elsif (arg =~ /^\-/) then
|
101
|
+
dbg "Finding flags! arg = #{arg}"
|
102
|
+
$g_flags.push(arg)
|
103
|
+
else
|
104
|
+
print "# Unsupported file #{arg}, skipping..."
|
105
|
+
end
|
106
|
+
end
|
107
|
+
if $g_f_out == false then
|
108
|
+
print "you must specify output file!\n"
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
|
112
|
+
dbg "flags", $g_flags
|
113
|
+
|
114
|
+
obj_make()
|
115
|
+
cmake_create($g_f_out, $g_files, $g_flags)
|
116
|
+
tools_run($g_f_out, $g_flags)
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: macb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wojciech A. Koszek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: CLI for createing Xcode projects
|
14
|
+
email: wojciech@koszek.com
|
15
|
+
executables:
|
16
|
+
- macb
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/macb
|
21
|
+
homepage: http://github.com/wkoszek/macb
|
22
|
+
licenses:
|
23
|
+
- BSD
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.14
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: CLI for creating Xcode projects
|
45
|
+
test_files: []
|