comet-build 0.1.5 → 0.1.6

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
  SHA1:
3
- metadata.gz: e6d1b9c646e5148cd226250a5eff737bc29c33b7
4
- data.tar.gz: 1312bf7a715b183187680a19ffb11df391c3f287
3
+ metadata.gz: 2c00a89fe790f0f634689c7c6e41f41cd61a85f6
4
+ data.tar.gz: aed176dc8182228ac62e9397a0fdc29dd0eaad6d
5
5
  SHA512:
6
- metadata.gz: e32b6e0da93bdc14e78ef6ce41f5797de15438c179532f8d45f1e2d1f8cf17293cd03006f28cfdde2833d8bc6f1569e7aa46b08a4ae47ed834937234964460f2
7
- data.tar.gz: 9061dad804552e02fc956ee5fb3ee0ddaf03bd016a08015bfea61f105402794119b88122e7425d5ae761e358f9bb943d81b7f7f7ae1bf05f94e6113f102e1d2c
6
+ metadata.gz: 6237b71f39a4f7746ebeb2dad06dc2fd8373f6d5baf8560101de9715c88e1ec3eaca0a08de58766e8a94fb8fddae0a673daadfeec377bf5d7b118c27fb9af58f
7
+ data.tar.gz: 0ac5632fbd6b3310714f1491dab2d268dea17ccc11fc498ca5e14dffa1cfe1efb27dc323dad5fe48cdf522e4732dfe9c06f8732da4e2d86695ec847b4e165020
data/README.md CHANGED
@@ -13,7 +13,7 @@ Comet is a no-nonsense build tool primarily oriented towards embedded or cross-c
13
13
 
14
14
  Functionally, Comet is a Makefile generator which accepts a domain-specific language from a build file, produces a Makefile, and executes it, placing all intermediate files inside a hidden `.comet` temporary directory. The only thing you need to do as a developer is write your `comet.rb` build file and add `.comet` to your gitignore file.
15
15
 
16
- **WARNING**: this software is still in the testing phase, use in production at your own risk. Improvement suggestions and pull requests are welcome and appreciated. Currently only the C language is supported (C++ will be added shortly) and the tool probably only works on Linux as of now, but just a couple parts of the code are OS-dependent.
16
+ **WARNING**: this software is still in the testing phase, use in production at your own risk. Improvement suggestions and pull requests are welcome and appreciated. Currently only C and C++ language support is implemented through Clang and the tool probably only works on Linux as of now, but just a couple parts of the code are OS-dependent.
17
17
 
18
18
  Installation
19
19
  ------------
@@ -43,6 +43,7 @@ Language support for compiling source files is shown below. Adding support for a
43
43
  | -------- | ----------- | ------------------ |
44
44
  | *Native* | `:native` | None (link-only) |
45
45
  | C | `:c` | Clang |
46
+ | C++ | `:cpp` | Clang |
46
47
 
47
48
  Native languages are those for which the source code is either already LLVM bitcode, or is already in a lower representation than LLVM IR, such as assembly. These will be passed directly to the linker after compiled LLVM bitcode, therefore:
48
49
 
@@ -53,7 +54,6 @@ Native languages are those for which the source code is either already LLVM bitc
53
54
  Planned features
54
55
  ----------------
55
56
 
56
- - C++ language support
57
57
  - Windows support
58
58
  - Clarification of linker parameters (triple, isa, cpu)
59
59
  - Ability to import other build files recursively
@@ -225,14 +225,14 @@ source language: :native do
225
225
  end
226
226
  ```
227
227
 
228
- ### C Source Directive
228
+ ### C/C++ Source Directive
229
229
 
230
- C source directives take an array of header include paths as a parameter, and accept source file import directives, option directives (to pass in compiler flags) and define directives (to pass in preprocessor macros).
230
+ C/C++ source directives take an array of header include paths as a parameter, and accept source file import directives, option directives (to pass in compiler flags) and define directives (to pass in preprocessor macros).
231
231
 
232
232
  #### Grammar
233
233
 
234
234
  ```ruby
235
- source language: :c, headers: ['dir1', 'dir2', ...] do
235
+ source language: :c|:cpp, headers: ['dir1', 'dir2', ...] do
236
236
  # import directives
237
237
  # option directives
238
238
  # define directives
@@ -250,6 +250,12 @@ source language: :c, headers: ['include'] do
250
250
  end
251
251
  ```
252
252
 
253
+ You can unset a previously defined option by using the special symbol `:remove` as a value. For instance:
254
+
255
+ ```ruby
256
+ option :Werror => :remove
257
+ ```
258
+
253
259
  Advanced Usage
254
260
  --------------
255
261
 
@@ -297,6 +303,10 @@ hardware 'hal', targets: :device2 do
297
303
  end
298
304
  ```
299
305
 
306
+ ### Overriding external programs
307
+
308
+ Any external tool called by a Comet-generated Makefile can be overridden through environment variables of the form `COMET_TOOLNAME`. For instance, `cp` is invoked through `COMET_CP`, `clang` is invoked through `COMET_CLANG`, and so on. You can see the list of tools by inspecting the generated Makefile with `comet -s`, they will be at the top.
309
+
300
310
  ### Some helper Ruby methods
301
311
 
302
312
  In the spirit of its DSL, Comet defines some convenience methods to make your build file more expressive.
@@ -1,6 +1,6 @@
1
1
  module Comet
2
2
  module DSL
3
- module C
3
+ module CLike
4
4
  class Source
5
5
  include Comet::DSL::Helpers
6
6
  alias inject instance_exec
@@ -17,7 +17,8 @@ module Comet
17
17
  @options.add('D', *args, **kwargs)
18
18
  end
19
19
 
20
- def initialize(headers:, &block)
20
+ def initialize(language:, headers:, &block)
21
+ @language = language
21
22
  @headers = headers
22
23
  @imports = []
23
24
  @options = Comet::DSL::Options.new
@@ -26,17 +27,18 @@ module Comet
26
27
  end
27
28
 
28
29
  def to_s
29
- 'C source'
30
+ if language == :c
31
+ 'C source'
32
+ elsif language == :cpp
33
+ 'C++ source'
34
+ end
30
35
  end
31
36
 
37
+ attr_reader :language
32
38
  attr_reader :headers
33
39
  attr_reader :imports
34
40
  attr_reader :options
35
41
 
36
- def language
37
- :c
38
- end
39
-
40
42
  def native?
41
43
  false
42
44
  end
@@ -4,15 +4,21 @@ module Comet
4
4
  class << self
5
5
  def create(language:, **kwargs, &block)
6
6
  raise "unknown language #{language}" unless valid? language
7
- LANGUAGES[language].new(**kwargs, &block) # pass extra args
7
+ LANGUAGES[language].call(**kwargs, &block)
8
8
  end
9
9
 
10
10
  private
11
11
 
12
12
  LANGUAGES = {
13
- c: C::Source,
14
- cpp: CPP::Source,
15
- native: Native::Source
13
+ c: proc do |**kwargs, &block|
14
+ CLike::Source.new(language: :c, **kwargs, &block)
15
+ end,
16
+ cpp: proc do |**kwargs, &block|
17
+ CLike::Source.new(language: :cpp, **kwargs, &block)
18
+ end,
19
+ native: proc do |**kwargs, &block|
20
+ Native::Source.new(**kwargs, &block)
21
+ end
16
22
  }.freeze
17
23
 
18
24
  def valid?(language)
@@ -13,6 +13,7 @@ module Comet
13
13
  triple: @linker.triple,
14
14
  isa: @linker.isa,
15
15
  cpu: @linker.cpu,
16
+ language: @source.language,
16
17
  flags: Set[formatted_flags],
17
18
  headers: formatted_headers,
18
19
  dependencies: Set[dependencies]
@@ -52,7 +53,7 @@ module Comet
52
53
  [
53
54
  '$(COMET_CC)',
54
55
  '-x',
55
- 'c',
56
+ @source.language == :c ? 'c' : 'c++',
56
57
  "--target=#{@linker.triple}",
57
58
  "-march=#{@linker.isa}",
58
59
  "-mcpu=#{@linker.cpu}",
data/lib/comet/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Comet
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
@@ -9,48 +9,48 @@ COMET_RM ?= rm
9
9
  .PHONY: all
10
10
  all: test
11
11
  .PHONY: test
12
- test: .comet/41f8b3e8804fea68ec6b.phony .comet/b5c19fd070359b597edd.phony
12
+ test: .comet/8030c3912f57888f83ad.phony .comet/70ed28144e43c7deae81.phony
13
13
  .PHONY: test/linux_x64
14
- test/linux_x64: .comet/b5c19fd070359b597edd.phony
14
+ test/linux_x64: .comet/70ed28144e43c7deae81.phony
15
15
  .PHONY: test/linux_x86
16
- test/linux_x86: .comet/41f8b3e8804fea68ec6b.phony
16
+ test/linux_x86: .comet/8030c3912f57888f83ad.phony
17
17
  .PHONY: .comet
18
18
  .comet:
19
19
  if [ ! -d "$@" ] || [ ! -d "`readlink .comet`" ]; then $(COMET_LN) -sf `mktemp -d` $@; fi
20
- .PHONY: .comet/41f8b3e8804fea68ec6b.phony
21
- .comet/41f8b3e8804fea68ec6b.phony: .comet/58e4769019097316a2f4.elf .comet/3bc14a6c241d158c30cd.bin
22
- $(COMET_CP) .comet/58e4769019097316a2f4.elf bin/test_linux_x86.elf
23
- $(COMET_CP) .comet/3bc14a6c241d158c30cd.bin bin/test_linux_x64.bin
24
- $(COMET_CP) .comet/58e4769019097316a2f4.map bin/test_linux_x86.map
25
- .comet/58e4769019097316a2f4.elf: .comet/55978226b396c7da38ec.s | .comet
26
- $(COMET_LD) --target=x86-unknown-linux-gnu -march=skylake -mcpu=skylake -Wl,-Map=.comet/58e4769019097316a2f4.map -o $@ $^
27
- .comet/55978226b396c7da38ec.s: .comet/45b8ac54c1523683a185.ll | .comet
20
+ .PHONY: .comet/8030c3912f57888f83ad.phony
21
+ .comet/8030c3912f57888f83ad.phony: .comet/e542f5d8ea9b413c1db8.elf .comet/e7b25529bcd9f873ade7.bin
22
+ $(COMET_CP) .comet/e542f5d8ea9b413c1db8.elf bin/test_linux_x86.elf
23
+ $(COMET_CP) .comet/e7b25529bcd9f873ade7.bin bin/test_linux_x64.bin
24
+ $(COMET_CP) .comet/e542f5d8ea9b413c1db8.map bin/test_linux_x86.map
25
+ .comet/e542f5d8ea9b413c1db8.elf: .comet/ae8d70c4ad166e5f05e6.s | .comet
26
+ $(COMET_LD) --target=x86-unknown-linux-gnu -march=skylake -mcpu=skylake -Wl,-Map=.comet/e542f5d8ea9b413c1db8.map -o $@ $^
27
+ .comet/ae8d70c4ad166e5f05e6.s: .comet/1a6fa701e7f59b5130cf.ll | .comet
28
28
  $(COMET_OPT) -S -Ofast --target=x86-unknown-linux-gnu -march=skylake -mcpu=skylake -o $@ $<
29
- .comet/45b8ac54c1523683a185.ll: .comet/066c9d603b1250716309.ll .comet/1eddb1ee8e3f2bd08fa2.ll .comet/e49cdc7c30bb85a26a1e.ll | .comet
29
+ .comet/1a6fa701e7f59b5130cf.ll: .comet/848a630ef53895b3e139.ll .comet/44b0462bd14ef6c5f324.ll .comet/3e98d572194d9f0797c2.ll | .comet
30
30
  $(COMET_LINK) -S -o $@ $^
31
- .comet/066c9d603b1250716309.ll: src/module_a/impl.c src/module_a/impl.h src/common.h include/public_api.h | .comet
31
+ .comet/848a630ef53895b3e139.ll: src/module_a/impl.c src/module_a/impl.h src/common.h include/public_api.h | .comet
32
32
  $(COMET_CC) -x c --target=x86-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -Isrc -Iinclude -DFOO=BAR -std=c89 -o $@ -c $<
33
- .comet/1eddb1ee8e3f2bd08fa2.ll: src/module_b/impl.c src/module_b/impl.h src/common.h include/public_api.h | .comet
33
+ .comet/44b0462bd14ef6c5f324.ll: src/module_b/impl.c src/module_b/impl.h src/common.h include/public_api.h | .comet
34
34
  $(COMET_CC) -x c --target=x86-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -Isrc -Iinclude -DFOO=BAZ -std=c89 -o $@ -c $<
35
- .comet/e49cdc7c30bb85a26a1e.ll: src/main.c src/common.h src/library.h src/module_a/impl.h src/module_b/impl.h include/public_api.h | .comet
35
+ .comet/3e98d572194d9f0797c2.ll: src/main.c src/common.h src/library.h src/module_a/impl.h src/module_b/impl.h include/public_api.h | .comet
36
36
  $(COMET_CC) -x c --target=x86-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -Isrc -Iinclude -std=c89 -o $@ -c $<
37
- .comet/3bc14a6c241d158c30cd.bin: .comet/58e4769019097316a2f4.elf | .comet
37
+ .comet/e7b25529bcd9f873ade7.bin: .comet/e542f5d8ea9b413c1db8.elf | .comet
38
38
  (command -v x86-unknown-linux-gnu-$(COMET_OBJCOPY) > /dev/null) && x86-unknown-linux-gnu-$(COMET_OBJCOPY) -O binary $< $@ || $(COMET_OBJCOPY) -O binary $< $@
39
- .PHONY: .comet/b5c19fd070359b597edd.phony
40
- .comet/b5c19fd070359b597edd.phony: .comet/239aef468b7c74e8eb07.elf
41
- $(COMET_CP) .comet/239aef468b7c74e8eb07.elf bin/test_linux_x64.elf
42
- $(COMET_CP) .comet/239aef468b7c74e8eb07.map bin/test_linux_x64.map
43
- .comet/239aef468b7c74e8eb07.elf: .comet/9eb2d2641e6518828e34.s | .comet
44
- $(COMET_LD) --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -Wl,-Map=.comet/239aef468b7c74e8eb07.map -o $@ $^
45
- .comet/9eb2d2641e6518828e34.s: .comet/c743dd82509170cb5828.ll | .comet
39
+ .PHONY: .comet/70ed28144e43c7deae81.phony
40
+ .comet/70ed28144e43c7deae81.phony: .comet/9dc94950d9e3e85125d8.elf
41
+ $(COMET_CP) .comet/9dc94950d9e3e85125d8.elf bin/test_linux_x64.elf
42
+ $(COMET_CP) .comet/9dc94950d9e3e85125d8.map bin/test_linux_x64.map
43
+ .comet/9dc94950d9e3e85125d8.elf: .comet/c8008c83512b753cc0f5.s | .comet
44
+ $(COMET_LD) --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -Wl,-Map=.comet/9dc94950d9e3e85125d8.map -o $@ $^
45
+ .comet/c8008c83512b753cc0f5.s: .comet/5b532eac405115700e15.ll | .comet
46
46
  $(COMET_OPT) -S -O3 --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -o $@ $<
47
- .comet/c743dd82509170cb5828.ll: .comet/9e5dea7cf944c74e7a6c.ll .comet/e054566ad272c0a69ba6.ll .comet/b299d49b84f938ace557.ll | .comet
47
+ .comet/5b532eac405115700e15.ll: .comet/4b993a43966c8f84b121.ll .comet/29c2bb990093d697ea4f.ll .comet/1872519e0f2a83f8c783.ll | .comet
48
48
  $(COMET_LINK) -S -o $@ $^
49
- .comet/9e5dea7cf944c74e7a6c.ll: src/module_a/impl.c src/module_a/impl.h src/common.h include/public_api.h | .comet
49
+ .comet/4b993a43966c8f84b121.ll: src/module_a/impl.c src/module_a/impl.h src/common.h include/public_api.h | .comet
50
50
  $(COMET_CC) -x c --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -Isrc -Iinclude -DFOO=BAR -std=c89 -o $@ -c $<
51
- .comet/e054566ad272c0a69ba6.ll: src/module_b/impl.c src/module_b/impl.h src/common.h include/public_api.h | .comet
51
+ .comet/29c2bb990093d697ea4f.ll: src/module_b/impl.c src/module_b/impl.h src/common.h include/public_api.h | .comet
52
52
  $(COMET_CC) -x c --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -Isrc -Iinclude -DFOO=BAZ -std=c89 -o $@ -c $<
53
- .comet/b299d49b84f938ace557.ll: src/main.c src/common.h src/library.h src/module_a/impl.h src/module_b/impl.h include/public_api.h | .comet
53
+ .comet/1872519e0f2a83f8c783.ll: src/main.c src/common.h src/library.h src/module_a/impl.h src/module_b/impl.h include/public_api.h | .comet
54
54
  $(COMET_CC) -x c --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -Isrc -Iinclude -std=c89 -o $@ -c $<
55
55
  .PHONY: clean
56
56
  clean:
@@ -8,22 +8,22 @@ COMET_RM ?= rm
8
8
  .PHONY: all
9
9
  all: main
10
10
  .PHONY: main
11
- main: .comet/fb5bd0bc5bbbcfb8d75d.phony
11
+ main: .comet/116dd1901deffe3fa447.phony
12
12
  .PHONY: main/linux_x64
13
- main/linux_x64: .comet/fb5bd0bc5bbbcfb8d75d.phony
13
+ main/linux_x64: .comet/116dd1901deffe3fa447.phony
14
14
  .PHONY: .comet
15
15
  .comet:
16
16
  if [ ! -d "$@" ] || [ ! -d "`readlink .comet`" ]; then $(COMET_LN) -sf `mktemp -d` $@; fi
17
- .PHONY: .comet/fb5bd0bc5bbbcfb8d75d.phony
18
- .comet/fb5bd0bc5bbbcfb8d75d.phony: .comet/6a16a16dcf71bbd81420.elf
19
- $(COMET_CP) .comet/6a16a16dcf71bbd81420.elf main
20
- .comet/6a16a16dcf71bbd81420.elf: .comet/6da374969db200830aba.s | .comet
21
- $(COMET_LD) --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -Wl,-Map=.comet/6a16a16dcf71bbd81420.map -o $@ $^
22
- .comet/6da374969db200830aba.s: .comet/d00df735d73ec90af321.ll | .comet
17
+ .PHONY: .comet/116dd1901deffe3fa447.phony
18
+ .comet/116dd1901deffe3fa447.phony: .comet/457234dc02f9dfb5542f.elf
19
+ $(COMET_CP) .comet/457234dc02f9dfb5542f.elf main
20
+ .comet/457234dc02f9dfb5542f.elf: .comet/ccb40296b80a66398214.s | .comet
21
+ $(COMET_LD) --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -Wl,-Map=.comet/457234dc02f9dfb5542f.map -o $@ $^
22
+ .comet/ccb40296b80a66398214.s: .comet/93cf4b5489860f6a6154.ll | .comet
23
23
  $(COMET_OPT) -S -O1 --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -o $@ $<
24
- .comet/d00df735d73ec90af321.ll: .comet/15a47430b29cc4417a92.ll | .comet
24
+ .comet/93cf4b5489860f6a6154.ll: .comet/02c92d481320c450e153.ll | .comet
25
25
  $(COMET_LINK) -S -o $@ $^
26
- .comet/15a47430b29cc4417a92.ll: main.c ./stuff.h | .comet
26
+ .comet/02c92d481320c450e153.ll: main.c ./stuff.h | .comet
27
27
  $(COMET_CC) -x c --target=x86_64-unknown-linux-gnu -march=skylake -mcpu=skylake -S -flto -I. -o $@ -c $<
28
28
  .PHONY: clean
29
29
  clean:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comet-build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Beneteau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2017-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,8 +114,7 @@ files:
114
114
  - comet-build.gemspec
115
115
  - lib/comet.rb
116
116
  - lib/comet/dsl/bin_output.rb
117
- - lib/comet/dsl/c/source.rb
118
- - lib/comet/dsl/cpp/source.rb
117
+ - lib/comet/dsl/clike/source.rb
119
118
  - lib/comet/dsl/elf_output.rb
120
119
  - lib/comet/dsl/firmware.rb
121
120
  - lib/comet/dsl/hardware.rb
@@ -1,57 +0,0 @@
1
- module Comet
2
- module DSL
3
- module CPP
4
- class Source
5
- include Comet::DSL::Helpers
6
- alias inject instance_exec
7
-
8
- def import(pattern)
9
- @imports.push pattern
10
- end
11
-
12
- def option(*args, **kwargs)
13
- @options.add('', *args, **kwargs)
14
- end
15
-
16
- def define(*args, **kwargs)
17
- @options.add('D', *args, **kwargs)
18
- end
19
-
20
- def initialize(headers:, &block)
21
- @headers = headers
22
- @imports = []
23
- @options = Comet::DSL::Options.new
24
-
25
- instance_exec(&block) if block_given?
26
- end
27
-
28
- def to_s
29
- 'C++ source'
30
- end
31
-
32
- attr_reader :headers
33
- attr_reader :imports
34
- attr_reader :options
35
-
36
- def language
37
- :cpp
38
- end
39
-
40
- def native?
41
- false
42
- end
43
-
44
- def files
45
- @imports.flat_map do |pattern|
46
- Dir.glob pattern
47
- end.uniq
48
- end
49
-
50
- def validate!
51
- raise "#{self} references no source files" if @imports.empty?
52
- @options.validate!
53
- end
54
- end
55
- end
56
- end
57
- end