build-tool 0.0.3 → 0.1.0
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.
- data.tar.gz.sig +0 -0
- data/History.txt +28 -1
- data/Manifest.txt +91 -52
- data/README.txt +63 -0
- data/Rakefile +20 -23
- data/bin/build-tool +53 -0
- data/lib/build-tool.rb +7 -0
- data/lib/build-tool/GUI.rb +360 -0
- data/lib/build-tool/application.rb +84 -0
- data/lib/build-tool/build-system/autoconf.rb +60 -0
- data/lib/build-tool/build-system/base.rb +142 -0
- data/lib/build-tool/build-system/cmake.rb +119 -0
- data/lib/build-tool/build-system/custom.rb +115 -0
- data/lib/build-tool/build-system/qt.rb +113 -0
- data/lib/build-tool/cfg/lexer.rb +558 -0
- data/lib/build-tool/cfg/lexer.rex +248 -0
- data/lib/build-tool/cfg/lexer_base.rb +82 -0
- data/lib/build-tool/cfg/node.rb +94 -0
- data/lib/build-tool/cfg/parser.rb +871 -0
- data/lib/build-tool/cfg/parser.y +279 -0
- data/lib/build-tool/cfg/visitor.rb +471 -0
- data/lib/build-tool/commands.rb +639 -0
- data/lib/build-tool/commands/build.rb +120 -0
- data/lib/build-tool/commands/configure.rb +73 -0
- data/lib/build-tool/commands/ctags.rb +46 -0
- data/lib/build-tool/commands/environments.rb +29 -0
- data/lib/build-tool/commands/environments/list.rb +37 -0
- data/lib/build-tool/commands/environments/set.rb +33 -0
- data/lib/build-tool/commands/fetch.rb +50 -0
- data/lib/build-tool/commands/files.rb +73 -0
- data/lib/build-tool/commands/help.rb +22 -0
- data/lib/build-tool/commands/info.rb +48 -0
- data/lib/build-tool/commands/install.rb +56 -0
- data/lib/build-tool/commands/modules.rb +29 -0
- data/lib/build-tool/commands/modules/info.rb +75 -0
- data/lib/build-tool/commands/modules/list.rb +49 -0
- data/lib/build-tool/commands/modules/shell.rb +40 -0
- data/lib/build-tool/commands/rebase.rb +46 -0
- data/lib/build-tool/commands/recipes.rb +32 -0
- data/lib/build-tool/commands/recipes/info.rb +46 -0
- data/lib/build-tool/commands/recipes/install.rb +184 -0
- data/lib/build-tool/commands/recipes/list.rb +33 -0
- data/lib/build-tool/configuration.rb +115 -0
- data/lib/build-tool/environment.rb +119 -0
- data/lib/build-tool/errors.rb +9 -0
- data/lib/build-tool/module.rb +366 -0
- data/lib/build-tool/pluginbase.rb +43 -0
- data/lib/build-tool/recipe.rb +180 -0
- data/lib/build-tool/repository.rb +59 -0
- data/lib/build-tool/server.rb +43 -0
- data/lib/build-tool/singleton.rb +50 -0
- data/lib/build-tool/sshkey.rb +22 -0
- data/lib/build-tool/vcs/base.rb +105 -0
- data/lib/build-tool/vcs/git-svn.rb +154 -0
- data/lib/build-tool/vcs/git.rb +187 -0
- data/lib/build-tool/vcs/svn.rb +136 -0
- data/lib/mj/logging.rb +31 -0
- data/lib/mj/tools/ssh.rb +64 -0
- data/lib/{kde-build → mj/tools}/subprocess.rb +21 -16
- data/lib/mj/visitor.rb +21 -0
- data/recipes/kde/files/finish_installation.sh +16 -0
- data/recipes/kde/files/kde4.desktop +22 -0
- data/recipes/kde/files/xsession +89 -0
- data/recipes/kde/info.yaml +10 -0
- data/recipes/kde/recipe +585 -0
- data/recipes/kde/recipe-local +90 -0
- data/recipes/kde/settings.yaml +52 -0
- data/recipes/kde43/info.yaml +10 -0
- data/recipes/kde43/recipe +256 -0
- data/recipes/kde43/recipe-local +90 -0
- data/recipes/kde43/settings.yaml +32 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh +77 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh +70 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh +39 -0
- data/recipes/kdeqt4.6/info.yaml +7 -0
- data/recipes/kdeqt4.6/recipe +155 -0
- data/recipes/kdeqt4.6/recipe-local +30 -0
- data/recipes/kdeqt4.6/settings.yaml +27 -0
- data/tags +745 -0
- data/tasks/genfiles.rake +28 -0
- data/tasks/rdoc.rake +34 -0
- data/tasks/rspec.rake +21 -0
- data/test.rb +28 -0
- data/test/commands/test_build.rb +29 -0
- data/test/test_build_system.rb +98 -0
- data/test/test_cli.rb +61 -0
- data/test/test_command.rb +175 -0
- data/test/test_configuration_parser.rb +542 -0
- data/test/test_environment.rb +82 -0
- data/test/test_helper.rb +39 -7
- data/test/test_module.rb +158 -0
- data/test/test_repository.rb +75 -0
- data/test/test_singleton.rb +51 -0
- data/test/test_ssh_key.rb +14 -0
- data/test/test_svn_parser.rb +28 -0
- data/test/test_vcs.rb +33 -0
- metadata +139 -90
- metadata.gz.sig +0 -0
- data/PostInstall.txt +0 -3
- data/TODO +0 -2
- data/bin/kde-build.rb +0 -21
- data/config/website.yml +0 -2
- data/config/website.yml.sample +0 -2
- data/lib/kde-build.rb +0 -18
- data/lib/kde-build/application.rb +0 -270
- data/lib/kde-build/build_system.rb +0 -28
- data/lib/kde-build/build_system/autoconf.rb +0 -108
- data/lib/kde-build/build_system/base.rb +0 -139
- data/lib/kde-build/build_system/cmake.rb +0 -94
- data/lib/kde-build/build_system/qtcopy.rb +0 -127
- data/lib/kde-build/command.rb +0 -42
- data/lib/kde-build/command/build.rb +0 -106
- data/lib/kde-build/command/compile.rb +0 -39
- data/lib/kde-build/command/configure.rb +0 -48
- data/lib/kde-build/command/ctags.rb +0 -41
- data/lib/kde-build/command/fetch.rb +0 -33
- data/lib/kde-build/command/help.rb +0 -71
- data/lib/kde-build/command/info.rb +0 -45
- data/lib/kde-build/command/install.rb +0 -39
- data/lib/kde-build/command/module_based.rb +0 -44
- data/lib/kde-build/command/rebase.rb +0 -50
- data/lib/kde-build/command/version.rb +0 -43
- data/lib/kde-build/configuration.rb +0 -209
- data/lib/kde-build/exception.rb +0 -6
- data/lib/kde-build/metaaid.rb +0 -18
- data/lib/kde-build/module.rb +0 -227
- data/lib/kde-build/module_configuration.rb +0 -107
- data/lib/kde-build/moduleregistry.rb +0 -85
- data/lib/kde-build/tools/ctags.rb +0 -59
- data/lib/kde-build/tools/logging.rb +0 -49
- data/lib/kde-build/tools/make.rb +0 -58
- data/lib/kde-build/tools/ssh.rb +0 -47
- data/lib/kde-build/vcs.rb +0 -28
- data/lib/kde-build/vcs/base.rb +0 -85
- data/lib/kde-build/vcs/git-svn.rb +0 -139
- data/lib/kde-build/vcs/git.rb +0 -121
- data/lib/kde-build/vcs/svn.rb +0 -102
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -71
- data/test.yaml.tmpl +0 -632
- data/test/test_kde-build.rb +0 -11
- data/test/test_vcs_svn.rb +0 -44
- data/website/index.html +0 -84
- data/website/index.txt +0 -59
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -159
- data/website/template.html.erb +0 -50
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'build-tool/application'
|
2
|
+
require 'build-tool/commands'
|
3
|
+
require 'ftools'
|
4
|
+
|
5
|
+
module BuildTool; module Commands; module Recipes
|
6
|
+
|
7
|
+
#
|
8
|
+
# BuildCommand
|
9
|
+
#
|
10
|
+
class Install < Standard
|
11
|
+
|
12
|
+
name "install"
|
13
|
+
description "install a build recipe"
|
14
|
+
|
15
|
+
def initialize_options
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def do_execute(args)
|
20
|
+
|
21
|
+
require 'build-tool/GUI'
|
22
|
+
|
23
|
+
# Check parameters
|
24
|
+
if args.length < 1 or args.length > 2
|
25
|
+
return usage("Wrong number of arguments")
|
26
|
+
end
|
27
|
+
|
28
|
+
# First param is recipename
|
29
|
+
recipename = args[0]
|
30
|
+
# Second optional parameter is command name
|
31
|
+
if args.length == 2
|
32
|
+
commandname = args[1]
|
33
|
+
else
|
34
|
+
commandname = args[0]
|
35
|
+
end
|
36
|
+
exename = "#{commandname}-build"
|
37
|
+
conffile = Application::instance.local_configuration_dir.join("#{commandname}.yaml")
|
38
|
+
|
39
|
+
# Our executable
|
40
|
+
buildtool = Application::instance.application_root.join( 'bin', 'build-tool' ).to_s
|
41
|
+
|
42
|
+
# Load the recipe
|
43
|
+
recipe = Recipe.find_recipe(recipename)
|
44
|
+
if !recipe
|
45
|
+
logger.error "Unknown recipe #{recipename}!"
|
46
|
+
return -1
|
47
|
+
end
|
48
|
+
|
49
|
+
say ""
|
50
|
+
say "Step 1)"
|
51
|
+
say "Add a symbolic link name '#{exename}' somewhere into your $PATH."
|
52
|
+
|
53
|
+
# Check if there are already commands with exename
|
54
|
+
existing = find_in_path( ENV['PATH'], exename )
|
55
|
+
found = false # Was the link found?
|
56
|
+
existing.each do |exe|
|
57
|
+
if exe.exist?
|
58
|
+
if exe.symlink? and File.identical? exe, buildtool
|
59
|
+
found = true
|
60
|
+
else
|
61
|
+
logger.warn "Found another command named #{exename} at #{exe.to_s}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if found == true
|
67
|
+
say "The symlink already exists. Skipping this step"
|
68
|
+
else
|
69
|
+
dirs = find_writable_dirs( ENV['PATH'] )
|
70
|
+
dir = nil
|
71
|
+
if dirs.empty?
|
72
|
+
logger.error "No writable directory found in $PATH. Please add one (usually $HOME/bin) or"
|
73
|
+
logger.error "create a symbolic link in a directory that is part of $PATH yourself."
|
74
|
+
logger.error "> ln -s #{buildtool} #{exename}"
|
75
|
+
elsif dirs.length == 1
|
76
|
+
dir = dirs[0]
|
77
|
+
say "Exactly one writeable directory found in your $PATH. Symbolic link will be"
|
78
|
+
say "created in :#{dir}"
|
79
|
+
else
|
80
|
+
if dirs.length > 1
|
81
|
+
( dir, index ) = Gem::DefaultUserInteraction.ui.choose_from_list(
|
82
|
+
"More than one writeable directory found in $PATH. Which one should i use?", dirs)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
link = Pathname.new(dir).join(exename)
|
86
|
+
if link.exist?
|
87
|
+
logger.error "Can not create the link because the 'to' already exists. Please create"
|
88
|
+
logger.error "a symbolic link in a directory that is part of $PATH yourself."
|
89
|
+
logger.error "> ln -s #{buildtool} #{exename}"
|
90
|
+
else
|
91
|
+
File.symlink(buildtool, Pathname.new(dir).join(exename))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Now write the settings file
|
96
|
+
say <<EOS
|
97
|
+
|
98
|
+
Step 2)"
|
99
|
+
Create a example configuration file. Please open the file in a editor and
|
100
|
+
change it to your preferences. It is important to at least set LIB_SUFFIX and
|
101
|
+
MAKEFLAGS to values your system needs or can handle.
|
102
|
+
|
103
|
+
LIB_SUFFIX is either '64', '32' or ''. Issue 'gcc -v' and search for
|
104
|
+
--libdir=lib(64|32|). Set LIB_SUFFIX accordingly. If you can't see --libdir
|
105
|
+
set LIB_SUFFIX to "". Those information is only correct if you not use the
|
106
|
+
-m32 Generate 32bit i386 code
|
107
|
+
-m64 Generate 64bit x86-64 code
|
108
|
+
gcc options.
|
109
|
+
|
110
|
+
MAKEFLAGS can be used provide flags to the make command. The '-jN' options is
|
111
|
+
used to parallelize the compiling. Set N to your the number of cpu cores+1 for
|
112
|
+
a start.
|
113
|
+
|
114
|
+
You will find the file at #{conffile.to_s}.
|
115
|
+
EOS
|
116
|
+
if conffile.exist?
|
117
|
+
say "The config file already exists. Copying omitted."
|
118
|
+
else
|
119
|
+
File.copy(recipe.join("settings.yaml"), conffile)
|
120
|
+
end
|
121
|
+
|
122
|
+
say <<EOS
|
123
|
+
|
124
|
+
Step 3)
|
125
|
+
Creating a local configuration file you can use to change very aspect from the
|
126
|
+
global configuration file, You will find it at
|
127
|
+
> #{Application::instance.local_configuration_dir.join( commandname, 'recipe' )}
|
128
|
+
EOS
|
129
|
+
if File.exist?( Application::instance.local_configuration_dir.join(commandname))
|
130
|
+
logger.error( "Local configuration for #{commandname} already exists!" )
|
131
|
+
else
|
132
|
+
FileUtils.mkdir_p( Application::instance.local_configuration_dir.join( commandname ) )
|
133
|
+
File.copy(recipe.join("recipe-local"),
|
134
|
+
Application::instance.local_configuration_dir.join( commandname, 'recipe' ))
|
135
|
+
end
|
136
|
+
|
137
|
+
say <<EOS
|
138
|
+
|
139
|
+
Step 4)
|
140
|
+
You now can start to use your recipe. The first command to look at are:
|
141
|
+
# Show the configuration
|
142
|
+
> #{exename} info
|
143
|
+
# Show all modules
|
144
|
+
> #{exename} module list
|
145
|
+
# Show detailed info for a module
|
146
|
+
> #{exename} module info <module>
|
147
|
+
# Build a module (-u = enable updating)
|
148
|
+
> #{exename} build -u <module>
|
149
|
+
EOS
|
150
|
+
|
151
|
+
# We were successful
|
152
|
+
return 0
|
153
|
+
end
|
154
|
+
|
155
|
+
def find_writable_dirs(path)
|
156
|
+
dirs = []
|
157
|
+
path.split(':').each do |dir|
|
158
|
+
dirhd = Pathname.new(dir)
|
159
|
+
if dirhd.directory? and dirhd.writable?
|
160
|
+
dirs << dir
|
161
|
+
end
|
162
|
+
end
|
163
|
+
dirs
|
164
|
+
end
|
165
|
+
|
166
|
+
def find_in_path( path, name )
|
167
|
+
dirs = []
|
168
|
+
path.split(':').each do |dir|
|
169
|
+
hd = Pathname.new(dir).join(name)
|
170
|
+
if hd.exist?
|
171
|
+
dirs << hd
|
172
|
+
end
|
173
|
+
end
|
174
|
+
dirs
|
175
|
+
end
|
176
|
+
|
177
|
+
end # class
|
178
|
+
|
179
|
+
end; end # module Commands::Recipes
|
180
|
+
|
181
|
+
end; # module BuildTool
|
182
|
+
|
183
|
+
|
184
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'build-tool/commands'
|
2
|
+
require 'build-tool/recipe'
|
3
|
+
|
4
|
+
module BuildTool; module Commands; module Recipes
|
5
|
+
|
6
|
+
#
|
7
|
+
# BuildCommand
|
8
|
+
#
|
9
|
+
class List < Standard
|
10
|
+
|
11
|
+
name "list"
|
12
|
+
description "list build recipes"
|
13
|
+
|
14
|
+
def initialize_options
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def do_execute( args )
|
19
|
+
recipes = Recipe.all_recipes
|
20
|
+
recipes.keys.sort.each do |name|
|
21
|
+
say format( "%-20s - %s", name, recipes[name].short_description )
|
22
|
+
end
|
23
|
+
|
24
|
+
return 0
|
25
|
+
end
|
26
|
+
|
27
|
+
end # class
|
28
|
+
|
29
|
+
end; end # module Commands::Recipes
|
30
|
+
|
31
|
+
end; # module BuildTool
|
32
|
+
|
33
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'build-tool/vcs/git'
|
2
|
+
require 'build-tool/vcs/git-svn'
|
3
|
+
require 'build-tool/vcs/svn'
|
4
|
+
|
5
|
+
require 'build-tool/build-system/cmake'
|
6
|
+
require 'build-tool/build-system/qt'
|
7
|
+
require 'build-tool/build-system/autoconf'
|
8
|
+
require 'build-tool/build-system/custom'
|
9
|
+
|
10
|
+
|
11
|
+
module BuildTool
|
12
|
+
|
13
|
+
class Configuration
|
14
|
+
|
15
|
+
attr_reader :recipe
|
16
|
+
attr_reader :modules
|
17
|
+
attr_reader :environments
|
18
|
+
|
19
|
+
def log_directory
|
20
|
+
return @log_directory if @log_directory
|
21
|
+
raise BuildTool::ConfigurationError, "No log directory configured"
|
22
|
+
end
|
23
|
+
def log_directory=( path )
|
24
|
+
@log_directory = File.expand_path( path, "~" );
|
25
|
+
end
|
26
|
+
|
27
|
+
def environment( name )
|
28
|
+
@environments[name]
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_environment( env)
|
32
|
+
@environments[env.name] = env
|
33
|
+
end
|
34
|
+
|
35
|
+
def module( name )
|
36
|
+
@module[name]
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_module( mod )
|
40
|
+
@module[mod.name] = mod
|
41
|
+
@modules << mod
|
42
|
+
end
|
43
|
+
|
44
|
+
def repository( name )
|
45
|
+
@repository[name]
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_repository( repo )
|
49
|
+
@repository[repo.name] = repo
|
50
|
+
end
|
51
|
+
|
52
|
+
def server( name )
|
53
|
+
@server[name]
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_server( server )
|
57
|
+
@server[ server.name ] = server
|
58
|
+
end
|
59
|
+
|
60
|
+
def sshkey( name )
|
61
|
+
@sshkey[name]
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_sshkey( key )
|
65
|
+
@sshkey[key.name] = key
|
66
|
+
end
|
67
|
+
|
68
|
+
def initialize( recipe = nil )
|
69
|
+
@recipe = recipe
|
70
|
+
@server = {}
|
71
|
+
@log_directory = nil
|
72
|
+
@environments = {}
|
73
|
+
@module = {}
|
74
|
+
@modules = []
|
75
|
+
@build_system = {}
|
76
|
+
@repository = {}
|
77
|
+
@sshkey = {}
|
78
|
+
end
|
79
|
+
|
80
|
+
def vcs( name )
|
81
|
+
case name
|
82
|
+
when "git-svn"
|
83
|
+
return BuildTool::VCS::GitSvnConfiguration.new
|
84
|
+
when "git"
|
85
|
+
return BuildTool::VCS::GitConfiguration.new
|
86
|
+
when "svn"
|
87
|
+
return BuildTool::VCS::SvnConfiguration.new
|
88
|
+
else
|
89
|
+
raise StandardError, "Unknown Version Control System #{name}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def build_system( name )
|
94
|
+
return @build_system[name] if @build_system[name]
|
95
|
+
case name
|
96
|
+
when "cmake"
|
97
|
+
return BuildTool::BuildSystem::CMake.new
|
98
|
+
when "qt"
|
99
|
+
return BuildTool::BuildSystem::Qt.new
|
100
|
+
when "qmake"
|
101
|
+
return BuildTool::BuildSystem::QMake.new
|
102
|
+
when "custom"
|
103
|
+
return BuildTool::BuildSystem::Custom.new
|
104
|
+
else
|
105
|
+
raise StandardError, "Unknown Version Control System #{name}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def add_build_system( bs )
|
110
|
+
@build_system[bs.name] = bs
|
111
|
+
end
|
112
|
+
|
113
|
+
end # Configuration
|
114
|
+
|
115
|
+
end # module BuildTool
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'mj/tools/subprocess'
|
2
|
+
|
3
|
+
module BuildTool
|
4
|
+
|
5
|
+
#
|
6
|
+
# Encapsulates all environment related options for a build
|
7
|
+
#
|
8
|
+
class Environment
|
9
|
+
|
10
|
+
include MJ::Tools::SubProcess
|
11
|
+
|
12
|
+
# Name for the environment
|
13
|
+
attr_reader :name
|
14
|
+
|
15
|
+
# Parent environment
|
16
|
+
attr_accessor :parent
|
17
|
+
|
18
|
+
# Create a environment object
|
19
|
+
def initialize( name )
|
20
|
+
raise StandardError.new "Environment.name has to be set" if name.nil?
|
21
|
+
@name = name
|
22
|
+
@vars = Hash.new
|
23
|
+
@parent = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
# Set a environment variable
|
27
|
+
def append( name, value )
|
28
|
+
if @vars.has_key?(name.to_s) and !@vars[name.to_s].empty?
|
29
|
+
@vars[name.to_s] = "#{@vars[name.to_s]}:#{value.to_s}"
|
30
|
+
else
|
31
|
+
set( name, "$#{name.to_s}:#{value}" )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Execute command in a shell with the environment set.
|
36
|
+
def execute( command, wd = nil )
|
37
|
+
rc = self.class.execute( command.to_s, wd, values )
|
38
|
+
if rc != 0
|
39
|
+
raise StandardError, "#{command.to_s} failed with error code #{rc}";
|
40
|
+
end
|
41
|
+
rc
|
42
|
+
end
|
43
|
+
|
44
|
+
# Prepend +value+ to variable +name+. A ':' is added when necessary.
|
45
|
+
def prepend( name, value )
|
46
|
+
if @vars.has_key?(name.to_s) and !@vars[name.to_s].empty?
|
47
|
+
@vars[name.to_s] = "#{value.to_s}:#{@vars[name.to_s]}"
|
48
|
+
else
|
49
|
+
set( name, "#{value}:$#{name.to_s}" )
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def set( name, value )
|
54
|
+
@vars[name.to_s] = value.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
# Open a shell with the environment set.
|
58
|
+
#
|
59
|
+
# It sets an environment variable *BUILD_TOOL_ENV* with the name of
|
60
|
+
# the environment set. This can be used to add this information to
|
61
|
+
# the prompt.
|
62
|
+
def shell( wd = nil )
|
63
|
+
begin
|
64
|
+
ENV['JAM_PROJECT'] = name
|
65
|
+
self.class.adjust_environment( wd, values ) {
|
66
|
+
logger.info "Starting #{ENV['SHELL']}"
|
67
|
+
system( ENV['SHELL'] )
|
68
|
+
logger.info "#{ENV['SHELL']} stopped."
|
69
|
+
return 0;
|
70
|
+
}
|
71
|
+
ensure
|
72
|
+
ENV['JAM_PROJECT'] = nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def vars
|
77
|
+
if @parent
|
78
|
+
( @vars.keys + @parent.vars ).uniq
|
79
|
+
else
|
80
|
+
@vars.keys
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def values
|
85
|
+
vals = {}
|
86
|
+
vars.each do |var|
|
87
|
+
vals[var] = self[var]
|
88
|
+
end
|
89
|
+
vals
|
90
|
+
end
|
91
|
+
|
92
|
+
# Get the value of a environment variable
|
93
|
+
def []( name )
|
94
|
+
parentval = ""
|
95
|
+
# Get the value from the parent
|
96
|
+
if @parent
|
97
|
+
parentval = @parent[name]
|
98
|
+
end
|
99
|
+
# If we don't know the var return the parents value
|
100
|
+
if !@vars.has_key?( name.to_s )
|
101
|
+
return parentval
|
102
|
+
end
|
103
|
+
if parentval.empty?
|
104
|
+
val = @vars[name.to_s].sub( ":$#{name.to_s}:", "" )
|
105
|
+
val.sub!( ":$#{name.to_s}", "" )
|
106
|
+
val.sub!( "$#{name.to_s}:", "" )
|
107
|
+
return val
|
108
|
+
else
|
109
|
+
return @vars[name.to_s].sub( "$#{name.to_s}", parentval )
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def to_s
|
114
|
+
"Environment: #{name}"
|
115
|
+
end
|
116
|
+
|
117
|
+
end # class Environment
|
118
|
+
|
119
|
+
end # module BuildTool
|