filament 0.2.0 → 0.2.1
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/CHANGELOG +8 -0
- data/lib/filament/package.rb +42 -3
- data/lib/filament/util/fileutils.rb +1 -1
- data/lib/filament/workspace.rb +24 -0
- data/lib/filament.rb +34 -21
- data/plugins/00util/lib/filament/plugins/util.rb +22 -1
- data/plugins/10svn/lib/filament/plugins/svn.rb +7 -2
- data/plugins/10svn/lib/filament/scm/svn.rb +69 -0
- data/plugins/10svn/lib/init.rb +3 -1
- metadata +4 -4
- data/plugins/10svn/lib/filament/package/svn.rb +0 -121
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.2.1:
|
2
|
+
Filament:
|
3
|
+
- Added ability to create workspace, package
|
4
|
+
- Added ability to checkout (and create) a package
|
5
|
+
- Can now execute the filament command outside a workspace
|
6
|
+
- Moved svn parts to PackageScm
|
7
|
+
- Supports in place to work with other forms of version control
|
8
|
+
|
1
9
|
0.2.0:
|
2
10
|
Filament:
|
3
11
|
- removed old tests
|
data/lib/filament/package.rb
CHANGED
@@ -2,6 +2,7 @@ require 'fileutils'
|
|
2
2
|
require 'pathname'
|
3
3
|
require 'yaml'
|
4
4
|
require 'open-uri'
|
5
|
+
require 'memoize'
|
5
6
|
|
6
7
|
require 'filament/util/fileutils'
|
7
8
|
require 'filament/util/lazy_list'
|
@@ -16,15 +17,42 @@ module Filament
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
20
|
+
class PackageScm
|
21
|
+
def self.applies?(package)
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(package)
|
26
|
+
@package = package
|
27
|
+
end
|
28
|
+
|
29
|
+
def revision; return nil; end
|
30
|
+
|
31
|
+
def update; end
|
32
|
+
|
33
|
+
def status; end
|
34
|
+
|
35
|
+
def commit(msg); end
|
36
|
+
end
|
37
|
+
|
19
38
|
class Package
|
39
|
+
include Memoize
|
40
|
+
|
41
|
+
@@package_scms = []
|
42
|
+
def self.scm(klass)
|
43
|
+
@@package_scms << klass
|
44
|
+
end
|
45
|
+
|
20
46
|
def target(name, klass, &block)
|
21
47
|
klass.new(name, &block)
|
22
48
|
end
|
23
49
|
|
24
|
-
attr_reader :parent, :name, :realpath, :workspace, :package_resolver, :target_resolver, :build_context
|
50
|
+
attr_reader :parent, :name, :realpath, :workspace, :package_resolver, :target_resolver, :build_context
|
25
51
|
alias :pathname :realpath
|
26
52
|
|
27
53
|
def initialize(h)
|
54
|
+
memoize :scm
|
55
|
+
|
28
56
|
@parent = h[:parent]
|
29
57
|
@workspace = h[:workspace]
|
30
58
|
|
@@ -129,7 +157,7 @@ module Filament
|
|
129
157
|
# 1. this package refers to a directory that exists
|
130
158
|
# 2. this package has a valid parent
|
131
159
|
def valid?
|
132
|
-
return false unless exist? and @
|
160
|
+
return false unless exist? and @realpath.directory?
|
133
161
|
return has_valid_parent?
|
134
162
|
end
|
135
163
|
|
@@ -169,6 +197,11 @@ module Filament
|
|
169
197
|
return nil
|
170
198
|
end
|
171
199
|
|
200
|
+
def create
|
201
|
+
raise "directory #{@realpath} does not exist" unless exist?
|
202
|
+
make_valid!
|
203
|
+
end
|
204
|
+
|
172
205
|
# returns the full name of the package
|
173
206
|
def uri
|
174
207
|
return '//' + path
|
@@ -252,6 +285,13 @@ module Filament
|
|
252
285
|
end
|
253
286
|
end
|
254
287
|
|
288
|
+
def scm
|
289
|
+
@@package_scms.each do |scm|
|
290
|
+
return scm.new(self) if scm.applies?(self)
|
291
|
+
end
|
292
|
+
return nil
|
293
|
+
end
|
294
|
+
|
255
295
|
# executes cmd with this packages as the wd, and with $this_package set to self
|
256
296
|
def execute(&block)
|
257
297
|
@execution_context.execute(&block)
|
@@ -301,7 +341,6 @@ module Filament
|
|
301
341
|
pn += "#{subdir}/#{$build_dir_prefix}"
|
302
342
|
end
|
303
343
|
|
304
|
-
# mkdir_p(pn) unless pn.exist?
|
305
344
|
return pn.to_s
|
306
345
|
end
|
307
346
|
|
data/lib/filament/workspace.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
require 'pathname'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
require 'filament/package'
|
4
5
|
require 'filament/resolver'
|
5
6
|
|
6
7
|
module Filament
|
7
8
|
class Workspace
|
9
|
+
class << self
|
10
|
+
def create(path)
|
11
|
+
FileUtils.mkdir_p(path)
|
12
|
+
FileUtils.cd path do
|
13
|
+
FileUtils.touch('.workspace')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
attr_reader :package_resolver, :realpath
|
9
19
|
|
10
20
|
def initialize(path)
|
@@ -39,6 +49,20 @@ module Filament
|
|
39
49
|
return package
|
40
50
|
end
|
41
51
|
|
52
|
+
def create_package_for_path(path)
|
53
|
+
return nil if path.nil?
|
54
|
+
|
55
|
+
FileUtils.mkdir_p(path)
|
56
|
+
realpath_p = Pathname.new(path).realpath
|
57
|
+
|
58
|
+
puts realpath_p
|
59
|
+
package = package_for_realpath(realpath_p)
|
60
|
+
|
61
|
+
package.create
|
62
|
+
|
63
|
+
return package
|
64
|
+
end
|
65
|
+
|
42
66
|
def resolve_package(uri)
|
43
67
|
@package_resolver.resolve_package(uri)
|
44
68
|
end
|
data/lib/filament.rb
CHANGED
@@ -64,7 +64,7 @@ module Filament
|
|
64
64
|
def initialize
|
65
65
|
@cmd = CmdParse::CommandParser.new(true)
|
66
66
|
@cmd.program_name = "filament"
|
67
|
-
@cmd.program_version = [0, 2,
|
67
|
+
@cmd.program_version = [0, 2, 1]
|
68
68
|
@cmd.add_command(CmdParse::HelpCommand.new)
|
69
69
|
@cmd.add_command(CmdParse::VersionCommand.new)
|
70
70
|
@cmd.options = CmdParse::OptionParserWrapper.new do |opt|
|
@@ -78,40 +78,58 @@ module Filament
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
82
|
-
|
81
|
+
def workspace_path
|
82
|
+
return ENV['WORKSPACE_PATH'] || Filament::find_dir(Pathname.pwd, '.workspace')
|
83
|
+
end
|
84
|
+
|
85
|
+
def subcommand(name, short_desc, has_subcommands=false, &block)
|
86
|
+
subcommand = CmdParse::Command.new(name, has_subcommands)
|
83
87
|
subcommand.short_desc = short_desc
|
84
88
|
subcommand.set_execution_block(&block)
|
85
89
|
@cmd.add_command(subcommand)
|
90
|
+
return subcommand
|
91
|
+
end
|
92
|
+
|
93
|
+
def parse(args)
|
94
|
+
@cmd.parse(args)
|
86
95
|
end
|
87
96
|
|
97
|
+
|
88
98
|
def run(args)
|
89
99
|
verbose(false)
|
90
100
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
101
|
+
if workspace_path.nil?
|
102
|
+
parse(args)
|
103
|
+
else
|
104
|
+
$workspace = Workspace.new(workspace_path)
|
105
|
+
$workspace.load_tasks
|
106
|
+
this_package = $workspace.package_for_realpath(Pathname.pwd.realpath)
|
107
|
+
if this_package.nil?
|
108
|
+
parse(args)
|
109
|
+
else
|
110
|
+
this_package.execute do
|
111
|
+
log "ROOT PACKAGES: #{$context[:package_resolver].root_package_names.join(', ')}"
|
112
|
+
# do it.
|
113
|
+
@cmd.parse(args)
|
114
|
+
end
|
115
|
+
end
|
96
116
|
end
|
97
117
|
end
|
98
118
|
end
|
99
119
|
|
100
120
|
class << self
|
121
|
+
def versioned_subdir(path)
|
122
|
+
base_dir = Pathname.new(path).parent
|
123
|
+
version = (base_dir + 'VERSION').read.chomp
|
124
|
+
return base_dir + version
|
125
|
+
end
|
126
|
+
|
101
127
|
def get_plugin_dirs(path)
|
102
128
|
pn = Pathname.new(path)
|
103
129
|
return pn.children.sort
|
104
130
|
end
|
105
131
|
|
106
|
-
def update_env(plugin_base_dir)
|
107
|
-
plugin_dirs = get_plugin_dirs(plugin_base_dir)
|
108
|
-
script_dirs = plugin_dirs.collect {|dir| dir + 'script' }
|
109
|
-
ENV['PATH'] = script_dirs.join(':') + ':' + ENV['PATH']
|
110
|
-
end
|
111
|
-
|
112
132
|
def load_plugins(plugin_base_dir)
|
113
|
-
update_env(plugin_base_dir)
|
114
|
-
|
115
133
|
plugins = []
|
116
134
|
dirs = get_plugin_dirs(plugin_base_dir)
|
117
135
|
dirs.each do |child|
|
@@ -152,8 +170,6 @@ module Filament
|
|
152
170
|
ENV[key] = val
|
153
171
|
end
|
154
172
|
|
155
|
-
workspace_path = ENV['WORKSPACE_PATH'] || Filament::find_dir(Pathname.pwd, '.workspace')
|
156
|
-
|
157
173
|
$target_platform = (ENV['TARGET_PLATFORM'] || :mpp_sdk || :i860 || :wt2_2).to_sym
|
158
174
|
$build_type = (ENV['BUILD_TYPE'] || :DBG || :OPT || :TEST).to_sym
|
159
175
|
raise "unknown build type: '#{$build_type}'" unless [:DBG, :OPT, :TEST].member?($build_type)
|
@@ -165,9 +181,6 @@ module Filament
|
|
165
181
|
pn = Pathname.new(__FILE__).parent.parent + 'plugins'
|
166
182
|
Filament::load_plugins(pn.realpath)
|
167
183
|
|
168
|
-
$workspace = Workspace.new(workspace_path)
|
169
|
-
$workspace.load_tasks
|
170
|
-
|
171
184
|
Filament::Application.new.run(args)
|
172
185
|
end
|
173
186
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cmdparse'
|
1
2
|
require 'filament/plugin'
|
2
3
|
|
3
4
|
module Filament::Plugins
|
@@ -50,10 +51,30 @@ module Filament::Plugins
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
app.subcommand('
|
54
|
+
generate = app.subcommand('generate', "Generates directory or file templates", true)
|
54
55
|
|
56
|
+
generate_workspace = CmdParse::Command.new('workspace', false)
|
57
|
+
generate_workspace.short_desc = "Creates a workspace at the given path"
|
58
|
+
generate_workspace.set_execution_block do |args|
|
59
|
+
args.each do |path|
|
60
|
+
Workspace.create(path)
|
61
|
+
puts "Workspace created."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
generate.add_command(generate_workspace)
|
66
|
+
|
67
|
+
generate_package = CmdParse::Command.new('package', false)
|
68
|
+
generate_package.short_desc = "Creates a package with the given name"
|
69
|
+
generate_package.set_execution_block do |args|
|
70
|
+
args.each do |path|
|
71
|
+
raise "Workspace not defined." if $workspace.nil?
|
72
|
+
$workspace.create_package_for_path(path)
|
73
|
+
puts "Package created."
|
74
|
+
end
|
55
75
|
end
|
56
76
|
|
77
|
+
generate.add_command(generate_package)
|
57
78
|
end
|
58
79
|
end
|
59
80
|
end
|
@@ -18,10 +18,15 @@ module Filament::Plugins
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
app.subcommand('checkout', "Checks out a package
|
22
|
-
url,
|
21
|
+
app.subcommand('checkout', "Checks out a package to a path in the workspace, creating a package if necessary") do |args|
|
22
|
+
url, path = *args
|
23
23
|
|
24
|
+
raise "Workspace not defined." if $workspace.nil?
|
24
25
|
|
26
|
+
package = $workspace.create_package_for_path(path)
|
27
|
+
|
28
|
+
svn = SVN.new(url)
|
29
|
+
svn.checkout(package.realpath)
|
25
30
|
end
|
26
31
|
end
|
27
32
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'filament/package'
|
2
|
+
|
3
|
+
module Filament::Scm
|
4
|
+
class SvnPackageScm < PackageScm
|
5
|
+
# returns true if this package is under svn control
|
6
|
+
def self.applies?(package)
|
7
|
+
p = package.realpath + '.svn'
|
8
|
+
return p.exist?
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build_uri(h)
|
12
|
+
uri = h[:uri]
|
13
|
+
|
14
|
+
return uri unless @uri.nil?
|
15
|
+
|
16
|
+
package_path = h[:package_path]
|
17
|
+
base_uri = h[:repos_uri] || ENV['FILAMENT_SVN_REPOS_URL']
|
18
|
+
|
19
|
+
tag = h[:tag]
|
20
|
+
branch = h[:branch]
|
21
|
+
|
22
|
+
return "#{base_uri}/tags/#{package_path}/#{tag}" unless tag.nil?
|
23
|
+
return "#{base_uri}/branches/#{package_path}/#{branch}" unless branch.nil?
|
24
|
+
return "#{base_uri}/trunk/#{package_path}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def revision
|
28
|
+
return svn_info['Last Changed Rev'].to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
# if this package is under version control, it will update it
|
32
|
+
# if this package has subpackages, it will update them
|
33
|
+
def update
|
34
|
+
puts @package.full_name
|
35
|
+
system("svn update #{@package.realpath}")
|
36
|
+
subpackages.each { |s| s.scm.update }
|
37
|
+
end
|
38
|
+
|
39
|
+
# if this package is under version control, it will print its status
|
40
|
+
# if this package has subpackages it will print their status
|
41
|
+
def status
|
42
|
+
puts @package.full_name
|
43
|
+
system("svn status #{@package.realpath}")
|
44
|
+
subpackages.each { |s| s.scm.status }
|
45
|
+
end
|
46
|
+
|
47
|
+
# if this package is under version control, it will commit it with the
|
48
|
+
# given msg
|
49
|
+
# if this package has subpackages it will commit them
|
50
|
+
def commit(msg)
|
51
|
+
puts @package.full_name
|
52
|
+
system("svn ci -m '#{msg.gsub(/"/,"\\\"")}'")
|
53
|
+
subpackages.each { |s| s.scm.commit(msg) }
|
54
|
+
end
|
55
|
+
|
56
|
+
def svn_url
|
57
|
+
return svn_info['URL']
|
58
|
+
end
|
59
|
+
|
60
|
+
def svn_base_url
|
61
|
+
return url.gsub(/\/(trunk|branches\/[.^\/]*|tags\/[.^\/]*)$/, '')
|
62
|
+
end
|
63
|
+
|
64
|
+
def svn_info
|
65
|
+
stream = IO.popen("svn info #{@package.realpath}")
|
66
|
+
return YAML.load(stream)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/plugins/10svn/lib/init.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: filament
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2006-03-
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2006-03-18 00:00:00 -05:00
|
8
8
|
summary: A flexible dependency-based build platform based on Rake
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -108,10 +108,10 @@ files:
|
|
108
108
|
- plugins/10svn/lib/filament
|
109
109
|
- plugins/10svn/lib/init.rb
|
110
110
|
- plugins/10svn/lib/svn.rb
|
111
|
-
- plugins/10svn/lib/filament/package
|
112
111
|
- plugins/10svn/lib/filament/plugins
|
113
|
-
- plugins/10svn/lib/filament/
|
112
|
+
- plugins/10svn/lib/filament/scm
|
114
113
|
- plugins/10svn/lib/filament/plugins/svn.rb
|
114
|
+
- plugins/10svn/lib/filament/scm/svn.rb
|
115
115
|
- README
|
116
116
|
- CHANGELOG
|
117
117
|
test_files: []
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'filament/package'
|
2
|
-
|
3
|
-
module Filament
|
4
|
-
class Package
|
5
|
-
# returns true if this package is under svn control
|
6
|
-
def svn?
|
7
|
-
p = @realpath + '.svn'
|
8
|
-
return p.exist?
|
9
|
-
end
|
10
|
-
|
11
|
-
def revision
|
12
|
-
return svn_revision
|
13
|
-
end
|
14
|
-
|
15
|
-
def update
|
16
|
-
return svn_update
|
17
|
-
end
|
18
|
-
|
19
|
-
def status
|
20
|
-
return svn_status
|
21
|
-
end
|
22
|
-
|
23
|
-
def commit(msg)
|
24
|
-
return svn_commit(msg)
|
25
|
-
end
|
26
|
-
|
27
|
-
def svn_info
|
28
|
-
stream = IO.popen("svn info #{@pathname.realpath}")
|
29
|
-
return YAML.load(stream)
|
30
|
-
end
|
31
|
-
|
32
|
-
def svn_revision
|
33
|
-
return 0 unless svn?
|
34
|
-
return svn_info['Last Changed Rev'].to_i
|
35
|
-
end
|
36
|
-
|
37
|
-
def svn_url
|
38
|
-
return nil unless svn?
|
39
|
-
return svn_info['URL']
|
40
|
-
end
|
41
|
-
|
42
|
-
def svn_base_url
|
43
|
-
return url.gsub(/\/(trunk|branches\/[.^\/]*|tags\/[.^\/]*)$/, '')
|
44
|
-
end
|
45
|
-
|
46
|
-
# if this package is under version control, it will update it
|
47
|
-
# if this package has subpackages, it will update them
|
48
|
-
def svn_update
|
49
|
-
if svn?
|
50
|
-
puts full_name
|
51
|
-
system('svn update')
|
52
|
-
end
|
53
|
-
subpackages.each { |s| s.update }
|
54
|
-
end
|
55
|
-
|
56
|
-
# if this package is under version control, it will print its status
|
57
|
-
# if this package has subpackages it will print their status
|
58
|
-
def svn_status
|
59
|
-
if svn?
|
60
|
-
puts full_name
|
61
|
-
system('svn status')
|
62
|
-
end
|
63
|
-
subpackages.each { |s| s.status }
|
64
|
-
end
|
65
|
-
|
66
|
-
# if this package is under version control, it will commit it with the
|
67
|
-
# given msg
|
68
|
-
# if this package has subpackages it will commit them
|
69
|
-
def svn_commit(msg)
|
70
|
-
if svn?
|
71
|
-
puts full_name
|
72
|
-
system("svn ci -m \"#{msg}\"")
|
73
|
-
end
|
74
|
-
subpackages.each { |s| s.commit(msg) }
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.build_uri(h)
|
78
|
-
uri = h[:uri]
|
79
|
-
|
80
|
-
return uri unless @uri.nil?
|
81
|
-
|
82
|
-
package_path = h[:package_path]
|
83
|
-
base_uri = h[:root_uri] || ENV['BASE_SVN_URL']
|
84
|
-
|
85
|
-
tag = h[:tag]
|
86
|
-
branch = h[:branch]
|
87
|
-
|
88
|
-
return "#{base_uri}/tags/#{package_path}/#{tag}" unless tag.nil?
|
89
|
-
return "#{base_uri}/branches/#{package_path}/#{branch}" unless branch.nil?
|
90
|
-
return "#{base_uri}/trunk/#{package_path}"
|
91
|
-
end
|
92
|
-
|
93
|
-
# checks out the package into the current wd (preserving its path)
|
94
|
-
def self.checkout(h)
|
95
|
-
uri = Package.build_uri(h)
|
96
|
-
pkg = Package.create(h)
|
97
|
-
pkg.system("svn co #{uri} .")
|
98
|
-
return pkg
|
99
|
-
end
|
100
|
-
|
101
|
-
# exports a url to a given dir
|
102
|
-
def self.export(h)
|
103
|
-
uri = Package.build_uri(h)
|
104
|
-
pkg = Package.create(h)
|
105
|
-
pkg.system("svn export #{uri} .")
|
106
|
-
return pkg
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
#class URI::Generic
|
113
|
-
# def to_package
|
114
|
-
# s = SVN.new(uri)
|
115
|
-
# raise "not an svn uri" unless s.valid?
|
116
|
-
# pkg = export(:package_path => s.path,
|
117
|
-
# :uri => s.uri,
|
118
|
-
# :root_dir => Filament::Package.CACHE_DIR)
|
119
|
-
# return pkg
|
120
|
-
# end
|
121
|
-
#end
|