canoe 0.3.2.3 → 0.3.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0518fcb695948644be7df59c7200eaf996a1c753bb8b575721764d36fcde61cb'
4
- data.tar.gz: 385806c9e2035fa9c0cd1caf2556ca8aba1994ca73caad835f252003bbe1c36e
3
+ metadata.gz: 18aa4cddd71a6a2b06ea69ea320de7e75b5a9155685d5f4918b5047faf9a83af
4
+ data.tar.gz: 488a487b6b2cb872fed7b81e604756c7676e279a3b750e720f3c219aa1f29210
5
5
  SHA512:
6
- metadata.gz: fe763993a442305afd7180eba5bb52fe63cd5ba9c8520c985a1cecec3ecbabb52296c5b6afd5ac7a72fa2341ebe432a6e7ca7b261145ca211dfc436f5066d22c
7
- data.tar.gz: 9eb610ca364b557e9e1999c18dd497912503cdc0580f3f403ef3abf6f4ac58803b81d5a1c352f02e5e00685d6bb1e471866f33c3da2f12651063fb4e6a5f33bc
6
+ metadata.gz: c0e5a956513c53ecee63750c6d13b2ff5ebba51716e72e6631aed667962d5df5e0ea3eee064ba0435a6d3f37ebf3cc2d6128bc5fce0145d6952500ef39eac0e4
7
+ data.tar.gz: 1cf7cd8b486bb92f32c646fa0eebebf94288a97c00362e6af749814c352305a2b3903e4df2ffde3689365d90020522eb681e5e07d9ed486b3a0871a49edb16e7
data/lib/config_reader.rb CHANGED
@@ -1,11 +1,17 @@
1
1
  require 'json'
2
+ require_relative 'util'
2
3
 
3
4
  ##
4
5
  # class ConfigReader
5
6
  # Just read a json file
6
7
  class ConfigReader
7
- def self.extract_flags(file)
8
- abort_on_err("config file #{file} does not exsit") unless File.exist? file
9
- JSON.parse(File.read(file))
8
+ include Canoe::Err
9
+ def initialize(file)
10
+ @config_file = file
11
+ end
12
+
13
+ def extract_flags
14
+ abort_on_err("config file #{@config_file} does not exsit") unless File.exist? @config_file
15
+ JSON.parse(File.read(@config_file))
10
16
  end
11
17
  end
data/lib/util.rb CHANGED
@@ -25,7 +25,7 @@ module Canoe
25
25
  module WorkSpaceUtil
26
26
  def current_workspace
27
27
  abort_on_err 'not in a canoe workspace' unless File.exist? '.canoe'
28
- config = ConfigReader.extract_flags('config.json')
28
+ config = ConfigReader.new('config.json').extract_flags
29
29
 
30
30
  src_sfx = config['source-suffix'] || 'cpp'
31
31
  hdr_sfx = config['header-suffix'] || 'hpp'
@@ -18,6 +18,10 @@ module Canoe
18
18
  end
19
19
  end
20
20
 
21
+ def hdr_of_src(file)
22
+ file.gsub(".#{@source_suffix}", ".#{@header_suffix}")
23
+ end
24
+
21
25
  # args are commandline parameters passed to `canoe build`,
22
26
  # could be 'all', 'test', 'target', 'base' or empty
23
27
  def build(arg = 'target')
@@ -43,14 +47,14 @@ module Canoe
43
47
  end
44
48
 
45
49
  def build_compiler_from_config
46
- flags = ConfigReader.extract_flags "config.json"
47
- compiler_name = flags["compiler"] ? flags["compiler"] : "clang++"
50
+ flags = ConfigReader.new('config.json').extract_flags
51
+ compiler_name = flags['compiler'] ? flags['compiler'] : 'clang++'
48
52
 
49
53
  abort_on_err "compiler #{compiler_name} not found" unless system "which #{compiler_name} > /dev/null"
50
- compiler_flags = ["-Isrc/components"]
54
+ compiler_flags = ['-Isrc/components']
51
55
  linker_flags = []
52
56
 
53
- c_flags, l_flags = flags["flags"]["compile"], flags["flags"]["link"]
57
+ c_flags, l_flags = flags['flags']['compile'], flags['flags']['link']
54
58
  build_flags(compiler_flags, c_flags)
55
59
  build_flags(linker_flags, l_flags)
56
60
 
@@ -267,7 +267,7 @@ module Canoe
267
267
 
268
268
  class WorkSpace
269
269
  def make
270
- config = ConfigReader.extract_flags "config.json"
270
+ config = ConfigReader.new('config.json').extract_flags
271
271
 
272
272
  deps = target_deps.merge tests_deps
273
273
 
@@ -50,15 +50,19 @@ module Canoe
50
50
  rebuild ||= !File.exist?(bin)
51
51
 
52
52
  file = "#{@tests_short}/test_#{name}.#{@source_suffix}"
53
+ rebuild ||= File.mtime(bin) < File.mtime(file)
53
54
 
54
55
  deps = fetch_all_deps
55
- extract_one_file(file, deps).push(file).each do |f|
56
- rebuild ||= File.mtime(bin) < File.mtime(f)
56
+ extract_one_file(file, deps).each do |f|
57
+ rebuild ||= File.mtime(bin) < File.mtime(f) || File.mtime(bin) < File.mtime(hdr_of_src(f))
57
58
  end
58
59
 
59
- build_compiler_from_config && build_one_test(file, deps) if rebuild
60
-
61
- issue_command bin
60
+ if rebuild
61
+ build_compiler_from_config
62
+ issue_command bin if build_one_test(file, deps)
63
+ else
64
+ issue_command bin
65
+ end
62
66
  end
63
67
 
64
68
  def fetch_all_test_files
@@ -84,7 +88,7 @@ module Canoe
84
88
  def compile_one_test(test_file, deps)
85
89
  extract_one_file(test_file, deps).each do |f|
86
90
  o = file_to_obj(f)
87
- next if File.exist?(o) && File.mtime(o) > File.mtime(f)
91
+ next if File.exist?(o) && File.mtime(o) > File.mtime(f) && File.mtime(o) > File.mtime(hdr_of_src(f))
88
92
 
89
93
  compile(f, o)
90
94
  end
@@ -2,7 +2,7 @@ module Canoe
2
2
  class WorkSpace
3
3
  def self.version
4
4
  puts <<~VER
5
- canoe v0.3.2.3
5
+ canoe v0.3.2.4
6
6
  For features in this version, please visit https://github.com/Dicridon/canoe
7
7
  Currently, canoe can do below:
8
8
  - project creation
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canoe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.3
4
+ version: 0.3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - XIONG Ziwei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-18 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |+
14
14
  Canoe offers project management and building facilities to C/C++ projects.