Skip to content

Commit dcee72d

Browse files
committed
go.sh: add macos_setup_diskimage target
Add a target that just creates and mounts the MacOS disk image. Additionally, move macos specific setup for crosstool-ng into build_crosstool() function. Signed-off-by: Kumar Gala <[email protected]>
1 parent 91cb1ef commit dcee72d

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

go.sh

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,36 @@ case "${unameOut}" in
2222
esac
2323

2424
SDK_NG_HOME=${PWD}
25+
if [ "$os" == "macos" ]; then
26+
ImageName=CrossToolNGNew
27+
ImageNameExt=${ImageName}.sparseimage
28+
SDK_NG_HOME="/Volumes/${ImageName}"
29+
fi
2530

2631
CROSSTOOL_COMMIT="4d5660e34e7c5f522e8b07ded82d7a6a15b787ef"
2732
build_crosstool()
2833
{
2934
# only build if we don't already have a built binary
30-
3135
if [ ! -x "${SDK_NG_HOME}/bin/ct-ng" ]; then
36+
if [ "$os" == "macos" ]; then
37+
if [ -x "/opt/homebrew/bin/brew" ]; then
38+
export HOMEBREW_ROOT="/opt/homebrew"
39+
elif [ -x "/usr/local/bin/brew" ]; then
40+
export HOMEBREW_ROOT="/usr/local"
41+
else
42+
echo "No brew install found"
43+
exit 1
44+
fi
45+
46+
brew install autoconf automake bash binutils gawk gnu-sed gnu-tar help2man ncurses xz libtool
47+
48+
export PATH="$PATH:${HOMEBREW_ROOT}/opt/binutils/bin"
49+
export CPPFLAGS="-I${HOMEBREW_ROOT}/opt/ncurses/include -I${HOMEBREW_ROOT}/opt/gettext/include"
50+
export LDFLAGS="-L${HOMEBREW_ROOT}/opt/ncurses/lib -L${HOMEBREW_ROOT}/opt/gettext/lib"
51+
52+
macos_setup_diskimage
53+
fi
54+
3255
# Checkout crosstool-ng if we haven't already
3356
if [ ! -d "${SDK_NG_HOME}/crosstool-ng" ]; then
3457
pushd ${SDK_NG_HOME}
@@ -49,25 +72,8 @@ build_crosstool()
4972
fi
5073
}
5174

52-
if [ "$os" == "macos" ]; then
53-
if [ -x "/opt/homebrew/bin/brew" ]; then
54-
export HOMEBREW_ROOT="/opt/homebrew"
55-
elif [ -x "/usr/local/bin/brew" ]; then
56-
export HOMEBREW_ROOT="/usr/local"
57-
else
58-
echo "No brew install found"
59-
exit 1
60-
fi
61-
62-
brew install autoconf automake bash binutils gawk gnu-sed gnu-tar help2man ncurses xz libtool
63-
64-
export PATH="$PATH:${HOMEBREW_ROOT}/opt/binutils/bin"
65-
export CPPFLAGS="-I${HOMEBREW_ROOT}/opt/ncurses/include -I${HOMEBREW_ROOT}/opt/gettext/include"
66-
export LDFLAGS="-L${HOMEBREW_ROOT}/opt/ncurses/lib -L${HOMEBREW_ROOT}/opt/gettext/lib"
67-
68-
ImageName=CrossToolNGNew
69-
ImageNameExt=${ImageName}.sparseimage
70-
SDK_NG_HOME="/Volumes/${ImageName}"
75+
macos_setup_diskimage()
76+
{
7177
if [ ! -e "$ImageNameExt" ]; then
7278
diskutil umount force ${SDK_NG_HOME} && true
7379
rm -f ${ImageNameExt} && true
@@ -76,7 +82,7 @@ if [ "$os" == "macos" ]; then
7682
if [ ! -d ${SDK_NG_HOME} ]; then
7783
hdiutil mount ${ImageNameExt}
7884
fi
79-
fi
85+
}
8086

8187
CT_NG=${SDK_NG_HOME}/bin/ct-ng
8288

@@ -92,6 +98,9 @@ for t in ${TARGETS}; do
9298
elif [ "${t}" = "crosstool" ]; then
9399
build_crosstool
94100
exit $?
101+
elif [ "${t}" = "macos_setup_diskimage" ]; then
102+
macos_setup_diskimage
103+
exit $?
95104
fi
96105
done
97106

0 commit comments

Comments
 (0)