From 7b42b976106ee97dd4e2fb00f411edb5f7b118bd Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Tue, 13 Oct 2020 15:20:40 +0700 Subject: [PATCH] Update build script Former-commit-id: fd39635fc5c0b7c39959d94e8dcdbebb94498e00 --- .dockerignore | 3 ++ .gitmodules | 2 - CHANGELOG.md | 2 + README.md | 28 +++++------ .../x11/libgodotxtermnative.so.REMOVED.git-id | 2 +- addons/godot_xterm/native/build.sh | 49 +++++++++++-------- addons/godot_xterm/native/shell.nix | 11 +++++ docker-compose.yml | 4 +- dockerfiles/archlinux | 6 ++- dockerfiles/ubuntu | 8 ++- 10 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 .dockerignore create mode 100644 addons/godot_xterm/native/shell.nix diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b50f0bc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +addons/godot_xterm/native/external/* +addons/godot_xterm/native/bin/**/* +addons/godot_xterm/native/.sconsign*.dblite diff --git a/.gitmodules b/.gitmodules index 9af9d15..892bf69 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,5 +4,3 @@ [submodule "addons/godot_xterm/libtsm"] path = addons/godot_xterm/native/external/libtsm url = https://github.com/Aetf/libtsm -[submodule "godot-cpp/"] - url = https://github.com/godotengine/godot-cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f3eb0..a64e17a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Updated build script (`addons/godot_xterm/native/build.sh`). Git submodules will now be initialized if they haven't already. Moved nix-shell related stuff to a seperate shell.nix file so the same build command can be used on all Linux based OSes. ## [1.0.0] - 2020-10-05 ### Added diff --git a/README.md b/README.md index 78f2a21..530d596 100644 --- a/README.md +++ b/README.md @@ -17,38 +17,34 @@ Terminal emulator for Godot using GDNative and [libtsm](https://github.com/Aetf/ ### All Operating Systems -**Important**: The main dependencies of this project are included as git submodules. -You can install them in this repo after cloning with: -``` -git submodule update --init --recursive -``` -In addition to these, you will need some other dependencies including: +You will need at least these dependencies in order to build this plugin: +- Git (for git submodules) - a C++ compiler (e.g. gcc) - ar (part of GNU Binutils) - CMake - Python - SCons -### Operating System Specific +### Linux #### NixOS -On NixOS you can simply run the [build.sh] script in the `addons/godot_xterm/native` directory: +You can simply run the [build.sh] script in the `addons/godot_xterm/native` directory: ``` -cd addons/godot_xterm/native -./build.sh +addons/godot_xterm/native/build.sh ``` All dependencies will be pulled in by nix-shell and the build steps will run. #### Arch Linux and Ubuntu -See the [Arch Linux Dockerfile](dockerfiles/archlinux) and [Ubuntu Dockerfile](dockerfiles/ubuntu) for a list of packages that need to be installed. Once installed, run the [build.sh] script from the `addons/godot_xterm/native` directory: +See the [Arch Linux Dockerfile](dockerfiles/archlinux) and [Ubuntu Dockerfile](dockerfiles/ubuntu) for a list of packages that need to be installed. Once installed, run the [build.sh] script in the `addons/godot_xterm/native` directory: ``` -cd addons/godot_xterm/native -bash ./build.sh +addons/godot_xterm/native/build.sh ``` -Make sure you use `bash` to run the script as the default interpreter is set to nix-shell. -#### Other -Other operating systems will probably be similar to the above. When in doubt check the documentation in the submodule repos, the [build.sh] script, and the [SConstruct] file. +#### Other Linux Distributions +Will probably be similar to the above. When in doubt check the documentation in the submodule repos, the [build.sh] script, and the [SConstruct] file. + +### Other Operating Systems +This plugin is not currently supported for other operating systems (e.g. MacOS, Windows). If you manage to build it on one of these platforms, please submit a PR for this readme. ## Usage diff --git a/addons/godot_xterm/native/bin/x11/libgodotxtermnative.so.REMOVED.git-id b/addons/godot_xterm/native/bin/x11/libgodotxtermnative.so.REMOVED.git-id index e2e41f4..f6f960f 100644 --- a/addons/godot_xterm/native/bin/x11/libgodotxtermnative.so.REMOVED.git-id +++ b/addons/godot_xterm/native/bin/x11/libgodotxtermnative.so.REMOVED.git-id @@ -1 +1 @@ -1dcc20e0ef6e62c4371e3345e33bef19229c471a \ No newline at end of file +a17dbf3cdfca56910de1517e42a39770c19aef81 \ No newline at end of file diff --git a/addons/godot_xterm/native/build.sh b/addons/godot_xterm/native/build.sh index 874527c..baf1c4a 100755 --- a/addons/godot_xterm/native/build.sh +++ b/addons/godot_xterm/native/build.sh @@ -1,28 +1,37 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i bash --pure -p binutils.bintools cmake scons +#!/bin/sh set -e -# Make sure we are in the addons/godot_xterm directory -cd ${BASH_SOURCE%/*} +# Get the absolute path to the directory this script is in. +NATIVE_DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" -# Initialize godot-cpp -if [ ! -d "external/godot-cpp/bin" ] -then - cd external/godot-cpp - scons platform=linux generate_bindings=yes -j12 - cd ../.. +# Run script inside a nix shell if it is available. +if command -v nix-shell && [ $NIX_PATH ] && [ -z $IN_NIX_SHELL ]; then + cd ${NATIVE_DIR} + nix-shell shell.nix --pure --run "./build.sh" + exit fi -# Build libtsm -if [ ! -f "external/libtsm/build/src/tsm/libtsm.a" ] -then - cd external/libtsm - mkdir -p build - cd build - cmake -DBUILD_SHARED_LIBS=n .. - make - cd ../../.. +# Build libtsm. +LIBTSM_DIR=${NATIVE_DIR}/external/libtsm +if [ ! -d "$LIBTSM_DIR" ]; then + cd ${NATIVE_DIR} + git submodule update --init --recursive -- $LIBTSM_DIR fi +cd $LIBTSM_DIR +mkdir -p build +cd build +cmake -DBUILD_SHARED_LIBS=n .. +make -# Build godotxtermnative +# Build godot-cpp. +GODOT_CPP_DIR=${NATIVE_DIR}/external/godot-cpp +if [ ! -d "${GODOT_CPP_DIR}" ]; then + cd ${NATIVE_DIR} + git submodule update --init --recursive -- $GODOT_CPP_DIR +fi +cd $GODOT_CPP_DIR +scons platform=linux generate_bindings=yes -j12 + +# Build godotxtermnative. +cd ${NATIVE_DIR} scons platform=linux diff --git a/addons/godot_xterm/native/shell.nix b/addons/godot_xterm/native/shell.nix new file mode 100644 index 0000000..abcd05d --- /dev/null +++ b/addons/godot_xterm/native/shell.nix @@ -0,0 +1,11 @@ +with (import {}); +mkShell { + buildInputs = with pkgs; [ + binutils.bintools + cmake + git + libxkbcommon + pkg-config + scons + ]; +} diff --git a/docker-compose.yml b/docker-compose.yml index c060d05..ce0fc40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: build: context: . dockerfile: ./dockerfiles/archlinux - command: bash /src/addons/godot_xterm/native/build.sh + command: /src/addons/godot_xterm/native/build.sh build-nixos: build: context: . @@ -14,4 +14,4 @@ services: build: context: . dockerfile: ./dockerfiles/ubuntu - command: bash /src/addons/godot_xterm/native/build.sh + command: /src/addons/godot_xterm/native/build.sh diff --git a/dockerfiles/archlinux b/dockerfiles/archlinux index c6d2d63..9b4b559 100644 --- a/dockerfiles/archlinux +++ b/dockerfiles/archlinux @@ -1,3 +1,7 @@ FROM archlinux:20200908 -RUN pacman -Sy --needed --noconfirm base-devel cmake scons +RUN pacman -Sy --needed --noconfirm \ + base-devel \ + cmake \ + git \ + scons COPY . /src diff --git a/dockerfiles/ubuntu b/dockerfiles/ubuntu index 55e70a0..d48b4cd 100644 --- a/dockerfiles/ubuntu +++ b/dockerfiles/ubuntu @@ -1,4 +1,8 @@ FROM ubuntu:18.04 -RUN apt-get update -y -RUN apt-get install -y build-essential cmake python3 scons +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + git \ + python3 \ + scons COPY . /src