Skip to content

Commit

Permalink
Restructure tests, adjust CI script
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Oct 2, 2023
1 parent e0dd924 commit a2606e8
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 71 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ jobs:
matrix:
dotnet-version: ['6.0.x']
platform:
- {arch: 'Win32', dir: 'x32'}
- {arch: 'x64', dir: 'x64'}
- {build: 'Win32', arch: 'x32'}
- {build: 'x64', arch: 'x64'}
env:
CONFIGURATION: Release
PLATFORM: ${{ matrix.platform.arch }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v1.3
- name: Build
run: |
cmake . -B build -DCMAKE_BUILD_TYPE=Release -A ${{ matrix.platform.arch }}
cmake . -B build -DCMAKE_BUILD_TYPE=Release -A ${{ matrix.platform.build }}
cmake --build build
- name: Tests
run: |
pushd .
cd bin\${{ matrix.platform.dir }}\tests
Tests.exe
cd bin\${{ matrix.platform.arch }}\tests
Dotx64DbgTests.exe
popd
- name: Upload artifacts (CI)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dotx64Dbg-${{ runner.os }}-${{ matrix.platform.arch }}
path: bin
path: bin/
if-no-files-found: error
package:
needs: build
name: Package
runs-on: ubuntu-latest
steps:
- name: Fetch artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Display structure of downloaded files
Expand All @@ -56,22 +56,28 @@ jobs:
- name: Merge artifacts
shell: bash
run: |
mkdir package
cp -R -n ./artifacts/dotx64Dbg-Windows-x64/* ./package/
cp -R -n ./artifacts/dotx64Dbg-Windows-x86/* ./package/
rm -R ./package/x32/tests
rm -R ./package/x64/tests
mkdir -p package/x64/plugins/Dotx64Dbg
mkdir -p package/x32/plugins/Dotx64Dbg
mkdir package/dotplugins
mkdir package/dotscripts
rm -R ./artifacts/dotx64Dbg-Windows-x32/x32/tests
rm -R ./artifacts/dotx64Dbg-Windows-x64/x64/tests
cp -R -n ./artifacts/dotx64Dbg-Windows-x64/x64/* ./package/x64/plugins/Dotx64Dbg
cp -R -n ./artifacts/dotx64Dbg-Windows-x32/x32/* ./package/x32/plugins/Dotx64Dbg
cp -R -n ./artifacts/dotx64Dbg-Windows-x32/dotplugins/* ./package/dotplugins/
cp -R -n ./artifacts/dotx64Dbg-Windows-x32/dotscripts/* ./package/dotscripts/
cp -R -n ./artifacts/dotx64Dbg-Windows-x32/dotx64dbg.json ./package/dotx64dbg.json
find ./package -type f -name '*.pdb' -delete
find ./package -type f -name '*.lib' -delete
find ./package -type f -name '*.exp' -delete
find ./package -type f -name '*.ilk' -delete
- name: Upload package (CI)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dotx64dbg
path: package
if-no-files-found: error
- name: Compress artifacts
- name: Compress package
uses: papeloto/action-zip@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
Expand Down
75 changes: 40 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ project(Dotx64Dbg
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64/plugins/Dotx64Dbg)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32/plugins/Dotx64Dbg)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32)
endif()

# thirdparty
Expand Down Expand Up @@ -179,8 +179,13 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
)
endif()

target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32bridge.dll")
endif()
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:titanengine.dll")

unset(CMKR_TARGET)
Expand Down Expand Up @@ -334,57 +339,57 @@ endif()
unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64DbgManagedTests
set(CMKR_TARGET Dotx64DbgManagedTests)
set(Dotx64DbgManagedTests_SOURCES "")

list(APPEND Dotx64DbgManagedTests_SOURCES
"src/Dotx64DbgManagedTests/Testing.cs"
"src/Dotx64DbgManagedTests/Runner.cs"
"src/Dotx64DbgManagedTests/Tests/Tests.Assembler.cs"
"src/Dotx64DbgManagedTests/Tests/Tests.Decoder.cs"
"src/Dotx64DbgManagedTests/Tests/Tests.Generator.cs"
"src/Dotx64DbgManagedTests/Tests/Tests.Operands.cs"
"src/Dotx64DbgManagedTests/Tests/Tests.RegisterMaskGp.cs"
"src/Dotx64DbgManagedTests/Tests/Tests.Registers.cs"
# Target Dotx64DbgTests
set(CMKR_TARGET Dotx64DbgTests)
set(Dotx64DbgTests_SOURCES "")

list(APPEND Dotx64DbgTests_SOURCES
"src/Dotx64DbgTests/Testing.cs"
"src/Dotx64DbgTests/Runner.cs"
"src/Dotx64DbgTests/Tests/Tests.Assembler.cs"
"src/Dotx64DbgTests/Tests/Tests.Decoder.cs"
"src/Dotx64DbgTests/Tests/Tests.Generator.cs"
"src/Dotx64DbgTests/Tests/Tests.Operands.cs"
"src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs"
"src/Dotx64DbgTests/Tests/Tests.Registers.cs"
)

list(APPEND Dotx64DbgManagedTests_SOURCES
list(APPEND Dotx64DbgTests_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64DbgManagedTests_SOURCES})
add_executable(Dotx64DbgManagedTests)
set(CMKR_SOURCES ${Dotx64DbgTests_SOURCES})
add_executable(Dotx64DbgTests)

if(Dotx64DbgManagedTests_SOURCES)
target_sources(Dotx64DbgManagedTests PRIVATE ${Dotx64DbgManagedTests_SOURCES})
if(Dotx64DbgTests_SOURCES)
target_sources(Dotx64DbgTests PRIVATE ${Dotx64DbgTests_SOURCES})
endif()

get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgManagedTests)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgTests)
endif()

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgManagedTests_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgTests_SOURCES})

if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
target_compile_definitions(Dotx64DbgManagedTests PRIVATE
target_compile_definitions(Dotx64DbgTests PRIVATE
_X86_
)
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
target_compile_definitions(Dotx64DbgManagedTests PRIVATE
target_compile_definitions(Dotx64DbgTests PRIVATE
_X64_
)
endif()

target_link_libraries(Dotx64DbgManagedTests PRIVATE
target_link_libraries(Dotx64DbgTests PRIVATE
dotx64dbg::managed
dotx64dbg::bindings
)

set_target_properties(Dotx64DbgManagedTests PROPERTIES
set_target_properties(Dotx64DbgTests PROPERTIES
RUNTIME_OUTPUT_NAME
Dotx64DbgTests
DOTNET_SDK
Expand All @@ -406,28 +411,28 @@ set_target_properties(Dotx64DbgManagedTests PROPERTIES
VS_GLOBAL_SatelliteResourceLanguages
neutral
VS_DOTNET_REFERENCES_COPY_LOCAL
false
true
)

if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
set_target_properties(Dotx64DbgManagedTests PROPERTIES
set_target_properties(Dotx64DbgTests PROPERTIES
VS_GLOBAL_PlatformTarget
x86
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
"${BUILD_OUTPUT_DIR}/tests"
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
"${BUILD_OUTPUT_DIR}/tests"
)
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
set_target_properties(Dotx64DbgManagedTests PROPERTIES
set_target_properties(Dotx64DbgTests PROPERTIES
VS_GLOBAL_PlatformTarget
x64
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
"${BUILD_OUTPUT_DIR}/tests"
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
"${BUILD_OUTPUT_DIR}/tests"
)
endif()

Expand Down
Empty file removed bin/x32/plugins/.empty
Empty file.
Empty file removed bin/x64/plugins/.empty
Empty file.
43 changes: 24 additions & 19 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ cmake-after = '''
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64/plugins/Dotx64Dbg)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32/plugins/Dotx64Dbg)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32)
endif()
'''

Expand Down Expand Up @@ -79,8 +79,13 @@ private-link-libraries = [
"Zydis",
]
cmake-after = '''
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32bridge.dll")
endif()
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:titanengine.dll")
'''

Expand Down Expand Up @@ -185,17 +190,17 @@ x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}"
x32.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}"
x32.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}"

[target.Dotx64DbgManagedTests]
[target.Dotx64DbgTests]
type = "executable"
sources = [
"src/Dotx64DbgManagedTests/Testing.cs",
"src/Dotx64DbgManagedTests/Runner.cs",
"src/Dotx64DbgManagedTests/Tests/Tests.Assembler.cs",
"src/Dotx64DbgManagedTests/Tests/Tests.Decoder.cs",
"src/Dotx64DbgManagedTests/Tests/Tests.Generator.cs",
"src/Dotx64DbgManagedTests/Tests/Tests.Operands.cs",
"src/Dotx64DbgManagedTests/Tests/Tests.RegisterMaskGp.cs",
"src/Dotx64DbgManagedTests/Tests/Tests.Registers.cs",
"src/Dotx64DbgTests/Testing.cs",
"src/Dotx64DbgTests/Runner.cs",
"src/Dotx64DbgTests/Tests/Tests.Assembler.cs",
"src/Dotx64DbgTests/Tests/Tests.Decoder.cs",
"src/Dotx64DbgTests/Tests/Tests.Generator.cs",
"src/Dotx64DbgTests/Tests/Tests.Operands.cs",
"src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs",
"src/Dotx64DbgTests/Tests/Tests.Registers.cs",
]
private-link-libraries = [
"dotx64dbg::managed",
Expand All @@ -204,7 +209,7 @@ private-link-libraries = [
x32.private-compile-definitions = ["_X86_"]
x64.private-compile-definitions = ["_X64_"]

[target.Dotx64DbgManagedTests.properties]
[target.Dotx64DbgTests.properties]
RUNTIME_OUTPUT_NAME = "Dotx64DbgTests"
x32.VS_GLOBAL_PlatformTarget = "x86"
x64.VS_GLOBAL_PlatformTarget = "x64"
Expand All @@ -217,11 +222,11 @@ VS_GLOBAL_ProduceReferenceAssembly = "false"
VS_GLOBAL_ProduceReferenceAssemblyInOutDir = "false"
VS_GLOBAL_CopyLocalLockFileAssemblies = "true"
VS_GLOBAL_SatelliteResourceLanguages = "neutral"
VS_DOTNET_REFERENCES_COPY_LOCAL = "false"
x64.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}"
x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}"
x32.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}"
x32.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}"
VS_DOTNET_REFERENCES_COPY_LOCAL = "true"
x64.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}/tests"
x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}/tests"
x32.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}/tests"
x32.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}/tests"

### Dotx64Dbg
[target.Dotx64Dbg]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a2606e8

Please sign in to comment.