From 5babcac289d04a3c2f627dbbbd3e62718d3f98f3 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 17 May 2019 20:40:38 +0200 Subject: [PATCH] Build: Install most headers to Root (and libcore.a/libgui.a) This makes out-of-tree linking possible. And at the same time, add a CMakeToolchain.txt file that can be used to build arbitrary cmake-using applications on Serenity by pointing to the CMAKE_TOOLCHAIN_FILE when running cmake: -DCMAKE_TOOLCHAIN_FILE=~/code/serenity/Toolchain/CMakeToolchain.txt --- AK/install.sh | 4 ++++ Kernel/install.sh | 4 ++++ Kernel/makeall.sh | 7 +++++-- Kernel/sync.sh | 2 +- LibCore/Makefile | 9 +++++++++ LibCore/install.sh | 5 +++++ LibGUI/Makefile | 6 ++++++ LibGUI/install.sh | 5 +++++ Servers/WindowServer/install.sh | 4 ++++ SharedGraphics/install.sh | 4 ++++ Toolchain/CMakeToolchain.txt | 19 +++++++++++++++++++ Toolchain/UseIt.sh | 1 + 12 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 AK/install.sh create mode 100755 Kernel/install.sh create mode 100755 LibCore/install.sh create mode 100755 LibGUI/install.sh create mode 100755 Servers/WindowServer/install.sh create mode 100755 SharedGraphics/install.sh create mode 100644 Toolchain/CMakeToolchain.txt diff --git a/AK/install.sh b/AK/install.sh new file mode 100755 index 00000000000..d0827c75025 --- /dev/null +++ b/AK/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +mkdir -p ../Root/usr/include/AK/ +cp ../AK/*.h ../Root/usr/include/AK/ diff --git a/Kernel/install.sh b/Kernel/install.sh new file mode 100755 index 00000000000..46c09473b25 --- /dev/null +++ b/Kernel/install.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p ../Root/usr/include/Kernel/ +cp *.h ../Root/usr/include/Kernel/ diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh index 0b599e8753e..78f74ab407d 100755 --- a/Kernel/makeall.sh +++ b/Kernel/makeall.sh @@ -33,6 +33,7 @@ build_targets="$build_targets ../Games/Snake" build_targets="$build_targets ../Shell" build_targets="$build_targets ../Demos/HelloWorld" build_targets="$build_targets ../Demos/RetroFetch" +build_targets="$build_targets ." # the kernel for targ in $build_targets; do echo "Building $targ" @@ -45,7 +46,9 @@ for targ in $build_targets; do fi done -$make_cmd clean -$make_cmd +# has no need to build separately, but install headers. +(cd ../SharedGraphics && ./install.sh) +(cd ../AK && ./install.sh) + sudo ./sync.sh diff --git a/Kernel/sync.sh b/Kernel/sync.sh index 391d2679f7d..b548bcb2836 100755 --- a/Kernel/sync.sh +++ b/Kernel/sync.sh @@ -6,7 +6,7 @@ fi if [ $(id -u) != 0 ]; then echo "This needs to be run as root" - exit + exit 1 fi rm -vf _fs_contents.lock diff --git a/LibCore/Makefile b/LibCore/Makefile index b75c137b1a7..c86c210e03f 100644 --- a/LibCore/Makefile +++ b/LibCore/Makefile @@ -36,3 +36,12 @@ $(LIBRARY): $(OBJS) clean: @echo "CLEAN"; rm -f $(LIBRARY) $(OBJS) *.d +install: $(LIBRARY) + mkdir -p ../Root/usr/include/LibCore + mkdir -p ../Root/usr/include/AK + mkdir -p ../Root/usr/lib + # Copy headers + rsync -r -a --include '*/' --include '*.h' --exclude '*' . ../Root/usr/include/LibCore + rsync -r -a --include '*/' --include '*.h' --exclude '*' ../AK/ ../Root/usr/include/AK + # Install the library + cp $(LIBRARY) ../Root/usr/lib diff --git a/LibCore/install.sh b/LibCore/install.sh new file mode 100755 index 00000000000..fedc4b73fbd --- /dev/null +++ b/LibCore/install.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +mkdir -p ../Root/usr/include/LibCore/ +cp *.h ../Root/usr/include/LibCore/ +cp libcore.a ../Root/usr/lib/ diff --git a/LibGUI/Makefile b/LibGUI/Makefile index 766cc49db90..1039ff00a04 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -77,3 +77,9 @@ $(LIBRARY): $(OBJS) clean: @echo "CLEAN"; rm -f $(LIBRARY) $(OBJS) *.d +install: $(LIBRARY) + mkdir -p ../Root/usr/include/LibGUI + # Copy headers + rsync -r -a --include '*/' --include '*.h' --exclude '*' . ../Root/usr/include/LibGUI + # Install the library + cp $(LIBRARY) ../Root/usr/lib diff --git a/LibGUI/install.sh b/LibGUI/install.sh new file mode 100755 index 00000000000..e3cf91fcd77 --- /dev/null +++ b/LibGUI/install.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +mkdir -p ../Root/usr/include/LibGUI/ +cp *.h ../Root/usr/include/LibGUI/ +cp libgui.a ../Root/usr/lib/ diff --git a/Servers/WindowServer/install.sh b/Servers/WindowServer/install.sh new file mode 100755 index 00000000000..27a3a583be5 --- /dev/null +++ b/Servers/WindowServer/install.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p ../../Root/usr/include/WindowServer/ +cp *.h ../../Root/usr/include/WindowServer/ diff --git a/SharedGraphics/install.sh b/SharedGraphics/install.sh new file mode 100755 index 00000000000..5b19415f9d4 --- /dev/null +++ b/SharedGraphics/install.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p ../Root/usr/include/SharedGraphics/ +cp *.h ../Root/usr/include/SharedGraphics/ diff --git a/Toolchain/CMakeToolchain.txt b/Toolchain/CMakeToolchain.txt new file mode 100644 index 00000000000..e826e464857 --- /dev/null +++ b/Toolchain/CMakeToolchain.txt @@ -0,0 +1,19 @@ +set(CMAKE_SYSTEM_NAME Generic) + +if (NOT DEFINED ENV{SERENITY_ROOT}) + message(FATAL_ERROR "SERENITY_ROOT not set. Please source Toolchain/UseIt.sh.") +endif() + +# where to read from/write to +set(CMAKE_SYSROOT $ENV{SERENITY_ROOT}/Root) +set(CMAKE_STAGING_PREFIX $ENV{SERENITY_ROOT}/Root) +set(CMAKE_INSTALL_PREFIX $ENV{SERENITY_ROOT}/Root) + +set(CMAKE_C_COMPILER i686-pc-serenity-gcc) +set(CMAKE_CXX_COMPILER i686-pc-serenity-g++) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + diff --git a/Toolchain/UseIt.sh b/Toolchain/UseIt.sh index 4008a23c732..4c53049ff05 100644 --- a/Toolchain/UseIt.sh +++ b/Toolchain/UseIt.sh @@ -2,4 +2,5 @@ DIR=$( dirname $( readlink -e "$0" ) ) export PATH="$DIR/Local/bin:$PATH" export TOOLCHAIN="$DIR" +export SERENITY_ROOT="$DIR/.." echo "$PATH"