Skip to content

Commit 86e4311

Browse files
committed
Update to work with latest Haiku.
* Also introduces a couple patches to Haiku's configure that will probably be worth upstreaming. * Allows passing extra options directly to Haiku's configure. * Allows specifying alternate URIs for Haiku and buildtools repos.
1 parent 4ebef6d commit 86e4311

5 files changed

+200
-14
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 3e4068ec9f6cceb6edd603014e753c002ff2f28c Mon Sep 17 00:00:00 2001
2+
From: Jessica Hamilton <[email protected]>
3+
Date: Thu, 12 Sep 2024 12:20:46 +0000
4+
Subject: [PATCH 1/4] configure: add missing sanity check for cross tools
5+
options.
6+
7+
---
8+
configure | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/configure b/configure
12+
index 67902dfe07..aedf093cdb 100755
13+
--- a/configure
14+
+++ b/configure
15+
@@ -916,7 +916,7 @@ if [ "$HAIKU_HOST_BUILD_ONLY" = 1 ]; then
16+
HAIKU_STRIP=$invalidCommand
17+
else
18+
# On Haiku determine target architectures and tools automatically.
19+
- if [ -z "$targetArchs" ]; then
20+
+ if [ -z "$targetArchs" -o -n "$targetArchs" -a -z "$buildCrossTools" ]; then
21+
if [ $HOST_PLATFORM != haiku_host ]; then
22+
echo "Please specify the build tools to use or build (via" \
23+
"--cross-tools-prefix or --build-cross-tools) or specify a" \
24+
--
25+
2.25.1
26+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From a70a4b406950f6aaef021cdbc384d050cbdf9911 Mon Sep 17 00:00:00 2001
2+
From: Jessica Hamilton <[email protected]>
3+
Date: Thu, 12 Sep 2024 12:21:22 +0000
4+
Subject: [PATCH 2/4] configure: add a version check for python.
5+
6+
Tooling used by HaikuDepotServer relies on typing features that
7+
exist in Python >= 3.9.
8+
---
9+
configure | 13 +++++++++++++
10+
1 file changed, 13 insertions(+)
11+
12+
diff --git a/configure b/configure
13+
index aedf093cdb..1390f22b82 100755
14+
--- a/configure
15+
+++ b/configure
16+
@@ -889,6 +889,19 @@ else
17+
exit 1
18+
fi
19+
20+
+# check is python is new enough
21+
+# usage of python by HDS requires at least 3.9
22+
+PYTHON_VERSION=$("$HOST_PYTHON" --version | sed -e 's/Python //')
23+
+
24+
+case $PYTHON_VERSION in
25+
+ 2.* | 3.[1-8].*)
26+
+ echo "Python $PYTHON_VERSION is too old, need at least Python 3.9"
27+
+ exit 1
28+
+ ;;
29+
+ *)
30+
+ ;;
31+
+esac
32+
+
33+
# check if nasm can actually output ELF files
34+
# (the stock version in OSX can't)
35+
# XXX: should probably only test for x86* arch
36+
--
37+
2.25.1
38+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 8e9fed3307f345e1c8cd9f630a83004ecdcefa6e Mon Sep 17 00:00:00 2001
2+
From: Jessica Hamilton <[email protected]>
3+
Date: Thu, 12 Sep 2024 23:47:36 +0000
4+
Subject: [PATCH 3/4] build: add an optional UserProfileConfig.
5+
6+
Like UserBuildConfig, but read before the rules are loaded,
7+
allowing HAIKU_BUILD_PROFILE to be overridden to use a given
8+
build profile without specifying on the command line.
9+
---
10+
Jamrules | 7 +++++++
11+
build/jam/CommandLineArguments | 2 +-
12+
2 files changed, 8 insertions(+), 1 deletion(-)
13+
14+
diff --git a/Jamrules b/Jamrules
15+
index f242565d9c..ede46729e3 100644
16+
--- a/Jamrules
17+
+++ b/Jamrules
18+
@@ -12,6 +12,13 @@ if $(JAMBASEDATE) < 2018 {
19+
"by updating Jam itself.)" ;
20+
}
21+
22+
+# Allow for a separate UserProfileConfig per output directory.
23+
+local userProfileConfig
24+
+ = [ GLOB $(HAIKU_OUTPUT_DIR) : UserProfileConfig ] ;
25+
+if $(userProfileConfig) {
26+
+ include $(userProfileConfig) ;
27+
+}
28+
+
29+
# Make sure HAIKU_TOP is a relative path (and prefer it to be the current or
30+
# parent directory.)
31+
#
32+
diff --git a/build/jam/CommandLineArguments b/build/jam/CommandLineArguments
33+
index 26259bdc4c..8208570d51 100644
34+
--- a/build/jam/CommandLineArguments
35+
+++ b/build/jam/CommandLineArguments
36+
@@ -4,7 +4,7 @@ rule ProcessCommandLineArguments
37+
{
38+
# analyze and optionally replace jam's target parameters
39+
HAIKU_ORIGINAL_JAM_TARGETS = $(JAM_TARGETS) ;
40+
- HAIKU_BUILD_PROFILE = ;
41+
+ HAIKU_BUILD_PROFILE ?= ;
42+
if $(JAM_TARGETS) {
43+
switch $(JAM_TARGETS[1]) {
44+
# If the target to be built is "all" (i.e. the default) and we're in
45+
--
46+
2.25.1
47+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From cc6d7f9b33b7b132e96f40bad400531f33167caf Mon Sep 17 00:00:00 2001
2+
From: Jessica Hamilton <[email protected]>
3+
Date: Fri, 13 Sep 2024 03:57:15 +0000
4+
Subject: [PATCH 4/4] configure: allow specifying python to use --with-python.
5+
6+
---
7+
configure | 7 ++++++-
8+
1 file changed, 6 insertions(+), 1 deletion(-)
9+
10+
diff --git a/configure b/configure
11+
index 1390f22b82..0d4f7bfd52 100755
12+
--- a/configure
13+
+++ b/configure
14+
@@ -97,6 +97,8 @@ options:
15+
GDB for each arch we build the cross-tools for.
16+
--use-stack-protector Build with stack protection enabled
17+
--efi-signing-key Private keyfile to sign any EFI bootloaders
18+
+ --with-python <python> Specify python to use, instead of system
19+
+ default.
20+
21+
environment variables:
22+
CC The host compiler. Defaults to "gcc".
23+
@@ -831,6 +833,7 @@ while [ $# -gt 0 ] ; do
24+
HAIKU_EFI_SIGNING_KEY="$2"
25+
shift 2
26+
;;
27+
+ --with-python) pythonPath=$2; shift 2;;
28+
*) echo Invalid argument: \`$1\'; exit 1;;
29+
esac
30+
done
31+
@@ -880,7 +883,9 @@ if ! $JAMSHELL -c true; then
32+
fi
33+
34+
# locate python
35+
-if python3 --version < /dev/null > /dev/null 2>&1; then
36+
+if [ -n "$pythonPath" ] && "$pythonPath" --version < /dev/null > /dev/null 2>&1; then
37+
+ HOST_PYTHON="$pythonPath"
38+
+elif python3 --version < /dev/null > /dev/null 2>&1; then
39+
HOST_PYTHON="python3"
40+
elif python --version < /dev/null > /dev/null 2>&1; then
41+
HOST_PYTHON="python"
42+
--
43+
2.25.1
44+

build-rootfs.sh

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ set -e
44

55
usage()
66
{
7-
echo "Usage: $0 BuildArch [--jobs <N>] [--rootfsdir <directory>]"
7+
echo "Usage: $0 BuildArch [--jobs <N>] [--rootfsdir <directory>] [--haiku-repo <uri>] [--bt-repo <uri>] [-- {extra args}]"
88
echo "BuildArch can be: x86, x86_64, x86h, x86_gcc2h"
9-
echo "--rootfsdir dir - optional, defaults to current dir, where to"
10-
echo " put cross-compiler and Haiku sysroot."
11-
echo "--jobs N - optional, restrict to N jobs."
9+
echo "--rootfsdir dir - defaults to the current dir, where to"
10+
echo " put cross-compiler and Haiku sysroot."
11+
echo "--jobs N - restrict to N jobs, defaults to MAXCPUS."
12+
echo "--haiku-repo uri - alternate uri to clone Haiku repo from."
13+
echo "--bt-repo uri - alternate uri to clone buildtools from."
14+
echo "Any additional arguments after -- will be passed directly to"
15+
echo "Haiku's configure script."
1216
exit 1
1317
}
1418

@@ -48,14 +52,30 @@ while :; do
4852
shift
4953
MAXJOBS=$1
5054
;;
55+
--haiku-repo|-haiku-repo)
56+
shift
57+
__HaikuRepo=$1
58+
;;
59+
--bt-repo|-bt-repo)
60+
shift
61+
__BuildToolsRepo=$1
62+
;;
63+
--)
64+
shift
65+
break
66+
;;
5167
*)
68+
echo "Unknown option: $1"
5269
usage
53-
;;
5470
esac
5571

5672
shift
5773
done
5874

75+
if [ $# -gt 0 ]; then
76+
__ExtraArgs="$@"
77+
fi
78+
5979

6080
if [ -z "$__RootfsDir" ] && [ ! -z "$ROOTFS_DIR" ]; then
6181
__RootfsDir=$ROOTFS_DIR
@@ -66,6 +86,14 @@ echo "Using $__RootfsDir..."
6686
mkdir -p $__RootfsDir
6787
__RootfsDir="$( cd "$__RootfsDir" && pwd )"
6888

89+
if [ -z "$__HaikuRepo" ]; then
90+
__HaikuRepo="https://github.com/haiku/haiku"
91+
fi
92+
93+
if [ -z "$__BuildToolsRepo" ]; then
94+
__BuildToolsRepo="https://github.com/haiku/buildtools"
95+
fi
96+
6997
JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"}
7098

7199
if [ -z "$__BuildSecondaryArch" ]; then
@@ -76,45 +104,48 @@ fi
76104
mkdir -p "$__RootfsDir/tmp"
77105
if [ ! -e "$__RootfsDir/tmp/haiku/.git" ]; then
78106
cd "$__RootfsDir/tmp"
79-
git clone https://github.com/haiku/haiku
107+
git clone "$__HaikuRepo"
80108
cd haiku && git remote add review https://review.haiku-os.org/haiku && git fetch --tags review
81109
else
82110
echo "WARN: skipping clone of haiku repo, already exists"
83-
cd haiku && git fetch review
111+
cd "$__RootfsDir/tmp/haiku" && git fetch review
84112
fi
85113

86114
if [ ! -e "$__RootfsDir/tmp/buildtools/.git" ]; then
87115
cd "$__RootfsDir/tmp"
88-
git clone --depth=1 https://github.com/haiku/buildtools
116+
git clone --depth=1 "$__BuildToolsRepo"
89117
else
90118
echo "WARN: skipping clone of buildtools repo, already exists"
91119
fi
92120

93121
# Fetch some patches that haven't been merged yet
94122
cd "$__RootfsDir/tmp/haiku"
95123
git reset --hard review/master
96-
## add development build profile (slimmer than nightly)
97-
git am "$__InitialDir/0002-Add-extra-build-profile-development.patch"
124+
git am "$__InitialDir/0001-configure-add-missing-sanity-check-for-cross-tools-o.patch"
125+
git am "$__InitialDir/0002-configure-add-a-version-check-for-python.patch"
126+
git am "$__InitialDir/0003-build-add-an-optional-UserProfileConfig.patch"
127+
git am "$__InitialDir/0004-configure-allow-specifying-python-to-use-with-python.patch"
98128

99129
# Build jam
100130
echo 'Building jam buildtool'
101131
cd "$__RootfsDir/tmp/buildtools/jam"
102132
make
133+
./jam0 -sBINDIR="$__RootfsDir/bin" install
103134

104135
# Configure cross tools
105136
echo "Building cross tools with $JOBS parallel jobs"
106137
mkdir -p "$__RootfsDir/generated"
107138
cd "$__RootfsDir/generated"
108139
if [ -z "$__BuildSecondaryArch" ]; then
109-
"$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools $__BuildArch
140+
"$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools $__BuildArch $__ExtraArgs
110141
else
111-
"$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools $__BuildArch --build-cross-tools $__BuildSecondaryArch
142+
"$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools $__BuildArch --build-cross-tools $__BuildSecondaryArch $__ExtraArgs
112143
fi
113144

114145
# Build haiku packages
115146
echo 'Building Haiku packages and package tool'
116-
echo 'HAIKU_BUILD_PROFILE = "development-raw" ;' > UserProfileConfig
117-
"$__RootfsDir/tmp/buildtools/jam/jam0" -j"$JOBS" -q '<build>package' '<repository>Haiku'
147+
echo 'HAIKU_BUILD_PROFILE = "nightly-raw" ;' > UserProfileConfig
148+
"$__RootfsDir/bin/jam" -j"$JOBS" -q '<build>package' '<repository>Haiku'
118149

119150
# Find the package command
120151
__PackageCommand=`echo $__RootfsDir/generated/objects/*/*/release/tools/package/package`

0 commit comments

Comments
 (0)