Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by default" ON)
option(CAPSTONE_DEBUG "Whether to enable extra debug assertions" OFF)
option(CAPSTONE_INSTALL "Generate install target" ${PROJECT_IS_TOP_LEVEL})
option(CAPSTONE_NO_DEPRECATION_WARNING "Disable the deprecation warning" OFF)

# Capstone v5 will soon be deprecated. Set CAPSTONE_NO_DEPRECATION_WARNING to silence the notice.
if(NOT DEFINED ENV{CAPSTONE_NO_DEPRECATION_WARNING} AND NOT CAPSTONE_NO_DEPRECATION_WARNING)
message(DEPRECATION "Capstone v5 will soon be deprecated. Please migrate to Capstone v6 Beta. You can find details about migration in our release guide.")
endif()

if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
FATAL_ERROR("BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are both unset. Nothing to build.")
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ PKGCFGF = $(BLDIR)/$(LIBNAME).pc
.PHONY: all clean install uninstall dist

all: $(LIBRARY) $(ARCHIVE) $(PKGCFGF)
ifeq (,$(findstring yes,$(CAPSTONE_NO_DEPRECATION_WARNING)))
@echo "WARNING: Capstone v5 will soon be deprecated. Please migrate to Capstone v6 Beta. You can find details about migration in our release guide."
endif
ifeq (,$(findstring yes,$(CAPSTONE_BUILD_CORE_ONLY)))
@V=$(V) CC=$(CC) $(MAKE) -C cstool
ifndef BUILDDIR
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Capstone Engine
[![pypi downloads](https://pepy.tech/badge/capstone)](https://pepy.tech/project/capstone)
[![oss-fuzz Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/capstone.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:capstone)

> [!IMPORTANT]
>
> Capstone v5 will soon be deprecated. Please migrate to Capstone v6 Beta.
> You can find details about migration in our release guide:
> https://github.com/capstone-engine/capstone/blob/next/docs/cs_v6_release_guide.md

Capstone is a disassembly framework with the target of becoming the ultimate
disasm engine for binary analysis and reversing in the security community.

Expand Down
13 changes: 13 additions & 0 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,19 @@

import inspect

import warnings

# Capstone v5 will soon be deprecated. Please migrate to Capstone v6 Beta.
# You can find details about migration in our release guide.
# Set CAPSTONE_NO_DEPRECATION_WARNING=1 to silence.
if not os.environ.get('CAPSTONE_NO_DEPRECATION_WARNING'):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some considerations: most likely you want to use same env var for C and Python and it’s ok of course, otherwise you can also avoid the introduction of this env var for Python and remove this check because the end user can disable the warning with

PYTHONWARNINGS="ignore::DeprecationWarning:capstone"

In addition from Python cli can be used the arg

-W ignore::DeprecationWarning:capstone

or from the code

warnings.filterwarnings("ignore", category=DeprecationWarning, module="capstone")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Will change it. Also add a comment there how to disable it.

warnings.warn(
"Capstone v5 will soon be deprecated. Please migrate to Capstone v6 "
"Beta. You can find details about migration in our release guide.",
DeprecationWarning,
stacklevel=2,
)

if sys.version_info >= (3, 9):
import importlib.resources as resources
else:
Expand Down
10 changes: 10 additions & 0 deletions include/capstone/capstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ extern "C" {
#define CS_API_MAJOR 5
#define CS_API_MINOR 0

// Capstone v5 will soon be deprecated. Define CAPSTONE_NO_DEPRECATION_WARNING to
// silence the compile-time notice below.
#ifndef CAPSTONE_NO_DEPRECATION_WARNING
#if defined(_MSC_VER) && !defined(__clang__)
#pragma message("Capstone v5 will soon be deprecated. Please migrate to Capstone v6 Beta. You can find details about migration in our release guide.")
#elif defined(__GNUC__) || defined(__clang__) || defined(__IBMC__)
#warning "Capstone v5 will soon be deprecated. Please migrate to Capstone v6 Beta. You can find details about migration in our release guide."
#endif
#endif

// Version for bleeding edge code of the Github's "next" branch.
// Use this if you want the absolutely latest development code.
// This version number will be bumped up whenever we have a new major change.
Expand Down
Loading