From 9decc3d823d2142b3355658af8dfd8bf8abf4957 Mon Sep 17 00:00:00 2001 From: Marc Laval Date: Tue, 21 Jun 2016 00:25:55 +0200 Subject: [PATCH] build: fix some issues on Windows platforms Closes #9450 --- .gitattributes | 3 +++ build.sh | 10 +++++----- gulpfile.js | 4 +++- package.json | 2 +- scripts/windows/create-symlinks.sh | 10 ++++++++++ scripts/windows/packages.txt | 9 +++++++++ scripts/windows/remove-symlinks.sh | 10 ++++++++++ tools/tsc-watch/tsc_watch.ts | 4 +++- 8 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 scripts/windows/create-symlinks.sh create mode 100644 scripts/windows/packages.txt create mode 100644 scripts/windows/remove-symlinks.sh diff --git a/.gitattributes b/.gitattributes index b7ca95b5b7..0d98b71ce9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,6 @@ # JS files must always use LF for tools to work *.js eol=lf + +# Must keep Windows line ending to be parsed correctly +scripts/windows/packages.txt eol=crlf diff --git a/build.sh b/build.sh index 5f3a6e7f90..388c7ef079 100755 --- a/build.sh +++ b/build.sh @@ -73,12 +73,12 @@ do echo "====== TSC 1.8 d.ts compat for ${DESTDIR} =====" # safely strips 'readonly' specifier from d.ts files to make them compatible with tsc 1.8 - if [[ ${TRAVIS} ]]; then - find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -e 's/\(^ *(static |private )*\)*readonly */\1/g' - find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -E 's/^( +)abstract ([[:alnum:]]+\:)/\1\2/g' + if [ "$(uname)" == "Darwin" ]; then + find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -e 's/\(^ *(static |private )*\)*readonly */\1/g' + find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -E 's/^( +)abstract ([[:alnum:]]+\:)/\1\2/g' else - find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -e 's/\(^ *(static |private )*\)*readonly */\1/g' - find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i '' -E 's/^( +)abstract ([[:alnum:]]+\:)/\1\2/g' + find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -e 's/\(^ *(static |private )*\)*readonly */\1/g' + find ${DESTDIR} -type f -name '*.d.ts' -print0 | xargs -0 sed -i -E 's/^( +)abstract ([[:alnum:]]+\:)/\1\2/g' fi if [[ ${PACKAGE} != compiler-cli ]]; then diff --git a/gulpfile.js b/gulpfile.js index e23eede86d..4e532b0aa1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,6 +8,7 @@ require('./tools/check-environment')( const gulp = require('gulp'); const path = require('path'); +const os = require('os'); const srcsToFmt = ['tools/**/*.ts', 'modules/@angular/**/*.ts']; @@ -61,7 +62,8 @@ function tsc(projectPath, done) { child_process .spawn( - `${__dirname}/node_modules/.bin/tsc`, ['-p', path.join(__dirname, projectPath)], + path.normalize(`${__dirname}/node_modules/.bin/tsc`) + (/^win/.test(os.platform()) ? '.cmd' : ''), + ['-p', path.join(__dirname, projectPath)], {stdio: 'inherit'}) .on('close', (errorCode) => done(errorCode)); } diff --git a/package.json b/package.json index d82944a544..077188f193 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "url": "https://github.com/angular/angular.git" }, "scripts": { - "postinstall": "node tools/npm/copy-npm-shrinkwrap; webdriver-manager update" + "postinstall": "node tools/npm/copy-npm-shrinkwrap && webdriver-manager update" }, "dependencies": { "es6-shim": "^0.35.0", diff --git a/scripts/windows/create-symlinks.sh b/scripts/windows/create-symlinks.sh new file mode 100644 index 0000000000..36658ff349 --- /dev/null +++ b/scripts/windows/create-symlinks.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +cd `dirname $0` + +while read PACKAGE +do + DESTDIR=./../../modules/\@angular/${PACKAGE}/src + mv ${DESTDIR}/facade ${DESTDIR}/facade.old + cmd <<< "mklink \"..\\..\\modules\\\@angular\\"${PACKAGE}"\\src\\facade\" \"..\\..\\facade\\src\\\"" +done < packages.txt diff --git a/scripts/windows/packages.txt b/scripts/windows/packages.txt new file mode 100644 index 0000000000..0182748e50 --- /dev/null +++ b/scripts/windows/packages.txt @@ -0,0 +1,9 @@ +common +compiler +core +forms +http +platform-browser +platform-browser-dynamic +platform-server +router-deprecated diff --git a/scripts/windows/remove-symlinks.sh b/scripts/windows/remove-symlinks.sh new file mode 100644 index 0000000000..0b6f261316 --- /dev/null +++ b/scripts/windows/remove-symlinks.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +cd `dirname $0` + +while read PACKAGE +do + DESTDIR=./../../modules/\@angular/${PACKAGE}/src + rm ${DESTDIR}/facade + mv ${DESTDIR}/facade.old ${DESTDIR}/facade +done < packages.txt diff --git a/tools/tsc-watch/tsc_watch.ts b/tools/tsc-watch/tsc_watch.ts index 5aa79db5b4..fc2534ef9e 100644 --- a/tools/tsc-watch/tsc_watch.ts +++ b/tools/tsc-watch/tsc_watch.ts @@ -1,4 +1,6 @@ import {spawn} from 'child_process'; +import {platform} from 'os'; +import {normalize} from 'path'; import {resolve} from 'url'; enum State { @@ -7,7 +9,7 @@ enum State { error } -export const TSC = 'node_modules/typescript/bin/tsc'; +export const TSC = normalize('node_modules/.bin/tsc') + (/^win/.test(platform()) ? '.cmd' : ''); export type Command = (stdIn: any, stdErr: any) => Promise; export class TscWatch {