shog-build 0.1.1 → 0.1.2

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
- SHA256:
3
- metadata.gz: 7f49d027a321448925e0f892832dccc8b404ca19bc4bc0562c1d8f590e7bcc56
4
- data.tar.gz: 3e6e8a0c6735f9f384fbfae3801a7dc9dd308a66741e8cb984b0b1bf666d2905
2
+ SHA1:
3
+ metadata.gz: a26351c3bae67007049fe193705610225870f2b2
4
+ data.tar.gz: 5fd6af4692ed58a853d217cb17e865d998640382
5
5
  SHA512:
6
- metadata.gz: 42fe34af7f11eae56ed29ab62143436c9edfdfd6cddfb39e4467081e6ff9be6e8ea025eaab644991eb662d73a2dba3ece969db197c42e54e2c64a4c8e1f7bf06
7
- data.tar.gz: a0d658bd2812311da1d7814d928d974cffe871e6e1e0dc2f0139b6329d5a3fd8d0be69bbe7ed3e317affd41d9d6471bedec75ab80314620502f4b679052757e5
6
+ metadata.gz: 0e57714c706dd40877a7779ad0ac0c1820ed4fe0834f0b86dd778998007066e4ea190b7f6d0d477b0765dd8afd0cf17f422f101d73287da1fc38d5444d22c842
7
+ data.tar.gz: 1e1a0af9442049652ed6a89e78ebf7122ce4b4119c8ee3b7c3b2492f0f92803ba46d8d3871c30dfb22b0a0184010e0f36c96e06fb9477b3fe1523dbb4ecd30d7
data/lib/context.rb CHANGED
@@ -1,5 +1,5 @@
1
- require_relative 'util'
2
- require_relative 'pathset'
1
+ require_relative "util"
2
+ require_relative "pathset"
3
3
 
4
4
  module Shog
5
5
  # An instance of this class is visible to our build scripts with name @shog
@@ -30,7 +30,7 @@ module Shog
30
30
  ctx = new_ctx ? deep_clone() : self
31
31
 
32
32
  Path.pwd = File.join(Path.pwd, dir)
33
- script = cwd('shog.build')
33
+ script = cwd("shog.build")
34
34
  @rule[:generate_build].deps << script
35
35
  script_name = script.path
36
36
  build_script = File.read(script_name)
data/lib/generator.rb CHANGED
@@ -1,10 +1,10 @@
1
- require_relative 'context'
2
- require_relative 'rule/cc'
3
- require_relative 'rule/link'
4
- require_relative 'rule/objcopy'
5
- require_relative 'rule/kconfig'
6
- require_relative 'rule/generate_build'
7
- require_relative 'rule/yacc'
1
+ require_relative "context"
2
+ require_relative "rule/cc"
3
+ require_relative "rule/link"
4
+ require_relative "rule/objcopy"
5
+ require_relative "rule/kconfig"
6
+ require_relative "rule/generate_build"
7
+ require_relative "rule/yacc"
8
8
 
9
9
  module Shog
10
10
  class Generator
@@ -16,8 +16,9 @@ module Shog
16
16
  emitter = @backend.emitter
17
17
  ctx = Context.new(@backend, emitter)
18
18
 
19
- if File.exists?('Kconfig') and not File.exists?('.config')
20
- system 'conf --alldefconfig -s Kconfig'
19
+ if File.exists?("Kconfig") and not File.exists?(".config")
20
+ success = system("conf --alldefconfig -s Kconfig")
21
+ exit 1 unless success
21
22
  end
22
23
 
23
24
  # Register all rules
@@ -28,8 +29,8 @@ module Shog
28
29
  ctx.register_rule(GenerateBuild)
29
30
  ctx.register_rule(Yacc)
30
31
 
31
- Path.pwd = '.'
32
- ctx.visit_dir('.', false)
32
+ Path.pwd = "."
33
+ ctx.visit_dir(".", false)
33
34
 
34
35
  emitter.default(ctx.default_target)
35
36
 
data/lib/ninja.rb CHANGED
@@ -3,8 +3,8 @@ module Shog
3
3
  attr_reader :backend_file
4
4
 
5
5
  def initialize
6
- @out_dir = 'out'
7
- @backend_file = File.join(@out_dir, 'build.ninja')
6
+ @out_dir = "out"
7
+ @backend_file = File.join(@out_dir, "build.ninja")
8
8
  end
9
9
 
10
10
  def configured?
@@ -21,7 +21,7 @@ module Shog
21
21
 
22
22
  class Emitter
23
23
  def initialize(file)
24
- @out = File.open(file, 'w')
24
+ @out = File.open(file, "w")
25
25
  end
26
26
 
27
27
  def finish
@@ -30,7 +30,7 @@ module Shog
30
30
 
31
31
  def default(target)
32
32
  unless target.empty?
33
- @out.puts "default #{target.join(' ')}"
33
+ @out.puts "default #{target.join(" ")}"
34
34
  @out.puts
35
35
  end
36
36
  end
@@ -46,13 +46,13 @@ module Shog
46
46
 
47
47
  def emit(target)
48
48
  rule = target[:rule]
49
- input = target[:input].join(' ')
49
+ input = target[:input].join(" ")
50
50
  implicit_input = if target[:implicit_input] and not target[:implicit_input].empty?
51
- ' | ' + target[:implicit_input].join(' ')
51
+ " | " + target[:implicit_input].join(" ")
52
52
  else
53
- ''
53
+ ""
54
54
  end
55
- output = target[:output].join(' ')
55
+ output = target[:output].join(" ")
56
56
  variables = target[:variables]
57
57
  @out.puts "build #{output}: #{rule} #{input}#{implicit_input}"
58
58
  for k, v in variables
data/lib/path.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'pathname'
1
+ require "pathname"
2
2
 
3
3
  module Shog
4
4
  class Path
5
- @pwd = '.'
5
+ @pwd = "."
6
6
 
7
7
  class << self
8
8
  attr_accessor :pwd
@@ -65,7 +65,7 @@ module Shog
65
65
  if @outoftree or @absolute
66
66
  @path
67
67
  else
68
- File.join('..', @path)
68
+ File.join("..", @path)
69
69
  end
70
70
  end
71
71
  end
data/lib/pathset.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative 'path'
1
+ require_relative "path"
2
2
 
3
3
  module Shog
4
4
  class PathSet < Array
data/lib/rule/cc.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../path'
1
+ require_relative "../path"
2
2
 
3
3
  module Shog
4
4
  class CC
@@ -16,10 +16,10 @@ module Shog
16
16
 
17
17
  def rule
18
18
  {
19
- 'command' => '$bin $cflags -MMD -MQ $out -MF $out.d -c $in -o $out',
20
- 'description' => 'Compile $in',
21
- 'deps' => 'gcc',
22
- 'depfile' => '$out.d',
19
+ "command" => "$bin $cflags -MMD -MQ $out -MF $out.d -c $in -o $out",
20
+ "description" => "Compile $in",
21
+ "deps" => "gcc",
22
+ "depfile" => "$out.d",
23
23
  }
24
24
  end
25
25
 
@@ -31,25 +31,25 @@ module Shog
31
31
  if params[:output]
32
32
  output << Path.make(params[:output], :outoftree => true)
33
33
  else
34
- output << Path.make(params[:input].single_path, :outoftree => true).with_suffix('.o')
34
+ output << Path.make(params[:input].single_path, :outoftree => true).with_suffix(".o")
35
35
  end
36
36
 
37
37
  cflags = @cflags.dup
38
38
  cflags << params[:cflags] if params[:cflags]
39
- cflags += @includes.map { |i| '-I' + i }
39
+ cflags += @includes.map { |i| "-I" + i }
40
40
  includes = params[:includes]
41
41
  if includes
42
42
  includes = PathSet.make(includes)
43
- cflags += includes.map { |i| '-I' + i }
43
+ cflags += includes.map { |i| "-I" + i }
44
44
  end
45
45
 
46
46
  variables = {
47
- 'cflags' => cflags.join(' '),
48
- 'bin' => params[:bin] || @bin || 'gcc',
47
+ "cflags" => cflags.join(" "),
48
+ "bin" => params[:bin] || @bin || "gcc",
49
49
  }
50
50
  implicit_input = @implicit_input.dup
51
51
  implicit_input += params[:implicit_input] if params[:implicit_input]
52
- {:rule => 'cc', :input => input, :implicit_input => implicit_input, :output => output, :variables => variables}
52
+ {:rule => "cc", :input => input, :implicit_input => implicit_input, :output => output, :variables => variables}
53
53
  end
54
54
  end
55
55
  end
@@ -1,4 +1,4 @@
1
- require_relative '../path'
1
+ require_relative "../path"
2
2
 
3
3
  module Shog
4
4
  class GenerateBuild
@@ -14,20 +14,20 @@ module Shog
14
14
 
15
15
  def rule
16
16
  {
17
- 'command' => 'cd .. && shog generate',
18
- 'description' => 'Generate Build Script',
17
+ "command" => "cd .. && (shog generate || rm out/build.ninja)",
18
+ "description" => "Generate Build Script",
19
19
  }
20
20
  end
21
21
 
22
22
  def target(params)
23
23
  output = PathSet.new
24
- output << Path.make('build.ninja', :outoftree => true, :root => true)
24
+ output << Path.make("build.ninja", :outoftree => true, :root => true)
25
25
  variables = {
26
- 'generator' => '1',
26
+ "generator" => "1",
27
27
  }
28
28
  input = PathSet.new(params[:input])
29
29
  input += @deps
30
- {:rule => 'generate_build', :input => input, :output => output, :variables => variables}
30
+ {:rule => "generate_build", :input => input, :output => output, :variables => variables}
31
31
  end
32
32
  end
33
33
  end
data/lib/rule/kconfig.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../path'
1
+ require_relative "../path"
2
2
 
3
3
  module Shog
4
4
  class Kconfig
@@ -12,21 +12,21 @@ module Shog
12
12
 
13
13
  def rule
14
14
  {
15
- 'command' => 'KCONFIG_CONFIG=$out conf --oldconfig -s $in',
16
- 'description' => 'Generate .config file',
15
+ "command" => "KCONFIG_CONFIG=$out conf --oldconfig -s $in",
16
+ "description" => "Generate .config file",
17
17
  }
18
18
  end
19
19
 
20
20
  def target(params)
21
21
  output = PathSet.new(Path.make(params[:output]))
22
22
  input = PathSet.new(Path.make(params[:input]))
23
- {:rule => 'kconfig', :input => input, :output => output}
23
+ {:rule => "kconfig", :input => input, :output => output}
24
24
  end
25
25
 
26
26
  def self.parse(file)
27
27
  config = {}
28
28
  for line in IO.readlines(file)
29
- next if line.start_with?('#')
29
+ next if line.start_with?("#")
30
30
  if line =~ /^CONFIG_(.*?)=(.*)$/
31
31
  key = $1.to_sym
32
32
  val = $2
data/lib/rule/link.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../path'
1
+ require_relative "../path"
2
2
 
3
3
  module Shog
4
4
  class Link
@@ -14,8 +14,8 @@ module Shog
14
14
 
15
15
  def rule
16
16
  {
17
- 'command' => '$bin $ldflags $in -o $out',
18
- 'description' => 'Linking $out',
17
+ "command" => "$bin $ldflags $in -o $out",
18
+ "description" => "Linking $out",
19
19
  }
20
20
  end
21
21
 
@@ -24,17 +24,17 @@ module Shog
24
24
  input = PathSet.make(params[:input])
25
25
  ldflags = params[:ldflags]
26
26
  if ldflags.nil?
27
- ldflags = ''
27
+ ldflags = ""
28
28
  elsif ldflags.is_a?(Array)
29
- ldflags = ldflags.join(' ')
29
+ ldflags = ldflags.join(" ")
30
30
  end
31
31
  variables = {
32
- 'ldflags' => ldflags,
33
- 'bin' => params[:bin] || @bin || 'gcc',
32
+ "ldflags" => ldflags,
33
+ "bin" => params[:bin] || @bin || "gcc",
34
34
  }
35
35
  implicit_input = @implicit_input.dup
36
36
  implicit_input += params[:implicit_input] if params[:implicit_input]
37
- {:rule => 'ld', :input => input, :implicit_input => implicit_input, :output => output, :variables => variables}
37
+ {:rule => "ld", :input => input, :implicit_input => implicit_input, :output => output, :variables => variables}
38
38
  end
39
39
  end
40
40
  end
data/lib/rule/objcopy.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../path'
1
+ require_relative "../path"
2
2
 
3
3
  module Shog
4
4
  class ObjCopy
@@ -10,8 +10,8 @@ module Shog
10
10
 
11
11
  def rule
12
12
  {
13
- 'command' => '$bin -O $arch $in $out',
14
- 'description' => 'Objcopy $out',
13
+ "command" => "$bin -O $arch $in $out",
14
+ "description" => "Objcopy $out",
15
15
  }
16
16
  end
17
17
 
@@ -26,10 +26,10 @@ module Shog
26
26
  end
27
27
 
28
28
  variables = {
29
- 'bin' => params[:bin] || @bin || 'objcopy',
29
+ "bin" => params[:bin] || @bin || "objcopy",
30
30
  }
31
- variables['arch'] = params[:arch] if params[:arch]
32
- {:rule => 'objcopy', :input => input, :output => output, :variables => variables}
31
+ variables["arch"] = params[:arch] if params[:arch]
32
+ {:rule => "objcopy", :input => input, :output => output, :variables => variables}
33
33
  end
34
34
  end
35
35
  end
data/lib/rule/yacc.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../path'
1
+ require_relative "../path"
2
2
 
3
3
  module Shog
4
4
  class Yacc
@@ -8,15 +8,15 @@ module Shog
8
8
 
9
9
  def rule
10
10
  {
11
- 'command' => 'yacc -o $out $in',
12
- 'description' => 'Yacc $in',
11
+ "command" => "yacc -o $out $in",
12
+ "description" => "Yacc $in",
13
13
  }
14
14
  end
15
15
 
16
16
  def target(params)
17
17
  input = PathSet.make(params[:input])
18
18
  output = PathSet.make(Path.make(params[:output], :outoftree => true))
19
- {:rule => 'yacc', :input => input, :output => output, :variables => {}}
19
+ {:rule => "yacc", :input => input, :output => output, :variables => {}}
20
20
  end
21
21
  end
22
22
  end
data/lib/runner.rb CHANGED
@@ -1,9 +1,9 @@
1
- require_relative 'ninja'
2
- require_relative 'generator'
1
+ require_relative "ninja"
2
+ require_relative "generator"
3
3
 
4
4
  module Shog
5
5
  module Runner
6
- WORKDIR = 'out'
6
+ WORKDIR = "out"
7
7
 
8
8
  def generate(backend)
9
9
  Dir.mkdir(WORKDIR) unless Dir.exists?(WORKDIR)
@@ -12,7 +12,7 @@ module Shog
12
12
  end
13
13
 
14
14
  def run(argv)
15
- unless File.exists?('shog.build')
15
+ unless File.exists?("shog.build")
16
16
  puts "shog.build file is not found in #{Dir.pwd}"
17
17
  exit 1
18
18
  end
@@ -20,13 +20,14 @@ module Shog
20
20
  backend = Ninja.new
21
21
 
22
22
  cmd = argv[0]
23
- if cmd == 'generate'
23
+ if cmd == "generate"
24
24
  generate(backend)
25
25
  return
26
26
  end
27
27
 
28
28
  generate(backend) unless backend.configured?
29
- backend.run
29
+ success = backend.run
30
+ exit 1 unless success
30
31
  end
31
32
 
32
33
  module_function :run, :generate
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shog-build
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatol Pomozov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-19 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project:
87
- rubygems_version: 2.7.6
87
+ rubygems_version: 2.5.2.2
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Ruby frontend for Ninja build system