Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

First stage for adding goog.provide/require style dependencies. #1965

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build/
# Refer http://www.kernel.org/pub/software/scm/git/docs/gitignore.html

/build/
angularjs.netrc
jstd.log
.DS_Store
Expand All @@ -12,3 +14,4 @@ angular.js.tmproj
node_modules
angular.xcodeproj
.idea
*.pyc
35 changes: 30 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'tempfile'
require 'yaml'
include FileUtils

Expand Down Expand Up @@ -60,9 +61,10 @@ end

desc 'Concat AngularJS files'
task :concat => :init do
angularjs_temp = closure_builder(files['angularSrc'])
concat_file('angular.js', [
'src/angular.prefix',
files['angularSrc'],
angularjs_temp,
'src/angular.suffix',
], gen_css('css/angular.css', true))

Expand Down Expand Up @@ -306,6 +308,21 @@ def closure_compile(filename)
end


def closure_builder(deps)
tempfile = Tempfile.new('angular-').path
puts "Invoking closure_builder.py --output_file=#{tempfile} ..."
sh "./lib/closure-library/closure/bin/build/closurebuilder.py" +
" --root=./lib/closure-library/closure" +
" --namespace=angular" +
" --output_mode=script" +
" --output_file=#{tempfile}" +
" " + deps.flatten.join(" ")
rewrite_file(tempfile) do |content| fixup_concat_contents(content)
return tempfile
end
end


def concat_file(filename, deps, footer='')
puts "Creating #{filename} ..."
File.open(path_to(filename), 'w') do |f|
Expand All @@ -316,9 +333,8 @@ def concat_file(filename, deps, footer='')
gsub('"NG_VERSION_MAJOR"', NG_VERSION.major).
gsub('"NG_VERSION_MINOR"', NG_VERSION.minor).
gsub('"NG_VERSION_DOT"', NG_VERSION.dot).
gsub('"NG_VERSION_CODENAME"', NG_VERSION.codename).
gsub(/^\s*['"]use strict['"];?\s*$/, ''). # remove all file-specific strict mode flags
sub(/\(function\([^)]*\)\s*\{/, "\\0\n'use strict';") # add single strict mode flag
gsub('"NG_VERSION_CODENAME"', NG_VERSION.codename)
content = fixup_concat_contents(content)

f.write(content)
f.write(footer)
Expand All @@ -331,13 +347,22 @@ def concat_module(name, files, footer='')
end


def fixup_concat_contents(content)
return content.
gsub(/^\s*goog\.(require|provide)\(.*$/, ''). # remove all goog.require / goog.provide directives
gsub(/^\s*['"]use strict['"];?\s*$/, ''). # remove all file-specific strict mode flags
sub(/\n\/\/ BEGIN_FILE: goog\/base.js\n.*\n\/\/ END_FILE: goog\/base.js/m, "") # remove goog\/base.js
sub(/\(function\([^)]*\)\s*\{/, "\\0\n'use strict';") # add single strict mode flag
end


def rewrite_file(filename)
File.open(filename, File::RDWR) do |f|
content = f.read

content = yield content

raise "File rewrite failed - No content!" unless content
raise "File rewrite failed - No content! (file: #{filename}" unless content

f.truncate 0
f.rewind
Expand Down
9 changes: 9 additions & 0 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ angularFiles = {

'src/auto/injector.js',

'src/_all.js',
'src/ng/_all.js',
'src/ng/anchorScroll.js',
'src/ng/browser.js',
'src/ng/cacheFactory.js',
Expand All @@ -31,11 +33,13 @@ angularFiles = {
'src/ng/timeout.js',

'src/ng/filter.js',
'src/ng/filter/_all.js',
'src/ng/filter/filter.js',
'src/ng/filter/filters.js',
'src/ng/filter/limitTo.js',
'src/ng/filter/orderBy.js',

'src/ng/directive/_all.js',
'src/ng/directive/directives.js',
'src/ng/directive/a.js',
'src/ng/directive/booleanAttrs.js',
Expand Down Expand Up @@ -63,8 +67,11 @@ angularFiles = {
],

'angularSrcModules': [
'src/ngCookies/_all.js',
'src/ngCookies/cookies.js',
'src/ngResource/_all.js',
'src/ngResource/resource.js',
'src/ngSanitize/_all.js',
'src/ngSanitize/sanitize.js',
'src/ngSanitize/directive/ngBindHtml.js',
'src/ngSanitize/filter/linky.js',
Expand All @@ -74,6 +81,7 @@ angularFiles = {
],

'angularScenario': [
'src/ngScenario/_all.js',
'src/ngScenario/Scenario.js',
'src/ngScenario/Application.js',
'src/ngScenario/Describe.js',
Expand Down Expand Up @@ -114,6 +122,7 @@ angularFiles = {
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
'lib/jquery/jquery.js',
'test/jquery_remove.js',
'lib/closure-library/closure/goog/base.js',
'@angularSrc',
'src/publishExternalApis.js',
'@angularSrcModules',
Expand Down
36 changes: 25 additions & 11 deletions lib/closure-compiler/README
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ the parse tree data structures were extracted and modified
significantly for use by Google's JavaScript compiler.

Local Modifications: The packages have been renamespaced. All code not
relavant to parsing has been removed. A JSDoc parser and static typing
relevant to parsing has been removed. A JsDoc parser and static typing
system have been added.


-----
Code in:
lib/libtrunk_rhino_parser_jarjared.jar
lib/rhino

Rhino
URL: http://www.mozilla.org/rhino
Expand All @@ -161,9 +161,8 @@ License: Netscape Public License and MPL / GPL dual license

Description: Mozilla Rhino is an implementation of JavaScript for the JVM.

Local Modifications: None. We've used JarJar to renamespace the code
post-compilation. See:
http://code.google.com/p/jarjar/
Local Modifications: Minor changes to parsing JSDoc that usually get pushed
up-stream to Rhino trunk.


-----
Expand All @@ -172,7 +171,7 @@ lib/args4j.jar

Args4j
URL: https://args4j.dev.java.net/
Version: 2.0.12
Version: 2.0.16
License: MIT

Description:
Expand All @@ -188,7 +187,7 @@ lib/guava.jar

Guava Libraries
URL: http://code.google.com/p/guava-libraries/
Version: r08
Version: 13.0.1
License: Apache License 2.0

Description: Google's core Java libraries.
Expand All @@ -210,13 +209,28 @@ Description: Annotations for software defect detection.
Local Modifications: None.


-----
Code in:
lib/jarjar.jar

Jar Jar Links
URL: http://jarjar.googlecode.com/
Version: 1.1
License: Apache License 2.0

Description:
A utility for repackaging Java libraries.

Local Modifications: None.


----
Code in:
lib/junit.jar

JUnit
URL: http://sourceforge.net/projects/junit/
Version: 4.8.2
Version: 4.10
License: Common Public License 1.0

Description: A framework for writing and running automated tests in Java.
Expand All @@ -230,7 +244,7 @@ lib/protobuf-java.jar

Protocol Buffers
URL: http://code.google.com/p/protobuf/
Version: 2.3.0
Version: 2.4.1
License: New BSD License

Description: Supporting libraries for protocol buffers,
Expand Down Expand Up @@ -267,9 +281,9 @@ Local Modifications: None

---
Code in:
tools/maven-ant-tasks-2.1.1.jar
tools/maven-ant-tasks-2.1.3.jar
URL: http://maven.apache.org
Version 2.1.1
Version 2.1.3
License: Apache License 2.0
Description:
Maven Ant tasks are used to manage dependencies and to install/deploy to
Expand Down
Binary file modified lib/closure-compiler/compiler.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion lib/closure-compiler/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
20110615
Version: 20121212 built at r2388

Url: http://closure-compiler.googlecode.com/files/compiler-20121212.zip
Loading