Skip to content

Commit

Permalink
Merge pull request #36 from nvtkaszpir/travis
Browse files Browse the repository at this point in the history
Add first travis builds for multiple architectures
  • Loading branch information
deurk authored Aug 12, 2017
2 parents ed869aa + d5038cb commit 6014d31
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ config.status
src/Makefile.dl
src/Makefile.dl32
src/Makefile.vm

#virtualenv
.venv/

# build output dirs
build_*/
67 changes: 67 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
dist: trusty
sudo: required

# branches:
# only:
# - master

os:
- linux

# in theory travis should detect what to install,
# but we use meson, which is not supported by travis yet and we need custom commands
compiler:
- gcc

language:
- c

matrix:
include:
- os: linux
dist: trusty
env: TARGET=linux-i386
- os: linux
dist: trusty
env: TARGET=linux-amd64
- os: linux
dist: trusty
env: TARGET=linux-armv7hl
- os: linux
dist: trusty
env: TARGET=win-x86
- os: linux
dist: trusty
env: TARGET=win-x64

before_install:
# show some extra info
- export | sort
- env | sort
# update base distro
- sudo apt-get update
# - sudo apt-get -y upgrade
# - sudo apt-get -y dist-upgrade
# install base packages
- sudo apt-get -y install build-essential python-virtualenv python3-dev python3-pip ninja-build cmake gcc-multilib
# install cross complier if we gonna do binaries for windows
- if [ -z "${TARGET##*win*}" ]; then sudo apt-get -y install mingw-w64 ; fi
# install cross compiler tools if we gonna do binares for arm/raspberry
# notice it will remove gcc-multilib
- if [ -z "${TARGET##*arm*}" ]; then sudo apt-get -y install gcc-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf ;fi
# activate virtualenv with python3, meson requires python3
- virtualenv .venv --python=python3
- . .venv/bin/activate
- pip3 install --upgrade pip
# install python packages like meson, ninja etc...
- pip3 install -r requirements.txt

# each script section is executed in matrix build
script:
- mkdir build_${TARGET} || true
- meson build_${TARGET} --cross-file cross-compilation_${TARGET}.txt
- ninja -v -C build_${TARGET}
# print basic info about complied files
- find build_${TARGET}/ -type f -name "qwprogs.*" -exec file {} \;


122 changes: 116 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
KTX: a Quakeworld™ server mod
===
===================================

[KTX] is a popular **Quakeworld™** server modification, adding numerous features to the core features of the server.

Expand All @@ -8,12 +8,12 @@ Although it had been developed to be **Quakeworld™** server agnostic, it h
Current code status: [![Build Status](https://drone.io/github.com/qwassoc/ktx/status.png)](https://drone.io/github.com/qwassoc/ktx/latest)

Features
----
--------
*To be detailled*


Build from source
----
Build from source (old way)
---------------------------

Linux:

Expand All @@ -25,8 +25,118 @@ make build-dl
Now, you should have the qwprogs.so. Copy it to your ktx game directory of your quakeworld server.


Build from source with meson
----------------------------

Detailed commands to install packages, tools and compilation can be found in ``.travis.yml`` file.
There are extra conditionals to install desired packages based on the TARGET.

In general:

- use Ubuntu 14.04 (but should work under 16.04 as well) as virtual machine, check out source code there
- install required packages for compilation
- set up virtualenv and install python packages (required for meson and ninja builders)
- run meson build for given directory (optionally with cross compilation settings)
- run ninja to generate .so file
- you should have ``qwprogs.so`` file in ``build_*`` directory, put it in your quake server/ktx/ directory.

You should be able to compile binaries for most popular platforms, such as:

- Linux 32-bit and 64-bit
- Windows 32-bit and 64-bit (WoW64)
- Arm 7 - for RaspBerry Pi 3 with Raspbian

Example builiding under Ubuntu 14.04 binaries for Raspberry Pi 3 (Raspbian):

Install required packages:

```bash
$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get -y install build-essential python-virtualenv python3-dev python3-pip ninja-build cmake gcc-multilib
```

Install required packaes specifically for arm architecture for Raspberry Pi 3 (Raspbian):

```bash
$ sudo apt-get -y install gcc-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf
```

Check out the code to the current directory:

```bash
git clone https://github.com/deurk/mvdsv.git .
```

Create virtualenv + install python packages:

```bash
$ virtualenv .venv --python=python3
$ . .venv/bin/activate
$ pip3 install --upgrade pip
$ pip3 install -r requirements.txt
```

Export env var to define what target to compile, run the build commands.


```bash
$ export TARGET=linux-armv7hl
$ rm -rf build_${TARGET}

$ meson build_${TARGET} --cross-file cross-compilation_${TARGET}.txt
The Meson build system
Version: 0.41.2
Source dir: /home/kaszpir/src/deurk/ktx
Build dir: /home/kaszpir/src/deurk/ktx/build_linux-armv7hl
Build type: cross build
Project name: ktx
Native c compiler: cc (gcc 5.4.0)
Cross c compiler: arm-linux-gnueabihf-gcc (gcc 5.4.0)
Host machine cpu family: arm
Host machine cpu: armv7hl
Target machine cpu family: arm
Target machine cpu: armv7hl
Build machine cpu family: x86_64
Build machine cpu: x86_64
Library m found: YES
Build targets in project: 1

$ ninja -C build_${TARGET}

ninja: Entering directory `build_linux-armv7hl'
[25/99] Compiling C object 'qwprogs@sha/src_bot_movement.c.o'.
../src/bot_movement.c: In function ‘ApplyPhysics’:
../src/bot_movement.c:191:10: warning: unused variable ‘dot_prod’ [-Wunused-variable]
float dot_prod = 0.0f;
^
[80/99] Compiling C object 'qwprogs@sha/src_race.c.o'.
../src/race.c: In function ‘race_finish_capture’:
../src/race.c:3766:9: warning: unused variable ‘race_time’ [-Wunused-variable]
float race_time = race_match_mode() ? player_match_info[player_num].best_time : race.currentrace[player_num].time;
^
[99/99] Linking target qwprogs.so.
```
Check the output binary file:
```bash
$ find build_${TARGET}/ -type f -name "qwprogs.*" -exec file {} \;
build_linux-armv7hl/qwprogs.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=5d5ff9fd0172ef1aa929c1704a6a16b68906641f, not stripped
```
In ``build_*/`` there will be ``qwprogs.so`` or ``qwprogs.dll`` binary, change permissions to executable and copy it to quake/ktx/ directory to start quake server with ktx mod enabled.
Known issues:
- When using cross compiling between 32bit and 64bit architecture make sure to reinstall *dev packages or run in chroot. See ``.travis.yml`` lines, there is ``apt-get remove`` command for this, because curl and pcre are in dependency but not required.
- When changing architecture builds, for example for arm, apt-get will install/remove conflicting packages. Don't be surprised that you compile ``linux-amd64``, then ``linux-armv7hl`` and then back ``linux-amd64`` and it does not work because files are missing :)
Building KTX as VM bytecode
----
---------------------------
If your qw server is [MVDSV] you may want to build KTX as a quake virtual machine. Virtual machine building needs Quake 3 bytecode assembly tools, namely q3asm and q3lcc. We packaged those inside the tools directory. It is up to you to build them.
Expand All @@ -52,7 +162,7 @@ Configure should have found q3asm and q3lcc. After make, you should find qwprogs
License
----
-------
All files inside this repository are licensed under the Gnu General Publice License v2 (GPLv2). You wil find a copy of the license in the LICENSE file.
Expand Down
Empty file removed build_linux32/.gitkeep
Empty file.
Empty file removed build_linux64/.gitkeep
Empty file.
Empty file removed build_win32/.gitkeep
Empty file.
Empty file removed build_win64/.gitkeep
Empty file.
File renamed without changes.
12 changes: 12 additions & 0 deletions cross-compilation_linux-armv7hl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-cpp'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
pkgconfig = 'arm-linux-gnueabihf-pkg-config'

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7hl'
endian = 'little'
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
meson==0.41.2
ninja==1.7.2.post2
scikit-build==0.6.1

0 comments on commit 6014d31

Please sign in to comment.