-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcopy_objects.sh
executable file
·86 lines (78 loc) · 4.56 KB
/
copy_objects.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
HAIKU_UNIX_ARCH=${HAIKU_UNIX_ARCH:-"$(uname -m)"}
case $HAIKU_UNIX_ARCH in
"aarch64")
HAIKU_ARCH="arm64"
;;
*)
HAIKU_ARCH=$HAIKU_UNIX_ARCH
;;
esac
# TODO: This is personalized for my local environment, but making this a subdirectory of the HyClone
# tree (such as "haiku-build") seems to be a better idea.
HAIKU_BUILD_ENVIRONMENT_ROOT=${HAIKU_BUILD_ENVIRONMENT_ROOT:-"$SCRIPT_DIR/.."}
HAIKU_BUILD_SOURCE_DIRECTORY=${HAIKU_BUILD_SOURCE_DIRECTORY:-"$HAIKU_BUILD_ENVIRONMENT_ROOT/haiku"}
HAIKU_BUILD_TOOLS_DIRECTORY=${HAIKU_BUILD_TOOLS_DIRECTORY:-"$HAIKU_BUILD_ENVIRONMENT_ROOT/buildtools"}
HAIKU_BUILD_OUTPUT_ROOT=${HAIKU_BUILD_OUTPUT_ROOT:-"$HAIKU_BUILD_SOURCE_DIRECTORY/generated.$HAIKU_ARCH"}
HAIKU_RUNTIME_LOADER="$HAIKU_BUILD_OUTPUT_ROOT/objects/haiku/$HAIKU_ARCH/release/system/runtime_loader"
HAIKU_RUNTIME_LOADER_ARCH="$HAIKU_RUNTIME_LOADER/arch/$HAIKU_ARCH"
HAIKU_LIBROOT="$HAIKU_BUILD_OUTPUT_ROOT/objects/haiku/$HAIKU_ARCH/release/system/libroot"
HAIKU_SYSLIBS=$(echo $HAIKU_BUILD_OUTPUT_ROOT/build_packages/gcc_syslibs-*$HAIKU_ARCH)"/lib"
HAIKU_SYSLIBS_DEVEL=$(echo $HAIKU_BUILD_OUTPUT_ROOT/build_packages/gcc_syslibs_devel*$HAIKU_ARCH)"/develop/lib"
HAIKU_GLUE="$HAIKU_BUILD_OUTPUT_ROOT/objects/haiku/$HAIKU_ARCH/release/system/glue"
HAIKU_GLUE_ARCH="$HAIKU_GLUE/arch/$HAIKU_ARCH"
# Some distros store the GCC glue objects in lib64, others in lib.
HAIKU_GLUE_GCC=$(echo $HAIKU_BUILD_OUTPUT_ROOT/cross-tools-$HAIKU_ARCH/lib64/gcc/$HAIKU_UNIX_ARCH-unknown-haiku/**)
if [ ! -f "$HAIKU_GLUE_GCC/crtbeginS.o" ]; then
HAIKU_GLUE_GCC=$(echo $HAIKU_BUILD_OUTPUT_ROOT/cross-tools-$HAIKU_ARCH/lib/gcc/$HAIKU_UNIX_ARCH-unknown-haiku/**)
fi
# If Haiku is not built, build it!
if [ ! -d "$HAIKU_BUILD_OUTPUT_ROOT" ]; then
echo "Haiku source tree not found. Building Haiku..."
pushd
mkdir -p $HAIKU_BUILD_ENVIRONMENT_ROOT
cd $HAIKU_BUILD_ENVIRONMENT_ROOT
git clone https://review.haiku-os.org/buildtools $HAIKU_BUILD_TOOLS_DIRECTORY
git clone https://review.haiku-os.org/haiku $HAIKU_BUILD_SOURCE_DIRECTORY
cd haiku
mkdir -p $HAIKU_BUILD_OUTPUT_ROOT
cd $HAIKU_BUILD_OUTPUT_ROOT
$HAIKU_BUILD_SOURCE_DIRECTORY/configure --cross-tools-source $HAIKU_BUILD_TOOLS_DIRECTORY --build-cross-tools $HAIKU_ARCH -j$(nproc)
cd $HAIKU_BUILD_TOOLS_DIRECTORY/jam
make -j$(nproc)
cd $HAIKU_BUILD_OUTPUT_ROOT
$HAIKU_BUILD_TOOLS_DIRECTORY/jam/jam0 -q -j$(nproc) libroot.so runtime_loader kernel_core.o "<build>fs_shell.a"
popd
fi
# Some useless objects may be copied, ignore them.
# They'll be handled by CMake.
mkdir -p $SCRIPT_DIR/libroot/os/arch/$HAIKU_ARCH
mkdir -p $SCRIPT_DIR/libhyclonefs/haiku_include/fs_shell
mkdir -p $SCRIPT_DIR/libhyclonefs/haiku_include/private/fs_shell
mkdir -p $SCRIPT_DIR/libhyclonefs/fs_shell
mkdir -p $SCRIPT_DIR/libhyclonefs/libroot_host
cp -fpv $HAIKU_RUNTIME_LOADER_ARCH/*.a $SCRIPT_DIR/runtime_loader
cp -fpv $HAIKU_RUNTIME_LOADER/*.a $SCRIPT_DIR/runtime_loader
cp -fpv $HAIKU_RUNTIME_LOADER/*.o $SCRIPT_DIR/runtime_loader
cp -fpv $HAIKU_SYSLIBS_DEVEL/*-kernel.a $SCRIPT_DIR/runtime_loader
cp -fpv $HAIKU_LIBROOT/posix/posix*.o $SCRIPT_DIR/libroot/posix
cp -fpv $HAIKU_LIBROOT/posix/**/posix*.o $SCRIPT_DIR/libroot/posix
cp -fpv $HAIKU_LIBROOT/posix/glibc/**/posix*.o $SCRIPT_DIR/libroot/posix
cp -fpv $HAIKU_LIBROOT/posix/arch/$HAIKU_ARCH/posix*.o $SCRIPT_DIR/libroot/posix
cp -fpv $HAIKU_LIBROOT/posix/**/arch/$HAIKU_ARCH/posix*.o $SCRIPT_DIR/libroot/posix
cp -fpv $HAIKU_LIBROOT/posix/signal/*.o $SCRIPT_DIR/libroot/posix/signal
cp -fpv $HAIKU_LIBROOT/posix/stdlib/*.o $SCRIPT_DIR/libroot/posix/stdlib
cp -fpv $HAIKU_LIBROOT/os/arch/$HAIKU_ARCH/*.o $SCRIPT_DIR/libroot/os/arch/$HAIKU_ARCH
cp -fpv $HAIKU_LIBROOT/os/*.o $SCRIPT_DIR/libroot/os
cp -fpv $HAIKU_LIBROOT/libroot_init.o $SCRIPT_DIR/libroot
cp -fpv $HAIKU_SYSLIBS_DEVEL/*.a $SCRIPT_DIR/libroot
cp -fpv $HAIKU_SYSLIBS/libgcc_s.so.1 $SCRIPT_DIR/libroot
cp -fpv $HAIKU_GLUE/init_term_dyn.o $SCRIPT_DIR/libroot
cp -fpv $HAIKU_GLUE_ARCH/crti.o $SCRIPT_DIR/libroot
cp -fpv $HAIKU_GLUE_ARCH/crtn.o $SCRIPT_DIR/libroot
cp -fpv $HAIKU_GLUE_GCC/crtbeginS.o $SCRIPT_DIR/libroot
cp -fpv $HAIKU_GLUE_GCC/crtendS.o $SCRIPT_DIR/libroot
cp -fpv $HAIKU_BUILD_SOURCE_DIRECTORY/src/tools/fs_shell/*.h $SCRIPT_DIR/libhyclonefs/haiku_include/fs_shell
cp -fpv $HAIKU_BUILD_SOURCE_DIRECTORY/headers/private/fs_shell/*.h $SCRIPT_DIR/libhyclonefs/haiku_include/private/fs_shell
cp -fpv $HAIKU_BUILD_OUTPUT_ROOT/objects/haiku/$HAIKU_ARCH/release/system/kernel/syscalls.o $SCRIPT_DIR/monika/dispatcher/syscalls.o