add --do-not-build-core to setup.py to prevent it install core library
This commit is contained in:
parent
8b839a2af4
commit
60dcfa0948
|
@ -13,18 +13,39 @@ from distutils.command.sdist import sdist
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
from distutils.sysconfig import get_python_lib
|
from distutils.sysconfig import get_python_lib
|
||||||
|
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
# platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
|
# platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
|
||||||
VERSION = '3.0'
|
VERSION = '3.0'
|
||||||
SYSTEM = platform.system().lower()
|
SYSTEM = platform.system().lower()
|
||||||
|
|
||||||
|
FLAG_DONT_BUILD_CORE = "--do-not-build-core"
|
||||||
|
# parse parameters to detect if FLAG_DONT_BUILD_CORE exists
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option(
|
||||||
|
"",
|
||||||
|
FLAG_DONT_BUILD_CORE,
|
||||||
|
action="store_true",
|
||||||
|
dest="do_not_build_core",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
(option, _) = parser.parse_args()
|
||||||
|
|
||||||
|
# remove FLAG_DONT_BUILD_CORE to prevent it pass to distutils setup parameters
|
||||||
|
if FLAG_DONT_BUILD_CORE in sys.argv:
|
||||||
|
sys.argv.remove(FLAG_DONT_BUILD_CORE)
|
||||||
|
|
||||||
|
|
||||||
SITE_PACKAGES = os.path.join(get_python_lib(), "capstone")
|
SITE_PACKAGES = os.path.join(get_python_lib(), "capstone")
|
||||||
|
|
||||||
SETUP_DATA_FILES = []
|
SETUP_DATA_FILES = []
|
||||||
|
|
||||||
if SYSTEM == "darwin":
|
if not option.do_not_build_core:
|
||||||
SETUP_DATA_FILES.append("src/libcapstone.dylib")
|
if SYSTEM == "darwin":
|
||||||
elif SYSTEM != "win32":
|
SETUP_DATA_FILES.append("src/libcapstone.dylib")
|
||||||
SETUP_DATA_FILES.append("src/libcapstone.so")
|
elif SYSTEM != "win32":
|
||||||
|
SETUP_DATA_FILES.append("src/libcapstone.so")
|
||||||
|
|
||||||
class LazyList(list):
|
class LazyList(list):
|
||||||
"""A list which re-evaluates each time.
|
"""A list which re-evaluates each time.
|
||||||
|
@ -105,6 +126,9 @@ class custom_build_clib(build_clib):
|
||||||
build_clib.finalize_options(self)
|
build_clib.finalize_options(self)
|
||||||
|
|
||||||
def build_libraries(self, libraries):
|
def build_libraries(self, libraries):
|
||||||
|
if option.do_not_build_core:
|
||||||
|
return
|
||||||
|
|
||||||
for (lib_name, build_info) in libraries:
|
for (lib_name, build_info) in libraries:
|
||||||
sources = self.get_source_files()
|
sources = self.get_source_files()
|
||||||
sources = list(sources)
|
sources = list(sources)
|
||||||
|
|
Loading…
Reference in New Issue