blob: 6c4ea59c3c7f6f518994b5874769e241582cbc96 [file] [log] [blame]
Meier, Rogerc7cb3342014-11-19 15:26:18 +01001# Copyright Roger Meier <r.meier@siemens.com>
2# SPDX-License-Identifier: GPL-2.0+
3
4# build U-Boot on Travis CI - https://travis-ci.org/
5
Tom Rini2bb76f32016-10-20 11:03:19 -04006sudo: required
7dist: trusty
Stephen Warrene4c1b4d2016-02-03 10:41:34 -07008
Meier, Rogerc7cb3342014-11-19 15:26:18 +01009language: c
10
Roger Meier050c7562016-01-25 20:22:41 +010011addons:
12 apt:
13 packages:
14 - cppcheck
15 - sloccount
16 - sparse
17 - bc
18 - build-essential
19 - libsdl1.2-dev
Stephen Warren07bf2122016-02-08 18:23:35 -070020 - python
21 - python-virtualenv
Tom Rinicd402e02016-10-20 11:08:26 -040022 - gcc-powerpc-linux-gnu
23 - gcc-arm-linux-gnueabihf
Tom Rini5eba31c2016-10-29 17:11:17 -040024 - gcc-aarch64-linux-gnu
Tom Rinicd402e02016-10-20 11:08:26 -040025 - iasl
Alexander Graf0e4e38a2016-11-18 13:18:00 +010026 - grub-efi-ia32-bin
27 - rpm2cpio
28 - wget
Meier, Rogerc7cb3342014-11-19 15:26:18 +010029
30install:
Meier, Rogerc7cb3342014-11-19 15:26:18 +010031 # install latest device tree compiler
Tom Rini4084c7f2016-10-20 11:04:10 -040032 - git clone --depth=1 git://git.kernel.org/pub/scm/utils/dtc/dtc.git /tmp/dtc
Meier, Rogerc7cb3342014-11-19 15:26:18 +010033 - make -j4 -C /tmp/dtc
Tom Rini5ac58612016-10-20 11:26:40 -040034 # Clone uboot-test-hooks
35 - git clone --depth=1 git://github.com/swarren/uboot-test-hooks.git /tmp/uboot-test-hooks
36 - ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname`
37 - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
Meier, Rogerc7cb3342014-11-19 15:26:18 +010038 # prepare buildman environment
Stephen Warren43a68e42016-10-26 11:05:31 -060039 - echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rinicd402e02016-10-20 11:08:26 -040040 - echo -e "\n[toolchain-alias]\nblackfin = bfin\nsh = sh4\nopenrisc = or32" >> ~/.buildman
Meier, Rogerc7cb3342014-11-19 15:26:18 +010041 - cat ~/.buildman
Stephen Warren07bf2122016-02-08 18:23:35 -070042 - virtualenv /tmp/venv
43 - . /tmp/venv/bin/activate
44 - pip install pytest
Alexander Graf0e4e38a2016-11-18 13:18:00 +010045 - grub-mkimage -o ~/grub_x86.efi -O i386-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd
46 - mkdir ~/grub2-arm
47 - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/suse/armv7hl/grub2-arm-efi-2.02~beta2-87.1.armv7hl.rpm | rpm2cpio | cpio -di )
Meier, Rogerc7cb3342014-11-19 15:26:18 +010048
49env:
50 global:
Tom Rini3c643fb2016-12-07 11:20:40 -050051 - PATH=/tmp/dtc:/tmp/qemu-install/bin:/tmp/uboot-test-hooks/bin:$PATH
Alexander Grafe0196602016-11-17 18:31:04 +010052 - PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci
Meier, Rogerc7cb3342014-11-19 15:26:18 +010053 - BUILD_DIR=build
Meier, Rogerc7cb3342014-11-19 15:26:18 +010054 - HOSTCC="cc"
55 - HOSTCXX="c++"
Meier, Rogerc7cb3342014-11-19 15:26:18 +010056
57before_script:
Roger Meier050c7562016-01-25 20:22:41 +010058 # install toolchains based on TOOLCHAIN} variable
Roger Meier050c7562016-01-25 20:22:41 +010059 - if [[ "${TOOLCHAIN}" == *avr32* ]]; then ./tools/buildman/buildman --fetch-arch avr32 ; fi
Tom Rinicd402e02016-10-20 11:08:26 -040060 - if [[ "${TOOLCHAIN}" == *bfin* ]]; then ./tools/buildman/buildman --fetch-arch bfin ; fi
Roger Meier050c7562016-01-25 20:22:41 +010061 - if [[ "${TOOLCHAIN}" == *m68k* ]]; then ./tools/buildman/buildman --fetch-arch m68k ; fi
Tom Rinicd402e02016-10-20 11:08:26 -040062 - if [[ "${TOOLCHAIN}" == *microblaze* ]]; then ./tools/buildman/buildman --fetch-arch microblaze ; fi
Roger Meier050c7562016-01-25 20:22:41 +010063 - if [[ "${TOOLCHAIN}" == *mips* ]]; then ./tools/buildman/buildman --fetch-arch mips ; fi
Tom Rinicd402e02016-10-20 11:08:26 -040064 - if [[ "${TOOLCHAIN}" == *or32* ]]; then ./tools/buildman/buildman --fetch-arch or32 ; fi
65 - if [[ "${TOOLCHAIN}" == *sh4* ]]; then ./tools/buildman/buildman --fetch-arch sh4 ; fi
Stephen Warren2ded4bf2016-10-26 11:05:33 -060066 - if [[ "${TOOLCHAIN}" == *x86_64* ]]; then
67 ./tools/buildman/buildman --fetch-arch x86_64;
68 echo -e "\n[toolchain-prefix]\nx86 = ${HOME}/.buildman-toolchains/gcc-4.9.0-nolibc/x86_64-linux/bin/x86_64-linux-" >> ~/.buildman;
69 fi
Tom Rinicd402e02016-10-20 11:08:26 -040070 - if [[ "${TOOLCHAIN}" == *xtensa* ]]; then ./tools/buildman/buildman --fetch-arch xtensa ; fi
Tom Rini3c643fb2016-12-07 11:20:40 -050071 - if [[ "${QEMU_TARGET}" != "" ]]; then
72 git clone git://git.qemu.org/qemu.git /tmp/qemu;
73 pushd /tmp/qemu;
74 git submodule update --init dtc &&
75 git checkout v2.8.0-rc3 &&
76 ./configure --prefix=/tmp/qemu-install --target-list=${QEMU_TARGET} &&
77 make -j4 all install;
78 popd;
79 fi
Meier, Rogerc7cb3342014-11-19 15:26:18 +010080
81script:
Stephen Warren8304f052016-10-26 11:05:36 -060082 # Comments must be outside the command strings below, or the Travis parser
83 # will get confused.
84 #
Tom Rini48992102016-10-20 11:05:57 -040085 # Exit code 129 means warnings only.
Roger Meier050c7562016-01-25 20:22:41 +010086 - if [[ "${BUILDMAN}" != "" ]]; then
Tom Rini48992102016-10-20 11:05:57 -040087 set +e;
Stephen Warren440d8462016-10-26 11:05:34 -060088 tools/buildman/buildman -P ${BUILDMAN};
Stephen Warren0c5145f2016-10-26 11:05:32 -060089 ret=$?;
Stephen Warrenbf1c0882016-10-26 11:05:35 -060090 if [[ $ret -ne 0 && $ret -ne 129 ]]; then
Tom Rinibaade492016-11-05 19:34:49 -040091 tools/buildman/buildman -sdeP ${BUILDMAN};
Stephen Warren0c5145f2016-10-26 11:05:32 -060092 exit $ret;
93 fi;
Roger Meier050c7562016-01-25 20:22:41 +010094 fi
Stephen Warren8304f052016-10-26 11:05:36 -060095 # "not a_test_which_does_not_exist" is a dummy -k parameter which will
96 # never prevent any test from running. That way, we can always pass
97 # "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom
98 # value.
Alexander Graffaec2902016-11-17 18:31:03 +010099 - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD};
Alexander Graf0e4e38a2016-11-18 13:18:00 +0100100 cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/;
101 cp ~/grub2-arm/usr/lib/grub2/arm-efi/grub.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi;
Alexander Graffaec2902016-11-17 18:31:03 +0100102 if [[ "${TEST_PY_BD}" != "" ]]; then
Stephen Warren8304f052016-10-26 11:05:36 -0600103 ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
104 -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
Alexander Graffaec2902016-11-17 18:31:03 +0100105 --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
Stephen Warren8304f052016-10-26 11:05:36 -0600106 fi
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100107
108matrix:
109 include:
110 # we need to build by vendor due to 50min time limit for builds
111 # each env setting here is a dedicated build
112 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400113 - BUILDMAN="arm11"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100114 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400115 - BUILDMAN="arm7"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100116 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100117 - BUILDMAN="arm920t"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100118 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400119 - JOB="arm926ejs"
120 BUILDMAN="arm926ejs -x mx,siemens,atmel"
121 - env:
122 - BUILDMAN="arm946es"
123 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100124 - BUILDMAN="atmel -x avr32"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100125 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100126 - BUILDMAN="avr32"
127 TOOLCHAIN="avr32"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100128 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100129 - BUILDMAN="denx"
Heiko Schocherd9aa0192015-03-05 09:02:23 +0100130 - env:
Tom Rinibb417f12016-11-30 14:05:08 -0500131 - JOB="Freescale ARM32"
132 BUILDMAN="freescale -x powerpc,m68k,aarch64"
133 - env:
134 - JOB="Freescale AArch64"
135 BUILDMAN="freescale -x powerpc,m68k,armv7,arm9,arm11"
Heiko Schocherd9aa0192015-03-05 09:02:23 +0100136 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400137 - JOB="i.MX (non-Freescale)"
138 BUILDMAN="mx -x freescale"
139 - env:
Tom Rinidbd5df82016-11-29 12:41:19 -0500140 - BUILDMAN="samsung"
141 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400142 - BUILDMAN="sun4i"
143 - env:
144 - BUILDMAN="sun5i"
145 - env:
146 - BUILDMAN="sun6i"
147 - env:
148 - BUILDMAN="sun7i"
149 - env:
150 - BUILDMAN="sun8i"
151 - env:
152 - BUILDMAN="sun9i"
153 - env:
154 - BUILDMAN="sun50i"
155 - env:
156 - JOB="Catch-all ARM"
Stefan Roese0bf1bc42016-12-01 13:52:08 +0100157 BUILDMAN="arm -x arm11,arm7,arm9,aarch64,atmel,denx,freescale,kirkwood,mvebu,siemens,tegra,uniphier,mx,samsung,sunxi,am33xx,omap3,omap4,omap5,pxa,rockchip"
Tom Rinibaade492016-11-05 19:34:49 -0400158 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100159 - BUILDMAN="sandbox x86"
Tom Rinicd402e02016-10-20 11:08:26 -0400160 TOOLCHAIN="x86_64"
Heiko Schocherd9aa0192015-03-05 09:02:23 +0100161 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100162 - BUILDMAN="kirkwood"
Heiko Schocherd9aa0192015-03-05 09:02:23 +0100163 - env:
Stefan Roese0bf1bc42016-12-01 13:52:08 +0100164 - BUILDMAN="mvebu"
165 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400166 - BUILDMAN="pxa"
167 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100168 - BUILDMAN="m68k"
169 TOOLCHAIN="m68k"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100170 - env:
Tom Rini76761e72016-10-20 11:23:15 -0400171 - BUILDMAN="microblaze"
172 TOOLCHAIN="microblaze"
173 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100174 - BUILDMAN="mips"
175 TOOLCHAIN="mips"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100176 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100177 - BUILDMAN="mpc512x"
Heiko Schocherd9aa0192015-03-05 09:02:23 +0100178 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100179 - BUILDMAN="mpc5xx"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100180 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100181 - BUILDMAN="mpc5xxx"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100182 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100183 - BUILDMAN="mpc8260"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100184 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100185 - BUILDMAN="mpc83xx"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100186 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100187 - BUILDMAN="mpc85xx -x freescale"
Heiko Schocherd9aa0192015-03-05 09:02:23 +0100188 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100189 - BUILDMAN="mpc85xx -x t208xrdb -x t4qds -x t102* -x p1_p2_rdb_pc -x p1010rdb -x corenet_ds -x b4860qds -x sbc8548 -x bsc91*"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100190 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100191 - BUILDMAN="t208xrdb t4qds t102*"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100192 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100193 - BUILDMAN="p1_p2_rdb_pc p1010rdb"
Heiko Schocher8cb21012015-03-17 08:21:41 +0100194 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100195 - BUILDMAN="corenet_ds b4860qds sbc8548 bsc91*"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100196 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100197 - BUILDMAN="mpc86xx"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100198 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100199 - BUILDMAN="mpc8xx"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100200 - env:
Roger Meier050c7562016-01-25 20:22:41 +0100201 - BUILDMAN="siemens"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100202 - env:
Tom Rini5eba31c2016-10-29 17:11:17 -0400203 - BUILDMAN="tegra"
Stephen Warren1fcf0ee2016-10-26 13:05:52 -0600204 - env:
Tom Rinibaade492016-11-05 19:34:49 -0400205 - JOB="am33xx"
206 BUILDMAN="am33xx -x siemens"
207 - env:
208 - BUILDMAN="omap3"
209 - env:
210 - BUILDMAN="omap4"
211 - env:
212 - BUILDMAN="omap5"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100213 - env:
Tom Rini5eba31c2016-10-29 17:11:17 -0400214 - BUILDMAN="uniphier"
215 - env:
Stefan Roese0bf1bc42016-12-01 13:52:08 +0100216 - BUILDMAN="aarch64 -x tegra,freescale,mvebu,uniphier,sunxi,samsung,rockchip"
Roger Meier050c7562016-01-25 20:22:41 +0100217 TOOLCHAIN="aarch64"
Tom Rini76761e72016-10-20 11:23:15 -0400218 - env:
Tom Rinidbd5df82016-11-29 12:41:19 -0500219 - BUILDMAN="rockchip"
220 - env:
Tom Rini76761e72016-10-20 11:23:15 -0400221 - BUILDMAN="sh4"
222 TOOLCHAIN="sh4"
223 - env:
224 - BUILDMAN="xtensa"
225 TOOLCHAIN="xtensa"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100226
227 # QA jobs for code analytics
228 # static code analysis with cppcheck (we can add --enable=all later)
Stephen Warrend7882212016-10-24 16:41:48 -0600229 - env:
230 - JOB="cppcheck"
231 script:
Tom Rinic85b52e2016-10-20 11:24:52 -0400232 - cppcheck --force --quiet --inline-suppr .
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100233 # search for TODO within source tree
Stephen Warrend7882212016-10-24 16:41:48 -0600234 - env:
235 - JOB="grep TODO"
236 script:
Tom Rinic85b52e2016-10-20 11:24:52 -0400237 - grep -r TODO .
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100238 # search for FIXME within source tree
Stephen Warrend7882212016-10-24 16:41:48 -0600239 - env:
240 - JOB="grep FIXME HACK"
241 script:
Tom Rinic85b52e2016-10-20 11:24:52 -0400242 - grep -r FIXME .
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100243 # search for HACK within source tree and ignore HACKKIT board
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100244 script:
245 - grep -r HACK . | grep -v HACKKIT
246 # some statistics about the code base
Stephen Warrend7882212016-10-24 16:41:48 -0600247 - env:
248 - JOB="sloccount"
249 script:
Tom Rinic85b52e2016-10-20 11:24:52 -0400250 - sloccount .
Stephen Warren8304f052016-10-26 11:05:36 -0600251
Stephen Warren07bf2122016-02-08 18:23:35 -0700252 # test/py
Stephen Warrend7882212016-10-24 16:41:48 -0600253 - env:
Stephen Warren8304f052016-10-26 11:05:36 -0600254 - TEST_PY_BD="sandbox"
255 BUILDMAN="^sandbox$"
256 TOOLCHAIN="x86_64"
Tom Rini5ac58612016-10-20 11:26:40 -0400257 - env:
Stephen Warren8304f052016-10-26 11:05:36 -0600258 - TEST_PY_BD="vexpress_ca15_tc2"
259 TEST_PY_ID="--id qemu"
Tom Rini3c643fb2016-12-07 11:20:40 -0500260 QEMU_TARGET="arm-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600261 BUILDMAN="^vexpress_ca15_tc2$"
Tom Rini5ac58612016-10-20 11:26:40 -0400262 - env:
Stephen Warren8304f052016-10-26 11:05:36 -0600263 - TEST_PY_BD="vexpress_ca9x4"
264 TEST_PY_ID="--id qemu"
Tom Rini3c643fb2016-12-07 11:20:40 -0500265 QEMU_TARGET="arm-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600266 BUILDMAN="^vexpress_ca9x4$"
Tom Rini5ac58612016-10-20 11:26:40 -0400267 - env:
Stephen Warren8304f052016-10-26 11:05:36 -0600268 - TEST_PY_BD="integratorcp_cm926ejs"
Alexander Graf78992842016-11-17 18:31:07 +0100269 TEST_PY_TEST_SPEC="not sleep"
Stephen Warren8304f052016-10-26 11:05:36 -0600270 TEST_PY_ID="--id qemu"
Tom Rini3c643fb2016-12-07 11:20:40 -0500271 QEMU_TARGET="arm-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600272 BUILDMAN="^integratorcp_cm926ejs$"
Tom Rini5ac58612016-10-20 11:26:40 -0400273 - env:
Stephen Warren8304f052016-10-26 11:05:36 -0600274 - TEST_PY_BD="qemu_mips"
275 TEST_PY_TEST_SPEC="not sleep"
Tom Rini3c643fb2016-12-07 11:20:40 -0500276 QEMU_TARGET="mips-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600277 BUILDMAN="^qemu_mips$"
278 TOOLCHAIN="mips"
279 - env:
280 - TEST_PY_BD="qemu_mipsel"
281 TEST_PY_TEST_SPEC="not sleep"
Tom Rini3c643fb2016-12-07 11:20:40 -0500282 QEMU_TARGET="mipsel-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600283 BUILDMAN="^qemu_mipsel$"
284 TOOLCHAIN="mips"
285 - env:
286 - TEST_PY_BD="qemu_mips64"
287 TEST_PY_TEST_SPEC="not sleep"
Tom Rini3c643fb2016-12-07 11:20:40 -0500288 QEMU_TARGET="mips64-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600289 BUILDMAN="^qemu_mips64$"
290 TOOLCHAIN="mips"
291 - env:
292 - TEST_PY_BD="qemu_mips64el"
293 TEST_PY_TEST_SPEC="not sleep"
Tom Rini3c643fb2016-12-07 11:20:40 -0500294 QEMU_TARGET="mips64el-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600295 BUILDMAN="^qemu_mips64el$"
296 TOOLCHAIN="mips"
297 - env:
298 - TEST_PY_BD="qemu-ppce500"
299 TEST_PY_TEST_SPEC="not sleep"
Tom Rini3c643fb2016-12-07 11:20:40 -0500300 QEMU_TARGET="ppc-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600301 BUILDMAN="^qemu-ppce500$"
302 - env:
303 - TEST_PY_BD="qemu-x86"
304 TEST_PY_TEST_SPEC="not sleep"
Tom Rini3c643fb2016-12-07 11:20:40 -0500305 QEMU_TARGET="i386-softmmu"
Stephen Warren8304f052016-10-26 11:05:36 -0600306 BUILDMAN="^qemu-x86$"
307 TOOLCHAIN="x86_64"
308 BUILD_ROM="yes"
Michal Simek41122d32016-12-14 09:47:23 +0100309 - env:
310 - TEST_PY_BD="zynq_zc702"
311 TEST_PY_TEST_SPEC="not sleep"
312 QEMU_TARGET="arm-softmmu"
313 TEST_PY_ID="--id qemu"
314 BUILDMAN="^zynq_zc702$"
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100315
Meier, Rogerc7cb3342014-11-19 15:26:18 +0100316# TODO make it perfect ;-r