cpp_build 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cpp_build.rb +109 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60a537d3abeb0ffbc29d57d2114055d4cdad2fef
4
+ data.tar.gz: 33450bd1cbb82ff2c51c25ecabfdf2740c2ef0e5
5
+ SHA512:
6
+ metadata.gz: 6287221982dda536862464913a68f1651ae63a8870ad769910a2c5a1ffbca2825039edd6ac9b27b0ed7d12faeb7eb7faa1d1ab2a58943918a1fae646d380b927
7
+ data.tar.gz: 38ed15a3552d5ebd257595c1f7489385eb246d3c936b4b7a009318db614298bcb8aad93a6731ce142b55b34962d9566e90ab29e67d07563e5152254e972ddf81
data/lib/cpp_build.rb ADDED
@@ -0,0 +1,109 @@
1
+
2
+ # Builds a command line string for clang++
3
+ def clang_compiler_build_str(out_name, files, inc_dirs, config)
4
+
5
+ # Compiler
6
+ cc = "clang++"
7
+
8
+ # Config
9
+ if config == :debug
10
+ config = "-g -O0"
11
+ elsif config == :release
12
+ config = "-O2"
13
+ end
14
+
15
+ # Files
16
+ if files.class == Array then files = files.join(" ") end
17
+
18
+ if files == :not_set
19
+ return "echo \"No Files Given\""
20
+ end
21
+
22
+ # Inc Dirs
23
+ if inc_dirs.class == Array then inc_dirs = inc_dirs.join(" -I") end
24
+ if inc_dirs.class == String then inc_dirs = "-I" + inc_dirs end
25
+ if inc_dirs == :not_set then inc_dirs = "" end
26
+
27
+ # Output
28
+ build = "-o #{out_name}"
29
+
30
+ # Other Stuff
31
+ cpp_standard = "-std=c++11"
32
+
33
+ # Build cmd string
34
+ cmd_string = "#{cc} #{files} #{inc_dirs} #{config} #{cpp_standard} #{build}"
35
+
36
+ return cmd_string
37
+ end
38
+
39
+ $build_list = []
40
+
41
+ class CppBuild
42
+
43
+ attr_accessor :name, :compiler, :files, :config, :inc_dirs, :arch, :defines, :out_dir
44
+
45
+ def initialize()
46
+ @name = "cpp_build"
47
+ @compiler = :clang
48
+ @files = :not_set
49
+ @config = :not_set
50
+ @arch = :not_set
51
+ @defines = :not_set
52
+ @out_dir = "./"
53
+ end
54
+
55
+
56
+ def self.settings(&block)
57
+ # Override the defaults.
58
+ end
59
+
60
+
61
+ def self.build(build_name, &block)
62
+
63
+ build = CppBuild.new
64
+ build.name = build_name.to_s
65
+ build.instance_eval(&block)
66
+
67
+
68
+ if ARGV[0]
69
+ unless ARGV[0] == build_name.to_s then return end
70
+ else
71
+ puts "#{build.name} - #{build.compiler.to_s}, #{build.config.to_s}, #{build.files.length.to_s} files"
72
+
73
+ return
74
+ end
75
+
76
+ if build.compiler == :clang
77
+ compiler_cmd = clang_compiler_build_str(build.out_dir + build.name, build.files, build.inc_dirs, build.config)
78
+ else
79
+ compiler_cmd = "echo \"Compiler not supported.\""
80
+ end
81
+
82
+ puts "#{compiler_cmd}"
83
+
84
+ `#{compiler_cmd}`
85
+
86
+ # Hiding output
87
+ # if ARGV[1] == "-r"
88
+ # `./#{build.name}`
89
+ # end
90
+ end
91
+
92
+
93
+ def self.list()
94
+
95
+ end
96
+
97
+ end
98
+
99
+
100
+ # Process arguments
101
+ ARGV.each do |a|
102
+ # -r --run
103
+ # -d <name> --define <name>
104
+ # -cd --config_debug
105
+ # -cr --config_release
106
+ # -cc <name> --compiler <name>
107
+ # -o <name> --output <name>
108
+ end
109
+
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cpp_build
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Phil CK
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'A build system that lets you create cross platform build scripts for
14
+ C++. '
15
+ email: phil@cooperking.net
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/cpp_build.rb
21
+ homepage: https://github.com/PhilCK/cpp-build
22
+ licenses:
23
+ - MIT
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.2.2
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Cross platform C++ build helper.
45
+ test_files: []