adafruit-beaglebone-io-python/setup.py
Drew Fustini baf41fce84 Add -Wno-strict-aliasing to CFLAGS to ignore gcc warning
GitHub issue #133 was raised by @archey:
Compilation issues due to strict aliasing

These errors occured when building with gcc 6.3:
```
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -march=x86-64 -mtune=generic -O3 -pipe -fstack-protector-all --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -DBBBVERSION41 -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-x86_64-2.7/source/py_gpio.o -Wall -Werror -Wextra -Wno-missing-field-initializers
source/py_gpio.c: In function ‘py_event_detected’:
source/py_gpio.c:433:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
       Py_RETURN_TRUE;
       ^~~~~~~~~~~~~~
source/py_gpio.c:435:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
       Py_RETURN_FALSE;
       ^~~~~~~~~~~~~~~
source/py_gpio.c: In function ‘py_wait_for_edge’:
source/py_gpio.c:479:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
       Py_RETURN_FALSE;
       ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
error: command 'gcc' failed with exit status 1
```

Py_RETURN_TRUE and Py_RETURN_FALSE are part of the Python C API:
https://docs.python.org/2/c-api/bool.html
2017-02-08 03:52:41 -06:00

53 lines
2.5 KiB
Python

try:
from overlays import builder
builder.compile()
builder.copy()
except:
pass
import distribute_setup
import io
import sys
import platform
distribute_setup.use_setuptools()
from setuptools import setup, Extension, find_packages
open_as_utf8 = lambda x: io.open(x, encoding='utf-8')
kernel = platform.release()
if kernel >= '4.1.0':
kernel41 = [('BBBVERSION41', None)]
else:
kernel41 = None
CFLAGS = ['-Wall', '-Werror', '-Wextra', '-Wno-missing-field-initializers', '-Wno-strict-aliasing' ]
classifiers = ['Development Status :: 3 - Alpha',
'Operating System :: POSIX :: Linux',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Software Development',
'Topic :: Home Automation',
'Topic :: System :: Hardware']
setup(name = 'Adafruit_BBIO',
version = '1.0.2',
author = 'Justin Cooper',
author_email = 'justin@adafruit.com',
description = 'A module to control BeagleBone IO channels',
long_description = open_as_utf8('README.rst').read() + open_as_utf8('CHANGELOG.rst').read(),
license = 'MIT',
keywords = 'Adafruit BeagleBone IO GPIO PWM ADC',
url = 'https://github.com/adafruit/adafruit-beaglebone-io-python/',
classifiers = classifiers,
packages = find_packages(),
py_modules = ['Adafruit_I2C'],
ext_modules = [Extension('Adafruit_BBIO.GPIO', ['source/py_gpio.c', 'source/event_gpio.c', 'source/c_pinmux.c', 'source/constants.c', 'source/common.c'], extra_compile_args=CFLAGS, define_macros=kernel41),
Extension('Adafruit_BBIO.PWM', ['source/py_pwm.c', 'source/c_pwm.c', 'source/c_pinmux.c', 'source/constants.c', 'source/common.c'], extra_compile_args=CFLAGS, define_macros=kernel41),
Extension('Adafruit_BBIO.ADC', ['source/py_adc.c', 'source/c_adc.c', 'source/constants.c', 'source/common.c'], extra_compile_args=CFLAGS, define_macros=kernel41),
Extension('Adafruit_BBIO.SPI', ['source/spimodule.c', 'source/constants.c', 'source/common.c'], extra_compile_args=CFLAGS, define_macros=kernel41),
Extension('Adafruit_BBIO.UART', ['source/py_uart.c', 'source/c_uart.c', 'source/constants.c', 'source/common.c'], extra_compile_args=CFLAGS, define_macros=kernel41)] )