mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-14 00:37:41 -04:00
Currently setup.py depends on being invoked from the right directory (specifically it needs to be run from the root of the project). That's a bit confusing. This updates setup.py to no longer depend on the invoking directory by instead having it change directory to the location of the script itself, then using internal paths relative to that. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
43 lines
915 B
Python
Executable file
43 lines
915 B
Python
Executable file
#!/usr/bin/env python2
|
|
|
|
"""
|
|
setup.py file for SWIG libfdt
|
|
Copyright (C) 2017 Google, Inc.
|
|
Written by Simon Glass <sjg@chromium.org>
|
|
"""
|
|
|
|
from distutils.core import setup, Extension
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
|
|
VERSION_PATTERN = '^#define DTC_VERSION "DTC ([^"]*)"$'
|
|
|
|
|
|
def get_version():
|
|
version_file = "../version_gen.h"
|
|
f = open(version_file, 'rt')
|
|
m = re.match(VERSION_PATTERN, f.readline())
|
|
return m.group(1)
|
|
|
|
setupdir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
os.chdir(setupdir)
|
|
|
|
libfdt_module = Extension(
|
|
'_libfdt',
|
|
sources = ['libfdt.i'],
|
|
include_dirs = ['../libfdt'],
|
|
libraries = ['fdt'],
|
|
library_dirs = ['../libfdt'],
|
|
swig_opts = ['-I../libfdt'],
|
|
)
|
|
|
|
setup(
|
|
name='libfdt',
|
|
version= get_version(),
|
|
author='Simon Glass <sjg@chromium.org>',
|
|
description='Python binding for libfdt',
|
|
ext_modules=[libfdt_module],
|
|
py_modules=['libfdt'],
|
|
)
|