c-dependencies 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4710ae38237a141810ec0bfab78b5a00f7f19f74
4
- data.tar.gz: c21b6ab27d7456536c22ff292278dece6e15da53
3
+ metadata.gz: 09d1e1c95ea48673c0f6a108c92933f0efd6003e
4
+ data.tar.gz: c966beca09ab5b52bfd5e10924bb981862d8379f
5
5
  SHA512:
6
- metadata.gz: c641b8d87f6596e3a48b53bcb9f8e7208aa4fe025cbf22873a7afcd9f50f0e000a5802514f8c2d1c8fee7a51688fb9108f6428a9c96d48d57755e7cd5d864f05
7
- data.tar.gz: 8eb08801174891763d9705852888429a9cab76de56e279ca44bab9c26b1b239bff89a7eb4a25fe6fbfa1b8ddf988b79e6bf05bd1c33fa8236e2d916de9bb6279
6
+ metadata.gz: 7de1a7cd8d6f2ef0c096760ade5535ab1c8af6ff8b9813c01637dbe871cffd4791579ef948bd07ca2d6a284c7eb561f64f9977fd629afd1ebe50d4a71785c29f
7
+ data.tar.gz: bbe72d140e388907d9c28ea1a764dbc381ea77efbbe0379e9d8b2e650eb2c251a848557697cb1fe47eb29a01943a4ac24af49da54e74382fa4238c78f505ee7a
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ sudo: false
3
+
4
+ os:
5
+ - linux
6
+ - osx
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- c-dependencies (0.1.0)
4
+ c-dependencies (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -18,7 +18,10 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install c-dependencies
20
20
 
21
+ ## Contributing
22
+
23
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
24
+
21
25
  ## License
22
26
 
23
27
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
24
-
@@ -6,7 +6,6 @@ module CDependencies
6
6
  attr_accessor :tool_name
7
7
  attr_accessor :flags
8
8
  attr_accessor :input_path
9
- attr_accessor :output_file
10
9
  attr_accessor :output_path
11
10
 
12
11
  EXTENSION_MAP = { '.c' => 'cc',
@@ -30,6 +29,19 @@ module CDependencies
30
29
  end
31
30
 
32
31
  def tool_name
32
+ name = default_tool_name
33
+
34
+ case name
35
+ when 'c++'
36
+ get_env_named('CXX') || name
37
+ when 'cc'
38
+ get_env_named('CC') || name
39
+ else
40
+ name
41
+ end
42
+ end
43
+
44
+ def default_tool_name
33
45
  EXTENSION_MAP[input_extension]
34
46
  end
35
47
 
@@ -37,17 +49,22 @@ module CDependencies
37
49
  "#{tool_cmd} #{dependency_flag} '#{input_path}'"
38
50
  end
39
51
 
40
- def has_flags?
41
- !flags.nil? && flags != ''
52
+ def compile_cmd
53
+ cmd = tool_cmd
54
+ cmd += " -c '#{input_path}'"
55
+ cmd += " -o '#{output_path}'"
56
+ cmd
42
57
  end
43
58
 
44
59
  private
45
60
  def tool_cmd
46
- has_flags? ? "#{tool_name} #{flags}" : tool_name
61
+ cmd = tool_name
62
+ cmd += ' ' + flags if !flags.nil? && flags != ''
63
+ cmd
47
64
  end
48
65
 
49
66
  def dependency_flag
50
- case tool_name
67
+ case default_tool_name
51
68
  when 'cc', 'c++'
52
69
  # -MM suppresses system header dependencies
53
70
  '-MM'
@@ -55,5 +72,16 @@ module CDependencies
55
72
  '-M'
56
73
  end
57
74
  end
75
+
76
+ private
77
+ def get_env_named(name)
78
+ env_var = ENV[name]
79
+
80
+ if env_var.nil? || env_var == ''
81
+ nil
82
+ else
83
+ env_var
84
+ end
85
+ end
58
86
  end
59
87
  end
@@ -19,15 +19,25 @@ module CDependencies
19
19
  list = File.readlines(path)
20
20
  list.map! { |x| x.chomp() }
21
21
 
22
- # make a non-empty list of files that also exist
23
- list.reject! { |x| x.empty? || !File.exist?(x) }
22
+ # make a non-empty list of files
23
+ list.reject! { |x| x.empty? }
24
+
25
+ # [path, sha] throwing away the sha part for now
26
+ list.map! { |x| x.split(',')[0] }
27
+
28
+ # remove files that do not exist
29
+ list.reject! { |x| !File.exist?(x) }
24
30
 
25
31
  DependencyList.new(list)
26
32
  end
27
33
 
34
+ def append(path)
35
+ @paths << File.absolute_path(path)
36
+ end
37
+
28
38
  private
29
39
  def serializable_dependency_entry(entry)
30
- entry
40
+ "#{entry}, #{file_hash(entry)}"
31
41
  end
32
42
 
33
43
  def serializable_entries
@@ -1,3 +1,3 @@
1
1
  module CDependencies
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c-dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Massicotte
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-15 00:00:00.000000000 Z
11
+ date: 2015-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,6 +59,7 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
61
  - ".gitignore"
62
+ - ".travis.yml"
62
63
  - CODE_OF_CONDUCT.md
63
64
  - Gemfile
64
65
  - Gemfile.lock