autorake 2.4.3 → 2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9283e42b88e9467bd88e329e70ab332c19ed8694
4
+ data.tar.gz: 80072d4b2e24272af48467a9b9f710943a327698
5
+ SHA512:
6
+ metadata.gz: 5c9f5c46b36d5df91e661dcf78498a6e4160ddb54ad2f56bf5579eaf18d4037e1380f7307397e56c5a72dc2867ac5dc0eaa28c6f47246aa22ea93d35e2db57b1
7
+ data.tar.gz: 0c7620c1b621f58ffb58749cc09115168dbc21d9eaea321d0f87f54df7d040182d9dd6413ff446715ddd3267bec502267c0a8163ee95fc130bd0096178687c29
data/LICENSE CHANGED
@@ -5,7 +5,7 @@
5
5
  /_/ \_\__,_|\__\___/|_| \__,_|_|\_\___|
6
6
 
7
7
 
8
- Copyright (c) 2009-2013, Bertram Scharpf <software@bertram-scharpf.de>.
8
+ Copyright (c) 2009-2016, Bertram Scharpf <software@bertram-scharpf.de>.
9
9
  All rights reserved.
10
10
 
11
11
  Redistribution and use in source and binary forms, with or without
data/README CHANGED
@@ -6,10 +6,11 @@ License: BSD
6
6
 
7
7
  This project wants to be to Rake what Autocmd is to Make.
8
8
 
9
- Have a look at the self-explaining examples directory.
10
-
11
9
  The script mkrf_conf will build a file .configure that contains
12
10
  the whole configuration information. The Rakefile will read it in
13
11
  by extending itself. Various #defines will be given in autoconf
14
12
  style.
15
13
 
14
+ Have a look at the self-explaining examples directory.
15
+ A quick start gives you the files in "examples/plainc/".
16
+
@@ -5,7 +5,7 @@
5
5
  #include "dl.h"
6
6
  #include <iostream>
7
7
 
8
- int main( int argc, const char *argv)
8
+ int main( int argc, const char **argv)
9
9
  {
10
10
  try {
11
11
  Dl dl( "./hello.so");
@@ -22,9 +22,14 @@ if has? :dial then
22
22
  )
23
23
  end
24
24
 
25
- ug = { :user => parm[ :user], :group => parm[ :group] }
25
+ if Process.uid == 0 then
26
+ ug = { :user => parm[ :user], :group => parm[ :group] }
27
+ end
26
28
 
27
- installer "vimfiles", "VIM"
29
+ task :install do
30
+ dst = expand "VIMFILES"
31
+ puts "Installing files to '#{dst}'."
32
+ end
28
33
 
29
34
  installer vims, "VIMFILES", ug
30
35
 
@@ -12,42 +12,42 @@ function s:Ruby() range
12
12
  append "#!! #$! (#{$!.class})"
13
13
  end
14
14
  .
15
- endfunc
15
+ endfunction
16
16
 
17
17
  function s:RubySum() range
18
18
  " Build sum of expressions.
19
19
  " Everything before :(colon) and after #(hash) is treated as a comment.
20
20
  exec a:lastline
21
- ruby <<
22
- begin
23
- $kfm = true
24
- _ = eval VIM.evaluate("getline(a:firstline,a:lastline)").map { |l|
25
- VIM.numbers_of l
26
- }.join( " + ")
27
- append "-"*32, ($kfm ? "%.2f" % _ : _.to_s)
28
- rescue Exception
29
- append "-"*32, "#!! #$! (#{$!.class})"
30
- end
21
+ ruby <<
22
+ begin
23
+ VIM.kfm = true
24
+ _ = eval VIM.evaluate("getline(a:firstline,a:lastline)").map { |l|
25
+ VIM.numbers_of l
26
+ }.join( " + ")
27
+ append "-"*32, (VIM.ntos _)
28
+ rescue Exception
29
+ append "-"*32, "#!! #$! (#{$!.class})"
30
+ end
31
31
  .
32
- endfunc
32
+ endfunction
33
33
 
34
34
  function s:RubySums() range
35
35
  ruby <<
36
36
  f, l = VIM.evaluate("a:firstline").to_i, VIM.evaluate("a:lastline").to_i
37
37
  c = VIM::Buffer.current
38
38
  _ = 0
39
- $kfm = true
39
+ VIM.kfm = true
40
40
  f.upto l do |i|
41
41
  begin
42
42
  _ += eval VIM.numbers_of( c[i])
43
- c[i] += " #=> " + ($kfm ? "%.2f" % _ : _.to_s)
43
+ c[i] += " #=> " + (VIM.ntos _)
44
44
  rescue Exception
45
45
  c[i] += " #!! #$! (#{$!.class})"
46
46
  break
47
47
  end
48
48
  end
49
49
  .
50
- endfunc
50
+ endfunction
51
51
 
52
52
 
53
53
  ruby <<
@@ -55,18 +55,22 @@ ruby <<
55
55
 
56
56
  module VIM
57
57
  class <<self
58
+ attr_accessor :kfm # Kaufmännische Zahlen
58
59
  def numbers_of line
59
60
  line.chomp!
60
- line.gsub! /^.*?[:=]/, ""
61
61
  line.gsub! /#.*?$/, ""
62
+ line.gsub! /^.*?[:=]/, ""
62
63
  line.gsub! /\d(\.\d{3})+,\d/ do |x|
63
64
  x.delete "."
64
65
  end
65
66
  line.gsub! /(\d+,)-/, "\\100"
66
67
  line.gsub! /(\d+),(\d+)(-)?/, "\\3\\1.\\2"
67
- $kfm &&= line !~ /(^|[^0-9.])\d+(\.(\d|\d{3,}))?([^0-9.]|$)/
68
+ @kfm &&= line !~ /(^|[^0-9.])\d+(\.(\d|\d{3,}))?([^0-9.]|$)/
68
69
  line =~ /\S/ ? line : "0"
69
70
  end
71
+ def ntos n
72
+ @kfm ? "%.2f" % n : n.to_s
73
+ end
70
74
  end
71
75
  end
72
76
  def append *s
@@ -2,26 +2,46 @@
2
2
  # Rakefile -- build executable
3
3
  #
4
4
 
5
+ # A simple require statement loads the ".configure" file.
5
6
  require "autorake"
6
7
 
7
- c = compiler "-O2"
8
- l = linker
9
8
 
9
+ # The commands we will call
10
+ #
11
+ c = compiler "-O2" # compile command
12
+ d = compiler "-dM", "-E" # dump #define macros
13
+ l = linker # link command
14
+ #
15
+ # Options for -D macros, for include and library directories
16
+ # will be added automatically.
17
+
18
+
19
+ # compile rule uses the compile command
10
20
  rule ".o" => ".c" do |t|
11
21
  c.cc t.name, t.source
12
22
  end
13
23
 
24
+ # link target uses the link command
14
25
  file "hello" => "hello.o" do |t|
15
26
  l.cc t.name, t.prerequisites
16
27
  end
17
28
 
29
+
18
30
  task :default => "hello"
19
31
 
20
32
  task :clean do
21
33
  FileList[ "*.o", "hello"].each { |f| rm_f f }
22
34
  end
23
35
 
24
- task :foo do
25
- puts "Parameter foo is: %s." % parm[ :foo]
36
+
37
+ # just show the parameters from ./mkrf_conf
38
+ task :parameters do
39
+ puts "Parameter `foo' is: `%s'." % parm[ :foo]
40
+ puts "Parameter `other' is: `%s'." % parm[ :other]
41
+ end
42
+
43
+ # this task dumps the #define macros to stdout
44
+ task :dump do
45
+ d.cc "/dev/stdout", "hello.c"
26
46
  end
27
47
 
@@ -7,14 +7,30 @@
7
7
  #define SAY_IT
8
8
  #endif
9
9
 
10
+ #ifdef FEATURE_NOW
11
+ #include <string.h>
12
+ #endif
13
+
14
+
15
+ #define CONFIGFILE WITH_SYSCONF "/myproj.cfg"
16
+ #define DATAFILE WITH_MYPROJ "/somedata"
17
+
18
+
10
19
  int main( int argc, char **argv)
11
20
  {
21
+
12
22
  #ifdef SAY_IT
13
23
  printf( "Hello, world!\n");
14
24
  #endif
25
+
15
26
  #ifdef FEATURE_NOW
16
- printf( "Now is the time.\n");
27
+ if (strcmp( WITH_FOO, "dummy") == 0)
28
+ printf( "Now is the time.\n");
17
29
  #endif
30
+
31
+ printf( "Config file is: '%s'\n", CONFIGFILE);
32
+ printf( "Data file is: '%s'\n", DATAFILE);
33
+
18
34
  return 0;
19
35
  }
20
36
 
@@ -8,13 +8,42 @@ require "autorake/mkconfig"
8
8
 
9
9
  Autorake.configure {
10
10
 
11
- have_header "stdio.h"
11
+ # Normal header and library lookup
12
+ have_header "stdio.h" # Look if there is a header of this name.
13
+ have_library "curses" # Look for library
12
14
 
15
+ # We #include from there.
16
+ incdir :bar, "INCLUDE/anotherproject"
17
+ # We bind in libraries from there
18
+ libdir :baz, "LIB/anotherproject"
19
+
20
+
21
+ # HAVE_HEADER_NONEXISTENT_H will never be set.
22
+ have_header "nonexistent.h"
23
+
24
+
25
+ have_macro "__STDC__" # This cannot go wrong.
26
+
27
+
28
+ disable :weirdfeature do
29
+ # Call it as "./mkrf_conf --enable-weirdfeature" to let it fail.
30
+ have_library "nonexistent"
31
+ end
32
+
33
+
34
+ # Look at macro FEATURE_NOW (twice) in "hello.c" to see what this does.
13
35
  disable :now do
14
- with :foo, "dummy"
15
- # incdir :bar, "/path/to/bar"
16
- # libdir :baz, "/path/to/baz"
36
+ with :foo, 'dummy'
17
37
  end
18
38
 
39
+ # The variable will be an integer in "Rakefile" but a string in C code.
40
+ with :other, 234
41
+
42
+
43
+ # Define a directory and make is accessible through a -D macro.
44
+ directory :myproj, "DATA/myproj"
45
+ with :myproj
46
+ with :sysconf
47
+
19
48
  }
20
49
 
@@ -38,17 +38,21 @@ module Autorake
38
38
  case arg
39
39
  when /\A--/ then
40
40
  a, val = $'.split "=", 2
41
- do_option a do val end
41
+ do_option a do val || $*.shift end
42
42
  when /\A-/ then
43
43
  arg = $'
44
44
  until (a = arg.slice! 0, 1).empty? do
45
45
  do_option a do
46
- arg.slice! 0, arg.length unless arg.empty?
46
+ unless arg.empty? then
47
+ arg.slice! 0, arg.length
48
+ else
49
+ $*.shift
50
+ end
47
51
  end
48
52
  end
49
53
  else
50
54
  n, v = arg.split "="
51
- environ n, v
55
+ environ n, v||"1"
52
56
  end
53
57
  end
54
58
  end
@@ -93,8 +97,7 @@ module Autorake
93
97
  o or raise "Unknown option: #{a}"
94
98
  c = o.call
95
99
  if o.arg then
96
- g = yield || $*.shift
97
- c.push g
100
+ c.push yield
98
101
  end
99
102
  send *c
100
103
  @rest.delete o
@@ -55,7 +55,7 @@ module Autorake
55
55
  @macros = macros.map { |k,v|
56
56
  next unless v
57
57
  m = "-D#{k}"
58
- m << "=#{v}" if String === v
58
+ m << "=#{v.to_s.inspect}" unless v == true
59
59
  m
60
60
  }
61
61
  @args = args
@@ -32,8 +32,8 @@ module Autorake
32
32
  c = Configuration.new @environment, @directories
33
33
  c.do_env
34
34
  c.features.update @features
35
- c.incdirs.push std_incdir
36
- c.libdirs.push std_libdir
35
+ d = @directories.expand "INCLUDE" ; c.incdirs.push d
36
+ d = @directories.expand "LIB" ; c.libdirs.push d
37
37
  af = @features.keys.map { |k| AddFeature.new k }
38
38
  am = @args[ :par].map { |k,v| AddMacro.new k, v }
39
39
  ai = @args[ :inc].map { |k,v| AddIncdir.new k, v }
@@ -44,11 +44,8 @@ module Autorake
44
44
 
45
45
  protected
46
46
 
47
- def std_incdir ; @directories.expand "INCLUDE" ; end
48
- def std_libdir ; @directories.expand "LIB" ; end
49
-
50
47
  def directory name, dir
51
- @directories[ name]= dir
48
+ @directories[ name] = dir
52
49
  end
53
50
 
54
51
  def feature name, enabled = nil
@@ -67,24 +64,26 @@ module Autorake
67
64
  feature name, false, &block
68
65
  end
69
66
 
70
- def with name, val ; argdef :par, name, val ; end
67
+ def with name, val = nil ; argdef :par, name, val ; end
71
68
 
72
69
  def incdir name, dir ; argdef :inc, name, dir ; end
73
70
  def libdir name, dir ; argdef :lib, name, dir ; end
74
71
 
75
- def extending_ruby
72
+ def extending_ruby full_libname = nil
76
73
  if RUBY_VERSION < "1.9" then
77
74
  incdir :ruby, RbConfig::CONFIG[ "topdir"]
78
75
  else
79
- h = RbConfig::CONFIG[ "rubyhdrdir"]
80
- incdir :ruby, h
81
- incdir :ruby_arch, (File.join h, RbConfig::CONFIG[ "arch"])
82
- #incdir :ruby_backward, (File.join h, "ruby/backward")
76
+ incdir :ruby, RbConfig::CONFIG[ "rubyhdrdir"]
77
+ incdir :ruby_arch, RbConfig::CONFIG[ "rubyarchhdrdir"]
83
78
  end
84
- libdir :ruby, RbConfig::CONFIG[ "libdir"]
79
+ libdir :ruby, RbConfig::CONFIG[ "libdir"]
80
+ libdir :ruby_arch, RbConfig::CONFIG[ "archlibdir"]
85
81
  l = RbConfig::CONFIG[ "LIBRUBY"]
86
- l.slice! /\Alib/
87
- l.slice! /\.so(?:\..*)?\z/
82
+ l = if full_libname then
83
+ ":#{l}"
84
+ else
85
+ l[ /\Alib(.*?)\.so(?:\..*)?\z/, 1]
86
+ end
88
87
  have_library l
89
88
  end
90
89
 
@@ -111,12 +110,10 @@ module Autorake
111
110
 
112
111
  private
113
112
 
114
- def argdef type, name, dir
115
- return unless dir
116
- dir.chomp!
117
- return if dir.empty?
113
+ def argdef type, name, val
114
+ String === val and val.chomp!
118
115
  name = "#@current/#{name}" if @current
119
- @args[ type][ name.to_sym] = dir
116
+ @args[ type][ name.to_sym] = val
120
117
  end
121
118
 
122
119
  end
@@ -128,14 +125,16 @@ module Autorake
128
125
  end
129
126
  def perform config
130
127
  @config = config
131
- check! and set!
128
+ relevant? and check! and set!
132
129
  ensure
133
130
  @config = nil
134
131
  end
135
132
  private
133
+ def relevant?
134
+ not @feature or @config.features[ @feature]
135
+ end
136
136
  def check!
137
- not @feature or
138
- @config.features[ @feature]
137
+ true
139
138
  end
140
139
  def set!
141
140
  end
@@ -167,14 +166,15 @@ module Autorake
167
166
  @val = val
168
167
  end
169
168
  private
170
- def expanded
171
- @config.directories.expand @val
169
+ def expanded v = nil
170
+ @config.directories.expand v||@val
172
171
  end
173
172
  end
174
173
  class AddMacro < AddKeyVal
175
174
  def set!
176
- @config.parameters[ @name] = @val
177
- @config.macros[ "WITH_#{name_upcase}"] = @val
175
+ v = @val || (expanded @name.to_s.upcase)
176
+ @config.parameters[ @name] = v
177
+ @config.macros[ "WITH_#{name_upcase}"] = v
178
178
  end
179
179
  end
180
180
  class AddIncdir < AddKeyVal
@@ -29,11 +29,11 @@ module Autorake
29
29
  end
30
30
 
31
31
  def [] key
32
- super key.to_sym
32
+ super key.to_sym.downcase
33
33
  end
34
34
 
35
35
  def []= key, value
36
- super key.to_sym, value
36
+ super key.to_sym.downcase, value
37
37
  end
38
38
 
39
39
  def expanded key
@@ -8,18 +8,28 @@ require "autorake/application"
8
8
  module Autorake
9
9
 
10
10
  class <<self
11
+
11
12
  def configure &block
12
13
  d = Definitions.new
13
14
  d.instance_eval &block
14
- p = MkConfig.new d
15
+ p = MkConfig.mkconfig.new d
15
16
  p.run
16
17
  nil
17
18
  end
19
+
18
20
  end
19
21
 
20
22
 
21
23
  class MkConfig < Application
22
24
 
25
+ @mkconfig = self
26
+ class <<self
27
+ attr_reader :mkconfig
28
+ def inherited cls
29
+ @mkconfig = cls
30
+ end
31
+ end
32
+
23
33
  attr_accessor :outfile
24
34
  attr_bang :clean, :verbose
25
35
 
@@ -35,7 +45,7 @@ module Autorake
35
45
  add_option %w(c clean), "delete config file resp. -o outfile",
36
46
  nil, :clean!
37
47
  add_option %w(d dump), "just dump the results", nil, :dump
38
- add_option %w(v verbose), "lots of ubly debugging information",
48
+ add_option %w(v verbose), "lots of ugly debugging information",
39
49
  nil, :verbose!
40
50
  super
41
51
  @definition.directories.each { |k,v|
@@ -70,7 +80,11 @@ module Autorake
70
80
  end
71
81
 
72
82
  def set_parm name, val
73
- @definition.parameters[ name.to_sym] = val
83
+ n = name.to_sym
84
+ if Numeric === @definition.parameters[ n] and val =~ /\A(0x)?\d+\z/ then
85
+ val = Integer val
86
+ end
87
+ @definition.parameters[ n] = val
74
88
  end
75
89
 
76
90
  def set_incdir name, val
@@ -93,14 +107,24 @@ module Autorake
93
107
  def execute
94
108
  if @clean then
95
109
  File.unlink @outfile if File.file? @outfile
110
+ cleaned
96
111
  else
97
112
  cfg = @definition.perform
98
113
  File.open @outfile, "w" do |f|
99
114
  f.write cfg.to_yaml
100
115
  end
116
+ made
101
117
  end
102
118
  end
103
119
 
120
+ # overwrite this to do additional work
121
+ def made
122
+ end
123
+
124
+ # overwrite this to do additional work
125
+ def cleaned
126
+ end
127
+
104
128
  end
105
129
 
106
130
  end
@@ -5,7 +5,7 @@
5
5
  module Autorake
6
6
 
7
7
  NAME = "autorake"
8
- VERSION = "2.4.3".freeze
8
+ VERSION = "2.7".freeze
9
9
  SUMMARY = "Automake like project config before Rake build or install."
10
10
 
11
11
  DESCRIPTION = <<EOT
@@ -15,7 +15,7 @@ with autocmd-like functionality.
15
15
  The config scripts may be held short and readable.
16
16
  EOT
17
17
 
18
- COPYRIGHT = "(C) 2013,2014 Bertram Scharpf"
18
+ COPYRIGHT = "(C) 2013-2015 Bertram Scharpf"
19
19
  LICENSE = "BSD"
20
20
  AUTHOR = "Bertram Scharpf <software@bertram-scharpf.de>"
21
21
  TEAM = [ "Bertram Scharpf"]
metadata CHANGED
@@ -1,32 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autorake
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
5
- prerelease:
4
+ version: '2.7'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bertram Scharpf
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2016-04-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ">="
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 0.8.7
19
+ version: '11'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ">="
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 0.8.7
26
+ version: '11'
30
27
  description: |
31
28
  This script allows you to write pretty mkrf_conf scripts
32
29
  with autocmd-like functionality.
@@ -39,39 +36,40 @@ extra_rdoc_files:
39
36
  - README
40
37
  - LICENSE
41
38
  files:
42
- - lib/autorake.rb
43
- - lib/autorake/application.rb
44
- - lib/autorake/configure.rb
45
- - lib/autorake/compile.rb
46
- - lib/autorake/definition.rb
47
- - lib/autorake/directories.rb
48
- - lib/autorake/mkconfig.rb
49
- - lib/autorake/version.rb
39
+ - LICENSE
40
+ - README
50
41
  - examples/dlcpp/Rakefile
51
- - examples/dlcpp/mkrf_conf
52
42
  - examples/dlcpp/dl.cpp
53
43
  - examples/dlcpp/dl.h
54
44
  - examples/dlcpp/hello.cpp
55
45
  - examples/dlcpp/hello.h
56
46
  - examples/dlcpp/main.cpp
47
+ - examples/dlcpp/mkrf_conf
57
48
  - examples/justinst/Rakefile
58
49
  - examples/justinst/mkrf_conf
59
50
  - examples/justinst/plugin/dial.vim
60
51
  - examples/justinst/plugin/ruby.vim
61
52
  - examples/justinst/plugin/yesno.vim
62
53
  - examples/plainc/Rakefile
63
- - examples/plainc/mkrf_conf
64
54
  - examples/plainc/hello.c
55
+ - examples/plainc/mkrf_conf
65
56
  - examples/rbextend/Rakefile
66
- - examples/rbextend/mkrf_conf
67
57
  - examples/rbextend/hello.c
68
58
  - examples/rbextend/hello.h
59
+ - examples/rbextend/mkrf_conf
69
60
  - examples/rbextend/rbhello
70
- - README
71
- - LICENSE
61
+ - lib/autorake.rb
62
+ - lib/autorake/application.rb
63
+ - lib/autorake/compile.rb
64
+ - lib/autorake/configure.rb
65
+ - lib/autorake/definition.rb
66
+ - lib/autorake/directories.rb
67
+ - lib/autorake/mkconfig.rb
68
+ - lib/autorake/version.rb
72
69
  homepage: http://www.bertram-scharpf.de/software/autorake
73
70
  licenses:
74
71
  - BSD
72
+ metadata: {}
75
73
  post_install_message:
76
74
  rdoc_options:
77
75
  - "--charset"
@@ -81,13 +79,11 @@ rdoc_options:
81
79
  require_paths:
82
80
  - lib
83
81
  required_ruby_version: !ruby/object:Gem::Requirement
84
- none: false
85
82
  requirements:
86
83
  - - ">="
87
84
  - !ruby/object:Gem::Version
88
85
  version: '0'
89
86
  required_rubygems_version: !ruby/object:Gem::Requirement
90
- none: false
91
87
  requirements:
92
88
  - - ">="
93
89
  - !ruby/object:Gem::Version
@@ -95,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
91
  requirements:
96
92
  - Rake
97
93
  rubyforge_project: NONE
98
- rubygems_version: 1.8.29
94
+ rubygems_version: 2.6.2
99
95
  signing_key:
100
- specification_version: 3
96
+ specification_version: 4
101
97
  summary: Automake like project config before Rake build or install.
102
98
  test_files: []