builddir 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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +42 -5
- data/bin/builddir_cmake +31 -6
- data/bin/builddir_configure +0 -0
- data/bin/builddir_generate_source_script +1 -1
- data/bin/builddir_impl +13 -5
- data/lib/builddir/utils.rb +1 -1
- data/lib/builddir/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d9161d3885f7096ee1c3a59a8ef96bdafb83d27
|
4
|
+
data.tar.gz: 647853ff7f8f2153d2a7d8289cd19d66fea09842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae988445fa2a8727c0d05c70fe01c40c025c3dd5435ab27446a2cd6239b9b9fbb1fced8ffa28ffb7de7f94c88fa995cdad314986c3fce44e2a71fe5e8cd4222
|
7
|
+
data.tar.gz: f65eb5155742b98c366a028b19adf63084ff9db3d9361eee932c478bea23fcf613769014b5dd2011eafefa6f7a0824f8600e2d0fc7ae027be2f4cac596caaa51
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
|
1
|
+
# Builddir
|
2
2
|
|
3
3
|
**builddir** is a little helper tool for C/C++ programmers to manage
|
4
4
|
out-of-source build directories. It manages mappings between build directories
|
5
5
|
and the associated source directories and allows to switch between them.
|
6
6
|
|
7
|
+
The provided configure and cmake wrappers additionally ease the configuration
|
8
|
+
by automatically specifying the path to the source directory.
|
9
|
+
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Installation consists out of multiple steps. The first is to install the
|
@@ -12,8 +15,8 @@ builddir gem:
|
|
12
15
|
gem install builddir
|
13
16
|
|
14
17
|
Second, a shell wrapper script (`builddir_source_script`) has to be placed in
|
15
|
-
the PATH. The script can either be installed by hand (from `lib/data`)
|
16
|
-
be generated using the `builddir_generate_source_script` command.
|
18
|
+
the PATH. The script can either be installed by hand (from `lib/builddir/data`)
|
19
|
+
or can be generated using the `builddir_generate_source_script` command.
|
17
20
|
|
18
21
|
builddir_generate_source_script ~/bin/builddir_source_script
|
19
22
|
|
@@ -39,9 +42,43 @@ variable definition to the configuration file
|
|
39
42
|
|
40
43
|
## Usage
|
41
44
|
|
42
|
-
|
45
|
+
The following sections describe the most common operations briefly assuming
|
46
|
+
that the recommended aliases have been configured.
|
47
|
+
|
48
|
+
### Change to the build directory
|
49
|
+
|
50
|
+
`cdb [baseName]` looks up the current directory as source directory and changes
|
51
|
+
to the associated build directory. If no mapping could be found then a new one
|
52
|
+
is created considering the optional basename.
|
53
|
+
|
54
|
+
### Change to the source directory
|
55
|
+
|
56
|
+
`cds` looks up the current directory as build directory and changes to the
|
57
|
+
associated source directory. An error is returned if no mapping could be found.
|
58
|
+
|
59
|
+
### Configuring inside of the build directory
|
60
|
+
|
61
|
+
The configuration of an out-of-source build requires the path to the source
|
62
|
+
directory. Wrapper scripts for the most common build systems are provided
|
63
|
+
which automatically specify this path when needed. It is therefore possible
|
64
|
+
to simply call `configure [options]` or `cmake [options]` in the build
|
65
|
+
directory without any source path.
|
66
|
+
|
67
|
+
#### cmake extension for toolchain files
|
68
|
+
|
69
|
+
Cross compilation with cmake usually requires a toolchain file which is often
|
70
|
+
distributed with the source code itself. Using such a file requires the
|
71
|
+
specification of the full path which kind of defeats the purpose of the wrapper.
|
72
|
+
Therefore, an additional option `-A <ARCH_NAME>` has been added which expands
|
73
|
+
into `-DCMAKE_TOOLCHAIN_FILE=<src_dir>/cmake/toolchain/<ARCH_NAME>.cmake`.
|
74
|
+
|
75
|
+
### Further operations (deleting, purging, ...)
|
76
|
+
|
77
|
+
The `bdir` command supports further operations like the deletion of mappings or
|
78
|
+
the purging of the build directory root from abandoned directories. The flags
|
79
|
+
for these and other operations can be found in the help of the command.
|
80
|
+
(`bdir --help`)
|
43
81
|
|
44
82
|
## TODO:
|
45
|
-
* add documentation
|
46
83
|
* add unit tests
|
47
84
|
* support multiple build directories?
|
data/bin/builddir_cmake
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'builddir'
|
3
3
|
|
4
|
-
# figure out if the src path
|
5
|
-
src_dir = nil
|
4
|
+
# figure out if the src path which should be added to the real cmake invocation
|
6
5
|
append_src_dir = true
|
7
6
|
|
8
7
|
# blacklist all flags where concatination of the src dir is not desired
|
@@ -13,17 +12,43 @@ append_src_dir = false if ARGV.any? { |val| val =~ /^--system-information$/ }
|
|
13
12
|
append_src_dir = false if ARGV.any? { |val| val =~ /^--build$/ }
|
14
13
|
append_src_dir = false if ARGV.any? { |val| val =~ /^-E$/ }
|
15
14
|
|
16
|
-
|
15
|
+
# add an option (-A <ARCH_NAME>) to specify an architecture for cross compilation
|
16
|
+
# this option is expanded into a CMAKE_TOOLCHAIN_FILE when it can be found
|
17
|
+
# in <src_dir>/cmake/toolchains
|
18
|
+
arch_idx = ARGV.index('-A')
|
19
|
+
arch_idx = nil if arch_idx == ARGV.length-1
|
20
|
+
|
21
|
+
# try to find the src path if needed
|
22
|
+
src_dir = nil
|
23
|
+
if append_src_dir or arch_idx
|
17
24
|
# try to find a mapping
|
18
25
|
mapping = Builddir.loadMapping()
|
19
26
|
mapping ||= []
|
20
|
-
|
27
|
+
|
21
28
|
currentDir = Dir.pwd
|
22
29
|
entry = Builddir.findExactMapping(mapping,currentDir)
|
23
|
-
src_dir = entry[:srcDir]
|
30
|
+
src_dir = entry[:srcDir] if entry && entry[:type] == :BUILD_DIR
|
31
|
+
|
32
|
+
if arch_idx and src_dir.nil?
|
33
|
+
$stderr.puts "ERROR! No SrcDir <-> BuildDir mapping could be found."
|
34
|
+
$stderr.puts "The -A option is only usable in a builddir managed build directory."
|
35
|
+
exit -1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# rewrite the -A option in ARGV to something meaningful for cmake
|
40
|
+
if arch_idx
|
41
|
+
toolchain_file = "#{src_dir}/cmake/toolchain/#{ARGV[arch_idx + 1]}.cmake"
|
42
|
+
unless File.file?(toolchain_file)
|
43
|
+
$stderr.puts "ERROR! Toolchain file (#{toolchain_file}) does not exist."
|
44
|
+
exit -1
|
45
|
+
end
|
46
|
+
# delete the parameter of -A and rewrite -A itself
|
47
|
+
ARGV.delete_at arch_idx + 1
|
48
|
+
ARGV[arch_idx] = "-DCMAKE_TOOLCHAIN_FILE=#{toolchain_file}"
|
24
49
|
end
|
25
50
|
|
26
|
-
|
51
|
+
if append_src_dir and src_dir
|
27
52
|
system 'cmake', *ARGV, src_dir
|
28
53
|
else
|
29
54
|
system 'cmake', *ARGV
|
data/bin/builddir_configure
CHANGED
File without changes
|
@@ -22,7 +22,7 @@ Trollop::with_standard_exception_handling p do
|
|
22
22
|
raise Trollop::HelpNeeded if ARGV.size() > 1 # show help screen
|
23
23
|
end
|
24
24
|
|
25
|
-
file_path = File.join(Builddir.
|
25
|
+
file_path = File.join(Builddir.getGemLibdir, "data", "builddir_source_script")
|
26
26
|
|
27
27
|
# write file content to stdout
|
28
28
|
if ARGV.size == 0
|
data/bin/builddir_impl
CHANGED
@@ -5,12 +5,20 @@ require 'trollop'
|
|
5
5
|
|
6
6
|
require 'builddir'
|
7
7
|
|
8
|
+
# Generate a non existing build directory path given a base name
|
9
|
+
#
|
10
|
+
# The function simply appends a count to the base name until a path which
|
11
|
+
# does not exist has been found.
|
12
|
+
#
|
13
|
+
# @param baseDir [String] path to the build directory root
|
14
|
+
# @param baseName [String] base name for the build directory
|
15
|
+
# @return [String] path to the new directory
|
8
16
|
def createBuildDirPath(baseDir,baseName)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
basePath = Pathname.new(File.join(baseDir,baseName))
|
18
|
+
return basePath.to_s unless File.exists?(basePath)
|
19
|
+
i = 1
|
20
|
+
while File.exists?(basePath.to_s + i.to_s) do i += 1 end
|
21
|
+
return basePath.to_s + i.to_s
|
14
22
|
end
|
15
23
|
|
16
24
|
# redirect stdout to stderr
|
data/lib/builddir/utils.rb
CHANGED
@@ -6,7 +6,7 @@ module Builddir
|
|
6
6
|
# http://stackoverflow.com/a/5805783
|
7
7
|
#
|
8
8
|
# @return [String] path to the library directory
|
9
|
-
def Builddir.
|
9
|
+
def Builddir.getGemLibdir
|
10
10
|
t = ["#{File.dirname(File.expand_path($0))}/../lib/#{NAME}",
|
11
11
|
"#{Gem.dir}/gems/#{NAME}-#{VERSION}/lib/#{NAME}"]
|
12
12
|
t.each {|i| return i if File.readable?(i) }
|
data/lib/builddir/version.rb
CHANGED
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: builddir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Werner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: trollop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
55
|
description: builddir manages mappings between build directories and the associated
|
@@ -64,7 +64,7 @@ executables:
|
|
64
64
|
extensions: []
|
65
65
|
extra_rdoc_files: []
|
66
66
|
files:
|
67
|
-
- .gitignore
|
67
|
+
- ".gitignore"
|
68
68
|
- CHANGELOG.md
|
69
69
|
- Gemfile
|
70
70
|
- LICENSE.txt
|
@@ -93,17 +93,17 @@ require_paths:
|
|
93
93
|
- lib
|
94
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.2.2
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: builddir is a little helper tool for C/C++ programmers to manage out-of-source
|