From 5c82d141287666588d135a884144b2b12d62f416 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 28 May 2019 00:02:29 +0200 Subject: [PATCH] Add the start of a simple ports infrastructure --- Ports/.port_include.sh | 78 ++++++++++++++++++++++++++++++++++++++++++ Ports/README.md | 15 ++++++++ Ports/SDL2.sh | 15 ++++++++ 3 files changed, 108 insertions(+) create mode 100644 Ports/.port_include.sh create mode 100644 Ports/README.md create mode 100755 Ports/SDL2.sh diff --git a/Ports/.port_include.sh b/Ports/.port_include.sh new file mode 100644 index 0000000000..b8033bbb6b --- /dev/null +++ b/Ports/.port_include.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +# This script contains common helpers for all ports. +set -e + +if [ -z "$MAKEOPTS" ]; then + MAKEOPTS="-j $(nproc)" +fi +if [ -z "$INSTALLOPTS" ]; then + MAKEOPTS="-j $(nproc)" +fi +if [ -z "$SERENITY_ROOT" ]; then + echo "You must have source'd UseIt.sh to build any ports!" + exit 1 +fi + +if [ -z "$PORT_DIR" ]; then + echo "Must set PORT_DIR to where the source should be cloned." + exit 1 +fi + +function run_fetch_git() { + if [ -d "$PORT_DIR/.git" ]; then + (cd "$PORT_DIR" && git fetch && git reset --hard FETCH_HEAD) + else + git clone "$1" "$PORT_DIR" + fi +} + +function run_configure_cmake() { + ( + cd "$PORT_DIR" + cmake -DCMAKE_TOOLCHAIN_FILE="$SERENITY_ROOT/Toolchain/CMakeToolchain.txt" . + ) +} + +function run_configure_autotools() { + ( + cd "$PORT_DIR" + ./configure --host=i686-pc-serenity + ) +} + +function run_make() { + ( + cd "$PORT_DIR" + make $MAKEOPTS "$@" + ) +} + +function run_make_install() { + ( + cd "$PORT_DIR" + make $INSTALLOPTS install "$@" + ) +} + +if [ -z "$1" ]; then + fetch + configure + build + install + exit 0 +fi + +if [ "$1" == "fetch" ]; then + fetch +elif [ "$1" == "configure" ]; then + configure +elif [ "$1" == "build" ]; then + build +elif [ "$1" == "install" ]; then + install +else + echo "Unknown verb: $1" + echo "Supported: (one of) fetch configure build install" + exit 1 +fi diff --git a/Ports/README.md b/Ports/README.md new file mode 100644 index 0000000000..0915ffd3d7 --- /dev/null +++ b/Ports/README.md @@ -0,0 +1,15 @@ +# What's this? + +Serenity has software patched to run on it. +These shell scripts will allow you to build that sort of software, easily. +For example, if you want to install SDL2, simply run the SDL2.sh script. +Note that you should have already built Serenity, and be in a Serenity build environment. + +# Using ports scripts + +To do everything, just run the script: `./SDL2.sh` +To do a single step, you can specify it: `./SDL2.sh build` + +# How do I contribute? + +Port software, and add new scripts to build it of course :) diff --git a/Ports/SDL2.sh b/Ports/SDL2.sh new file mode 100755 index 0000000000..0e6b0a1c2e --- /dev/null +++ b/Ports/SDL2.sh @@ -0,0 +1,15 @@ +#!/bin/sh +PORT_DIR=SDL +function fetch() { + run_fetch_git "https://github.com/SerenityOS/SDL" +} +function configure() { + run_configure_cmake +} +function build() { + run_make +} +function install() { + run_make_install +} +source ./.port_include.sh