Support all OSs.
This commit is contained in:
parent
ff5b295b88
commit
29ee560688
|
@ -1,4 +1,4 @@
|
||||||
recursive-include src *
|
recursive-include capstone *
|
||||||
recursive-include prebuilt *
|
recursive-include prebuilt *
|
||||||
include LICENSE.TXT
|
include LICENSE.TXT
|
||||||
include README
|
include README
|
||||||
|
|
|
@ -34,8 +34,6 @@ if "--user" in sys.argv:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
SETUP_DATA_FILES = []
|
|
||||||
|
|
||||||
# adapted from commit e504b81 of Nguyen Tan Cong
|
# adapted from commit e504b81 of Nguyen Tan Cong
|
||||||
# Reference: https://docs.python.org/2/library/platform.html#cross-platform
|
# Reference: https://docs.python.org/2/library/platform.html#cross-platform
|
||||||
is_64bits = sys.maxsize > 2**32
|
is_64bits = sys.maxsize > 2**32
|
||||||
|
@ -54,7 +52,7 @@ def copy_sources():
|
||||||
|
|
||||||
dir_util.copy_tree("../../arch", "src/arch/")
|
dir_util.copy_tree("../../arch", "src/arch/")
|
||||||
dir_util.copy_tree("../../include", "src/include/")
|
dir_util.copy_tree("../../include", "src/include/")
|
||||||
dir_util.copy_tree("../../msvc/headers", "src/msvc/headers")
|
# dir_util.copy_tree("../../msvc/headers", "src/msvc/headers")
|
||||||
|
|
||||||
src.extend(glob.glob("../../*.[ch]"))
|
src.extend(glob.glob("../../*.[ch]"))
|
||||||
src.extend(glob.glob("../../*.mk"))
|
src.extend(glob.glob("../../*.mk"))
|
||||||
|
@ -77,7 +75,9 @@ class custom_sdist(sdist):
|
||||||
"""Reshuffle files for distribution."""
|
"""Reshuffle files for distribution."""
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
for filename in glob.glob("capstone/*.{dll,so}"):
|
for filename in (glob.glob("capstone/*.dll")
|
||||||
|
+ glob.glob("capstone/*.so")
|
||||||
|
+ glob.glob("capstone/*.dylib")):
|
||||||
try:
|
try:
|
||||||
os.unlink(filename)
|
os.unlink(filename)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -124,42 +124,41 @@ class custom_build_clib(build_clib):
|
||||||
if not os.path.exists('src'):
|
if not os.path.exists('src'):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
for (lib_name, build_info) in libraries:
|
||||||
for (lib_name, build_info) in libraries:
|
log.info("building '%s' library", lib_name)
|
||||||
log.info("building '%s' library", lib_name)
|
|
||||||
|
|
||||||
os.chdir("src")
|
os.chdir("src")
|
||||||
|
|
||||||
# platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
|
|
||||||
if SYSTEM == "win32":
|
|
||||||
# Windows build: this process requires few things:
|
|
||||||
# - CMake + MSVC installed
|
|
||||||
# - Run this command in an environment setup for MSVC
|
|
||||||
os.mkdir("build")
|
|
||||||
os.chdir("build")
|
|
||||||
# Do not build tests & static library
|
|
||||||
os.system('cmake -DCMAKE_BUILD_TYPE=RELEASE -DCAPSTONE_BUILD_TESTS=0 -DCAPSTONE_BUILD_STATIC=0 -G "NMake Makefiles" ..')
|
|
||||||
os.system("nmake")
|
|
||||||
os.chdir("..")
|
|
||||||
SETUP_DATA_FILES.append("src/build/capstone.dll")
|
|
||||||
elif SYSTEM == "cygwin":
|
|
||||||
os.chmod("make.sh", stat.S_IREAD|stat.S_IEXEC)
|
|
||||||
if is_64bits:
|
|
||||||
os.system("CAPSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw64")
|
|
||||||
else:
|
|
||||||
os.system("CAPSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw32")
|
|
||||||
SETUP_DATA_FILES.append("src/capstone.dll")
|
|
||||||
else: # Unix
|
|
||||||
os.chmod("make.sh", stat.S_IREAD|stat.S_IEXEC)
|
|
||||||
os.system("CAPSTONE_BUILD_CORE_ONLY=yes ./make.sh")
|
|
||||||
if SYSTEM == "darwin":
|
|
||||||
SETUP_DATA_FILES.append("src/libcapstone.dylib")
|
|
||||||
else: # Non-OSX
|
|
||||||
SETUP_DATA_FILES.append("src/libcapstone.so")
|
|
||||||
|
|
||||||
|
# platform description refers at https://docs.python.org/2/library/sys.html#sys.platform
|
||||||
|
if SYSTEM == "win32":
|
||||||
|
# Windows build: this process requires few things:
|
||||||
|
# - CMake + MSVC installed
|
||||||
|
# - Run this command in an environment setup for MSVC
|
||||||
|
os.mkdir("build")
|
||||||
|
os.chdir("build")
|
||||||
|
# Do not build tests & static library
|
||||||
|
os.system('cmake -DCMAKE_BUILD_TYPE=RELEASE -DCAPSTONE_BUILD_TESTS=0 -DCAPSTONE_BUILD_STATIC=0 -G "NMake Makefiles" ..')
|
||||||
|
os.system("nmake")
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
except Exception:
|
so = "src/build/capstone.dll"
|
||||||
pass
|
elif SYSTEM == "cygwin":
|
||||||
|
os.chmod("make.sh", stat.S_IREAD|stat.S_IEXEC)
|
||||||
|
if is_64bits:
|
||||||
|
os.system("CAPSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw64")
|
||||||
|
else:
|
||||||
|
os.system("CAPSTONE_BUILD_CORE_ONLY=yes ./make.sh cygwin-mingw32")
|
||||||
|
|
||||||
|
so = "src/capstone.dll"
|
||||||
|
else: # Unix
|
||||||
|
os.chmod("make.sh", stat.S_IREAD|stat.S_IEXEC)
|
||||||
|
os.system("CAPSTONE_BUILD_CORE_ONLY=yes ./make.sh")
|
||||||
|
if SYSTEM == "darwin":
|
||||||
|
so = "src/libcapstone.dylib"
|
||||||
|
else: # Non-OSX
|
||||||
|
so = "src/libcapstone.so"
|
||||||
|
|
||||||
|
os.chdir("..")
|
||||||
|
shutil.copy(so, "capstone")
|
||||||
|
|
||||||
|
|
||||||
def dummy_src():
|
def dummy_src():
|
||||||
|
@ -192,7 +191,8 @@ setup(
|
||||||
),
|
),
|
||||||
)],
|
)],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
include_package_data=True,
|
||||||
package_data={
|
package_data={
|
||||||
"capstone": ["*.dll"],
|
"capstone": ["*.so", "*.dll", "*.dylib"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue