2017-09-27 10:10:02 +02:00
|
|
|
#!/usr/bin/env python2
|
2019-06-20 23:19:40 +02:00
|
|
|
# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
|
2017-03-17 23:14:30 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
setup.py file for SWIG libfdt
|
2017-04-07 23:51:32 +02:00
|
|
|
Copyright (C) 2017 Google, Inc.
|
|
|
|
Written by Simon Glass <sjg@chromium.org>
|
2017-03-17 23:14:30 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
from distutils.core import setup, Extension
|
|
|
|
import os
|
2017-04-07 23:51:32 +02:00
|
|
|
import re
|
2017-03-17 23:14:30 +01:00
|
|
|
import sys
|
|
|
|
|
2017-04-07 23:51:32 +02:00
|
|
|
|
2018-08-10 06:25:42 +02:00
|
|
|
VERSION_PATTERN = '^#define DTC_VERSION "DTC ([^"]*)"$'
|
2017-04-07 23:51:32 +02:00
|
|
|
|
|
|
|
|
2018-08-10 06:25:42 +02:00
|
|
|
def get_version():
|
2018-08-10 09:33:24 +02:00
|
|
|
version_file = "../version_gen.h"
|
2018-08-10 06:25:42 +02:00
|
|
|
f = open(version_file, 'rt')
|
|
|
|
m = re.match(VERSION_PATTERN, f.readline())
|
|
|
|
return m.group(1)
|
2017-04-07 23:51:32 +02:00
|
|
|
|
2018-11-23 12:11:33 +01:00
|
|
|
|
2018-08-10 09:33:24 +02:00
|
|
|
setupdir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
|
|
os.chdir(setupdir)
|
2017-03-17 23:14:30 +01:00
|
|
|
|
|
|
|
libfdt_module = Extension(
|
|
|
|
'_libfdt',
|
2018-11-23 12:11:33 +01:00
|
|
|
sources=['libfdt.i'],
|
|
|
|
include_dirs=['../libfdt'],
|
|
|
|
libraries=['fdt'],
|
|
|
|
library_dirs=['../libfdt'],
|
|
|
|
swig_opts=['-I../libfdt'],
|
2017-03-17 23:14:30 +01:00
|
|
|
)
|
|
|
|
|
2017-04-05 18:01:39 +02:00
|
|
|
setup(
|
|
|
|
name='libfdt',
|
2018-11-23 12:11:33 +01:00
|
|
|
version=get_version(),
|
2017-04-05 18:01:39 +02:00
|
|
|
author='Simon Glass <sjg@chromium.org>',
|
|
|
|
description='Python binding for libfdt',
|
|
|
|
ext_modules=[libfdt_module],
|
2018-08-10 09:33:24 +02:00
|
|
|
py_modules=['libfdt'],
|
2017-04-05 18:01:39 +02:00
|
|
|
)
|