From 65abfec720806e641c64471104d592aaafed26f7 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Fri, 4 Sep 2020 20:56:12 -0400 Subject: Added support for building with Docker and dropped automated Linux i386 builds. Also tweaked Makefile with basic git support for an eventual migration to a new build service. --- README.md | 7 ++++++ doc/index.html | 11 +++------ doc/manual.md | 64 +++++++++++++++++++++++++++++++++++++++--------- modules/lua/luadoc.patch | 22 ----------------- src/Dockerfile | 25 +++++++++++++++++++ src/Makefile | 56 +++++++++++++++++++++--------------------- src/luadoc.patch | 23 +++++++++++++++++ 7 files changed, 140 insertions(+), 68 deletions(-) delete mode 100644 modules/lua/luadoc.patch create mode 100644 src/Dockerfile create mode 100644 src/luadoc.patch diff --git a/README.md b/README.md index 6f33a4eb..ab1acd9b 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ General Requirements: Windows. * [OSX cross toolchain][] _with GCC_ 4.9+ (not Clang) when cross-compiling for macOS. +* _**OR**_ +* [Docker][] The following table provides a brief list of `make` rules for building Textadept on Linux and BSD. (On BSD, substitute `make` with `gmake`.) @@ -107,6 +109,9 @@ Command |Description `make osx` |Cross-compiles Textadept for macOS `make osx-curses` |Cross-compiles the terminal version for macOS +When building within Docker, the relevant [container image][] is +`textadept/build:v1.0`. + For more information on compiling Textadept, please see the [manual][]. [GNU C compiler]: https://gcc.gnu.org @@ -117,6 +122,8 @@ For more information on compiling Textadept, please see the [manual][]. [MinGW]: https://mingw.org [mingw-w64]: https://mingw-w64.org/ [OSX cross toolchain]: https://github.com/tpoechtrager/osxcross +[Docker]: https://www.docker.com/ +[container image]: https://hub.docker.com/repository/docker/textadept/build [manual]: https://foicica.com/textadept/manual.html#Compiling ## Contribute diff --git a/doc/index.html b/doc/index.html index 2c92d73b..6b4afaad 100644 --- a/doc/index.html +++ b/doc/index.html @@ -78,13 +78,10 @@

Nightly* Builds

diff --git a/doc/manual.md b/doc/manual.md index 0c1ec03c..d4061b39 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -343,10 +343,11 @@ you need Textadept to see. For example: **Linux Note:** providing a single binary that runs on all Linux systems proves challenging, since the versions of software installed vary widely from -distribution to distribution. If you get an error like: +distribution to distribution. If you get errors like: - error while loading shared libraries: : cannot open shared object - file: No such file or directory + * `//libc.so.6: version 'GLIBC_' not found` + * `error while loading shared libraries: : cannot open shared object + file: No such file or directory` you will need to [compile](#Compiling) Textadept manually for your system, which is a very straightforward and easy process. @@ -1569,9 +1570,10 @@ editing Lua code. For example, in your *~/.textadept/init.lua*: -------------------------------------------------------------------------------- Textadept is a bit unusual in that building it is only supported on Linux and -BSD. The application is cross-compiled for Windows and macOS from Linux. While -it is certainly possible to compile Textadept natively on those platforms, it is -simply not supported in any official capacity. +BSD, or within a [Docker][] [image][]. The application is cross-compiled for +Windows and macOS from Linux. While it is certainly possible to compile +Textadept natively on those platforms, it is simply not supported in any +official capacity. ### Requirements @@ -1587,10 +1589,12 @@ Linux requirements: * [GTK][] 2.24+ development libraries for the GUI version * [ncurses][](w) development libraries (wide character support) for the terminal version +* _**OR**_ +* [Docker][] **Note:** on Ubuntu for example, these dependencies would be provided by the -`build-essential`, `libgtk2.0-dev`, `libncurses5-dev`, and `libncursesw5-dev` -packages. +`build-essential`, `libgtk2.0-dev`, `libncurses5-dev`, `libncursesw5-dev`, and +`docker.io` packages. BSD requirements: @@ -1606,20 +1610,26 @@ BSD requirements: Windows cross-compiling requirements: * [MinGW][] or [mingw-w64][] 4.9+ (circa early 2014) +* _**OR**_ +* [Docker][] -**Note:** on Ubuntu for example, this dependency would be provided by the -`gcc-mingw-w64` and `g++-mingw-w64` packages. +**Note:** on Ubuntu for example, the compiler dependency would be provided by +the `gcc-mingw-w64` and `g++-mingw-w64` packages. macOS cross-compiling requirements: * [OSX cross toolchain][] with GCC 4.9+ (not Clang) +* _**OR**_ +* [Docker][] **Note:** make sure you run `./build_binutils.sh` before `./build_gcc.sh`. macOS SDK tarballs like *MacOSX10.5.tar.gz* can be found readily on the internet. -**Warning:** building an macOS cross toolchain can easily take 30 minutes or +**Warning:** building a macOS cross toolchain can easily take 30 minutes or more and ultimately consume nearly 3.5GB of disk space. +[Docker]: https://www.docker.com/ +[image]: https://hub.docker.com/repository/docker/textadept/build [GNU C compiler]: https://gcc.gnu.org [libstdc++]: https://gcc.gnu.org [GNU Make]: https://www.gnu.org/software/make/ @@ -1681,6 +1691,38 @@ specify your system's MinGW name prefix using the `CROSS` variable. For example: make CROSS=i586-mingw32-msvc- win32-deps make CROSS=i586-mingw32-msvc- win32 +#### Compiling using Docker + +You can use [Docker][] to build Textadept for Windows, macOS, or Linux. The +[image][] required to do so is about 2.5GB in size. For example: + + localhost$ docker pull textadept/build:v1.0 + localhost$ docker run -t -i -v /path/to/textadept:/ta -w /ta/src \ + textadept/build:v1.0 + container# make deps + container# make + container# exit + +If you prefer to build your own Docker image instead of pulling one, you can +run `docker build .` from Textadept's *src/* directory, which contains the +relevant *Dockerfile*. + +You can issue within the container any of the build commands given in +the previous table, though the install commands are meaningless. + +**Linux note:** if, when running one of the Linux binaries produced, you get an +error like `//libstdc++.so.6: version 'GLIBCXX_' not found`, then +try compiling with the following flags: + + container# make CXXFLAGS="-0s -std=c++11 -static-libstdc++" + +If you still get an error, this time like +`//libc.so.6: version 'GLIBC_' not found`, then you will have to +compile Textadept manually without Docker. + +[Docker]: https://www.docker.com/ +[image]: https://hub.docker.com/repository/docker/textadept/build + -------------------------------------------------------------------------------- ## Appendix -------------------------------------------------------------------------------- diff --git a/modules/lua/luadoc.patch b/modules/lua/luadoc.patch deleted file mode 100644 index 175b5942..00000000 --- a/modules/lua/luadoc.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- luadoc/util.lua.orig 2012-02-10 13:34:46.166184400 -0500 -+++ luadoc/util.lua 2012-02-10 13:36:59.847551200 -0500 -@@ -29,8 +29,8 @@ - -- @see string.gsub - - function trim_comment (s) -- s = string.gsub(s, "%-%-+(.*)$", "%1") -- return trim(s) -+ s = string.gsub(s, "%-%-+ ?(.*)$", "%1") -+ return s - end - - ------------------------------------------------------------------------------- -@@ -52,7 +52,7 @@ - if str1 == nil or string.len(str1) == 0 then - return str2 - else -- return str1 .. " " .. str2 -+ return str1 .. "\n" .. str2 - end - end - diff --git a/src/Dockerfile b/src/Dockerfile new file mode 100644 index 00000000..d565ed74 --- /dev/null +++ b/src/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:bionic +LABEL maintainer="textadept" + +RUN echo "Fetching packages" \ + && apt-get update \ + && DEBIAN_FRONTEND="noninteractive" apt-get install -y -q --no-install-recommends \ + build-essential ca-certificates curl git gnupg mercurial unzip wget zip \ + mingw-w64 \ + clang cmake libssl-dev libxml2-dev llvm-dev lzma-dev uuid-dev \ + libmpc-dev libmpfr-dev libgmp-dev \ + libgtk2.0-dev libncurses5-dev libncursesw5-dev \ + luadoc discount \ + && apt-get clean + +COPY luadoc.patch / +RUN echo "Patching LuaDoc" && cd /usr/share/lua/5.1 && patch -p0 < /luadoc.patch + +RUN echo "Building osxcross" \ + && wget https://github.com/tpoechtrager/osxcross/archive/748108aec4e3ceb672990df8164a11b0ac6084f7.zip \ + && unzip *.zip && mv osxcross-* /opt/osxcross && rm *.zip \ + && wget https://www.dropbox.com/s/yfbesd249w10lpc/MacOSX10.10.sdk.tar.xz \ + && mv MacOSX* /opt/osxcross/tarballs \ + && cd /opt/osxcross && UNATTENDED=1 SDK_VERSION="10.10" OSX_VERSION_MIN="10.6" ./build.sh +RUN echo "Cleaning up" && rm -rf /opt/osxcross/build /opt/osxcross/tarballs/MacOSX* +ENV PATH="$PATH:/opt/osxcross/target/bin" diff --git a/src/Makefile b/src/Makefile index 0f7f5776..c10c0a06 100644 --- a/src/Makefile +++ b/src/Makefile @@ -36,9 +36,11 @@ ifeq (win, $(findstring win, $(MAKECMDGOALS))) endif else ifeq (osx, $(findstring osx, $(MAKECMDGOALS))) # Cross-compile for macOS. - CROSS = x86_64-apple-darwin9- + CC = cc + CXX = c++ + CROSS = x86_64-apple-darwin14- CFLAGS += -mdynamic-no-pic - CXXFLAGS += -mdynamic-no-pic + CXXFLAGS += -mdynamic-no-pic -stdlib=libc++ LUA_CFLAGS = -DLUA_USE_MACOSX LDFLAGS = -liconv ifeq (, $(findstring curses, $(MAKECMDGOALS))) @@ -287,7 +289,7 @@ luadoc: ../modules ../core ../lexers/lexer.lua | ../modules/lua/lua.luadoc ifndef NIGHTLY basedir = textadept_$(version) else - basedir = textadept_NIGHTLY_$(shell date +"%F") + basedir = textadept_nightly_$(shell date +"%F") endif osxapp = Textadept.app osxapp_bin = $(osxapp)/Contents/MacOS @@ -303,30 +305,26 @@ osxapp_libs = libatk-1.0.0.dylib libcairo.2.dylib libexpat.1.dylib \ libpixman-1.0.dylib libpng16.16.dylib charset.alias \ gdk-pixbuf-2.0 gtk-2.0 -release-all: release release64 win32-release osx-release modules-release +release-all: release win32-release osx-release modules-release -$(basedir).i386: ; hg archive $@ -X ".hg*" -release: $(basedir).i386 +ifneq (, $(shell hg summary 2>/dev/null)) + archive = hg archive -X ".hg*" $(1) +else + archive = cd ../ && git archive HEAD --prefix src/$(1)/ | tar -xf - +endif + +$(basedir).linux: ; $(call archive,$@) +release: $(basedir).linux make deps clean doc sign-deps - PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig make -j4 \ - LDFLAGS="$(LDFLAGS) -static-libstdc++" - make -j4 LDFLAGS="$(LDFLAGS) -static-libstdc++" \ - CURSES_CFLAGS=-I/opt/ncursesw/include/ncursesw \ - CURSES_LIBS="-L/opt/ncursesw/lib -lncursesw" curses - cp -rL ../doc ../lexers ../textadept* $< && cp *.asc $