Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-build
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ruby-build
Commits
6c08c56d
Commit
6c08c56d
authored
Oct 27, 2013
by
Mislav Marohnić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect number of CPU cores used for `make`
Alt. implementation of #401, #434
parent
50bf60f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletions
+58
-1
bin/ruby-build
+12
-1
test/build.bats
+46
-0
No files found.
bin/ruby-build
View file @
6c08c56d
...
@@ -96,6 +96,17 @@ file_is_not_empty() {
...
@@ -96,6 +96,17 @@ file_is_not_empty() {
fi
fi
}
}
num_cpu_cores
()
{
local
num
=
""
if
[
"Darwin"
=
"
$(
uname
-s
)
"
]
;
then
num
=
"
$(
sysctl
-n
hw.ncpu 2>/dev/null
||
true
)
"
elif
[
-r
/proc/cpuinfo
]
;
then
num
=
"
$(
grep
-c
^processor /proc/cpuinfo
)
"
[
"
$num
"
-gt
0
]
||
num
=
""
fi
echo
"
${
num
:-
2
}
"
}
install_package
()
{
install_package
()
{
install_package_using
"tarball"
1
"
$@
"
install_package_using
"tarball"
1
"
$@
"
}
}
...
@@ -374,7 +385,7 @@ build_package_standard() {
...
@@ -374,7 +385,7 @@ build_package_standard() {
if
[
"
${
MAKEOPTS
+defined
}
"
]
;
then
if
[
"
${
MAKEOPTS
+defined
}
"
]
;
then
MAKE_OPTS
=
"
$MAKEOPTS
"
MAKE_OPTS
=
"
$MAKEOPTS
"
elif
[
-z
"
${
MAKE_OPTS
+defined
}
"
]
;
then
elif
[
-z
"
${
MAKE_OPTS
+defined
}
"
]
;
then
MAKE_OPTS
=
"-j
2
"
MAKE_OPTS
=
"-j
$(
num_cpu_cores
)
"
fi
fi
# Support YAML_CONFIGURE_OPTS, RUBY_CONFIGURE_OPTS, etc.
# Support YAML_CONFIGURE_OPTS, RUBY_CONFIGURE_OPTS, etc.
...
...
test/build.bats
View file @
6c08c56d
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
load test_helper
load test_helper
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
export MAKE=make
export MAKE=make
export MAKE_OPTS="-j 2"
setup() {
setup() {
mkdir -p "$INSTALL_ROOT"
mkdir -p "$INSTALL_ROOT"
...
@@ -91,6 +92,51 @@ make -j 2
...
@@ -91,6 +92,51 @@ make -j 2
OUT
OUT
}
}
@test "number of CPU cores defaults to 2" {
cached_tarball "ruby-2.0.0"
stub uname '-s : echo Darwin'
stub sysctl false
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
DEF
assert_success
unstub uname
unstub make
assert_build_log <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT
make -j 2
OUT
}
@test "number of CPU cores is detected on Mac" {
cached_tarball "ruby-2.0.0"
stub uname '-s : echo Darwin'
stub sysctl '-n hw.ncpu : echo 4'
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
DEF
assert_success
unstub uname
unstub sysctl
unstub make
assert_build_log <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT
make -j 4
OUT
}
@test "custom relative install destination" {
@test "custom relative install destination" {
export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT"
export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment