From dcc292fa677e692983d330dc2aca0f710cc9217c Mon Sep 17 00:00:00 2001 From: Binh Nguyen Date: Mon, 28 Mar 2016 00:33:07 +0700 Subject: [PATCH 1/2] Switch to use nodeJsEnv as default jsEnv to build scala.js By default, scala.js compiler uses `Rhino` as the js environment. But it usually requires a lot of memory and often lead to OOM. This PR replace the default to a node.js one that should be much faster and slimer. --- .travis.yml | 7 +++++++ build.sbt | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 30e14c9509..dd2a74d4c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ scala: script: - scripts/travis-publish.sh +# http://austinpray.com/ops/2015/09/20/change-travis-node-version.html +install: + - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION + notifications: webhooks: urls: @@ -21,12 +25,15 @@ env: global: - secure: Kf44XQFpq2QGe3rn98Dsf5Uz3WXzPDralS54co7sqT5oQGs1mYLYZRYz+I75ZSo5ffZ86H7M+AI9YFofqGwAjBixBbqf1tGkUh3oZp2fN3QfqzazGV3HzC+o41zALG5FL+UBaURev9ChQ5fYeTtFB7YAzejHz4y5E97awk934Rg= - secure: QbNAu0jCaKrwjJi7KZtYEBA/pYbTJ91Y1x/eLAJpsamswVOvwnThA/TLYuux+oiZQCiDUpBzP3oxksIrEEUAhl0lMtqRFY3MrcUr+si9NIjX8hmoFwkvZ5o1b7pmLF6Vz3rQeP/EWMLcljLzEwsrRXeK0Ei2E4vFpsg8yz1YXJg= + - TRAVIS_NODE_VERSION="4" cache: directories: - $HOME/.sbt/0.13/dependency - $HOME/.sbt/boot/scala* - $HOME/.sbt/launchers - $HOME/.ivy2/cache + - $HOME/.nvm + before_cache: - du -h -d 1 $HOME/.ivy2/cache - du -h -d 2 $HOME/.sbt/ diff --git a/build.sbt b/build.sbt index 51e15edba7..7ca986daf7 100644 --- a/build.sbt +++ b/build.sbt @@ -55,7 +55,11 @@ lazy val commonJsSettings = Seq( s"-P:scalajs:mapSourceURI:$a->$g/" }, scalaJSStage in Global := FastOptStage, - parallelExecution := false + parallelExecution := false, + // Using Rhino as jsEnv to build scala.js code can lead to OOM, switch to PhantomJS by default + scalaJSUseRhino := false, + requiresDOM := false, + jsEnv := NodeJSEnv().value ) lazy val commonJvmSettings = Seq( From ed5e72274bab184845a7b0e0196be92edd2cbdc6 Mon Sep 17 00:00:00 2001 From: Binh Nguyen Date: Mon, 28 Mar 2016 07:24:20 +0700 Subject: [PATCH 2/2] Enable `batchMode` on scala.js Optimizer The batchMode should help reduce the memory requirement to compile scala.js code as per https://github.com/scala-js/scala-js/issues/1788#issuecomment-178346142 Implementation details: botBuild is a sbt setting that will be turned on on travisCi so that it will not interfere with local dev experience. --- .travis.yml | 1 + build.sbt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd2a74d4c0..b56b245cde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ env: - secure: Kf44XQFpq2QGe3rn98Dsf5Uz3WXzPDralS54co7sqT5oQGs1mYLYZRYz+I75ZSo5ffZ86H7M+AI9YFofqGwAjBixBbqf1tGkUh3oZp2fN3QfqzazGV3HzC+o41zALG5FL+UBaURev9ChQ5fYeTtFB7YAzejHz4y5E97awk934Rg= - secure: QbNAu0jCaKrwjJi7KZtYEBA/pYbTJ91Y1x/eLAJpsamswVOvwnThA/TLYuux+oiZQCiDUpBzP3oxksIrEEUAhl0lMtqRFY3MrcUr+si9NIjX8hmoFwkvZ5o1b7pmLF6Vz3rQeP/EWMLcljLzEwsrRXeK0Ei2E4vFpsg8yz1YXJg= - TRAVIS_NODE_VERSION="4" + - CATS_BOT_BUILD=true cache: directories: - $HOME/.sbt/0.13/dependency diff --git a/build.sbt b/build.sbt index 7ca986daf7..1b1196f096 100644 --- a/build.sbt +++ b/build.sbt @@ -5,6 +5,8 @@ import sbtunidoc.Plugin.UnidocKeys._ import ReleaseTransformations._ import ScoverageSbtPlugin._ +lazy val botBuild = settingKey[Boolean]("Build by TravisCI instead of local dev environment") + lazy val scoverageSettings = Seq( ScoverageKeys.coverageMinimum := 60, ScoverageKeys.coverageFailOnMinimum := false, @@ -59,7 +61,11 @@ lazy val commonJsSettings = Seq( // Using Rhino as jsEnv to build scala.js code can lead to OOM, switch to PhantomJS by default scalaJSUseRhino := false, requiresDOM := false, - jsEnv := NodeJSEnv().value + jsEnv := NodeJSEnv().value, + // Only used for scala.js for now + botBuild := sys.props.getOrElse("CATS_BOT_BUILD", default="false") == "true", + // batch mode decreases the amount of memory needed to compile scala.js code + scalaJSOptimizerOptions := scalaJSOptimizerOptions.value.withBatchMode(botBuild.value) ) lazy val commonJvmSettings = Seq(