33TRACK=java
44TRACK_REPO=" $TRACK "
55TRACK_SRC_EXT=" java"
6+ CPU_CORES=` getconf NPROCESSORS_ONLN 2> /dev/null || getconf _NPROCESSORS_ONLN 2> /dev/null || echo 1`
67
78on_exit () {
89 echo " >>> on_exit()"
@@ -96,6 +97,14 @@ get_cpu_architecture() {
9697 esac
9798}
9899
100+ get_optimal_amount_of_jobs () {
101+ if [ " $CPU_CORES " -gt " 1" ]; then
102+ echo $(( CPU_CORES- 1 ))
103+ else
104+ echo 1
105+ fi
106+ }
107+
99108download_exercism_cli () {
100109 local os=" $1 "
101110 local arch=" $2 "
@@ -162,7 +171,7 @@ make_local_trackler() {
162171 cp -r ${track_root} /exercises tracks/${TRACK}
163172
164173 gem install bundler
165- bundle install
174+ bundle install --jobs $( get_optimal_amount_of_jobs )
166175 gem build trackler.gemspec
167176
168177 # Make *this* the gem that x-api uses when we build x-api.
@@ -179,7 +188,7 @@ start_x_api() {
179188 pushd $xapi_home
180189
181190 gem install bundler
182- bundle install
191+ bundle install --jobs $( get_optimal_amount_of_jobs )
183192 RACK_ENV=development rackup &
184193 xapi_pid=$!
185194 sleep 5
@@ -267,18 +276,24 @@ main() {
267276
268277 clean " ${build_dir} "
269278
270- # Make a local version of trackler that includes the source from this repo.
271- git_clone " x-api" " ${xapi_home} "
272- git_clone " trackler" " ${trackler_home} "
273- assert_ruby_installed " ${trackler_home} "
279+ # Download everything we need in parallel
280+ git_clone " x-api" " ${xapi_home} " &
281+ git_clone " trackler" " ${trackler_home} " &
282+ download_exercism_cli $( get_operating_system) $( get_cpu_architecture) " ${exercism_home} " &
283+ wait
284+
285+ # Check and install the ruby stuff we need in parallel
286+ assert_ruby_installed " ${trackler_home} " &
287+ assert_ruby_installed " ${xapi_home} " &
288+ wait
289+
290+ # Make a local version of trackler
274291 make_local_trackler " ${trackler_home} " " ${xapi_home} "
275292
276- # Stand-up a local instance of x-api so we can fetch the exercises through it.
277- assert_ruby_installed " ${xapi_home} "
293+ # Start-up a local instance of x-api so we can fetch the exercises through it.
278294 start_x_api " ${xapi_home} "
279295
280296 # Create a CLI install and config just for this build; this script does not use your CLI install.
281- download_exercism_cli $( get_operating_system) $( get_cpu_architecture) " ${exercism_home} "
282297 configure_exercism_cli " ${exercism_home} " " ${exercism_configfile} " " ${xapi_port} "
283298
284299 solve_all_exercises " ${exercism_home} " " ${exercism_configfile} "
0 commit comments