Skip to content

Commit

Permalink
Remove designated array initializers in rz_analysis.h (#3876)
Browse files Browse the repository at this point in the history
* Do not use designater array initializer because MSVC complains
* Add new Appveyor CI test for including C headers from C++ files

    * Need to test whether Rizin headers can be included in C++ when
      using MSVC, needed for Cutter to build successfully
    * Changed the name of `build-cpp` CI job in GitHUb jobs to
      `build-cpp-linux` to make it obvious that it only performs the
      test for Linux
  • Loading branch information
DMaroo authored Sep 25, 2023
1 parent 833c59c commit 714c338
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
32 changes: 27 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,31 @@ environment:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
BUILD_DIR: build
RUN_TESTS: false
TEST_INCLUDE_HEADERS_CPP: false
# VS2022 64
- builder: vs2022_64
PYTHON: 'C:\\Python38-x64'
INNO_SETUP: 'C:\\Program Files (x86)\\Inno Setup 6'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
BUILD_DIR: build
RUN_TESTS: true
TEST_INCLUDE_HEADERS_CPP: true
# VS2017 64 (Dynamic linking)
- builder: vs2017_64_dyn
PYTHON: 'C:\\Python37'
INNO_SETUP: 'C:\\Program Files (x86)\\Inno Setup 5'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
BUILD_DIR: build
RUN_TESTS: false
TEST_INCLUDE_HEADERS_CPP: false
# Clang-cl 64 (Dynamic linking)
- builder: clang_cl_64_dyn
PYTHON: 'C:\\Python38'
INNO_SETUP: 'C:\\Program Files (x86)\\Inno Setup 6'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
BUILD_DIR: build
RUN_TESTS: true
TEST_INCLUDE_HEADERS_CPP: false

only_commits:
files:
Expand Down Expand Up @@ -79,12 +83,11 @@ build_script:

- cmd: if %builder% == clang_cl_64_dyn ( set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH2019%" x64 && set CC=clang-cl && %PYTHON%\Scripts\meson setup --buildtype=release --prefix="%CD%\%DIST_FOLDER%" build && %PYTHON%\Scripts\ninja -C build install && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )

# Run tests only conditionally
for:
-
matrix:
only:
- RUN_TESTS: true
# Run tests only conditionally
- matrix:
only:
- RUN_TESTS: true

test_script:
- if %builder% == vs2017_64 ( call "%VSVARSALLPATH2017%" x64 )
Expand All @@ -105,6 +108,25 @@ for:
- rz-test -o results.json -L db
- cd ..

# Include header files from C++
- matrix:
only:
- TEST_INCLUDE_HEADERS_CPP: true

test_script:
- if %builder% == vs2017_64 ( call "%VSVARSALLPATH2017%" x64 )
- if %builder% == vs2022_64 ( call "%VSVARSALLPATH2022%" x64 )
- if %builder% == vs2017_64_dyn ( call "%VSVARSALLPATH2017%" x64 )
- if %builder% == clang_cl_64_dyn ( call "%VSVARSALLPATH2019%" x64 )
- set PATH=%APPVEYOR_BUILD_FOLDER%\%DIST_FOLDER%\bin;C:\Python38-x64;C:\msys64\mingw64\bin;%PATH%
- echo %PATH%
- where rizin
- rizin -v
- copy C:\Python38-x64\python.exe C:\Python38-x64\python3.exe
- "%PYTHON%\\Scripts\\meson setup build-cpp-test ./test/unit/cpp"
- "%PYTHON%\\Scripts\\meson compile -C build-cpp-test"
- "%PYTHON%\\Scripts\\meson test -C build-cpp-test --print-errorlogs"

# Artifacts
artifacts:
# Binaries
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ jobs:
name: rizin-android-${{ matrix.name }}
path: /tmp/rizin-android-${{ matrix.name }}.tar.gz

build-cpp:
name: Include Rizin headers from C++ program
build-cpp-linux:
name: Include Rizin headers from C++ program (Linux)
runs-on: ubuntu-22.04
if: contains(github.head_ref, 'dist') || contains(github.head_ref, 'cpp') || ((contains(github.ref, 'release-') || github.ref == 'refs/heads/stable') && github.event_name == 'push') || github.event_name == 'schedule'
needs: [build-and-test]
Expand Down
18 changes: 11 additions & 7 deletions librz/include/rz_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,8 @@ typedef enum rz_analysis_var_kind_t {
RZ_ANALYSIS_VAR_KIND_INVALID = 0, ///< Invalid or unspecified variable
RZ_ANALYSIS_VAR_KIND_FORMAL_PARAMETER, ///< Variable is function formal parameter
RZ_ANALYSIS_VAR_KIND_VARIABLE, ///< Variable is local variable
/* End enum */
RZ_ANALYSIS_VAR_KIND_END ///< Number of RzAnalysisVarKind enums
} RzAnalysisVarKind;

typedef struct dwarf_variable_t {
Expand All @@ -728,17 +730,19 @@ typedef struct dwarf_variable_t {
typedef enum {
RZ_ANALYSIS_VAR_ORIGIN_NONE = 0, ///< Variable was created from rizin
RZ_ANALYSIS_VAR_ORIGIN_DWARF, ///< Variable was created from DWARF information
/* End enum */
RZ_ANALYSIS_VAR_ORIGIN_END ///< Number of RzAnalysisVarOriginKind enums
} RzAnalysisVarOriginKind;

static const char *RzAnalysisVarKind_strings[] = {
[RZ_ANALYSIS_VAR_KIND_INVALID] = "invalid",
[RZ_ANALYSIS_VAR_KIND_FORMAL_PARAMETER] = "formal_parameter",
[RZ_ANALYSIS_VAR_KIND_VARIABLE] = "variable",
static const char *RzAnalysisVarKind_strings[RZ_ANALYSIS_VAR_KIND_END] = {
"invalid", /* RZ_ANALYSIS_VAR_KIND_INVALID */
"formal_parameter", /* RZ_ANALYSIS_VAR_KIND_FORMAL_PARAMETER */
"variable", /* RZ_ANALYSIS_VAR_KIND_VARIABLE */
};

static const char *RzAnalysisVarOriginKind_strings[] = {
[RZ_ANALYSIS_VAR_ORIGIN_NONE] = "none",
[RZ_ANALYSIS_VAR_ORIGIN_DWARF] = "DWARF",
static const char *RzAnalysisVarOriginKind_strings[RZ_ANALYSIS_VAR_ORIGIN_END] = {
"none", /* RZ_ANALYSIS_VAR_ORIGIN_NONE */
"DWARF", /* RZ_ANALYSIS_VAR_ORIGIN_DWARF */
};

#define RZ_ANALYSIS_AS_STRING_IMPL(T, name, strings) \
Expand Down

0 comments on commit 714c338

Please sign in to comment.