Skip to content

Instantly share code, notes, and snippets.

@iki

iki/README.md

Last active Dec 14, 2015
Embed
What would you like to do?
Building Angular.js on Windows

Building Angular.js on Windows

Current grunt based build

  1. Install grunt launcher.

     npm install -g grunt-cli
    
  2. Run grunt as Administrator. That's needed to create directory symlinks using mklink /d.

     grunt
    
  3. Test on local development server http://localhost:8000/build/docs

     grunt webserver
    

Previous rake based build in 1.1.3 and older

  1. Checkout the required version.

     git checkout 1.0.5  # or any other <=1.1.3
    
  2. Patch Rakefile to use mklink /d for symlinks and to not use fork. Patch docs/src/gen-docs.sh+writer.sh to do symlinks correctly. The second part was taken from angular switch to grunt in commit https://github.com/angular/angular.js/commit/79b51d5b578927bd510123c81953e7cc8c72f211

     curl -L http://j.mp/ng-rake-win-patch | patch -p 1 -f
    
  3. Run rake as Administrator. That's needed to create directory symlinks using mklink /d.

     rake
    
  4. Test on local development server http://localhost:8000/build/docs

     rake webserver
    
  5. Undo the changes before checking out master, or any other version tag.

     git reset HEAD --hard
    

Comments

Discuss in the mail list https://groups.google.com/d/topic/angular/4jyjYiSHIbY or at the gist http://j.mp/ng-win.

diff --git a/Rakefile b/Rakefile
index cdb1d78..2b64fba 100644
--- a/Rakefile
+++ b/Rakefile
@@ -40,6 +40,10 @@ end
desc 'Clean Generated Files'
task :clean do
+ # Win32 rmdir removes Windows symlinks safely.
+ 'css font img js'.split.each do |dir|
+ File.directory?("#{BUILD_DIR}/docs/#{dir}") && %x(rmdir "#{BUILD_DIR}\\docs\\#{dir}")
+ end
FileUtils.rm_r(BUILD_DIR, :force => true)
FileUtils.mkdir(BUILD_DIR)
FileUtils.rm_r('test_out', :force => true)
@@ -107,10 +111,11 @@ task :minify => [:init, :concat, :concat_scenario] do
'angular-bootstrap.js',
'angular-bootstrap-prettify.js'
].each do |file|
- fork { closure_compile(file) }
+ # Win32 incompatible: fork { closure_compile(file) }
+ closure_compile(file)
end
- Process.waitall
+ # Win32 incompatible: Process.waitall # forks
end
@@ -152,9 +157,13 @@ task :package => [:clean, :minify, :version, :docs] do
zip_dir = "angular-#{NG_VERSION.full}"
zip_file = "#{zip_dir}.zip"
- FileUtils.ln_s BUILD_DIR, zip_dir
+ # Win32 incompatible: FileUtils.ln_s BUILD_DIR, zip_dir
+ # Win32 mklink needs to run as Administrator!
+ %x(cmd /cmklink /d #{zip_dir} #{BUILD_DIR})
%x(zip -r #{zip_file} #{zip_dir})
- FileUtils.rm zip_dir
+ # Win32 incompatible: FileUtils.rm zip_dir
+ # Win32 rmdir removes Windows symlinks safely.
+ %x(rmdir #{zip_dir})
FileUtils.mv zip_file, path_to(zip_file)
diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js
index 62d22b1..f8d593a 100755
--- a/docs/src/gen-docs.js
+++ b/docs/src/gen-docs.js
@@ -42,10 +42,10 @@ writer.makeDir('build/docs/', true).then(function() {
function writeTheRest(writesFuture) {
var metadata = ngdoc.metadata(docs);
- writesFuture.push(writer.symlinkTemplate('css'));
- writesFuture.push(writer.symlinkTemplate('font'));
- writesFuture.push(writer.symlink('../../docs/img', 'build/docs/img'));
- writesFuture.push(writer.symlinkTemplate('js'));
+ writesFuture.push(writer.symlinkTemplate('css', 'dir'));
+ writesFuture.push(writer.symlinkTemplate('font', 'dir'));
+ writesFuture.push(writer.symlink('../../docs/img', 'build/docs/img', 'dir'));
+ writesFuture.push(writer.symlinkTemplate('js', 'dir'));
var manifest = 'manifest="/build/docs/appcache.manifest"';
@@ -89,4 +89,3 @@ function writeTheRest(writesFuture) {
function now() { return new Date().getTime(); }
function noop() {};
-
diff --git a/docs/src/writer.js b/docs/src/writer.js
index 450f7cb..b6403e3 100644
--- a/docs/src/writer.js
+++ b/docs/src/writer.js
@@ -61,22 +61,21 @@ exports.copy = function(from, to, transform) {
exports.symlink = symlink;
-function symlink(from, to) {
+function symlink(from, to, type) {
return qfs.exists(to).then(function(exists) {
if (!exists) {
- return qfs.symbolicLink(to, from);
+ return qfs.symbolicLink(to, from, type);
}
});
}
exports.symlinkTemplate = symlinkTemplate;
-function symlinkTemplate(filename) {
+function symlinkTemplate(filename, type) {
var dest = OUTPUT_DIR + filename,
dirDepth = dest.split('/').length,
src = Array(dirDepth).join('../') + 'docs/src/templates/' + filename;
-
- return symlink(src, dest);
+ return symlink(src, dest, type);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment