distil 0.10.4 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/assets/distil.js +359 -0
- data/bin/distil +33 -10
- data/distil.gemspec +35 -24
- data/lib/distil/configurable/file-set.rb +86 -0
- data/lib/distil/configurable/interpolated.rb +36 -0
- data/lib/distil/configurable/output-path.rb +25 -0
- data/lib/distil/configurable/project-path.rb +25 -0
- data/lib/distil/configurable.rb +164 -0
- data/lib/distil/error-reporter.rb +63 -0
- data/lib/distil/product/concatenated.rb +85 -0
- data/lib/distil/product/css-product.rb +37 -0
- data/lib/distil/product/debug.rb +34 -0
- data/lib/distil/product/javascript-base-product.rb +35 -0
- data/lib/distil/product/javascript-doc-product.rb +61 -0
- data/lib/distil/product/javascript-product.rb +131 -0
- data/lib/distil/product/minified.rb +32 -0
- data/lib/distil/product.rb +97 -0
- data/lib/distil/project/distil-project.rb +99 -0
- data/lib/distil/project/external-project.rb +53 -0
- data/lib/distil/project.rb +78 -0
- data/lib/distil/source-file/css-file.rb +14 -0
- data/lib/distil/source-file/html-file.rb +14 -0
- data/lib/distil/source-file/javascript-file.rb +17 -0
- data/lib/distil/source-file/json-file.rb +16 -0
- data/lib/distil/source-file.rb +172 -0
- data/lib/distil/target.rb +235 -0
- data/lib/distil/task/css-dependency-task.rb +64 -0
- data/lib/distil/task/jsl-dependency-task.rb +49 -0
- data/lib/distil/task/nib-task.rb +72 -0
- data/lib/distil/task/validate-js-task.rb +75 -0
- data/lib/distil/task.rb +50 -0
- data/lib/distil.rb +72 -0
- data/lib/jsl.conf +4 -0
- data/vendor/jsl-0.3.0/src/Makefile.ref +16 -6
- data/vendor/jsl-0.3.0/src/config.mk +32 -2
- data/vendor/jsl-0.3.0/src/fdlibm/Makefile.ref +1 -2
- data/vendor/jsl-0.3.0/src/jsl.c +124 -13
- data/vendor/jsl-0.3.0/src/rules.mk +2 -1
- metadata +49 -28
- data/lib/bootstrap-template.js +0 -58
- data/lib/configurable.rb +0 -161
- data/lib/file-set.rb +0 -49
- data/lib/file-types/css-file.rb +0 -12
- data/lib/file-types/html-file.rb +0 -11
- data/lib/file-types/javascript-file.rb +0 -24
- data/lib/file-types/json-file.rb +0 -17
- data/lib/filter.rb +0 -41
- data/lib/filters/css-filter.rb +0 -58
- data/lib/filters/file-reference-filter.rb +0 -30
- data/lib/filters/jsl-dependency-filter.rb +0 -44
- data/lib/project.rb +0 -174
- data/lib/source-file.rb +0 -197
- data/lib/target.rb +0 -102
- data/lib/task.rb +0 -212
- data/lib/tasks/copy-task.rb +0 -17
- data/lib/tasks/css-task.rb +0 -12
- data/lib/tasks/javascript-task.rb +0 -206
- data/lib/tasks/multiple-output-task.rb +0 -140
- data/lib/tasks/output-task.rb +0 -76
- data/lib/tasks/single-output-task.rb +0 -104
- data/lib/tasks/test-task.rb +0 -280
@@ -0,0 +1,235 @@
|
|
1
|
+
module Distil
|
2
|
+
|
3
|
+
class Target < Configurable
|
4
|
+
include ErrorReporter
|
5
|
+
|
6
|
+
attr_accessor :project, :assets
|
7
|
+
|
8
|
+
option :version, String
|
9
|
+
option :name, String
|
10
|
+
option :notice_file, ProjectPath, "$(source_folder)/NOTICE", :aliases=>['notice']
|
11
|
+
option :target_type, String, FRAMEWORK_TYPE, :aliases=>['type'], :valid_values=>[FRAMEWORK_TYPE, APP_TYPE]
|
12
|
+
|
13
|
+
option :include_files, FileSet, :aliases=>['source']
|
14
|
+
option :exclude_files, FileSet, :aliases=>['exclude']
|
15
|
+
|
16
|
+
option :include_projects, [], :aliases=>['include']
|
17
|
+
|
18
|
+
option :validate, true
|
19
|
+
option :generate_docs, false
|
20
|
+
|
21
|
+
option :minify, true
|
22
|
+
option :compress, true
|
23
|
+
|
24
|
+
def initialize(settings, project)
|
25
|
+
@project=project
|
26
|
+
|
27
|
+
super(settings, project)
|
28
|
+
|
29
|
+
@assets= Set.new
|
30
|
+
@probed= Set.new
|
31
|
+
@contents= {}
|
32
|
+
@asset_aliases= {}
|
33
|
+
|
34
|
+
if !include_files
|
35
|
+
self.include_files= FileSet.new
|
36
|
+
end
|
37
|
+
|
38
|
+
if !exclude_files
|
39
|
+
self.exclude_files= FileSet.new
|
40
|
+
end
|
41
|
+
|
42
|
+
include_projects.each { |p|
|
43
|
+
external_project= project.external_project_with_name(p)
|
44
|
+
if !external_project
|
45
|
+
raise ValidationError.new("No such external project: #{p}")
|
46
|
+
end
|
47
|
+
|
48
|
+
if (WEAK_LINKAGE==external_project.linkage)
|
49
|
+
external_project.linkage= STRONG_LINKAGE
|
50
|
+
end
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def source_folder
|
55
|
+
project.source_folder
|
56
|
+
end
|
57
|
+
|
58
|
+
def tasks
|
59
|
+
@tasks ||= Task.tasks.map { |task| task.new(@extras.clone, self) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def products
|
63
|
+
return @products if @products
|
64
|
+
|
65
|
+
product_types= [CssProduct, CssDebugProduct, JavascriptProduct, JavascriptDebugProduct]
|
66
|
+
if minify
|
67
|
+
product_types << CssMinifiedProduct
|
68
|
+
product_types << JavascriptMinifiedProduct
|
69
|
+
end
|
70
|
+
|
71
|
+
if generate_docs
|
72
|
+
product_types << JavascriptDocProduct
|
73
|
+
end
|
74
|
+
|
75
|
+
@products=[]
|
76
|
+
product_types.each { |t|
|
77
|
+
product= t.new(@extras.clone, self)
|
78
|
+
product.files= files
|
79
|
+
@products << product if !product.files.empty?
|
80
|
+
}
|
81
|
+
|
82
|
+
@products
|
83
|
+
end
|
84
|
+
|
85
|
+
def notice_text
|
86
|
+
@notice_text if @notice_text
|
87
|
+
|
88
|
+
if (nil==@notice_text)
|
89
|
+
if (!File.exists?(notice_file))
|
90
|
+
@notice_text= ""
|
91
|
+
else
|
92
|
+
text= File.read(notice_file).strip
|
93
|
+
text= " #{text}".gsub(/\n/, "\n ")
|
94
|
+
@notice_text= "/*!\n#{text}\n*/\n\n"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def include_file(file)
|
100
|
+
return if @probed.include?(file)
|
101
|
+
return if @files.include?(file)
|
102
|
+
return if !include_files.include?(file)
|
103
|
+
return if exclude_files.include?(file)
|
104
|
+
|
105
|
+
@probed << file
|
106
|
+
|
107
|
+
tasks.each { |t| t.include_file(file) }
|
108
|
+
|
109
|
+
file.dependencies.each { |d| include_file(d) }
|
110
|
+
@assets.merge(file.assets)
|
111
|
+
@assets << file
|
112
|
+
@files << file
|
113
|
+
end
|
114
|
+
|
115
|
+
def files
|
116
|
+
return @files if @files
|
117
|
+
|
118
|
+
@probed= Set.new
|
119
|
+
@files= []
|
120
|
+
|
121
|
+
tasks.each { |t|
|
122
|
+
extra_files= t.find_files
|
123
|
+
extra_files.each { |f| include_files.include_file(f) }
|
124
|
+
}
|
125
|
+
|
126
|
+
include_files.each { |i| include_file(i) }
|
127
|
+
|
128
|
+
@files
|
129
|
+
end
|
130
|
+
|
131
|
+
def symlink_assets
|
132
|
+
folders= []
|
133
|
+
|
134
|
+
assets.each { |a|
|
135
|
+
path= a.file_path || a.relative_to_folder(source_folder)
|
136
|
+
|
137
|
+
parts= File.dirname(path).split(File::SEPARATOR)
|
138
|
+
if ('.'==parts[0])
|
139
|
+
product_path= File.join(output_folder, path)
|
140
|
+
FileUtils.rm product_path if File.exists? product_path
|
141
|
+
File.symlink a.relative_to_folder(output_folder), product_path
|
142
|
+
next
|
143
|
+
end
|
144
|
+
|
145
|
+
for i in (0..parts.length-1)
|
146
|
+
f= parts[0..i].join(File::SEPARATOR)
|
147
|
+
if !folders.include?(f)
|
148
|
+
folders << f
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
}
|
153
|
+
|
154
|
+
folders.sort!
|
155
|
+
|
156
|
+
folders.each { |f|
|
157
|
+
src_folder= File.join(source_folder, f)
|
158
|
+
product_folder= File.join(project.output_folder, f)
|
159
|
+
|
160
|
+
next if File.exists?(product_folder)
|
161
|
+
File.symlink src_folder, product_folder
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
def copy_assets
|
166
|
+
assets.each { |a|
|
167
|
+
a.copy_to(project.output_folder, source_folder)
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
def build_assets
|
172
|
+
if (RELEASE_MODE==project.mode)
|
173
|
+
copy_assets
|
174
|
+
else
|
175
|
+
symlink_assets
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_asset(asset)
|
180
|
+
@assets << asset
|
181
|
+
end
|
182
|
+
|
183
|
+
def set_alias_for_asset(asset_alias, asset_file)
|
184
|
+
@assets << asset_file
|
185
|
+
@asset_aliases[asset_file.to_s]= asset_alias
|
186
|
+
end
|
187
|
+
|
188
|
+
def alias_for_asset(asset_file)
|
189
|
+
full_path= asset_file.to_s
|
190
|
+
@asset_aliases[full_path] || asset_file.relative_to_folder(source_folder)
|
191
|
+
end
|
192
|
+
|
193
|
+
def build
|
194
|
+
puts "\n#{name}:\n\n"
|
195
|
+
|
196
|
+
tasks.each { |t| t.process_files(files) }
|
197
|
+
|
198
|
+
products.each { |p| p.write_output }
|
199
|
+
|
200
|
+
build_assets
|
201
|
+
end
|
202
|
+
|
203
|
+
def find_file(file, source_file=nil)
|
204
|
+
return nil if project.external_projects.nil?
|
205
|
+
|
206
|
+
parts= file.split(File::SEPARATOR)
|
207
|
+
project_name= parts[0]
|
208
|
+
|
209
|
+
external_project= project.external_project_with_name(project_name)
|
210
|
+
return nil if !external_project
|
211
|
+
|
212
|
+
if 1==parts.length
|
213
|
+
return SourceFile::from_path(external_project.product_name(:import, source_file.extension))
|
214
|
+
else
|
215
|
+
return SourceFile::from_path(File.join(external_project.source_folder, *parts[1..-1]))
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def get_content_for_file(file)
|
220
|
+
file=SourceFile.from_path(file) if !file.is_a?(SourceFile)
|
221
|
+
@contents[file.to_s] ||= file.content
|
222
|
+
end
|
223
|
+
|
224
|
+
def set_content_for_file(file, content)
|
225
|
+
@contents[file.to_s] = content
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
# load all the other target types
|
233
|
+
# Dir.glob("#{File.dirname(__FILE__)}/target/*-target.rb") { |file|
|
234
|
+
# require file
|
235
|
+
# }
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Distil
|
2
|
+
|
3
|
+
CSS_IMPORT_REGEX = /@import\s+url\("?(.*\.css)"?\)/
|
4
|
+
|
5
|
+
class CssDependencyFilter < Task
|
6
|
+
|
7
|
+
def handles_file(file)
|
8
|
+
return ["css"].include?(file.content_type)
|
9
|
+
end
|
10
|
+
|
11
|
+
def include_file(file)
|
12
|
+
return if !handles_file(file)
|
13
|
+
|
14
|
+
content= target.get_content_for_file(file)
|
15
|
+
|
16
|
+
# Replace all ' (single quotes) with " (double quotes)
|
17
|
+
content.gsub!(/\'/,'"')
|
18
|
+
# Force a newline after a rule terminating ; (semi-colon)
|
19
|
+
content.gsub!(/;(\n|\r)*/, ";\n")
|
20
|
+
|
21
|
+
source_folder= get_option("source_folder")
|
22
|
+
|
23
|
+
# Rewrites the 'url("...")' rules to a relative path
|
24
|
+
# based on the location of the new concatenated CSS file.
|
25
|
+
line_num=0
|
26
|
+
|
27
|
+
lines= content.split("\n")
|
28
|
+
|
29
|
+
lines.each { |line|
|
30
|
+
|
31
|
+
line_num+=1
|
32
|
+
|
33
|
+
line.gsub!(CSS_IMPORT_REGEX) { |match|
|
34
|
+
css_file= File.join(file.parent_folder, $1)
|
35
|
+
|
36
|
+
if (!File.exists?(css_file))
|
37
|
+
file.error "Imported CSS file not found: #{$1}", line_num
|
38
|
+
# leave the @import rule in place
|
39
|
+
match
|
40
|
+
else
|
41
|
+
file.add_dependency(SourceFile.from_path(css_file))
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
line.gsub!(/url\("?(.*\.(jpg|png|gif))"?\)/) { |match|
|
46
|
+
image_file= File.join(file.parent_folder, $1)
|
47
|
+
|
48
|
+
if (!File.exists?(image_file))
|
49
|
+
file.warning "Resource not found: #{$1} (#{image_file})", line_num
|
50
|
+
"url(\"#{$1}\")"
|
51
|
+
else
|
52
|
+
asset= SourceFile.from_path(image_file)
|
53
|
+
file.add_asset(asset)
|
54
|
+
"url(\"#{asset.relative_to_folder(source_folder)}\")"
|
55
|
+
end
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
target.set_content_for_file(file, lines.join("\n"))
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Distil
|
2
|
+
|
3
|
+
JSL_IMPORT_REGEX= /\/\*jsl:import\s+([^\*]*)\*\//
|
4
|
+
|
5
|
+
class JslDependencyTask < Task
|
6
|
+
|
7
|
+
def handles_file(file)
|
8
|
+
return ["js"].include?(file.content_type)
|
9
|
+
end
|
10
|
+
|
11
|
+
def include_file(file)
|
12
|
+
return if !handles_file(file)
|
13
|
+
|
14
|
+
content= target.get_content_for_file(file).split("\n")
|
15
|
+
|
16
|
+
line_num=0
|
17
|
+
|
18
|
+
content.each { |line|
|
19
|
+
|
20
|
+
line_num+=1
|
21
|
+
|
22
|
+
# handle dependencies
|
23
|
+
line.gsub!(JSL_IMPORT_REGEX) { |match|
|
24
|
+
|
25
|
+
import_file= File.expand_path(File.join(file.parent_folder, $1))
|
26
|
+
if (File.exists?(import_file))
|
27
|
+
file.add_dependency SourceFile.from_path(import_file)
|
28
|
+
else
|
29
|
+
dependency= target.find_file($1, file)
|
30
|
+
if (dependency)
|
31
|
+
file.add_dependency dependency
|
32
|
+
else
|
33
|
+
file.error "Missing import file: #{$1}", line_num
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# replace jsl import with empty string
|
38
|
+
""
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|
43
|
+
|
44
|
+
target.set_content_for_file(file, content.join("\n"))
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Distil
|
2
|
+
|
3
|
+
NIB_ASSET_REGEX= /(NIB\.asset(?:Url)?)\(['"]([^)]+)['"]\)/
|
4
|
+
|
5
|
+
class NibTask < Task
|
6
|
+
include ErrorReporter
|
7
|
+
|
8
|
+
def handles_file(file)
|
9
|
+
return ["js"].include?(file.content_type)
|
10
|
+
end
|
11
|
+
|
12
|
+
def preprocess_file(nib_name, nib_folder, file)
|
13
|
+
return if !handles_file(file)
|
14
|
+
|
15
|
+
content= target.get_content_for_file(file).split("\n")
|
16
|
+
|
17
|
+
line_num=0
|
18
|
+
|
19
|
+
content.each { |line|
|
20
|
+
|
21
|
+
line_num+=1
|
22
|
+
|
23
|
+
# handle dependencies
|
24
|
+
line.gsub!(NIB_ASSET_REGEX) { |match|
|
25
|
+
asset_file= File.expand_path(File.join(file.parent_folder, $2))
|
26
|
+
asset_file= SourceFile.from_path(asset_file)
|
27
|
+
if (!File.exists?(asset_file))
|
28
|
+
file.warning "Asset not found: #{$2} (#{asset_file})", line_num
|
29
|
+
"#{$0}"
|
30
|
+
else
|
31
|
+
"#{$1}(\"#{asset_file.relative_to_folder(target.source_folder)}\")"
|
32
|
+
# "#{$1}(\"#{nib_name}##{asset_file.relative_to_folder(nib_folder)}\")"
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
target.set_content_for_file(file, content.join("\n"))
|
39
|
+
end
|
40
|
+
|
41
|
+
def include_file(file)
|
42
|
+
|
43
|
+
return if !File.fnmatch("**/*.jsnib/*.js", file)
|
44
|
+
# puts "Nib asset: #{file}"
|
45
|
+
match= file.to_s.match(/([^\.\/]+).jsnib\/(.*)\.js/)
|
46
|
+
return if match[1]!=match[2]
|
47
|
+
|
48
|
+
nib_name= match[1]
|
49
|
+
nib_folder= File.dirname(file)
|
50
|
+
|
51
|
+
preprocess_file(nib_name, nib_folder, file)
|
52
|
+
|
53
|
+
|
54
|
+
# Found main js file inside the JSNib add assets for all the other files
|
55
|
+
target.set_alias_for_asset("#{match[1]}##{match[2]}", file)
|
56
|
+
Dir.glob("#{File.dirname(file)}/**/*") { |asset|
|
57
|
+
next if File.directory?(asset) || asset.to_s==file.to_s
|
58
|
+
|
59
|
+
asset= SourceFile.from_path(asset)
|
60
|
+
preprocess_file(nib_name, nib_folder, asset)
|
61
|
+
file.add_asset(asset)
|
62
|
+
|
63
|
+
if 'html'==asset.content_type
|
64
|
+
target.set_alias_for_asset("#{nib_name}##{asset.relative_to_folder(nib_folder)}", asset)
|
65
|
+
end
|
66
|
+
}
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Distil
|
2
|
+
|
3
|
+
LINT_COMMAND= "#{VENDOR_DIR}/jsl-0.3.0/bin/jsl"
|
4
|
+
# LINT_COMMAND= "/Users/jeff/.gem/ruby/1.8/gems/distil-0.10.2/vendor/jsl-0.3.0/bin/jsl"
|
5
|
+
|
6
|
+
class ValidateJsTask < Task
|
7
|
+
|
8
|
+
include ErrorReporter
|
9
|
+
|
10
|
+
option :jsl_conf, "#{LIB_DIR}/jsl.conf"
|
11
|
+
|
12
|
+
def handles_file(file)
|
13
|
+
return ["js"].include?(file.content_type)
|
14
|
+
end
|
15
|
+
|
16
|
+
def process_files(files)
|
17
|
+
return if (!File.exists?(LINT_COMMAND))
|
18
|
+
|
19
|
+
tmp= Tempfile.new("jsl.conf")
|
20
|
+
|
21
|
+
conf_files= [ "jsl.conf",
|
22
|
+
"#{ENV['HOME']}/.jsl.conf",
|
23
|
+
jsl_conf
|
24
|
+
]
|
25
|
+
|
26
|
+
jsl_conf= conf_files.find { |f| File.exists?(f) }
|
27
|
+
|
28
|
+
tmp << File.read(jsl_conf)
|
29
|
+
tmp << "\n"
|
30
|
+
|
31
|
+
tmp << "+define distil\n"
|
32
|
+
|
33
|
+
# add aliases
|
34
|
+
target.project.external_projects.each { |project|
|
35
|
+
import_file= project.product_name(:import, 'js')
|
36
|
+
next if !File.exist?(import_file)
|
37
|
+
tmp << "+alias #{project.name} #{import_file}\n"
|
38
|
+
}
|
39
|
+
|
40
|
+
files.each { |f|
|
41
|
+
next if !handles_file(f)
|
42
|
+
tmp << "+process #{f}\n"
|
43
|
+
}
|
44
|
+
|
45
|
+
tmp.close()
|
46
|
+
|
47
|
+
command= "#{LINT_COMMAND} -nologo -nofilelisting -conf #{tmp.path}"
|
48
|
+
|
49
|
+
stdin, stdout, stderr= Open3.popen3(command)
|
50
|
+
stdin.close
|
51
|
+
output= stdout.read
|
52
|
+
errors= stderr.read
|
53
|
+
|
54
|
+
tmp.delete
|
55
|
+
|
56
|
+
output= output.split("\n")
|
57
|
+
summary= output.pop
|
58
|
+
match= summary.match(/(\d+)\s+error\(s\), (\d+)\s+warning\(s\)/)
|
59
|
+
if (match)
|
60
|
+
@@error_count+= match[1].to_i
|
61
|
+
@@warning_count+= match[2].to_i
|
62
|
+
end
|
63
|
+
|
64
|
+
output= output.join("\n")
|
65
|
+
|
66
|
+
if (!output.empty?)
|
67
|
+
puts output
|
68
|
+
puts
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/lib/distil/task.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Distil
|
4
|
+
|
5
|
+
class Task < Configurable
|
6
|
+
|
7
|
+
def initialize(options, target)
|
8
|
+
@target= target
|
9
|
+
super(options, target)
|
10
|
+
end
|
11
|
+
|
12
|
+
def project
|
13
|
+
target.project
|
14
|
+
end
|
15
|
+
|
16
|
+
def target
|
17
|
+
@target
|
18
|
+
end
|
19
|
+
|
20
|
+
@@tasks= []
|
21
|
+
def self.inherited(subclass)
|
22
|
+
@@tasks << subclass
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.tasks
|
26
|
+
@@tasks
|
27
|
+
end
|
28
|
+
|
29
|
+
def handles_file?(file)
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
def find_files
|
34
|
+
[]
|
35
|
+
end
|
36
|
+
|
37
|
+
def include_file(file)
|
38
|
+
end
|
39
|
+
|
40
|
+
def process_files(files)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# load all the other task types
|
48
|
+
Dir.glob("#{LIB_DIR}/distil/task/*-task.rb") { |file|
|
49
|
+
require file
|
50
|
+
}
|
data/lib/distil.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require "set"
|
2
|
+
require 'yaml'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'zlib'
|
6
|
+
require "open3"
|
7
|
+
require 'uri'
|
8
|
+
|
9
|
+
def class_attr(*rest)
|
10
|
+
rest.each { |name|
|
11
|
+
class_eval %(
|
12
|
+
def self.#{name}(*rest)
|
13
|
+
if (rest.length>0)
|
14
|
+
@#{name}= rest[0]
|
15
|
+
else
|
16
|
+
@#{name} || (superclass.respond_to?(name) ? superclass.#{name} : nil)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def self.#{name}=(value)
|
20
|
+
@#{name}= value
|
21
|
+
end
|
22
|
+
def #{name}
|
23
|
+
@#{name} || self.class.#{name}
|
24
|
+
end
|
25
|
+
def #{name}=(value)
|
26
|
+
@#{name}=value
|
27
|
+
end
|
28
|
+
)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def exist?(path, file)
|
33
|
+
File.file?(File.join(path, file))
|
34
|
+
end
|
35
|
+
|
36
|
+
module Distil
|
37
|
+
|
38
|
+
FRAMEWORK_TYPE = "framework"
|
39
|
+
APP_TYPE = "application"
|
40
|
+
|
41
|
+
WEAK_LINKAGE = 'weak'
|
42
|
+
STRONG_LINKAGE = 'strong'
|
43
|
+
LAZY_LINKAGE = 'lazy'
|
44
|
+
|
45
|
+
DEBUG_MODE = 'debug'
|
46
|
+
RELEASE_MODE = 'release'
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# Do a simple token substitution. Tokens begin and end with @.
|
51
|
+
def replace_tokens(string, params)
|
52
|
+
return string.gsub(/(\n[\t ]*)?@([^@ \t\r\n]*)@/) { |m|
|
53
|
+
key= $2
|
54
|
+
ws= $1
|
55
|
+
value= params[key]||m;
|
56
|
+
if (ws && ws.length)
|
57
|
+
ws + value.split("\n").join(ws);
|
58
|
+
else
|
59
|
+
value
|
60
|
+
end
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
require 'distil/error-reporter'
|
67
|
+
require 'distil/configurable'
|
68
|
+
require 'distil/source-file'
|
69
|
+
require 'distil/task'
|
70
|
+
require 'distil/product'
|
71
|
+
require 'distil/target'
|
72
|
+
require 'distil/project'
|
data/lib/jsl.conf
CHANGED
@@ -46,6 +46,10 @@
|
|
46
46
|
+legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
|
47
47
|
+jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
|
48
48
|
+useless_comparison # useless comparison; comparing identical expressions
|
49
|
+
+with_statement # with statement hides undeclared variables; use temporary variable instead
|
50
|
+
+trailing_comma_in_array # extra comma is not recommended in array initializers
|
51
|
+
+assign_to_function_call # assignment to a function call
|
52
|
+
+parseint_missing_radix # parseInt missing radix parameter
|
49
53
|
|
50
54
|
|
51
55
|
### Output format
|
@@ -89,9 +89,14 @@ LDFLAGS += -lm
|
|
89
89
|
endif
|
90
90
|
|
91
91
|
# Prevent floating point errors caused by VC++ optimizations
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
ifdef USE_MSVC
|
93
|
+
_MSC_VER = $(shell $(CC) 2>&1 | sed -n 's/.*Compiler Version \([0-9]*\)\.\([0-9]*\).*/\1\2/p')
|
94
|
+
ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
|
95
|
+
CFLAGS += -Op
|
96
|
+
else
|
97
|
+
CFLAGS += -fp:precise
|
98
|
+
endif
|
99
|
+
endif # USE_MSVC
|
95
100
|
|
96
101
|
#
|
97
102
|
# Ask perl what flags it was built with, so we can build js with similar flags
|
@@ -332,11 +337,15 @@ endif
|
|
332
337
|
# special rule for jsmath.o since we want to incrementally link
|
333
338
|
# against fdlibm to pull in only what is needed
|
334
339
|
$(OBJDIR)/jsmath.o: jsmath.c jsmath.h jslibmath.h $(FDLIBM_LIBRARY)
|
335
|
-
|
340
|
+
ifeq ($(OS_ARCH),OS2)
|
341
|
+
$(CC) -Fo$(JSMATH_PRELINK) -c $(CFLAGS) $<
|
342
|
+
else
|
343
|
+
ifdef USE_MSVC
|
336
344
|
$(CC) -Fo$(JSMATH_PRELINK) -c $(CFLAGS) $<
|
337
345
|
else
|
338
346
|
$(CC) -o $(JSMATH_PRELINK) -c $(CFLAGS) $<
|
339
347
|
endif
|
348
|
+
endif
|
340
349
|
|
341
350
|
ifeq ($(OS_ARCH),QNX)
|
342
351
|
ifneq ($(OS_TARGET),NTO)
|
@@ -345,12 +354,13 @@ else
|
|
345
354
|
$(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
346
355
|
endif
|
347
356
|
else
|
348
|
-
|
357
|
+
ifeq ($(OS_ARCH),WINNT)
|
349
358
|
@echo Warning: to use $(LIBRARY) must also link against $(FDLIBM_LIBRARY)
|
350
359
|
@cp $(JSMATH_PRELINK) $@
|
351
|
-
|
360
|
+
else
|
352
361
|
$(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
353
362
|
endif
|
363
|
+
endif
|
354
364
|
|
355
365
|
# Note: generated headers must be built before descending
|
356
366
|
# into fdlibm directory
|