canoe 0.2.3 → 0.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: 1d9763386960dfa876185c776041f832de8e6ff3fc050327fc8c616a02467137
4
- data.tar.gz: fde0dde4b2c9fc3a360a2bf91f2eb6828439cea7ea15d88790bae382abebbad7
3
+ metadata.gz: 6e9bebbc3472c5f6271c4c019f23bf18779492934ed86411f4d09384e51bfeab
4
+ data.tar.gz: 9aa82b75a58e0992653ddc5419bf14e129846cc54cc9358f08baa1d2014d8d5a
5
5
  SHA512:
6
- metadata.gz: 9fd27c0889f66c239c0c305b7554418c3afe9b40bf7a1d6eaa3eb9e76e13247dcec8ddee48aeb58dfbfc8995f13ac05dd63de36837d680c87c6dbbf932b657b2
7
- data.tar.gz: 27655015444a90c232c398b8f7e02d4dfb454769d68086e4dcaa7039f41bae8cee33968cce105cf36ab92bde0b10464251e79b5443385f2f5598aa6ce593b054
6
+ metadata.gz: fd9be9cc303239eaa9853c177501e460023279a6385094afbe79e55b912257cebe72860633b53503dff96583a61aa88ea6034ce0e741e36f4fce8acce33c2496
7
+ data.tar.gz: 6ee389790c8490d80ef9742e877fc0de8b13b6b74629361e68f363155c628a0dff1764d066f4608b0b7e7cef72f20b1775c2b214be487b4bdcf943ab1b985c3f
@@ -18,12 +18,18 @@ class Compiler
18
18
  system "#{name} -o #{out} #{flags_as_str} -c #{src}"
19
19
  end
20
20
 
21
- def link(out, objs)
21
+ def link_executable(out, objs)
22
22
  libs = flags.select {|f| f.start_with?('-l')}
23
23
  puts "#{name} -o #{out} #{objs.join(" ")} #{libs.join(" ")}"
24
24
  system "#{name} -o #{out} #{objs.join(" ")} #{libs.join(" ")}"
25
25
  end
26
26
 
27
+ def link_shared(out, objs)
28
+ libs = flags.select {|f| f.start_with?('-l')}
29
+ puts "#{name} -shared -o #{out}.so #{objs.join(" ")} #{libs.join(" ")}"
30
+ system "#{name} -shared -o #{out}.so #{objs.join(" ")} #{libs.join(" ")}"
31
+ end
32
+
27
33
  def inspect
28
34
  puts "compiler name: #{name.inspect}"
29
35
  puts "compiler flags: #{flags.inspect}"
@@ -35,6 +35,18 @@ class DefaultFiles
35
35
  )
36
36
  end
37
37
 
38
+ def self.create_lib_header(path, lib_name, suffix='hpp')
39
+ open_file_and_write(
40
+ "#{path}/#{lib_name}.#{suffix}",
41
+ <<~DOC
42
+ #ifndef __#{lib_name.upcase}__
43
+ #define __#{lib_name.upcase}__
44
+
45
+ #endif
46
+ DOC
47
+ )
48
+ end
49
+
38
50
  def self.create_emacs_dir_local(path)
39
51
  open_file_and_write(
40
52
  "#{path}/.dir-locals.el",
@@ -52,7 +64,7 @@ class DefaultFiles
52
64
  "#{filename}.#{src_sfx}",
53
65
  <<~DOC
54
66
  #include "#{filename}.#{hdr_sfx}"
55
- DOC
67
+ DOC
56
68
  )
57
69
  end
58
70
 
@@ -18,7 +18,9 @@ class WorkSpace
18
18
 
19
19
  canoe build: compile current project (execute this command in project directory)
20
20
 
21
- canoe generate: generate dependency relationship and store it in '.canoe.deps'
21
+ canoe generate: generate dependency relationships and store it in '.canoe.deps' file. Alias: update
22
+
23
+ canoe update: udpate dependency relationships and store it in '.canoe.deps' file.
22
24
 
23
25
  canoe run: compile and execute current project (execute this command in project directory)
24
26
 
@@ -27,7 +29,8 @@ class WorkSpace
27
29
  canoe help: show this help message
28
30
 
29
31
  canoe add tada: add a folder named tada under workspace/components,
30
- two files tada.hpp and tada.cpp would be craeted and intialized
32
+
33
+ canoe dep: show current dependency relationships of current project
31
34
 
32
35
  canoe verion: version information
33
36
 
@@ -38,11 +41,21 @@ class WorkSpace
38
41
 
39
42
  [mode]: --lib for a library and --bin for executable binaries
40
43
  [suffixes]: should be in 'source_suffix:header_suffix" format, notice the ':' between two suffixes
44
+ add component_name:
45
+ add a folder named tada under workspace/components.
46
+ two files tada.hpp and tada.cpp would be craeted and intialized. File suffix may differ according users' specifications.
47
+ if component_name is a path separated by '/', then canoe would create folders and corresponding files recursively.
41
48
 
42
49
  generate:
43
50
  generate dependence relationship for each file, this may accelarate
44
51
  `canoe buid` command. It's recommanded to execute this command everytime
45
52
  headers are added or removed from any file.
53
+
54
+ update:
55
+ this command is needed because '.canoe.deps' is actually a cache of dependency relationships so that
56
+ canoe doesn't have to analyze all the files when building a project.
57
+ So when a file includes new headers or some headers are removed, users have to use 'canoe udpate'
58
+ to update dependency relationships.
46
59
 
47
60
  build [options]:
48
61
  build current project, arguments in [options] will be passed to C++ compiler
@@ -95,7 +108,11 @@ class WorkSpace
95
108
  Dir.mkdir(@src)
96
109
  Dir.mkdir(@components)
97
110
  Dir.mkdir("#{@workspace}/obj")
98
- DefaultFiles.create_main(@src, @source_suffix) if @mode == :bin
111
+ if @mode == :bin
112
+ DefaultFiles.create_main(@src, @source_suffix)
113
+ else
114
+ DefaultFiles.create_lib_header(@src, @name, @header_suffix)
115
+ end
99
116
  File.new("#{@workspace}/.canoe", "w")
100
117
  DefaultFiles.create_config @workspace, @source_suffix, @header_suffix
101
118
  DefaultFiles.create_emacs_dir_local @workspace
@@ -136,6 +153,7 @@ class WorkSpace
136
153
  end
137
154
 
138
155
  def run(args)
156
+ return if @mode == :lib
139
157
  build []
140
158
  args = args.join " "
141
159
  puts "./target/#{@name} #{args}"
@@ -208,18 +226,30 @@ class WorkSpace
208
226
  @compiler.compile f, o
209
227
  end
210
228
 
211
- def link(odir, objs)
212
- status = system "#{@compiler} -o #{odir}/#{@name} #{objs.join(" ")}"
213
- unless status
214
- puts "compilation failed"
215
- return
216
- end
217
-
218
- @compiler.link "#{odir}/#{@name}", objs
229
+ def link_exectutable(odir, objs)
230
+ @compiler.link_executable "#{odir}/#{@name}", objs
231
+ end
232
+
233
+ def link_shared(odir, objs)
234
+ @compiler.link_shared "#{odir}/lib#{@name}", objs
219
235
  end
220
236
 
221
237
  def build_bin(files, args)
238
+ return if files.empty?
222
239
  build_compiler_from_config args
240
+ build_common files, args
241
+ link_exectutable('./target', Dir.glob("obj/*.o"))
242
+ end
243
+
244
+ def build_lib(files, args)
245
+ return if files.empty?
246
+ build_compiler_from_config args
247
+ @compiler.append_flag '-fPIC'
248
+ build_common files, args
249
+ link_shared('./target', Dir.glob("obj/*.o"))
250
+ end
251
+
252
+ def build_common(files, args)
223
253
  comps = files.select {|f| f.start_with? @components_prefix}
224
254
  srcs = files - comps
225
255
 
@@ -236,12 +266,6 @@ class WorkSpace
236
266
  .gsub('/', '_') + '.o'
237
267
  compile f, o
238
268
  end
239
-
240
- link('./target', Dir.glob("obj/*.o")) unless files.empty?
241
- end
242
-
243
- def build_lib
244
- puts "build a lib"
245
269
  end
246
270
 
247
271
  def clean_obj
metadata CHANGED
@@ -1,19 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canoe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.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: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |
14
- Tired of writing Makefile, CMakeList and even SConstruct? Let Canoe help you wipe them out.
13
+ description: |+
14
+ Canoe offers project management and building facilities to C/C++ projects.
15
+
16
+ If you are tired of writing Makefile, CMakeList and even SConstruct, please let Canoe help you wipe them out.
17
+
15
18
  Similar to Cargo for Rust, Canoe offers commands such as new, build, run, etc. to help you generate a C/C++ project and build it automatically.
16
- No more Makefiles, Canoe would analyze dependencies and build like our old friend make if you follow a few conventions over file names
19
+
20
+ Different from tools like Scons and Blade, Canoe requires users to write NO building scripts, Canoe would analyze dependencies and build like our old friend 'make' if a few conventions over file names are followed.
21
+
17
22
  email: noahxiong@outlook.com
18
23
  executables:
19
24
  - canoe
@@ -52,5 +57,5 @@ requirements: []
52
57
  rubygems_version: 3.1.2
53
58
  signing_key:
54
59
  specification_version: 4
55
- summary: a C/C++ project management and build tool
60
+ summary: a C/C++ project management and building tool
56
61
  test_files: []