Compare commits

..

36 Commits

Author SHA1 Message Date
WerWolv
0cf2477988 build: Bumped version to 1.33.1 2024-03-02 16:44:54 +01:00
WerWolv
cc3a5aed9a patterns: Updated pattern language 2024-03-02 15:59:59 +01:00
WerWolv
af10317bae impr: Added testers to About screen 2024-03-02 15:59:38 +01:00
WerWolv
5153ad6458 build: Allow precompiled headers to be turned off 2024-03-02 15:59:33 +01:00
WerWolv
432f2f0862 build: Added option to disable precompiled headers 2024-03-02 15:59:11 +01:00
WerWolv
7eb3ee7150 build: Disable precompiled headers in plugins again 2024-03-02 15:58:57 +01:00
WerWolv
6cf2990808 fix: Race condition when downloading multiple elements from the content store 2024-03-02 15:58:53 +01:00
WerWolv
6cb0d4d7d8 fix: MIME based auto loading not working correctly 2024-03-02 15:58:45 +01:00
WerWolv
0d08b36a73 impr: Prevent ImHex from getting stuck in an infinite crash loop 2024-03-02 15:58:26 +01:00
WerWolv
7efdaa73f1 fix: Platform window not being updated when recovering from a crash 2024-03-02 15:58:11 +01:00
WerWolv
6d548180bb fix: Endless loop when throwing exception in deferred tasks 2024-03-02 15:58:02 +01:00
WerWolv
4b64e044f7 fix: Compile error 2024-03-02 15:57:51 +01:00
WerWolv
4a118b94cc impr: Better recovery from exceptions thrown in main thread (#1577)
This PR improves many things which can be seen by the commit name, but
the most important thing is the addition of a popup telling the user
when an exception is thrown

![image](https://github.com/WerWolv/ImHex/assets/42669835/db796416-9cce-4aa5-ad60-c22f05b5fc73)
2024-03-02 15:57:30 +01:00
WerWolv
8e27eb8d36 build: Updated libwolv 2024-02-29 23:06:49 +01:00
WerWolv
b33453f03c git: Run workflows on release branches 2024-02-29 22:28:58 +01:00
WerWolv
7cf88d128b patterns: Updated pattern language 2024-02-29 22:24:01 +01:00
WerWolv
5b7c4324ff build: Disable unknown pragmas warning 2024-02-29 22:18:31 +01:00
WerWolv
aaf9fdf61c fix: Build with precompiled headers for WebAssembly 2024-02-29 22:18:22 +01:00
WerWolv
6e36586ebc fix: Build with precompiled headers on Linux 2024-02-29 22:18:14 +01:00
WerWolv
773f9d3f1c build: Don't add defines to libimhex after precompiling headers 2024-02-29 22:18:09 +01:00
WerWolv
b448583105 build: Added precompiled headers 2024-02-29 22:17:57 +01:00
WerWolv
d1de10c606 fix: Pressing buttons while window is unfocused not working 2024-02-29 22:17:22 +01:00
WerWolv
9ce3a9e612 fix: Inserting bytes and resizing files not working correctly 2024-02-29 22:17:15 +01:00
WerWolv
99eaca4d09 fix: MIME-based pattern loading not working correctly
Fixes #1574
2024-02-29 22:17:03 +01:00
WerWolv
29443af90f fix: Buggy window detachment 2024-02-29 22:16:57 +01:00
WerWolv
d1fb41783d fix: Make sure glfw waits properly on Wayland 2024-02-29 22:16:49 +01:00
WerWolv
99277d71cc fix: Frame limiting not working correctly on Linux 2024-02-28 18:48:24 +01:00
WerWolv
db11c4c791 fix: Crash when using CRC hashes 2024-02-27 22:39:28 +01:00
WerWolv
87c254a437 fix: Read-only file toast showing up for all providers 2024-02-27 20:20:56 +01:00
WerWolv
63a4d65d96 fix: Import menu being disabled with read-only providers
Fixes #1573
2024-02-27 19:42:03 +01:00
WerWolv
cf1868b0b3 impr: Implement a better algorithm to determine if the frame content has changed 2024-02-27 18:59:06 +01:00
WerWolv
a135381b80 fix: Yara rules not being read correctly in data information section 2024-02-27 18:59:01 +01:00
WerWolv
c424e71f7e impr: Add better error handling when loading projects 2024-02-27 18:58:50 +01:00
WerWolv
976baec753 fix: Opening project files through the command line opening them as regular files 2024-02-27 18:58:31 +01:00
WerWolv
25cfa6f10b patterns: Updated pattern language 2024-02-27 18:57:02 +01:00
WerWolv
265213bbac impr: Make hex editor minimap rows stay a fixed height 2024-02-27 18:56:53 +01:00
1113 changed files with 47232 additions and 199953 deletions

View File

@@ -1,97 +1,69 @@
# All rules should have a comment associated # Generated from CLion Inspection settings
# Directives that do not have any effect (e.g. disabling a rule that is not enabled) can be done to add an explanation comment. ---
# Or at least an empty comment # to show they were put here explicitely, Checks: '-*,
# and not as part of the historical CLion-generated rules mpi-*,
# Note: `- -X` means disable X bugprone-*,
# CLI usage: go to the build directory and run: `run-clang-tidy -allow-no-checks -source-filter ".*/lib/.*" -fix -j` -bugprone-signal-handler,
-bugprone-narrowing-conversions,
Checks: -bugprone-redundant-branch-condition,
- -* -bugprone-exception-escape,
- mpi-* -bugprone-shared-ptr-array-mismatch,
- bugprone-* -bugprone-implicit-widening-of-multiplication-result,
- -bugprone-signal-handler -bugprone-signed-char-misuse,
- -bugprone-narrowing-conversions -bugprone-unhandled-exception-at-new,
- -bugprone-redundant-branch-condition -bugprone-infinite-loop,
- -bugprone-exception-escape -bugprone-easily-swappable-parameters,
- -bugprone-shared-ptr-array-mismatch cert-err52-cpp,
- -bugprone-implicit-widening-of-multiplication-result cert-err60-cpp,
- -bugprone-signed-char-misuse cert-err34-c,
- -bugprone-unhandled-exception-at-new cert-str34-c,
- -bugprone-infinite-loop cert-dcl21-cpp,
- -bugprone-easily-swappable-parameters cert-msc50-cpp,
- -bugprone-float-loop-counter # cert-msc51-cpp,
- -bugprone-unchecked-string-to-number-conversion # Unfortunately no alternative cert-dcl58-cpp,
- -bugprone-branch-clone # Mostly warns about one-line duplicates cert-flp30-c,
- cert-err52-cpp cppcoreguidelines-avoid-const-or-ref-data-members,
- cert-err60-cpp cppcoreguidelines-pro-type-member-init,
- cert-str34-c cppcoreguidelines-slicing,
- cert-dcl21-cpp cppcoreguidelines-interfaces-global-init,
- cert-msc50-cpp cppcoreguidelines-pro-type-static-cast-downcast,
- cert-msc51-cpp cppcoreguidelines-narrowing-conversions,
- cert-dcl58-cpp google-default-arguments,
- cppcoreguidelines-avoid-const-or-ref-data-members google-runtime-operator,
- cppcoreguidelines-pro-type-member-init # We want to use default member initializers google-explicit-constructor,
- cppcoreguidelines-slicing hicpp-multiway-paths-covered,
- cppcoreguidelines-interfaces-global-init hicpp-exception-baseclass,
- -cppcoreguidelines-pro-type-static-cast-downcast # dynamic_cast has a runtime overhead misc-*,
- -cppcoreguidelines-narrowing-conversions # -misc-definitions-in-headers,
- google-runtime-operator -misc-unused-parameters,
- google-explicit-constructor -misc-unused-alias-decls,
- -google-default-arguments # Provider and ViewProvider read() is a good example of why this is useful -misc-use-anonymous-namespace,
- hicpp-multiway-paths-covered -misc-misleading-identifier,
- hicpp-exception-baseclass -misc-confusable-identifiers,
- misc-* -misc-misleading-bidirectional,
- -misc-definitions-in-headers -misc-static-assert,
- -misc-unused-parameters -misc-no-recursion,
- -misc-unused-alias-decls -misc-const-correctness,
- -misc-use-anonymous-namespace modernize-*,
- -misc-misleading-identifier -modernize-use-trailing-return-type,
- -misc-confusable-identifiers openmp-use-default-none,
- -misc-misleading-bidirectional performance-*,
- -misc-static-assert -performance-no-int-to-ptr,
- -misc-no-recursion portability-*,
- -misc-const-correctness -portability-restrict-system-includes,
- -misc-use-internal-linkage # False positives if header where function is defined is not included readability-*,
- -misc-include-cleaner # Allow indirect includes -readability-redundant-preprocessor,
- -misc-non-private-member-variables-in-classes # -readability-named-parameter,
- modernize-* -readability-function-size,
- -modernize-use-trailing-return-type -readability-use-anyofallof,
- -modernize-use-std-print # We want to use fmt::print instead -readability-identifier-length,
- -modernize-use-integer-sign-comparison # Too much occurrences to change -readability-magic-numbers,
- openmp-use-default-none -readability-braces-around-statements,
- performance-* -readability-suspicious-call-argument,
- -performance-no-int-to-ptr -readability-isolate-declaration,
- portability-* -readability-else-after-return,
- -portability-restrict-system-includes -readability-redundant-access-specifiers,
- readability-* -readability-function-cognitive-complexity,
- -readability-redundant-preprocessor -readability-identifier-naming,
- -readability-named-parameter *-include-cleaner,
- -readability-function-size -readability-qualified-auto'
- -readability-use-anyofallof
- -readability-identifier-length
- -readability-magic-numbers
- -readability-braces-around-statements
- -readability-suspicious-call-argument
- -readability-isolate-declaration
- -readability-else-after-return
- -readability-redundant-access-specifiers
- -readability-function-cognitive-complexity
- -readability-identifier-naming
- -readability-qualified-auto
- -readability-use-std-min-max # Less readable imo
- -readability-math-missing-parentheses # Basic math
- -readability-implicit-bool-conversion # Not much of a problem ?
- -readability-convert-member-functions-to-static #
- -readability-use-concise-preprocessor-directives # We do not use #ifdef
- -readability-uppercase-literal-suffix # Not important enough
- -readability-redundant-string-cstr # Sometimes used to stop at first null byte
- -readability-static-accessed-through-instance #
- -readability-ambiguous-smartptr-reset-call # Fix is hard to read
# Will fix later
- -modernize-avoid-c-arrays
- -readability-make-member-function-const # idk + lots of occurences
- -readability-misleading-indentation # We need to handle cases with #if defined()
- -bugprone-unchecked-optional-access
- -performance-unnecessary-value-param # idk
- -readability-avoid-nested-conditional-operator

View File

@@ -7,7 +7,6 @@ skip -rfu ^ImGui::
# Trigger breakpoint when execution reaches triggerSafeShutdown() # Trigger breakpoint when execution reaches triggerSafeShutdown()
break triggerSafeShutdown break triggerSafeShutdown
break __glibcxx_assert_fail
# Print backtrace after execution jumped to an invalid address # Print backtrace after execution jumped to an invalid address
define fixbt define fixbt

4
.github/FUNDING.yml vendored
View File

@@ -1,5 +1,5 @@
# Sponsor links # Sponsor links
patreon: werwolv
custom: https://werwolv.net/donate
github: WerWolv github: WerWolv
ko_fi: WerWolv
custom: "https://werwolv.net/donate"

5
.github/codecov.yml vendored
View File

@@ -1,5 +0,0 @@
comment: false
ignore:
- "lib/third_party" # Third party libraries should be ignored
- "lib/external" # Our own libraries should be checked in their own repositories
- "tests" # https://about.codecov.io/blog/should-i-include-test-files-in-code-coverage-calculations/

View File

@@ -1,7 +0,0 @@
#!/bin/sh
set -xe
ARTIFACT_NAME="$1"
ARTIFACT_ID=$(gh api repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts --jq ".artifacts[] | select(.name==\"$ARTIFACT_NAME\") | .id")
gh api -X DELETE repos/$GITHUB_REPOSITORY/actions/artifacts/$ARTIFACT_ID
echo "Deleted artifact $ARTIFACT_NAME with ID $ARTIFACT_ID"

View File

@@ -8,7 +8,7 @@ on:
jobs: jobs:
codeql: codeql:
name: 🐛 CodeQL name: 🐛 CodeQL
runs-on: ubuntu-24.04 runs-on: ubuntu-22.04
permissions: permissions:
actions: read actions: read
contents: read contents: read
@@ -49,18 +49,16 @@ jobs:
set -x set -x
mkdir -p build mkdir -p build
cd build cd build
CC=gcc-14 CXX=g++-14 cmake \ CC=gcc-12 CXX=g++-12 cmake \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \ -DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fuse-ld=lld" \ -DCMAKE_C_FLAGS="-fuse-ld=lld" \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \ -DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DIMHEX_PATTERNS_PULL_MASTER=ON \ -DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_EXCLUDE_PLUGINS="script_loader" \
-G Ninja \
.. ..
ninja install make -j 4 install
- name: 🗯️ Perform CodeQL Analysis - name: 🗯️ Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v2

File diff suppressed because it is too large Load Diff

79
.github/workflows/build_web.yml vendored Normal file
View File

@@ -0,0 +1,79 @@
name: Build for the web
on:
push:
branches:
- 'master'
- 'releases/**'
pull_request:
workflow_dispatch:
env:
BUILD_TYPE: Release
permissions:
pages: write
id-token: write
actions: write
jobs:
build:
runs-on: ubuntu-22.04
name: 🌍 WebAssembly
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: 📁 Restore docker /cache
uses: actions/cache@v4
with:
path: cache
key: web-cmakecache-${{ hashFiles('**/CMakeLists.txt') }}
- name: 🐳 Inject /cache into docker
uses: reproducible-containers/buildkit-cache-dance@v2
with:
cache-source: cache
cache-target: /cache
- name: 🛠️ Build using docker
run: |
docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out --target raw
- name: 🔨 Fix permissions
run: |
chmod -c -R +rX "out/"
- name: ⬆️ Upload artifacts
uses: actions/upload-pages-artifact@v2
with:
path: out/
# See https://github.com/actions/cache/issues/342#issuecomment-1711054115
- name: 🗑️ Delete old cache
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "build-web-cache" --confirm
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
name: 📃 Deploy to GitHub Pages
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' && github.event.repository.fork == false }}
needs: build
steps:
- name: 🌍 Deploy
id: deployment
uses: actions/deploy-pages@v2

View File

@@ -1,47 +0,0 @@
# https://gist.github.com/iTrooz/d5bacca32c0974edc6c1ac3ad3ee82f3
# See https://github.com/cli/cli/issues/9125
# Extract archive with `tar -xf cache.tzst --transform 's@\.\./@#@g' -P` to avoid ../ errors
name: Download cache key
on:
workflow_dispatch:
inputs:
cache_key:
description: 'Cache key'
required: true
type: string
jobs:
cache-download:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Query cache version
id: version
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(gh api repos/$GITHUB_REPOSITORY/actions/caches \
--jq "
.actions_caches[]
| select(.ref == \"refs/heads/$GITHUB_REF_NAME\")
| select(.key == \"${{ github.event.inputs.cache_key }}\")
| .version
")
echo "version=$VERSION" | tee $GITHUB_OUTPUT
- name: Restore cache
uses: iTrooz/cache/restore@restore_with_version
with:
# Path won't be actually used, we will match by 'version'.
path: .
key: ${{ github.event.inputs.cache_key }}
version: ${{ steps.version.outputs.version }}
- name: Upload cached folder as artifact
uses: actions/upload-artifact@v4
with:
name: cache-artifact
path: |
/home/runner/work/**/*.tzst

View File

@@ -1,144 +0,0 @@
permissions:
contents: write
name: Nightly Release
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
nightly-release:
runs-on: ubuntu-24.04
name: 🌃 Update Nightly Release
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
path: ImHex
fetch-depth: 0
fetch-tags: true
- name: 🌃 Check for new commits
id: check_commits
run: |
cd ImHex
git config --global --add safe.directory $(pwd)
if [ -z "$(git log nightly..HEAD --oneline)" ]; then
echo "No new commits since last nightly. Exiting."
echo "::set-output name=should_run::false"
else
echo "::set-output name=should_run::true"
fi
- name: 📜 Set version variable
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
project_version=`cat ImHex/VERSION`
echo "IMHEX_VERSION=$project_version" >> $GITHUB_ENV
# TODO: Replace by Github CLI when github.com/cli/cli/pull/12435 is closed
- name: ⬇️ Download artifacts from latest workflow
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build.yml
branch: master
workflow_conclusion: success
skip_unpack: true
- name: 🗜️ Unzip files when needed
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
set -x
for zipfile in ./*.zip
do
if [ `zipinfo -1 "$zipfile" | wc -l` -eq 1 ];
then
echo "unzipping $zipfile"
unzip "$zipfile"
rm "$zipfile"
else
echo "keeping $zipfile zipped"
fi
done
- name: 🟩 Rename artifacts when needed
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
mv "Windows Portable x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-x86_64.zip
mv "Windows Portable arm64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-arm64.zip
mv "Windows Portable NoGPU x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-NoGPU-x86_64.zip
mv "ImHex Web.zip" imhex-${{ env.IMHEX_VERSION }}-Web.zip
rm artifact.tar || true
- name: 📖 Generate Release Notes
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
id: release_notes
continue-on-error: true
run: |
cd ImHex
echo "## Nightly ${GITHUB_SHA::7} Changelog" > changelog.md
git fetch --tags --recurse-submodules=no
git log nightly..origin/master --oneline --no-merges --pretty=format:'* %s' >> changelog.md
- name: 📦 Update Pre-Release
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
run: |
set -e
cd ImHex
# Move nightly tag to latest commit
git tag -f nightly origin/master
git push origin nightly --force
# Auth for GitHub CLI
echo "${{ github.token }}" | gh auth login --with-token
# Delete existing assets
for asset in $(gh release view nightly --json assets --jq '.assets[].name'); do
gh release delete-asset nightly "$asset" --yes
done
# Update release notes
gh release edit nightly --notes-file changelog.md
# Upload new assets
gh release upload nightly ../*.* --clobber
- name: ⬆️ Publish x86_64 Snap package
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ env.IMHEX_VERSION }}-x86_64.snap
release: edge
- name: ⬆️ Publish arm64 Snap package
if: ${{ steps.check_commits.outputs.should_run == 'true' }}
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ env.IMHEX_VERSION }}-arm64.snap
release: edge
website_update:
name: 🌍 Update ImHex Landing Website
needs: nightly-release
runs-on: ubuntu-24.04
env:
WEBSITE_DISPATCH_TOKEN: ${{ secrets.WEBSITE_DISPATCH_TOKEN }}
steps:
- name: ✉️ Dispatch Landing page update
if: ${{ env.WEBSITE_DISPATCH_TOKEN != '' }}
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.WEBSITE_DISPATCH_TOKEN }}
repository: WerWolv/ImHexWebsite
event-type: update_page

View File

@@ -7,16 +7,10 @@ on:
release: release:
types: [published] types: [published]
workflow_dispatch: workflow_dispatch:
inputs:
commit_hash:
type: string
description: 'The commit hash to build (defaults to the latest commit on the default branch)'
required: false
default: ''
jobs: jobs:
release-update-repos: release-update-repos:
runs-on: ubuntu-24.04 runs-on: ubuntu-latest
name: Release Update Repos name: Release Update Repos
steps: steps:
@@ -31,7 +25,7 @@ jobs:
project_version=`cat ImHex/VERSION` project_version=`cat ImHex/VERSION`
tag_version="${{github.event.release.tag_name}}" tag_version="${{github.event.release.tag_name}}"
tag_version="${tag_version:1}" tag_version="${tag_version:1}"
if [ "$project_version" != "$tag_version" ] && [ ! -z "$tag_version" ]; then if [ "$project_version" != "$tag_version" ]; then
echo "::warning::$project_version and $tag_version are not the same ! Refusing to populate release" echo "::warning::$project_version and $tag_version are not the same ! Refusing to populate release"
exit 1 exit 1
fi fi
@@ -47,7 +41,6 @@ jobs:
tag: ImHex-v${{ env.IMHEX_VERSION }} tag: ImHex-v${{ env.IMHEX_VERSION }}
repo: PatternLanguage repo: PatternLanguage
token: ${{ secrets.RELEASE_TOKEN }} token: ${{ secrets.RELEASE_TOKEN }}
skipIfReleaseExists: true
- name: 🎫 Create ImHex-Patterns release - name: 🎫 Create ImHex-Patterns release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
@@ -58,7 +51,6 @@ jobs:
tag: ImHex-v${{ env.IMHEX_VERSION }} tag: ImHex-v${{ env.IMHEX_VERSION }}
repo: ImHex-Patterns repo: ImHex-Patterns
token: ${{ secrets.RELEASE_TOKEN }} token: ${{ secrets.RELEASE_TOKEN }}
skipIfReleaseExists: true
- name: 🎫 Create imhex-download-sdk release - name: 🎫 Create imhex-download-sdk release
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
@@ -69,13 +61,11 @@ jobs:
tag: v${{ env.IMHEX_VERSION }} tag: v${{ env.IMHEX_VERSION }}
repo: imhex-download-sdk repo: imhex-download-sdk
token: ${{ secrets.RELEASE_TOKEN }} token: ${{ secrets.RELEASE_TOKEN }}
skipIfReleaseExists: true
release-upload-artifacts: release-upload-artifacts:
runs-on: ubuntu-24.04 runs-on: ubuntu-latest
name: Release Upload Artifacts name: Release Upload Artifacts
outputs:
IMHEX_VERSION: ${{ steps.verify_version.outputs.IMHEX_VERSION }}
steps: steps:
- name: 🧰 Checkout - name: 🧰 Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -84,32 +74,29 @@ jobs:
submodules: recursive submodules: recursive
- name: 📜 Verify version and set version variable - name: 📜 Verify version and set version variable
id: verify_version
run: | run: |
set -x set -x
project_version=`cat ImHex/VERSION` project_version=`cat ImHex/VERSION`
tag_version="${{github.event.release.tag_name}}" tag_version="${{github.event.release.tag_name}}"
tag_version="${tag_version:1}" tag_version="${tag_version:1}"
if [ "$project_version" != "$tag_version" ] && [ ! -z "$tag_version" ]; then if [ "$project_version" != "$tag_version" ]; then
echo "::warning::$project_version and $tag_version are not the same ! Refusing to populate release" echo "::warning::$project_version and $tag_version are not the same ! Refusing to populate release"
exit 1 exit 1
fi fi
echo "IMHEX_VERSION=$project_version" >> $GITHUB_ENV echo "IMHEX_VERSION=$project_version" >> $GITHUB_ENV
echo "IMHEX_VERSION=$project_version" >> $GITHUB_OUTPUT
- name: 🗜️ Create tarball from sources with dependencies - name: 🗜️ Create tarball from sources with dependencies
run: tar --exclude-vcs -czvf Full.Sources.tar.gz ImHex run: tar --exclude-vcs -czvf Full.Sources.tar.gz ImHex
- name: ⬇️ Download artifacts from latest workflow - name: ⬇️ Download artifacts from latest workflow
uses: dawidd6/action-download-artifact@v6 uses: dawidd6/action-download-artifact@v2
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build.yml workflow: build.yml
branch: ${{ github.event.release.target_commitish }} branch: ${{ github.event.release.target_commitish }}
workflow_conclusion: success workflow_conclusion: success
skip_unpack: true skip_unpack: true
commit: ${{ github.event.inputs.commit_hash }}
- name: 🗜️ Unzip files when needed - name: 🗜️ Unzip files when needed
run: | run: |
@@ -128,87 +115,22 @@ jobs:
- name: 🟩 Rename artifacts when needed - name: 🟩 Rename artifacts when needed
run: | run: |
mv "Windows Portable x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-x86_64.zip || true mv "Windows Portable x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-x86_64.zip
mv "Windows Portable arm64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-arm64.zip || true mv "Windows Portable NoGPU x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-NoGPU-x86_64.zip
mv "Windows Portable NoGPU x86_64.zip" imhex-${{ env.IMHEX_VERSION }}-Windows-Portable-NoGPU-x86_64.zip || true
mv "ImHex Web.zip" imhex-${{ env.IMHEX_VERSION }}-Web.zip || true
rm artifact.tar || true
- name: ⬆️ Upload Unsigned x86_64 Windows Installer
uses: actions/upload-artifact@v4
id: upload-installer-x86_64
with:
if-no-files-found: error
name: Windows Installer x86_64
path: |
imhex-*-x86_64.msi
- name: ⬆️ Upload Unsigned ARM64 Windows Installer
if: false
uses: actions/upload-artifact@v4
id: upload-installer-arm64
with:
if-no-files-found: error
name: Windows Installer ARM64
path: |
imhex-*-arm64.msi
- name: 🗑️ Delete unsigned installers
run: |
rm imhex-*-x86_64.msi
- name: 🗝️ Sign x86_64 Installer
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: 'f605a0e8-86cd-411c-bb6f-e05025afcc33'
project-slug: 'ImHex'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{ steps.upload-installer-x86_64.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: '.'
- name: 🗝️ Sign ARM64 Installer
if: false
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: 'f605a0e8-86cd-411c-bb6f-e05025afcc33'
project-slug: 'ImHex'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{ steps.upload-installer-arm64.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: '.'
- name: ⬆️ Upload everything to release - name: ⬆️ Upload everything to release
uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981 uses: softprops/action-gh-release@v1
with: with:
files: '*' files: '*'
release-update-aur:
name: Release update AUR package
needs: release-upload-artifacts
runs-on: ubuntu-24.04
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
with:
path: ImHex
- name: ⬇️ Download artifacts
run: |
tagname=${GITHUB_REF#refs/tags/}
version=${tagname#v}
wget https://github.com/WerWolv/ImHex/releases/download/${tagname}/imhex-${version}-ArchLinux-x86_64.pkg.tar.zst
- name: ✒️ Prepare PKGBUILD - name: ✒️ Prepare PKGBUILD
run: | run: |
set -x set -x
cp ImHex/dist/Arch/PKGBUILD . cp ImHex/dist/Arch/PKGBUILD .
hash=`md5sum imhex-${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}-ArchLinux-x86_64.pkg.tar.zst | cut -d ' ' -f 1` hash=`md5sum imhex-${{ env.IMHEX_VERSION }}-ArchLinux-x86_64.pkg.tar.zst | cut -d ' ' -f 1`
sed -i 's/%version%/${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}/g' PKGBUILD sed -i 's/%version%/${{ env.IMHEX_VERSION }}/g' PKGBUILD
sed -i "s/(SKIP)/($hash)/g" PKGBUILD sed -i "s/(SKIP)/($hash)/g" PKGBUILD
- name: ⬆️ Publish AUR package - name: ⬆️ Publish AUR package
@@ -222,10 +144,10 @@ jobs:
pkgname: imhex-bin pkgname: imhex-bin
pkgbuild: ./PKGBUILD pkgbuild: ./PKGBUILD
commit_username: iTrooz commit_username: iTrooz
commit_email: hey@itrooz.fr commit_email: itrooz@protonmail.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Bump to version ${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }} commit_message: Bump to version ${{ env.IMHEX_VERSION }}
ssh_keyscan_types: rsa,ecdsa,ed25519 ssh_keyscan_types: rsa,dsa,ecdsa,ed25519
release-update-winget: release-update-winget:
name: Release update winget package name: Release update winget package
@@ -236,7 +158,6 @@ jobs:
shell: pwsh shell: pwsh
run: | run: |
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
- name: ⬆️ Update winget manifest - name: ⬆️ Update winget manifest
shell: pwsh shell: pwsh
env: env:
@@ -250,33 +171,3 @@ jobs:
if ($version -notmatch "-") { if ($version -notmatch "-") {
.\wingetcreate.exe submit .\manifests\w\WerWolv\ImHex\${version}\ --token $env:WINGET_GITHUB_TOKEN .\wingetcreate.exe submit .\manifests\w\WerWolv\ImHex\${version}\ --token $env:WINGET_GITHUB_TOKEN
} }
release-update-snapstore:
name: Release update snapstore package
needs: release-upload-artifacts
runs-on: ubuntu-24.04
steps:
- name: ⬇️ Download artifacts
run: |
tagname=${GITHUB_REF#refs/tags/}
version=${tagname#v}
wget https://github.com/WerWolv/ImHex/releases/download/${tagname}/imhex-${version}-x86_64.snap
wget https://github.com/WerWolv/ImHex/releases/download/${tagname}/imhex-${version}-arm64.snap
- name: ⬆️ Publish x86_64 Snap package
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}-x86_64.snap
release: stable
- name: ⬆️ Publish arm64 Snap package
continue-on-error: true
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
with:
snap: imhex-${{ needs.release-upload-artifacts.outputs.IMHEX_VERSION }}-arm64.snap
release: stable

View File

@@ -1,31 +0,0 @@
name: Close inactive issues
on:
schedule:
- cron: "30 1 * * 0"
workflow_dispatch:
jobs:
close-issues:
if: false # Disabled for now until I actually have time to take care of all these issues
runs-on: ubuntu-24.04
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
operations-per-run: '200'
ascending: true
days-before-issue-stale: 334
days-before-issue-close: 30
stale-issue-label: "stale"
stale-issue-message: |
This issue is marked stale as it has been open for 11 months without activity.
Please try the latest ImHex version. (Avaiable here: https://imhex.download/ for release and https://imhex.download/#nightly for development version)
If the issue persists on the latest version, please make a comment on this issue again
Without response, this issue will be closed in one month.
close-issue-message: ""
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -5,8 +5,6 @@ on:
branches: branches:
- 'master' - 'master'
- 'releases/**' - 'releases/**'
- 'tests/**'
- 'feature/**'
pull_request: pull_request:
branches: branches:
- 'master' - 'master'
@@ -16,7 +14,7 @@ on:
jobs: jobs:
tests: tests:
name: 🧪 Unit Tests name: 🧪 Unit Tests
runs-on: ubuntu-24.04 runs-on: ubuntu-22.04
permissions: permissions:
actions: read actions: read
contents: read contents: read
@@ -35,6 +33,14 @@ jobs:
restore-keys: ${{ runner.os }}-tests-build restore-keys: ${{ runner.os }}-tests-build
max-size: 50M max-size: 50M
- name: 📜 Restore CMakeCache
uses: actions/cache@v4
with:
path: |
build/CMakeCache.txt
key: ${{ runner.os }}-tests-build-${{ hashFiles('**/CMakeLists.txt') }}
- name: ⬇️ Install dependencies - name: ⬇️ Install dependencies
run: | run: |
sudo apt update sudo apt update
@@ -45,50 +51,21 @@ jobs:
set -x set -x
mkdir -p build mkdir -p build
cd build cd build
CC=gcc-14 CXX=g++-14 cmake \ CC=gcc-12 CXX=g++-12 cmake \
-DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_BUILD_TYPE=Debug \
-DIMHEX_ENABLE_UNIT_TESTS=ON \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DIMHEX_ENABLE_PLUGIN_TESTS=ON \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_FLAGS="-fuse-ld=lld -fsanitize=address,leak,undefined -fno-sanitize-recover=all" \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_FLAGS="-fuse-ld=lld -fsanitize=address,leak,undefined -fno-sanitize-recover=all" \
-DCMAKE_C_FLAGS="-fuse-ld=lld -fsanitize=address,leak,undefined -fno-sanitize-recover=all --coverage" \ -DIMHEX_OFFLINE_BUILD=ON \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld -fsanitize=address,leak,undefined -fno-sanitize-recover=all --coverage" \
-DIMHEX_OFFLINE_BUILD=ON \
-G Ninja \
.. ..
ninja unit_tests make -j4 unit_tests
ninja imhex_all
- name: 🧪 Perform plcli Integration Tests
run: |
cd lib/external/pattern_language
python tests/integration/integration.py ../../../build/imhex --pl
- name: 🧪 Perform Unit Tests - name: 🧪 Perform Unit Tests
run: | run: |
cd build cd build
ctest --output-on-failure ctest --output-on-failure
# Generate report from all gcov .gcda files
#- name: 🧪 Generate coverage report
# run: |
# sudo apt install python3-pip python3-venv
# python3 -m venv venv
# . venv/bin/activate
# pip3 install gcovr
# cd build
# gcovr --gcov-executable /usr/bin/gcov-14 --exclude '.*/yara_rules/' --exclude '.*/third_party/' --exclude '.*/external/' --root .. --xml coverage_report.xml --verbose --gcov-ignore-errors all
#
#- name: Upload coverage reports to Codecov
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# if: ${{ env.CODECOV_TOKEN }}
# uses: codecov/codecov-action@v4
# with:
# fail_ci_if_error: true
# token: ${{ secrets.CODECOV_TOKEN }}
# file: build/coverage_report.xml
langs: langs:
name: 🧪 Langs name: 🧪 Langs
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04

27
.gitignore vendored
View File

@@ -1,24 +1,13 @@
/.vscode/ .vscode/
/.idea/ .idea/
/.kdev4/
/.vs/
.venv/
/cmake-build-*/ cmake-build-*/
/build*/ build*/
/local/ local/
/venv/ venv/
/.cache/
/install/
/out/
/dist/ImHex.run.xml
*.mgc *.mgc
*.kdev4
imgui.ini imgui.ini
.DS_Store .DS_Store
CMakeUserPresets.json ./CMakeUserPresets.json
Brewfile.lock.json Brewfile.lock.json
vcpkg.json

23
.gitmodules vendored
View File

@@ -18,14 +18,10 @@
path = lib/third_party/capstone path = lib/third_party/capstone
url = https://github.com/capstone-engine/capstone url = https://github.com/capstone-engine/capstone
ignore = dirty ignore = dirty
[submodule "lib/third_party/edlib"] [submodule "lib/third_party/jthread/jthread"]
path = lib/third_party/edlib path = lib/third_party/jthread/jthread
url = https://github.com/Martinsos/edlib url = https://github.com/josuttis/jthread
ignore = dirty ignore = dirty
[submodule "lib/third_party/lunasvg"]
path = lib/third_party/lunasvg
url = https://github.com/sammycage/lunasvg
ignore = dirty
[submodule "lib/external/libromfs"] [submodule "lib/external/libromfs"]
path = lib/external/libromfs path = lib/external/libromfs
@@ -39,10 +35,7 @@
[submodule "lib/third_party/HashLibPlus"] [submodule "lib/third_party/HashLibPlus"]
path = lib/third_party/HashLibPlus path = lib/third_party/HashLibPlus
url = https://github.com/WerWolv/HashLibPlus url = https://github.com/WerWolv/HashLibPlus
[submodule "lib/external/disassembler"] [submodule "lib/third_party/edlib"]
path = lib/external/disassembler path = lib/third_party/edlib
url = https://github.com/WerWolv/Disassembler url = https://github.com/Martinsos/edlib
[submodule "lib/third_party/md4c"]
path = lib/third_party/md4c
url = https://github.com/mity/md4c

View File

@@ -1,68 +1,44 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.20)
# Options # Options
## General option(IMHEX_PLUGINS_IN_SHARE "Put the plugins in share/imhex/plugins instead of lib[..]/imhex/plugins (Linux only)" OFF)
option(IMHEX_STRIP_RELEASE "Strip the release builds" ON ) option(IMHEX_STRIP_RELEASE "Strip the release builds" ON )
option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF) option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF)
option(IMHEX_IGNORE_BAD_CLONE "Disable the bad clone prevention checks" OFF) option(IMHEX_IGNORE_BAD_CLONE "Disable the bad clone prevention checks" OFF)
option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF) option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF)
option(IMHEX_IGNORE_BAD_COMPILER "Allow compiling with an unsupported compiler" OFF) option(IMHEX_IGNORE_BAD_COMPILER "Allow compiling with an unsupported compiler" OFF)
option(IMHEX_USE_GTK_FILE_PICKER "Use GTK file picker instead of xdg-desktop-portals (Linux only)" OFF) option(IMHEX_USE_GTK_FILE_PICKER "Use GTK file picker instead of xdg-desktop-portals (Linux only)" OFF)
option(IMHEX_DISABLE_STACKTRACE "Disables support for printing stack traces" OFF)
option(IMHEX_BUNDLE_DOTNET "Bundle .NET runtime" ON ) option(IMHEX_BUNDLE_DOTNET "Bundle .NET runtime" ON )
option(IMHEX_ENABLE_LTO "Enables Link Time Optimizations if possible" OFF) option(IMHEX_ENABLE_LTO "Enables Link Time Optimizations if possible" OFF)
option(IMHEX_USE_DEFAULT_BUILD_SETTINGS "Use default build settings" OFF) option(IMHEX_USE_DEFAULT_BUILD_SETTINGS "Use default build settings" OFF)
option(IMHEX_BUILD_HARDENING "Enable hardening flags for build" ON ) option(IMHEX_STRICT_WARNINGS "Enable most available warnings and treat them as errors" ON )
option(IMHEX_GENERATE_PACKAGE "Specify if a cpack package should be built. (Windows only)" OFF) option(IMHEX_STATIC_LINK_PLUGINS "Statically link all plugins into the main executable" OFF)
option(IMHEX_MACOS_CREATE_BUNDLE "Creates a macOS .app bundle when building (macOS only)" ON ) option(IMHEX_GENERATE_PACKAGE "Specify if a native package should be built. (Windows and MacOS only)" OFF)
option(IMHEX_ENABLE_UNITY_BUILD "Enables building ImHex as a unity build." OFF) option(IMHEX_ENABLE_UNITY_BUILD "Enables building ImHex as a unity build." OFF)
option(IMHEX_ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" OFF)
option(IMHEX_ENABLE_CXX_MODULES "Enable C++20 Module compilation. Testing only!" OFF)
option(IMHEX_ENABLE_CPPCHECK "Enable cppcheck static analysis" OFF)
option(IMHEX_BUNDLE_PLUGIN_SDK "Enable bundling of Plugin SDK into install package" ON )
## Testing
option(IMHEX_ENABLE_UNIT_TESTS "Enable building unit tests" ON )
option(IMHEX_ENABLE_IMGUI_TEST_ENGINE "Enable the ImGui Test Engine" OFF)
option(IMHEX_ENABLE_STD_ASSERTS "Enable debug asserts in the C++ std library. (Breaks Plugin ABI!)" OFF)
## Debug info
option(IMHEX_COMPRESS_DEBUG_INFO "Compress debug information" ON )
option(IMHEX_GENERATE_PDBS "Enable generating PDB files in non-debug builds (Windows only)" OFF) option(IMHEX_GENERATE_PDBS "Enable generating PDB files in non-debug builds (Windows only)" OFF)
option(IMHEX_REPLACE_DWARF_WITH_PDB "Remove DWARF information from binaries when generating PDBS (Windows only)" OFF) option(IMHEX_REPLACE_DWARF_WITH_PDB "Remove DWARF information from binaries when generating PDBS (Windows only)" OFF)
option(IMHEX_STRICT_WARNINGS "Enable most available warnings and treat them as errors" ON ) option(IMHEX_ENABLE_STD_ASSERTS "Enable debug asserts in the C++ std library. (Breaks Plugin ABI!)" OFF)
option(IMHEX_DISABLE_STACKTRACE "Disables support for printing stack traces" OFF) option(IMHEX_ENABLE_UNIT_TESTS "Enable building unit tests" OFF)
## Plugins option(IMHEX_ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers" OFF)
option(IMHEX_STATIC_LINK_PLUGINS "Statically link all plugins into the main executable" OFF)
option(IMHEX_ENABLE_PLUGIN_TESTS "Enable building plugin tests" ON )
option(IMHEX_INCLUDE_PLUGINS "Semicolon-separated list of plugins to include in the build (empty = build all)" "" )
option(IMHEX_EXCLUDE_PLUGINS "Semicolon-separated list of plugins to exclude from the build" "" )
set(IMHEX_BASE_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${IMHEX_BASE_FOLDER}/cmake/modules")
# Optional IDE support
include("${IMHEX_BASE_FOLDER}/cmake/ide_helpers.cmake")
# Basic compiler and cmake configurations # Basic compiler and cmake configurations
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_SCAN_FOR_MODULES ${IMHEX_ENABLE_CXX_MODULES})
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(IMHEX_BASE_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${IMHEX_BASE_FOLDER}/cmake/modules")
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake") include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")
# Setup project # Setup project
loadVersion(IMHEX_VERSION IMHEX_VERSION_PLAIN) loadVersion(IMHEX_VERSION)
setVariableInParent(IMHEX_VERSION ${IMHEX_VERSION}) setVariableInParent(IMHEX_VERSION ${IMHEX_VERSION})
configureCMake() configureCMake()
project(ImHex project(imhex
LANGUAGES C CXX LANGUAGES C CXX
VERSION ${IMHEX_VERSION_PLAIN} VERSION ${IMHEX_VERSION}
DESCRIPTION "The ImHex Hex Editor" DESCRIPTION "The ImHex Hex Editor"
HOMEPAGE_URL "https://imhex.werwolv.net" HOMEPAGE_URL "https://imhex.werwolv.net"
) )
configureProject()
# Add ImHex sources
add_custom_target(imhex_all ALL)
# Make sure project is configured correctly # Make sure project is configured correctly
setDefaultBuiltTypeIfUnset() setDefaultBuiltTypeIfUnset()
@@ -80,27 +56,17 @@ configurePackingResources()
setUninstallTarget() setUninstallTarget()
addBundledLibraries() addBundledLibraries()
# Add ImHex sources
add_custom_target(imhex_all ALL)
add_subdirectory(lib/libimhex) add_subdirectory(lib/libimhex)
add_subdirectory(main) add_subdirectory(main)
addPluginDirectories()
add_subdirectory(lib/trace)
# Add unit tests # Add unit tests
if (IMHEX_ENABLE_UNIT_TESTS) enable_testing()
if (NOT TARGET unit_tests) add_subdirectory(tests EXCLUDE_FROM_ALL)
enable_testing()
add_custom_target(unit_tests)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif ()
endif ()
# Configure more resources that will be added to the install package # Configure more resources that will be added to the install package
if (IMHEX_BUNDLE_PLUGIN_SDK)
generateSDKDirectory()
endif()
# Handle package generation
createPackage() createPackage()
generatePDBs()
# Accommodate IDEs with FOLDER support generateSDKDirectory()
tweakTargetsForIDESupport()

View File

@@ -28,47 +28,7 @@
"displayName": "x86_64 Build", "displayName": "x86_64 Build",
"description": "x86_64 build", "description": "x86_64 build",
"inherits": [ "base" ] "inherits": [ "base" ]
}, }
{
"name": "xcode",
"inherits": [ "base" ],
"displayName": "Xcode",
"description": "Xcode with external compiler override",
"generator": "Xcode",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-fexperimental-library -Wno-shorten-64-to-32 -Wno-deprecated-declarations",
"IMHEX_IDE_HELPERS_OVERRIDE_XCODE_COMPILER": "ON"
}
},
{
"name": "vs2022",
"displayName": "Visual Studio 2022",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_DIR": "${sourceDir}/dist"
}
},
{
"name": "vs2022-x86",
"displayName": "Visual Studio 2022 x86",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_MANIFEST_DIR": "${sourceDir}/dist"
},
"environment": {
"VSCMD_ARG_TGT_ARCH": "x86"
}
}
], ],
"buildPresets": [ "buildPresets": [
{ {

View File

@@ -10,7 +10,9 @@ This document is a guide for developers who want to contribute to ImHex in any w
If you'd like to add new features, the best way to start is by joining our Discord and telling us about your idea. We can then discuss the best way to implement it and how it should be integrated into ImHex or if it should be done in a separate plugin. If you'd like to add new features, the best way to start is by joining our Discord and telling us about your idea. We can then discuss the best way to implement it and how it should be integrated into ImHex or if it should be done in a separate plugin.
There are standalone plugin templates that use ImHex as a submodule. You can find them located in the README's [Plugin Development](README.md#plugin-development) section. There are standalone plugin templates that use ImHex as a submodule. You can find them here:
- https://github.com/WerWolv/ImHex-Cpp-Plugin-Template
- https://github.com/WerWolv/ImHex-Rust-Plugin-Template
### Adding a new language ### Adding a new language
@@ -30,18 +32,18 @@ ImHex is written in C++ and usually uses the latest compiler and standard librar
### Structure ### Structure
- `main`: Contains the main application code - `main`: Contains the main application code
- Important to understand here is that the main ImHex application is basically just an empty shell. - Important to understand here is that the main ImHex application is basically just an empty shell.
- All it does is create a Window and a OpenGL context using GLFW, load all available plugins, properly configure ImGui and render it to the screen. - All it does is create a Window and a OpenGL context using GLFW, load all available plugins, properly configure ImGui and render it to the screen.
- Everything else is done inside of plugins. ImHex comes with a few plugins by default, most notably the `builtin` plugin which contains the majority of the application code. - Everything else is done inside of plugins. ImHex comes with a few plugins by default, most notably the `builtin` plugin which contains the majority of the application code.
- In most cases, this code doesn't need to be modified. Most features should be self-contained inside a plugin. - In most cases, this code doesn't need to be modified. Most features should be self-contained inside a plugin.
- `lib` - `lib`
- `libimhex`: Contains all helper utilities as well as various APIs for plugins to interact with ImHex. - `libimhex`: Contains all helper utilities as well as various APIs for plugins to interact with ImHex.
- The library's main purpose is for Dependency Inversion. The ImHex main application as well as libimhex do not know about the existence of plugins at build time. Plugins and the main application instead link against libimhex and use it as a common API to interact with each other. - The library's main purpose is for Dependency Inversion. The ImHex main application as well as libimhex do not know about the existence of plugins at build time. Plugins and the main application instead link against libimhex and use it as a common API to interact with each other.
- Since libimhex itself doesn't know about the existence of plugins, it cannot depend on any of them. This includes localizations and things that get registered by plugins after launch. - Since libimhex is a doesn't know about the existence of plugins, it cannot depend on any of them. This includes localizations and things that get registered by plugins after launch.
- Even if the builtin plugin is technically always available, it is still a plugin and should be treated that way. - Even if the builtin plugin is technically always available, it is still a plugin and should be treated that way.
- All important APIs can be found in the `hex/api` include directory and are documented in the respective header file. - All important APIs can be found in the `hex/api` include directory and are documented in the respective header file.
- `external`: All libraries that need custom patches or aren't typically available in package managers go into here. - `external`: All libraries that need custom patches or aren't typically available in package managers go into here.
- If you'd like to add new features to the Pattern language, please make a PR to https://github.com/WerWolv/PatternLanguage instead. ImHex usually depends on the latest commit of the master branch of this repo. - If you'd like to add new features to the Pattern language, please make a PR to https://github.com/WerWolv/PatternLanguage instead. ImHex usually depends on the latest commit of the master branch of this repo.
- `plugins` - `plugins`
- `builtin`: The builtin plugin. Contains the majority of the application code. - `builtin`: The builtin plugin. Contains the majority of the application code.
- It's the heart of ImHex's functionality. It contains most of the default views, providers, etc. so if you want to add new functionality to ImHex, this is the place to start. - It's the heart of ImHex's functionality. It contains most of the default views, providers, etc. so if you want to add new functionality to ImHex, this is the place to start.

View File

@@ -32,13 +32,6 @@ To install the Flatpak, make sure you have the Flathub repository added to your
```bash ```bash
flatpak install flathub net.werwolv.ImHex flatpak install flathub net.werwolv.ImHex
# or install the file directly
flatpak install ./imhex-*.flatpak
```
#### Snap
```bash
snap install ./imhex-*.snap
``` ```
#### Ubuntu DEB Package #### Ubuntu DEB Package

View File

@@ -1,8 +0,0 @@
# Privacy Policy
ImHex collects **anonymous** user statistics based on the user's preferences which are set on first launch and can be opted in or out at any moment through the settings interface.
These statistics contain basic system information such as: ImHex Version, System Architecture, OS, OS Version or Linux Distro version of the GPU in use. This information is linked to a randomly generated ID which cannot be used to identify a specific user.
Additionally, we allow uploading of anonymized crash log files in case of an error. These are never uploaded automatically but only after explicit consent by the user. This decision is not saved so logs can be uploaded on a per-error basis.
Information collected may be analyzed by members of our development team and will never be shared with third parties outside of the team. We may occasionally share general usage statistics publically in a summarized manner (For example a graph stating 70% of users are using a specific OS). We will never share information about individual users, even if they are anonymous.

123
README.md
View File

@@ -1,16 +1,14 @@
<a href="https://imhex.werwolv.net"> <a href="https://imhex.werwolv.net">
<h1 align="center"> <h1 align="center">
<picture> <picture>
<img height="300px" style="margin: 0; padding: 0" src="./resources/dist/common/logo/ImHexLogoSVGBG.svg"> <source media="(prefers-color-scheme: dark)" srcset="./resources/projects/logo_text_light.svg">
<img height="100px" src="./resources/projects/logo_text_dark.svg">
</picture> </picture>
</h1> </h1>
</a> </a>
<p align="center"> <p align="center">A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.</p>
A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
<br>
<a href="https://itinerarium.github.io/phoneme-synthesis/?w=/'ˈɪmhɛks/"><strong>/ˈɪmhɛks/</strong></a>
</p>
<p align="center"> <p align="center">
<a title="'Build' workflow Status" href="https://github.com/WerWolv/ImHex/actions?query=workflow%3ABuild"><img alt="'Build' workflow Status" src="https://img.shields.io/github/actions/workflow/status/WerWolv/ImHex/build.yml?longCache=true&style=for-the-badge&label=Build&logoColor=fff&logo=GitHub%20Actions&branch=master"></a> <a title="'Build' workflow Status" href="https://github.com/WerWolv/ImHex/actions?query=workflow%3ABuild"><img alt="'Build' workflow Status" src="https://img.shields.io/github/actions/workflow/status/WerWolv/ImHex/build.yml?longCache=true&style=for-the-badge&label=Build&logoColor=fff&logo=GitHub%20Actions&branch=master"></a>
<a title="Discord Server" href="https://discord.gg/X63jZ36xBY"><img alt="Discord Server" src="https://img.shields.io/discord/789833418631675954?label=Discord&logo=Discord&logoColor=fff&style=for-the-badge"></a> <a title="Discord Server" href="https://discord.gg/X63jZ36xBY"><img alt="Discord Server" src="https://img.shields.io/discord/789833418631675954?label=Discord&logo=Discord&logoColor=fff&style=for-the-badge"></a>
@@ -29,26 +27,17 @@
## Supporting ## Supporting
If you like my work, please consider supporting me on GitHub Sponsors, Ko-Fi or PayPal. Thanks a lot! If you like my work, please consider supporting me on GitHub Sponsors, Patreon or PayPal. Thanks a lot!
<p align="center"> <p align="center">
<a href="https://github.com/sponsors/WerWolv"><img src="https://werwolv.net/assets/github_banner.png" alt="GitHub donate button" /></a> <a href="https://github.com/sponsors/WerWolv"><img src="https://werwolv.net/assets/github_banner.png" alt="GitHub donate button" /></a>
<a href="https://ko-fi.com/WerWolv"><img src="https://werwolv.net/assets/kofi_banner.png" alt="Ko-Fi donate button" /></a> <a href="https://www.patreon.com/werwolv"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Patreon donate button" /></a>
<a href="https://werwolv.net/donate"><img src="https://werwolv.net/assets/paypal_banner.png" alt="PayPal donate button" /></a> <a href="https://werwolv.net/donate"><img src="https://werwolv.net/assets/paypal_banner.png" alt="PayPal donate button" /></a>
</p> </p>
### Notable Sponsors
| | |
|:---------------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------|
| [![JetBrains logo](https://avatars.githubusercontent.com/u/878437?s=48)](https://www.jetbrains.com) | JetBrains, providing us with free All Products Pack licenses for development |
| [![SignPath logo](https://avatars.githubusercontent.com/u/34448643?s=48)](https://signpath.io/) | SignPath, providing us with free Code Signing Certificates for our Windows builds |
| [![AWS logo](https://avatars.githubusercontent.com/u/2232217?s=48)](https://aws.amazon.com) | Amazon, providing us with free AWS Cloud Credits for our CI |
Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:imhex@werwolv.net)!
## Screenshots ## Screenshots
![Hex editor, patterns and data information](https://github.com/user-attachments/assets/902a7c4c-410d-490f-999e-14c856fec027) ![Hex editor, patterns and data information](https://github.com/WerWolv/ImHex/assets/10835354/4f358238-2d27-41aa-9015-a2c6cc3708cf)
![Bookmarks, data information, find view and data processor](https://github.com/user-attachments/assets/58eefa1f-31c9-4bb8-a1c1-8cdd8ddbd29f) ![Bookmarks, disassembler and data processor](https://github.com/WerWolv/ImHex/assets/10835354/183bc2cc-2439-4ded-b4c5-b140e19fc92f)
<details> <details>
<summary><strong>More Screenshots</strong></summary> <summary><strong>More Screenshots</strong></summary>
@@ -116,12 +105,11 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- Base64 files - Base64 files
- IPS and IPS32 patches - IPS and IPS32 patches
- Markdown reports - Markdown reports
- Binary arrays for various programming languages
</details> </details>
<details> <details>
<summary><strong>Data Inspector</strong></summary> <summary><strong>Data Inspector</strong></summary>
- Interpreting data as many different types with endianness, decimal, hexadecimal and octal support and bit inversion - Interpreting data as many different types with endianess, decimal, hexadecimal and octal support and bit inversion
- Unsigned and signed integers (8, 16, 24, 32, 48, 64 bit) - Unsigned and signed integers (8, 16, 24, 32, 48, 64 bit)
- Floats (16, 32, 64 bit) - Floats (16, 32, 64 bit)
- Signed and Unsigned LEB128 - Signed and Unsigned LEB128
@@ -150,13 +138,8 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- GDB Server - GDB Server
- Access the RAM of a running process or embedded devices through GDB - Access the RAM of a running process or embedded devices through GDB
- Intel Hex and Motorola SREC data - Intel Hex and Motorola SREC data
- Base64 encoded data
- UDP Packets
- Support for displaying raw data received over UDP
- Process Memory - Process Memory
- Inspect the entire address space of a running process - Inspect the entire address space of a running process
- Remote Files over SSH with SFTP
- Support for loading files from remote servers using SSH and SFTP
</details> </details>
<details> <details>
<summary><strong>Data searching</strong></summary> <summary><strong>Data searching</strong></summary>
@@ -175,7 +158,7 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- Numeric Value search - Numeric Value search
- Search for signed/unsigned integers and floats - Search for signed/unsigned integers and floats
- Search for ranges of values - Search for ranges of values
- Option to specify size and endianness - Option to specify size and endianess
- Option to ignore unaligned values - Option to ignore unaligned values
</details> </details>
<details> <details>
@@ -227,7 +210,6 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- WebAssembly - WebAssembly
- MOS65XX - MOS65XX
- Berkeley Packet Filter - Berkeley Packet Filter
- Support for writing custom disassemblers for your own architectures
</details> </details>
<details> <details>
<summary><strong>Bookmarks</strong></summary> <summary><strong>Bookmarks</strong></summary>
@@ -277,7 +259,6 @@ Would you like to appear here as well? Contact us at [imhex@werwolv.net](mailto:
- Division by invariant multiplication calculator - Division by invariant multiplication calculator
- TCP Client/Server - TCP Client/Server
- Euclidean algorithm calculator - Euclidean algorithm calculator
- HTTP Requests
</details> </details>
<details> <details>
<summary><strong>Built-in Content updater</strong></summary> <summary><strong>Built-in Content updater</strong></summary>
@@ -331,28 +312,22 @@ To use ImHex, the following minimal system requirements need to be met.
> ImHex requires a GPU with OpenGL 3.0 support in general. > ImHex requires a GPU with OpenGL 3.0 support in general.
> There are releases available (with the `-NoGPU` suffix) that are software rendered and don't require a GPU, however these can be a lot slower than the GPU accelerated versions. > There are releases available (with the `-NoGPU` suffix) that are software rendered and don't require a GPU, however these can be a lot slower than the GPU accelerated versions.
> >
> If possible at all, make ImHex use the dedicated GPU on your system instead of the integrated one. > If possible at all, make ImHex use the dedicated GPU on your system instead of the integrated one (especially Intel HD GPUs are known to cause issues).
> ImHex will usually run fine with integrated GPUs as well but certain Intel HD GPU drivers on Windows are known to cause graphical artifacts.
- **OS**: - **OS**:
- **Windows**: Windows 7 or higher (Windows 10/11 recommended) - **Windows**: Windows 7 or higher (Windows 10/11 recommended)
- **macOS**: macOS 15 (Sequoia) or higher, - **macOS**: macOS 11 (Big Sur) or higher,
- Lower versions should still work too, but you'll need to compile ImHex yourself. The release binaries will NOT work due to GitHub not having any macOS 15 or lower CI runners available. - **Linux**: "Modern" Linux. The following distributions have official releases available. Other distros are supported through the AppImage and Flatpak releases.
- The macOS build is not signed and will require you to manually allow them in the Security & Privacy settings. - Ubuntu 22.04/23.04
- **Linux**: "Modern" Linux. The following distributions have official releases available. Other distros are supported through the AppImage, Flatpak and Snap releases. - Fedora 36/37
- Ubuntu and Debian - RHEL/AlmaLinux 9
- Fedora
- RHEL/AlmaLinux
- Arch Linux - Arch Linux
- Basically any other distro will work as well when compiling ImHex from sources. - **CPU**: x86_64 (64 Bit)
- **FreeBSD**: Tested on FreeBSD 14.3
- Other versions will most likely work too but are untested
- **CPU**: Officially supported are x86, AMD64 and ARM64, though any Little Endian CPU should work.
- **GPU**: OpenGL 3.0 or higher - **GPU**: OpenGL 3.0 or higher
- Integrated Intel HD iGPUs are supported, however certain drivers are known to cause various graphical artifacts, especially on Windows. Use at your own risk. - Intel HD drivers are really buggy and often cause graphic artifacts
- In case you don't have a GPU available, there are software rendered releases available for Windows and macOS - In case you don't have a GPU available, there are software rendered releases available for Windows and macOS
- **RAM**: ~50MiB, more is required for more complex analysis - **RAM**: 256MB, more may be required for more complicated analysis
- **Storage**: ~100MiB - **Storage**: 100MB
## Installing ## Installing
@@ -361,10 +336,8 @@ Information on how to install ImHex can be found in the [Install](/INSTALL.md) g
## Compiling ## Compiling
To compile ImHex on any platform, GCC (or Clang) is required with a version that supports C++23 or higher. To compile ImHex on any platform, GCC (or Clang) is required with a version that supports C++23 or higher.
Windows and Linux releases are being built using latest available GCC. On macOS, Clang is also required to compile some ObjC code.
MacOS releases are being built using latest available LLVM Clang. All releases are being built using latest available GCC.
Important to note is, the MSVC and AppleClang compilers are both **NOT** supported since they're both generally severely outdated and lack features GCC and LLVM Clang have.
> [!NOTE] > [!NOTE]
> Many dependencies are bundled into the repository using submodules so make sure to clone it using the `--recurse-submodules` option. > Many dependencies are bundled into the repository using submodules so make sure to clone it using the `--recurse-submodules` option.
@@ -375,20 +348,9 @@ For more information, check out the [Compiling](/dist/compiling) guide.
## Contributing ## Contributing
See [Contributing](/CONTRIBUTING.md) See [Contributing](/CONTRIBUTING.md)
## Plugin development ## Plugin development
To develop plugins for ImHex, use the following template project to get started. You then have access to the entirety of libimhex as well as the ImHex API and the Content Registry to interact with ImHex or to add new content. To develop plugins for ImHex, use the following template project to get started. You then have access to the entirety of libimhex as well as the ImHex API and the Content Registry to interact with ImHex or to add new content.
To build a plugin, you will need to use our SDK
### Getting the SDK locally
You can build the SDK by compiling ImHex like this:
- `cmake -G Ninja -DIMHEX_BUNDLE_PLUGIN_SDK=ON -B build`
- `cd build`
- `DESTDIR=install ninja install`
The SDK will then be available at `install/usr/local/share/imhex/sdk`. You will need to set the variable `IMHEX_SDK_PATH` to that (absolute) path.
### Getting the SDK in a Github Actions CI
You can use [this action](https://github.com/WerWolv/imhex-download-sdk) to automatically download the SDK to your Github Runner
- [ImHex Plugin Template](https://github.com/WerWolv/ImHex-Plugin-Template) - [ImHex Plugin Template](https://github.com/WerWolv/ImHex-Plugin-Template)
@@ -396,30 +358,24 @@ You can use [this action](https://github.com/WerWolv/imhex-download-sdk) to auto
### Contributors ### Contributors
- [AxCut](https://github.com/paxcut) for a gigantic amount of contributions to the Pattern Text Editor and tons of other parts of ImHex - [Mary](https://github.com/marysaka) for her immense help porting ImHex to MacOS and help during development
- [iTrooz](https://github.com/iTrooz) for getting ImHex onto the Web as well as hundreds of contributions in every part of the project
- [jumanji144](https://github.com/jumanji144) for huge contributions to the Pattern Language and ImHex's infrastructure
- [Mary](https://github.com/marysaka) for her immense help porting ImHex to macOS and help during development
- [Roblabla](https://github.com/Roblabla) for adding MSI Installer support to ImHex - [Roblabla](https://github.com/Roblabla) for adding MSI Installer support to ImHex
- [jam1garner](https://github.com/jam1garner) and [raytwo](https://github.com/raytwo) for their help with adding Rust support to plugins
- [Mailaender](https://github.com/Mailaender) for getting ImHex onto Flathub - [Mailaender](https://github.com/Mailaender) for getting ImHex onto Flathub
- [iTrooz](https://github.com/iTrooz) for many improvements and new features to Imhex
- Everybody else who has reported issues on Discord or GitHub that I had great conversations with :) - Everybody else who has reported issues on Discord or GitHub that I had great conversations with :)
### Dependencies ### Dependencies
- Thanks a lot to ocornut for their amazing [Dear ImGui](https://github.com/ocornut/imgui) which is used for building the entire interface - Thanks a lot to ocornut for their amazing [Dear ImGui](https://github.com/ocornut/imgui) which is used for building the entire interface
- Thanks to epezent for [ImPlot](https://github.com/epezent/implot) used to plot data in various places - Thanks to ocornut as well for their hex editor view used as base for this project.
- Thanks to Nelarius for [ImNodes](https://github.com/Nelarius/imnodes) used as base for the data processor - Thanks to BalazsJako for their incredible [ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit) used for the pattern language syntax highlighting
- Thanks to BalazsJako for [ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit) used for the pattern language syntax highlighting - Thanks to nlohmann for their [json](https://github.com/nlohmann/json) library used for project files
- Thanks to nlohmann for their [json](https://github.com/nlohmann/json) library used for configuration files
- Thanks to vitaut for their [libfmt](https://github.com/fmtlib/fmt) library which makes formatting and logging so much better
- Thanks to btzy for [nativefiledialog-extended](https://github.com/btzy/nativefiledialog-extended) and their great support, used for handling file dialogs on all platforms
- Thanks to danyspin97 for [xdgpp](https://sr.ht/~danyspin97/xdgpp) used to handle folder paths on Linux
- Thanks to aquynh for [capstone](https://github.com/aquynh/capstone) which is the base of the disassembly window - Thanks to aquynh for [capstone](https://github.com/aquynh/capstone) which is the base of the disassembly window
- Thanks to vitaut for their [libfmt](https://github.com/fmtlib/fmt) library which makes formatting and logging so much better
- Thanks to rxi for [microtar](https://github.com/rxi/microtar) used for extracting downloaded store assets - Thanks to rxi for [microtar](https://github.com/rxi/microtar) used for extracting downloaded store assets
- Thanks to VirusTotal for [Yara](https://github.com/VirusTotal/yara) used by the Yara plugin - Thanks to btzy for [nativefiledialog-extended](https://github.com/btzy/nativefiledialog-extended)
- Thanks to Martinsos for [edlib](https://github.com/Martinsos/edlib) used for sequence searching in the diffing view - Thanks to danyspin97 for [xdgpp](https://sr.ht/~danyspin97/xdgpp)
- Thanks to ron4fun for [HashLibPlus](https://github.com/ron4fun/HashLibPlus) which implements every hashing algorithm under the sun
- Thanks to mackron for [miniaudio](https://github.com/mackron/miniaudio) used to play audio files
- Thanks to all other groups and organizations whose libraries are used in ImHex - Thanks to all other groups and organizations whose libraries are used in ImHex
### License ### License
@@ -430,18 +386,3 @@ Notable exceptions to this are the following parts which are under the LGPLv2.1
- **/plugins/ui**: The UI plugin library that contains some common UI elements that can be used by other plugins - **/plugins/ui**: The UI plugin library that contains some common UI elements that can be used by other plugins
The reason for this is to allow for proprietary plugins to be developed for ImHex. The reason for this is to allow for proprietary plugins to be developed for ImHex.
### Code Signing Policy
Free code signing provided by [SignPath.io](https://about.signpath.io/),
certificate by [SignPath Foundation](https://signpath.org/).
This program will not transfer any information to other networked systems
unless specifically requested by the user or the person installing or
operating it.
#### People with direct push access
- [WerWolv](https://github.com/WerWolv)
- [iTrooz](https://github.com/iTrooz)
- [jumanji144](https://github.com/jumanji144)
- [AxCut](https://github.com/paxcut)

View File

@@ -1 +1 @@
1.39.0.WIP 1.33.1

View File

View File

@@ -1,100 +1,3 @@
# Some libraries we use set the BUILD_SHARED_LIBS variable to ON, which causes CMake to
# display a warning about options being set using set() instead of option().
# Explicitly set the policy to NEW to suppress the warning.
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0141 NEW)
if (POLICY CMP0177)
set(CMAKE_POLICY_DEFAULT_CMP0177 OLD)
cmake_policy(SET CMP0177 OLD)
endif()
function(getTarget target type)
get_target_property(IMPORTED_TARGET ${target} IMPORTED)
if (IMPORTED_TARGET)
set(${type} INTERFACE PARENT_SCOPE)
else()
set(${type} PRIVATE PARENT_SCOPE)
endif()
endfunction()
function(addCFlag)
if (ARGC EQUAL 1)
add_compile_options($<$<COMPILE_LANGUAGE:C>:${ARGV0}>)
elseif (ARGC EQUAL 2)
getTarget(${ARGV1} TYPE)
target_compile_options(${ARGV1} ${TYPE} $<$<COMPILE_LANGUAGE:C>:${ARGV0}>)
endif()
endfunction()
function(addCXXFlag)
if (ARGC EQUAL 1)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${ARGV0}>)
elseif (ARGC EQUAL 2)
getTarget(${ARGV1} TYPE)
target_compile_options(${ARGV1} ${TYPE} $<$<COMPILE_LANGUAGE:CXX>:${ARGV0}>)
endif()
endfunction()
function(addObjCFlag)
if (ARGC EQUAL 1)
add_compile_options($<$<COMPILE_LANGUAGE:OBJC>:${ARGV0}>)
elseif (ARGC EQUAL 2)
getTarget(${ARGV1} TYPE)
target_compile_options(${ARGV1} ${TYPE} $<$<COMPILE_LANGUAGE:OBJC>:${ARGV0}>)
endif()
endfunction()
function(addLinkerFlag)
if (ARGC EQUAL 1)
add_link_options(${ARGV0})
elseif (ARGC EQUAL 2)
getTarget(${ARGV1} TYPE)
target_link_options(${ARGV1} ${TYPE} ${ARGV0})
endif()
endfunction()
function(addCCXXFlag)
addCFlag(${ARGV0} ${ARGV1})
addCXXFlag(${ARGV0} ${ARGV1})
endfunction()
function(addCommonFlag)
addCFlag(${ARGV0} ${ARGV1})
addCXXFlag(${ARGV0} ${ARGV1})
addObjCFlag(${ARGV0} ${ARGV1})
endfunction()
function(addCppCheck target)
if (NOT IMHEX_ENABLE_CPPCHECK)
return()
endif()
find_program(cppcheck_exe NAMES cppcheck REQUIRED)
if (NOT cppcheck_exe)
return()
endif()
set(target_build_dir $<TARGET_FILE_DIR:${target}>)
set(cppcheck_opts
--enable=all
--inline-suppr
--quiet
--std=c++23
--check-level=exhaustive
--error-exitcode=10
--suppressions-list=${CMAKE_SOURCE_DIR}/dist/cppcheck.supp
--checkers-report=${target_build_dir}/cppcheck-report.txt
)
set_target_properties(${target} PROPERTIES
CXX_CPPCHECK "${cppcheck_exe};${cppcheck_opts}"
)
endfunction()
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Disable deprecated warnings" FORCE)
include(FetchContent) include(FetchContent)
if(IMHEX_STRIP_RELEASE) if(IMHEX_STRIP_RELEASE)
@@ -156,9 +59,6 @@ macro(detectOS)
set(CMAKE_INSTALL_LIBDIR ".") set(CMAKE_INSTALL_LIBDIR ".")
set(PLUGINS_INSTALL_LOCATION "plugins") set(PLUGINS_INSTALL_LOCATION "plugins")
add_compile_definitions(WIN32_LEAN_AND_MEAN) add_compile_definitions(WIN32_LEAN_AND_MEAN)
add_compile_definitions(NOMINMAX)
add_compile_definitions(UNICODE)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
elseif (APPLE) elseif (APPLE)
add_compile_definitions(OS_MACOS) add_compile_definitions(OS_MACOS)
set(CMAKE_INSTALL_BINDIR ".") set(CMAKE_INSTALL_BINDIR ".")
@@ -170,16 +70,17 @@ macro(detectOS)
add_compile_definitions(OS_WEB) add_compile_definitions(OS_WEB)
elseif (UNIX AND NOT APPLE) elseif (UNIX AND NOT APPLE)
add_compile_definitions(OS_LINUX) add_compile_definitions(OS_LINUX)
if (BSD AND BSD STREQUAL "FreeBSD")
add_compile_definitions(OS_FREEBSD)
endif()
include(GNUInstallDirs) include(GNUInstallDirs)
set(PLUGINS_INSTALL_LOCATION "${CMAKE_INSTALL_LIBDIR}/imhex/plugins") if(IMHEX_PLUGINS_IN_SHARE)
set(PLUGINS_INSTALL_LOCATION "share/imhex/plugins")
else()
set(PLUGINS_INSTALL_LOCATION "${CMAKE_INSTALL_LIBDIR}/imhex/plugins")
# Add System plugin location for plugins to be loaded from # Add System plugin location for plugins to be loaded from
# IMPORTANT: This does not work for Sandboxed or portable builds such as the Flatpak or AppImage release # IMPORTANT: This does not work for Sandboxed or portable builds such as the Flatpak or AppImage release
add_compile_definitions(SYSTEM_PLUGINS_LOCATION="${CMAKE_INSTALL_FULL_LIBDIR}/imhex") add_compile_definitions(SYSTEM_PLUGINS_LOCATION="${CMAKE_INSTALL_FULL_LIBDIR}/imhex")
endif()
else () else ()
message(FATAL_ERROR "Unknown / unsupported system!") message(FATAL_ERROR "Unknown / unsupported system!")
@@ -188,8 +89,6 @@ macro(detectOS)
endmacro() endmacro()
macro(configurePackingResources) macro(configurePackingResources)
set(LIBRARY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
if (WIN32) if (WIN32)
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug")) if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
set(APPLICATION_TYPE WIN32) set(APPLICATION_TYPE WIN32)
@@ -201,18 +100,11 @@ macro(configurePackingResources)
set(CPACK_GENERATOR "WIX") set(CPACK_GENERATOR "WIX")
set(CPACK_PACKAGE_NAME "ImHex") set(CPACK_PACKAGE_NAME "ImHex")
set(CPACK_PACKAGE_VENDOR "WerWolv") set(CPACK_PACKAGE_VENDOR "WerWolv")
set(CPACK_WIX_VERSION 4)
set(CPACK_WIX_PRODUCT_GUID "*")
set(CPACK_WIX_UPGRADE_GUID "05000E99-9659-42FD-A1CF-05C554B39285") set(CPACK_WIX_UPGRADE_GUID "05000E99-9659-42FD-A1CF-05C554B39285")
set(CPACK_WIX_PRODUCT_ICON "${PROJECT_SOURCE_DIR}/resources/dist/windows/icon.ico") set(CPACK_WIX_PRODUCT_ICON "${PROJECT_SOURCE_DIR}/resources/dist/windows/icon.ico")
set(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_banner.png") set(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_banner.png")
set(CPACK_WIX_UI_DIALOG "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_dialog.png") set(CPACK_WIX_UI_DIALOG "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix_dialog.png")
set(CPACK_WIX_CULTURES "en-US;de-DE;ja-JP;it-IT;pt-BR;zh-CN;zh-TW;ru-RU") set(CPACK_WIX_CULTURES "en-US;de-DE;ja-JP;it-IT;pt-BR;zh-CN;zh-TW")
set(CPACK_WIX_TEMPLATE "${PROJECT_SOURCE_DIR}/resources/dist/windows/WIX.template.in")
set(CPACK_WIX_EXTENSIONS "WixToolset.UI.wixext")
file(GLOB_RECURSE CPACK_WIX_EXTRA_SOURCES "${PROJECT_SOURCE_DIR}/resources/dist/windows/wix/*.wxs")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ImHex") set(CPACK_PACKAGE_INSTALL_DIRECTORY "ImHex")
set_property(INSTALL "$<TARGET_FILE_NAME:main>" set_property(INSTALL "$<TARGET_FILE_NAME:main>"
PROPERTY CPACK_START_MENU_SHORTCUTS "ImHex" PROPERTY CPACK_START_MENU_SHORTCUTS "ImHex"
@@ -221,9 +113,9 @@ macro(configurePackingResources)
endif() endif()
elseif (APPLE OR ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") elseif (APPLE OR ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(IMHEX_ICON "${IMHEX_BASE_FOLDER}/resources/dist/macos/AppIcon.icns") set(IMHEX_ICON "${IMHEX_BASE_FOLDER}/resources/dist/macos/AppIcon.icns")
set(BUNDLE_NAME "ImHex.app") set(BUNDLE_NAME "imhex.app")
if (IMHEX_MACOS_CREATE_BUNDLE) if (IMHEX_GENERATE_PACKAGE)
set(APPLICATION_TYPE MACOSX_BUNDLE) set(APPLICATION_TYPE MACOSX_BUNDLE)
set_source_files_properties(${IMHEX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") set_source_files_properties(${IMHEX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(MACOSX_BUNDLE_ICON_FILE "AppIcon.icns") set(MACOSX_BUNDLE_ICON_FILE "AppIcon.icns")
@@ -239,9 +131,9 @@ macro(configurePackingResources)
string(TIMESTAMP CURR_YEAR "%Y") string(TIMESTAMP CURR_YEAR "%Y")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2020 - ${CURR_YEAR} WerWolv. All rights reserved." ) set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2020 - ${CURR_YEAR} WerWolv. All rights reserved." )
if ("${CMAKE_GENERATOR}" STREQUAL "Xcode") if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
set(IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${BUNDLE_NAME}") set (IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${BUNDLE_NAME}")
else () else ()
set(IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}") set (IMHEX_BUNDLE_PATH "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}")
endif() endif()
set(PLUGINS_INSTALL_LOCATION "${IMHEX_BUNDLE_PATH}/Contents/MacOS/plugins") set(PLUGINS_INSTALL_LOCATION "${IMHEX_BUNDLE_PATH}/Contents/MacOS/plugins")
@@ -250,17 +142,21 @@ macro(configurePackingResources)
endif() endif()
endmacro() endmacro()
macro(addPluginDirectories) macro(createPackage)
set(LIBRARY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
file(MAKE_DIRECTORY "plugins") file(MAKE_DIRECTORY "plugins")
foreach (plugin IN LISTS PLUGINS) foreach (plugin IN LISTS PLUGINS)
add_subdirectory("plugins/${plugin}") add_subdirectory("plugins/${plugin}")
if (TARGET ${plugin}) if (TARGET ${plugin})
set_target_properties(${plugin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins") set_target_properties(${plugin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins") set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
if (APPLE) if (APPLE)
if (IMHEX_MACOS_CREATE_BUNDLE) if (IMHEX_GENERATE_PACKAGE)
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGINS_INSTALL_LOCATION}) set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGINS_INSTALL_LOCATION})
else ()
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
endif () endif ()
else () else ()
if (WIN32) if (WIN32)
@@ -279,9 +175,9 @@ macro(addPluginDirectories)
add_dependencies(imhex_all ${plugin}) add_dependencies(imhex_all ${plugin})
endif () endif ()
endforeach() endforeach()
endmacro()
macro(createPackage) set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if (WIN32) if (WIN32)
# Install binaries directly in the prefix, usually C:\Program Files\ImHex. # Install binaries directly in the prefix, usually C:\Program Files\ImHex.
set(CMAKE_INSTALL_BINDIR ".") set(CMAKE_INSTALL_BINDIR ".")
@@ -291,17 +187,6 @@ macro(createPackage)
list(APPEND PLUGIN_TARGET_FILES "$<TARGET_FILE:${plugin}>") list(APPEND PLUGIN_TARGET_FILES "$<TARGET_FILE:${plugin}>")
endforeach () endforeach ()
if (DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_DEPS_FOLDER "")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(VCPKG_DEPS_FOLDER "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/debug/bin")
else()
set(VCPKG_DEPS_FOLDER "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/bin")
endif()
install(CODE "set(VCPKG_DEPS_FOLDER \"${VCPKG_DEPS_FOLDER}\")")
endif()
# Grab all dynamically linked dependencies. # Grab all dynamically linked dependencies.
install(CODE "set(CMAKE_INSTALL_BINDIR \"${CMAKE_INSTALL_BINDIR}\")") install(CODE "set(CMAKE_INSTALL_BINDIR \"${CMAKE_INSTALL_BINDIR}\")")
install(CODE "set(PLUGIN_TARGET_FILES \"${PLUGIN_TARGET_FILES}\")") install(CODE "set(PLUGIN_TARGET_FILES \"${PLUGIN_TARGET_FILES}\")")
@@ -315,15 +200,10 @@ macro(createPackage)
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" POST_EXCLUDE_REGEXES ".*system32/.*\\.dll"
) )
if(_c_deps_FILENAMES AND _c_deps AND NOT (_c_deps STREQUAL "")) if(_c_deps_FILENAMES)
message(WARNING "Conflicting dependencies for library: \"${_c_deps}\"!") message(WARNING "Conflicting dependencies for library: \"${_c_deps}\"!")
endif() endif()
if (DEFINED VCPKG_DEPS_FOLDER)
file(GLOB VCPKG_DEPS "${VCPKG_DEPS_FOLDER}/*.dll")
list(APPEND _r_deps ${VCPKG_DEPS})
endif()
foreach(_file ${_r_deps}) foreach(_file ${_r_deps})
file(INSTALL file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}"
@@ -334,49 +214,49 @@ macro(createPackage)
endforeach() endforeach()
]]) ]])
downloadImHexPatternsFiles(".") install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}" PERMISSIONS ${LIBRARY_PERMISSIONS})
downloadImHexPatternsFiles("./")
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION}) set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
configure_file(${IMHEX_BASE_FOLDER}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dist/DEBIAN/control.in ${CMAKE_BINARY_DIR}/DEBIAN/control)
install(FILES ${IMHEX_BASE_FOLDER}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_PREFIX}/share/licenses/imhex)
install(FILES ${IMHEX_BASE_FOLDER}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dist/imhex.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
install(FILES ${IMHEX_BASE_FOLDER}/dist/imhex.mime.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mime/packages RENAME imhex.xml) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/icon.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.png)
install(FILES ${IMHEX_BASE_FOLDER}/resources/icon.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps RENAME imhex.svg) install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}" PERMISSIONS ${LIBRARY_PERMISSIONS})
downloadImHexPatternsFiles("./share/imhex") downloadImHexPatternsFiles("./share/imhex")
# install AppStream file # install AppStream file
install(FILES ${IMHEX_BASE_FOLDER}/dist/net.werwolv.ImHex.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dist/net.werwolv.imhex.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo)
# install symlink for the old standard name
file(CREATE_LINK net.werwolv.imhex.metainfo.xml ${CMAKE_CURRENT_BINARY_DIR}/net.werwolv.imhex.appdata.xml SYMBOLIC)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/net.werwolv.imhex.appdata.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo)
endif() endif()
if (APPLE) if (APPLE)
if (IMHEX_MACOS_CREATE_BUNDLE) if (IMHEX_GENERATE_PACKAGE)
set(EXTRA_BUNDLE_LIBRARY_PATHS ${EXTRA_BUNDLE_LIBRARY_PATHS} "${IMHEX_SYSTEM_LIBRARY_PATH}")
include(PostprocessBundle) include(PostprocessBundle)
set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION}) set_target_properties(libimhex PROPERTIES SOVERSION ${IMHEX_VERSION})
set_property(TARGET main PROPERTY MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_INFO_PLIST}) set_property(TARGET main PROPERTY MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_INFO_PLIST})
set_property(TARGET main PROPERTY MACOSX_BUNDLE_BUNDLE_NAME "${MACOSX_BUNDLE_BUNDLE_NAME}")
# Fix rpath # Fix rpath
install(CODE "execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" $<TARGET_FILE:main>)") add_custom_command(TARGET imhex_all POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" $<TARGET_FILE:main> || true)
install(CODE "execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" $<TARGET_FILE:updater>)")
downloadImHexPatternsFiles("${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/MacOS") add_custom_target(build-time-make-plugins-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${IMHEX_BUNDLE_PATH}/Contents/MacOS/plugins")
add_custom_target(build-time-make-resources-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${IMHEX_BUNDLE_PATH}/Contents/Resources")
downloadImHexPatternsFiles("${IMHEX_BUNDLE_PATH}/Contents/MacOS")
install(FILES ${IMHEX_ICON} DESTINATION "${IMHEX_BUNDLE_PATH}/Contents/Resources")
install(TARGETS main BUNDLE DESTINATION ".") install(TARGETS main BUNDLE DESTINATION ".")
install(TARGETS updater DESTINATION "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/MacOS") install(FILES $<TARGET_FILE:main> DESTINATION "${IMHEX_BUNDLE_PATH}")
install( install(FILES $<TARGET_FILE:updater> DESTINATION "${IMHEX_BUNDLE_PATH}")
FILES ${IMHEX_BASE_FOLDER}/dist/cli/imhex.sh
DESTINATION "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/MacOS/cli"
RENAME imhex
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
# Update library references to make the bundle portable # Update library references to make the bundle portable
postprocess_bundle(imhex_all main) postprocess_bundle(imhex_all main)
@@ -385,19 +265,15 @@ macro(createPackage)
set(CPACK_GENERATOR "DragNDrop") set(CPACK_GENERATOR "DragNDrop")
set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/resources/dist/macos/AppIcon.icns") set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/resources/dist/macos/AppIcon.icns")
set(CPACK_BUNDLE_PLIST "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/Info.plist") set(CPACK_BUNDLE_PLIST "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}/Contents/Info.plist")
if (IMHEX_RESIGN_BUNDLE) if (IMHEX_RESIGN_BUNDLE)
message(STATUS "Resigning bundle...")
find_program(CODESIGN_PATH codesign) find_program(CODESIGN_PATH codesign)
if (CODESIGN_PATH) if (CODESIGN_PATH)
install(CODE "message(STATUS \"Signing bundle '${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}'...\")") add_custom_command(TARGET imhex_all POST_BUILD COMMAND "codesign" ARGS "--force" "--deep" "--sign" "-" "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}")
install(CODE "execute_process(COMMAND ${CODESIGN_PATH} --force --deep --entitlements ${CMAKE_SOURCE_DIR}/resources/macos/Entitlements.plist --sign - ${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME} COMMAND_ERROR_IS_FATAL ANY)")
endif() endif()
endif() endif()
install(CODE [[ message(STATUS "MacOS Bundle finalized. DO NOT TOUCH IT ANYMORE! ANY MODIFICATIONS WILL BREAK IT FROM NOW ON!") ]])
else()
downloadImHexPatternsFiles("${IMHEX_MAIN_OUTPUT_DIRECTORY}")
endif() endif()
else() else()
install(TARGETS main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
@@ -407,31 +283,9 @@ macro(createPackage)
if (TARGET main-forwarder) if (TARGET main-forwarder)
install(TARGETS main-forwarder BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS main-forwarder BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR})
endif() endif()
if (WIN32)
install(
FILES ${IMHEX_BASE_FOLDER}/dist/cli/imhex.bat
DESTINATION ${CMAKE_INSTALL_BINDIR}/cli
RENAME imhex.bat
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
else()
install(
FILES ${IMHEX_BASE_FOLDER}/dist/cli/imhex.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/imhex
RENAME imhex
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()
endif() endif()
if (IMHEX_MACOS_CREATE_BUNDLE) if (IMHEX_GENERATE_PACKAGE)
set(CPACK_BUNDLE_NAME "ImHex") set(CPACK_BUNDLE_NAME "ImHex")
include(CPack) include(CPack)
@@ -451,14 +305,11 @@ endfunction()
macro(configureCMake) macro(configureCMake)
message(STATUS "Configuring ImHex v${IMHEX_VERSION}") message(STATUS "Configuring ImHex v${IMHEX_VERSION}")
if (DEFINED CMAKE_TOOLCHAIN_FILE) # Enable C and C++ languages
message(STATUS "Using toolchain file: \"${CMAKE_TOOLCHAIN_FILE}\"") enable_language(C CXX)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Enable position independent code for all targets" FORCE) set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Enable position independent code for all targets" FORCE)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
# Configure use of recommended build tools # Configure use of recommended build tools
if (IMHEX_USE_DEFAULT_BUILD_SETTINGS) if (IMHEX_USE_DEFAULT_BUILD_SETTINGS)
message(STATUS "Configuring CMake to use recommended build tools...") message(STATUS "Configuring CMake to use recommended build tools...")
@@ -490,11 +341,8 @@ macro(configureCMake)
if (LD_LLD_PATH) if (LD_LLD_PATH)
set(CMAKE_LINKER ${LD_LLD_PATH}) set(CMAKE_LINKER ${LD_LLD_PATH})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld")
if (NOT XCODE AND NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld")
add_link_options("-fuse-ld=lld")
add_link_options("-fuse-ld=lld")
endif()
else () else ()
message(WARNING "lld not found, using default linker!") message(WARNING "lld not found, using default linker!")
endif () endif ()
@@ -505,32 +353,29 @@ macro(configureCMake)
message(WARNING "ninja not found, using default generator!") message(WARNING "ninja not found, using default generator!")
endif () endif ()
endif() endif()
endmacro()
function(configureProject)
# Enable C and C++ languages
enable_language(C CXX)
if (XCODE)
# Support Xcode's multi configuration paradigm by placing built artifacts into separate directories
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Configs/$<CONFIG>" PARENT_SCOPE)
else()
set(IMHEX_MAIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" PARENT_SCOPE)
endif()
# Enable LTO if desired and supported # Enable LTO if desired and supported
if (IMHEX_ENABLE_LTO) if (IMHEX_ENABLE_LTO)
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output_error) check_ipo_supported(RESULT result OUTPUT output_error)
if (result OR WIN32) if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION $<$<CONFIG:Release,RelWithDebInfo,MinSizeRel>:ON>) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "LTO enabled!") message(STATUS "LTO enabled!")
else () else ()
message(WARNING "LTO is not supported: ${output_error}") message(WARNING "LTO is not supported: ${output_error}")
endif () endif ()
endif () endif ()
endfunction()
# Some libraries we use set the BUILD_SHARED_LIBS variable to ON, which causes CMake to
# display a warning about options being set using set() instead of option().
# Explicitly set the policy to NEW to suppress the warning.
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Disable deprecated warnings" FORCE)
endmacro()
macro(setDefaultBuiltTypeIfUnset) macro(setDefaultBuiltTypeIfUnset)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@@ -539,18 +384,12 @@ macro(setDefaultBuiltTypeIfUnset)
endif() endif()
endmacro() endmacro()
function(loadVersion version plain_version) function(loadVersion version)
set(VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/VERSION") set(VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${VERSION_FILE}) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${VERSION_FILE})
file(READ "${VERSION_FILE}" read_version) file(READ "${VERSION_FILE}" read_version)
string(STRIP ${read_version} read_version) string(STRIP ${read_version} read_version)
string(REPLACE ".WIP" "" read_version_plain ${read_version})
set(${version} ${read_version} PARENT_SCOPE) set(${version} ${read_version} PARENT_SCOPE)
set(${plain_version} ${read_version_plain} PARENT_SCOPE)
if (read_version MATCHES ".+\.WIP")
set(IMHEX_PATTERNS_PULL_MASTER ON PARENT_SCOPE)
endif()
endfunction() endfunction()
function(detectBadClone) function(detectBadClone)
@@ -560,9 +399,6 @@ function(detectBadClone)
file (GLOB EXTERNAL_DIRS "lib/external/*" "lib/third_party/*") file (GLOB EXTERNAL_DIRS "lib/external/*" "lib/third_party/*")
foreach (EXTERNAL_DIR ${EXTERNAL_DIRS}) foreach (EXTERNAL_DIR ${EXTERNAL_DIRS})
if(NOT IS_DIRECTORY "${EXTERNAL_DIR}")
continue()
endif()
file(GLOB_RECURSE RESULT "${EXTERNAL_DIR}/*") file(GLOB_RECURSE RESULT "${EXTERNAL_DIR}/*")
list(LENGTH RESULT ENTRY_COUNT) list(LENGTH RESULT ENTRY_COUNT)
if(ENTRY_COUNT LESS_EQUAL 1) if(ENTRY_COUNT LESS_EQUAL 1)
@@ -580,8 +416,6 @@ function(verifyCompiler)
message(FATAL_ERROR "ImHex requires GCC 12.0.0 or newer. Please use the latest GCC version.") message(FATAL_ERROR "ImHex requires GCC 12.0.0 or newer. Please use the latest GCC version.")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0")
message(FATAL_ERROR "ImHex requires Clang 17.0.0 or newer. Please use the latest Clang version.") message(FATAL_ERROR "ImHex requires Clang 17.0.0 or newer. Please use the latest Clang version.")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) elseif (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
message(FATAL_ERROR "ImHex can only be compiled with GCC or Clang. ${CMAKE_CXX_COMPILER_ID} is not supported.") message(FATAL_ERROR "ImHex can only be compiled with GCC or Clang. ${CMAKE_CXX_COMPILER_ID} is not supported.")
endif() endif()
@@ -590,9 +424,7 @@ endfunction()
macro(detectBundledPlugins) macro(detectBundledPlugins)
file(GLOB PLUGINS_DIRS "plugins/*") file(GLOB PLUGINS_DIRS "plugins/*")
if (IMHEX_INCLUDE_PLUGINS) if (NOT DEFINED IMHEX_INCLUDE_PLUGINS)
set(PLUGINS ${IMHEX_INCLUDE_PLUGINS})
else()
foreach(PLUGIN_DIR ${PLUGINS_DIRS}) foreach(PLUGIN_DIR ${PLUGINS_DIRS})
if (EXISTS "${PLUGIN_DIR}/CMakeLists.txt") if (EXISTS "${PLUGIN_DIR}/CMakeLists.txt")
get_filename_component(PLUGIN_NAME ${PLUGIN_DIR} NAME) get_filename_component(PLUGIN_NAME ${PLUGIN_DIR} NAME)
@@ -601,6 +433,8 @@ macro(detectBundledPlugins)
endif () endif ()
endif() endif()
endforeach() endforeach()
else()
set(PLUGINS ${IMHEX_INCLUDE_PLUGINS})
endif() endif()
foreach(PLUGIN_NAME ${PLUGINS}) foreach(PLUGIN_NAME ${PLUGINS})
@@ -611,13 +445,9 @@ macro(detectBundledPlugins)
message(FATAL_ERROR "No bundled plugins enabled") message(FATAL_ERROR "No bundled plugins enabled")
endif() endif()
set(REQUIRED_PLUGINS builtin fonts ui) if (NOT ("builtin" IN_LIST PLUGINS))
foreach(PLUGIN ${REQUIRED_PLUGINS}) message(FATAL_ERROR "The 'builtin' plugin is required for ImHex to work!")
list(FIND PLUGINS ${PLUGIN} PLUGIN_INDEX) endif ()
if (PLUGIN_INDEX EQUAL -1)
message(FATAL_ERROR "Required plugin '${PLUGIN}' is not enabled!")
endif()
endforeach()
endmacro() endmacro()
macro(setVariableInParent variable value) macro(setVariableInParent variable value)
@@ -638,202 +468,68 @@ function(downloadImHexPatternsFiles dest)
set(PATTERNS_BRANCH ImHex-v${IMHEX_VERSION}) set(PATTERNS_BRANCH ImHex-v${IMHEX_VERSION})
endif () endif ()
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/ImHex-Patterns") FetchContent_Declare(
install(CODE "set(PATTERNS_BRANCH \"${PATTERNS_BRANCH}\")") imhex_patterns
install(CODE "set(imhex_patterns_SOURCE_DIR \"${imhex_patterns_SOURCE_DIR}\")") GIT_REPOSITORY https://github.com/WerWolv/ImHex-Patterns.git
install(CODE [[ GIT_TAG origin/master
message(STATUS "Downloading ImHex patterns from branch '${PATTERNS_BRANCH}'...") )
if (NOT EXISTS "${imhex_patterns_SOURCE_DIR}")
file(MAKE_DIRECTORY "${imhex_patterns_SOURCE_DIR}") message(STATUS "Downloading ImHex-Patterns repo branch ${PATTERNS_BRANCH}...")
FetchContent_MakeAvailable(imhex_patterns)
execute_process( message(STATUS "Finished downloading ImHex-Patterns")
COMMAND
git clone --recurse-submodules --branch ${PATTERNS_BRANCH} https://github.com/WerWolv/ImHex-Patterns.git "${imhex_patterns_SOURCE_DIR}"
COMMAND_ERROR_IS_FATAL ANY
)
endif()
]])
else () else ()
set(imhex_patterns_SOURCE_DIR "")
# Maybe patterns are cloned to a subdirectory # Maybe patterns are cloned to a subdirectory
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR}) set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
endif()
# Or a sibling directory
if (NOT EXISTS ${imhex_patterns_SOURCE_DIR})
set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ImHex-Patterns")
endif()
endif () endif ()
install(CODE "set(imhex_patterns_SOURCE_DIR \"${imhex_patterns_SOURCE_DIR}\")") if (EXISTS ${imhex_patterns_SOURCE_DIR})
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns magic nodes)
if(XCODE) foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
install(CODE [[ install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION ${dest} PATTERN "**/_schema.json" EXCLUDE)
# The Xcode build has multiple configurations, which each need a copy of these files endforeach ()
file(GLOB_RECURSE sourceFilePaths LIST_DIRECTORIES NO CONFIGURE_DEPENDS RELATIVE "${imhex_patterns_SOURCE_DIR}"
"${imhex_patterns_SOURCE_DIR}/constants/*"
"${imhex_patterns_SOURCE_DIR}/encodings/*"
"${imhex_patterns_SOURCE_DIR}/includes/*"
"${imhex_patterns_SOURCE_DIR}/patterns/*"
"${imhex_patterns_SOURCE_DIR}/magic/*"
"${imhex_patterns_SOURCE_DIR}/nodes/*"
)
list(FILTER sourceFilePaths EXCLUDE REGEX "_schema.json$")
foreach(relativePath IN LISTS sourceFilePaths)
file(GENERATE OUTPUT "${dest}/${relativePath}" INPUT "${imhex_patterns_SOURCE_DIR}/${relativePath}")
endforeach()
]])
else()
if (NOT (imhex_patterns_SOURCE_DIR STREQUAL ""))
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns magic nodes)
foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "${dest}" PATTERN "**/_schema.json" EXCLUDE)
endforeach ()
endif()
endif () endif ()
endfunction() endfunction()
# Compress debug info. See https://github.com/WerWolv/ImHex/issues/1714 for relevant problem
macro(setupDebugCompressionFlag)
include(CheckCXXCompilerFlag)
include(CheckLinkerFlag)
check_cxx_compiler_flag(-gz=zstd ZSTD_AVAILABLE_COMPILER)
check_linker_flag(CXX -gz=zstd ZSTD_AVAILABLE_LINKER)
check_cxx_compiler_flag(-gz COMPRESS_AVAILABLE_COMPILER)
check_linker_flag(CXX -gz COMPRESS_AVAILABLE_LINKER)
if (NOT DEBUG_COMPRESSION_FLAG) # Cache variable
if (ZSTD_AVAILABLE_COMPILER AND ZSTD_AVAILABLE_LINKER)
message("Using Zstd compression for debug info because both compiler and linker support it")
set(DEBUG_COMPRESSION_FLAG "-gz=zstd" CACHE STRING "Cache to use for debug info compression")
elseif (COMPRESS_AVAILABLE_COMPILER AND COMPRESS_AVAILABLE_LINKER)
message("Using default compression for debug info because both compiler and linker support it")
set(DEBUG_COMPRESSION_FLAG "-gz" CACHE STRING "Cache to use for debug info compression")
else()
set(DEBUG_COMPRESSION_FLAG "" CACHE STRING "Cache to use for debug info compression")
endif()
endif()
addCommonFlag(${DEBUG_COMPRESSION_FLAG})
endmacro()
macro(setupCompilerFlags target) macro(setupCompilerFlags target)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
addCommonFlag("/W4" ${target})
addCommonFlag("/wd4127" ${target}) # conditional expression is constant
addCommonFlag("/wd4242" ${target}) # 'identifier': conversion from 'type1' to 'type2', possible loss of data
addCommonFlag("/wd4244" ${target}) # 'conversion': conversion from 'type1' to 'type2', possible loss of data
addCommonFlag("/wd4267" ${target}) # 'var': conversion from 'size_t' to 'type', possible loss of data
addCommonFlag("/wd4305" ${target}) # truncation from 'double' to 'float'
addCommonFlag("/wd4996" ${target}) # 'function': was declared deprecated
addCommonFlag("/wd5244" ${target}) # 'include' in the purview of module 'module' appears erroneous
if (IMHEX_STRICT_WARNINGS)
addCommonFlag("/WX" ${target})
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
addCommonFlag("-Wall" ${target})
addCommonFlag("-Wextra" ${target})
addCommonFlag("-Wpedantic" ${target})
# Define strict compilation flags # Define strict compilation flags
if (IMHEX_STRICT_WARNINGS) if (IMHEX_STRICT_WARNINGS)
addCommonFlag("-Werror" ${target}) set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -Wall -Wextra -Wpedantic -Werror")
endif() endif()
if (UNIX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") if (UNIX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
addCommonFlag("-rdynamic" ${target}) set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -rdynamic")
endif() endif()
addCXXFlag("-fexceptions" ${target}) set(IMHEX_CXX_FLAGS "-fexceptions -frtti")
addCXXFlag("-frtti" ${target})
addCommonFlag("-fno-omit-frame-pointer" ${target})
# Disable some warnings # Disable some warnings
addCCXXFlag("-Wno-array-bounds" ${target}) set(IMHEX_C_CXX_FLAGS "-Wno-unknown-warning-option -Wno-array-bounds -Wno-deprecated-declarations -Wno-unknown-pragmas")
addCCXXFlag("-Wno-deprecated-declarations" ${target})
addCCXXFlag("-Wno-unknown-pragmas" ${target})
addCXXFlag("-Wno-include-angled-in-module-purview" ${target})
# Enable hardening flags
if (IMHEX_BUILD_HARDENING)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
addCommonFlag("-U_FORTIFY_SOURCE" ${target})
addCommonFlag("-D_FORTIFY_SOURCE=3" ${target})
if (NOT EMSCRIPTEN)
addCommonFlag("-fstack-protector-strong" ${target})
endif()
endif()
endif()
endif() endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (WIN32) if (IMHEX_ENABLE_UNITY_BUILD AND WIN32)
addLinkerFlag("-Wa,mbig-obj" ${target}) set(IMHEX_COMMON_FLAGS "${IMHEX_COMMON_FLAGS} -Wa,-mbig-obj")
endif () endif ()
endif() endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND APPLE)
addCCXXFlag("-Wno-unknown-warning-option" ${target})
# On macOS, when using clang from Homebrew, properly setup the libc++ library path so
# it's using the one from Homebrew instead of the system one.
execute_process(COMMAND brew --prefix llvm OUTPUT_VARIABLE LLVM_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT LLVM_PREFIX STREQUAL "" AND ${CMAKE_CXX_COMPILER} STREQUAL "${LLVM_PREFIX}/bin/clang++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${LLVM_PREFIX}/lib/c++")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
addCommonFlag("/bigobj" ${target})
addCFlag("/std:clatest" ${target})
addCXXFlag("/std:c++latest" ${target})
endif()
# Disable some warnings for gcc # Disable some warnings for gcc
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
addCCXXFlag("-Wno-restrict" ${target}) set(IMHEX_C_CXX_FLAGS "${IMHEX_C_CXX_FLAGS} -Wno-restrict -Wno-stringop-overread -Wno-stringop-overflow -Wno-dangling-reference")
addCCXXFlag("-Wno-stringop-overread" ${target})
addCCXXFlag("-Wno-stringop-overflow" ${target})
addCCXXFlag("-Wno-dangling-reference" ${target})
endif() endif()
# Define emscripten-specific disabled warnings # Define emscripten-specific disabled warnings
if (EMSCRIPTEN) if (EMSCRIPTEN)
addCCXXFlag("-pthread" ${target}) set(IMHEX_C_CXX_FLAGS "${IMHEX_C_CXX_FLAGS} -pthread -Wno-dollar-in-identifier-extension -Wno-pthreads-mem-growth")
addCCXXFlag("-Wno-dollar-in-identifier-extension" ${target})
addCCXXFlag("-Wno-pthreads-mem-growth" ${target})
endif () endif ()
if (IMHEX_COMPRESS_DEBUG_INFO) # Set actual CMake flags
setupDebugCompressionFlag() set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${IMHEX_COMMON_FLAGS} ${IMHEX_C_CXX_FLAGS}")
endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${IMHEX_COMMON_FLAGS} ${IMHEX_C_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${IMHEX_COMMON_FLAGS} ${IMHEX_C_CXX_FLAGS} ${IMHEX_CXX_FLAGS}")
# Only generate minimal debug information for stacktraces in RelWithDebInfo builds set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} ${IMHEX_COMMON_FLAGS}")
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
addCCXXFlag("-g1" ${target})
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Add flags for debug info in inline functions
addCCXXFlag("-gstatement-frontiers" ${target})
addCCXXFlag("-ginline-points" ${target})
endif()
endif()
endmacro() endmacro()
# uninstall target # uninstall target
@@ -850,16 +546,11 @@ macro(setUninstallTarget)
endmacro() endmacro()
macro(addBundledLibraries) macro(addBundledLibraries)
# Make sure the build is using vcpkg on Windows and Emscripten, otherwise none of these dependencies will be found
if (MSVC OR EMSCRIPTEN)
if (NOT (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg"))
message(AUTHOR_WARNING "Your current environment probably needs to be setup to use vcpkg, otherwise none of the dependencies will be found!")
endif()
endif()
set(EXTERNAL_LIBS_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/lib/external") set(EXTERNAL_LIBS_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/lib/external")
set(THIRD_PARTY_LIBS_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/lib/third_party") set(THIRD_PARTY_LIBS_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/lib/third_party")
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/imgui)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/microtar EXCLUDE_FROM_ALL) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/microtar EXCLUDE_FROM_ALL)
@@ -869,7 +560,6 @@ macro(addBundledLibraries)
set(FPHSA_NAME_MISMATCHED ON CACHE BOOL "") set(FPHSA_NAME_MISMATCHED ON CACHE BOOL "")
if(NOT USE_SYSTEM_FMT) if(NOT USE_SYSTEM_FMT)
set(FMT_INSTALL OFF CACHE BOOL "Disable install targets for libfmt" FORCE)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/fmt EXCLUDE_FROM_ALL) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/fmt EXCLUDE_FROM_ALL)
set(FMT_LIBRARIES fmt::fmt-header-only) set(FMT_LIBRARIES fmt::fmt-header-only)
else() else()
@@ -905,48 +595,34 @@ macro(addBundledLibraries)
set(NLOHMANN_JSON_LIBRARIES nlohmann_json::nlohmann_json) set(NLOHMANN_JSON_LIBRARIES nlohmann_json::nlohmann_json)
endif() endif()
if (NOT USE_SYSTEM_LUNASVG)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/lunasvg EXCLUDE_FROM_ALL)
set(LUNASVG_LIBRARIES lunasvg)
else()
find_package(lunasvg REQUIRED)
set(LUNASVG_LIBRARIES lunasvg::lunasvg)
endif()
if (NOT USE_SYSTEM_MD4C)
set(BUILD_MD2HTML_EXECUTABLE OFF CACHE BOOL "Disable md2html executable" FORCE)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/md4c EXCLUDE_FROM_ALL)
add_library(md4c_lib INTERFACE)
add_library(md4c::md4c ALIAS md4c_lib)
target_include_directories(md4c_lib INTERFACE ${THIRD_PARTY_LIBS_FOLDER}/md4c/src)
target_link_libraries(md4c_lib INTERFACE md4c)
else()
find_package(md4c REQUIRED)
endif()
if (NOT USE_SYSTEM_LLVM) if (NOT USE_SYSTEM_LLVM)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/llvm-demangle EXCLUDE_FROM_ALL) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/llvm-demangle EXCLUDE_FROM_ALL)
else() else()
find_package(LLVM REQUIRED Demangle) find_package(LLVM REQUIRED Demangle)
endif() endif()
if (USE_SYSTEM_BOOST) if (NOT USE_SYSTEM_JTHREAD)
find_package(Boost REQUIRED CONFIG COMPONENTS regex) add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/jthread EXCLUDE_FROM_ALL)
set(BOOST_LIBRARIES Boost::regex) set(JTHREAD_LIBRARIES jthread)
else() else()
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/boost ${CMAKE_CURRENT_BINARY_DIR}/boost EXCLUDE_FROM_ALL) find_path(JOSUTTIS_JTHREAD_INCLUDE_DIRS "condition_variable_any2.hpp")
set(BOOST_LIBRARIES boost::regex) include_directories(${JOSUTTIS_JTHREAD_INCLUDE_DIRS})
add_library(jthread INTERFACE)
target_include_directories(jthread INTERFACE ${JOSUTTIS_JTHREAD_INCLUDE_DIRS})
set(JTHREAD_LIBRARIES jthread)
endif() endif()
set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF CACHE BOOL "" FORCE) set(LIBPL_BUILD_CLI_AS_EXECUTABLE OFF CACHE BOOL "" FORCE)
set(LIBPL_ENABLE_PRECOMPILED_HEADERS ${IMHEX_ENABLE_PRECOMPILED_HEADERS} CACHE BOOL "" FORCE) set(LIBPL_ENABLE_PRECOMPILED_HEADERS ${IMHEX_ENABLE_PRECOMPILED_HEADERS} CACHE BOOL "" FORCE)
set(LIBPL_SHARED_LIBRARY OFF CACHE BOOL "" FORCE) if (WIN32)
set(LIBPL_SHARED_LIBRARY ON CACHE BOOL "" FORCE)
else()
set(LIBPL_SHARED_LIBRARY OFF CACHE BOOL "" FORCE)
endif()
add_subdirectory(${EXTERNAL_LIBS_FOLDER}/pattern_language EXCLUDE_FROM_ALL) add_subdirectory(${EXTERNAL_LIBS_FOLDER}/pattern_language EXCLUDE_FROM_ALL)
add_subdirectory(${EXTERNAL_LIBS_FOLDER}/disassembler EXCLUDE_FROM_ALL)
add_subdirectory(${THIRD_PARTY_LIBS_FOLDER}/imgui)
if (LIBPL_SHARED_LIBRARY) if (LIBPL_SHARED_LIBRARY)
install( install(
@@ -971,6 +647,30 @@ macro(addBundledLibraries)
find_package(mbedTLS 3.4.0 REQUIRED) find_package(mbedTLS 3.4.0 REQUIRED)
find_package(Magic 5.39 REQUIRED) find_package(Magic 5.39 REQUIRED)
if (NOT IMHEX_DISABLE_STACKTRACE)
if (WIN32)
message(STATUS "StackWalk enabled!")
set(LIBBACKTRACE_LIBRARIES DbgHelp.lib)
else ()
find_package(Backtrace)
if (${Backtrace_FOUND})
message(STATUS "Backtrace enabled! Header: ${Backtrace_HEADER}")
if (Backtrace_HEADER STREQUAL "execinfo.h")
set(LIBBACKTRACE_LIBRARIES ${Backtrace_LIBRARY})
set(LIBBACKTRACE_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
add_compile_definitions(BACKTRACE_HEADER=\"${Backtrace_HEADER}\")
add_compile_definitions(HEX_HAS_EXECINFO)
elseif (Backtrace_HEADER STREQUAL "backtrace.h")
set(LIBBACKTRACE_LIBRARIES ${Backtrace_LIBRARY})
set(LIBBACKTRACE_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})
add_compile_definitions(BACKTRACE_HEADER=\"${Backtrace_HEADER}\")
add_compile_definitions(HEX_HAS_BACKTRACE)
endif ()
endif()
endif ()
endif ()
endmacro() endmacro()
function(enableUnityBuild TARGET) function(enableUnityBuild TARGET)
@@ -979,22 +679,71 @@ function(enableUnityBuild TARGET)
endif () endif ()
endfunction() endfunction()
function(setSDKPaths) function(generatePDBs)
if (WIN32) if (NOT IMHEX_GENERATE_PDBS)
set(SDK_PATH "./sdk" PARENT_SCOPE) return()
elseif (APPLE) endif ()
set(SDK_PATH "${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME}/Contents/Resources/sdk" PARENT_SCOPE)
else() if (NOT WIN32 OR CMAKE_BUILD_TYPE STREQUAL "Debug")
set(SDK_PATH "share/imhex/sdk" PARENT_SCOPE) return()
endif() endif ()
include(FetchContent)
FetchContent_Declare(
cv2pdb
URL "https://github.com/rainers/cv2pdb/releases/download/v0.52/cv2pdb-0.52.zip"
DOWNLOAD_EXTRACT_TIMESTAMP ON
)
FetchContent_Populate(cv2pdb)
set(PDBS_TO_GENERATE main main-forwarder libimhex ${PLUGINS})
foreach (PDB ${PDBS_TO_GENERATE})
if (PDB STREQUAL "main")
set(GENERATED_PDB imhex)
elseif (PDB STREQUAL "main-forwarder")
set(GENERATED_PDB imhex-gui)
elseif (PDB STREQUAL "libimhex")
set(GENERATED_PDB libimhex)
else ()
set(GENERATED_PDB plugins/${PDB})
endif ()
if (IMHEX_REPLACE_DWARF_WITH_PDB)
set(PDB_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${GENERATED_PDB})
else ()
set(PDB_OUTPUT_PATH)
endif()
add_custom_target(${PDB}_pdb DEPENDS ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.pdb)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.pdb
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND
(
${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.pdb &&
${cv2pdb_SOURCE_DIR}/cv2pdb64.exe $<TARGET_FILE:${PDB}> ${PDB_OUTPUT_PATH} &&
${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/${GENERATED_PDB}
) || (exit 0)
COMMAND_EXPAND_LISTS)
install(FILES ${CMAKE_BINARY_DIR}/${GENERATED_PDB}.pdb DESTINATION ".")
add_dependencies(imhex_all ${PDB}_pdb)
endforeach ()
set(SDK_BUILD_PATH "${CMAKE_BINARY_DIR}/sdk" PARENT_SCOPE)
endfunction() endfunction()
function(generateSDKDirectory) function(generateSDKDirectory)
setSDKPaths() if (WIN32)
set(SDK_PATH "./sdk")
elseif (APPLE)
set(SDK_PATH "${BUNDLE_NAME}/Contents/Resources/sdk")
else()
set(SDK_PATH "share/imhex/sdk")
endif()
set(SDK_BUILD_PATH "${CMAKE_BINARY_DIR}/sdk")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/libimhex DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE) install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/libimhex DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/trace DESTINATION "${SDK_PATH}/lib" PATTERN "**/source/*" EXCLUDE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/external DESTINATION "${SDK_PATH}/lib") install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/external DESTINATION "${SDK_PATH}/lib")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/imgui DESTINATION "${SDK_PATH}/lib/third_party" PATTERN "**/source/*" EXCLUDE) install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/imgui DESTINATION "${SDK_PATH}/lib/third_party" PATTERN "**/source/*" EXCLUDE)
if (NOT USE_SYSTEM_FMT) if (NOT USE_SYSTEM_FMT)
@@ -1003,27 +752,11 @@ function(generateSDKDirectory)
if (NOT USE_SYSTEM_NLOHMANN_JSON) if (NOT USE_SYSTEM_NLOHMANN_JSON)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/nlohmann_json DESTINATION "${SDK_PATH}/lib/third_party") install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/nlohmann_json DESTINATION "${SDK_PATH}/lib/third_party")
endif() endif()
if (NOT USE_SYSTEM_BOOST)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/third_party/boost DESTINATION "${SDK_PATH}/lib/third_party")
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/modules DESTINATION "${SDK_PATH}/cmake") install(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/modules DESTINATION "${SDK_PATH}/cmake")
install(FILES ${CMAKE_SOURCE_DIR}/cmake/build_helpers.cmake DESTINATION "${SDK_PATH}/cmake") install(FILES ${CMAKE_SOURCE_DIR}/cmake/build_helpers.cmake DESTINATION "${SDK_PATH}/cmake")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/sdk/ DESTINATION "${SDK_PATH}") install(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/sdk/ DESTINATION "${SDK_PATH}")
install(TARGETS libimhex ARCHIVE DESTINATION "${SDK_PATH}/lib") install(TARGETS libimhex ARCHIVE DESTINATION "${SDK_PATH}/lib")
install(TARGETS tracing ARCHIVE DESTINATION "${SDK_PATH}/lib")
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/ui/include DESTINATION "${SDK_PATH}/lib/ui/include")
install(FILES ${CMAKE_SOURCE_DIR}/plugins/ui/CMakeLists.txt DESTINATION "${SDK_PATH}/lib/ui/")
if (WIN32)
install(TARGETS ui ARCHIVE DESTINATION "${SDK_PATH}/lib")
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins/fonts/include DESTINATION "${SDK_PATH}/lib/fonts/include")
install(FILES ${CMAKE_SOURCE_DIR}/plugins/fonts/CMakeLists.txt DESTINATION "${SDK_PATH}/lib/fonts/")
if (WIN32)
install(TARGETS fonts ARCHIVE DESTINATION "${SDK_PATH}/lib")
endif()
endfunction() endfunction()
function(addIncludesFromLibrary target library) function(addIncludesFromLibrary target library)
@@ -1037,12 +770,11 @@ function(precompileHeaders target includeFolder)
endif() endif()
file(GLOB_RECURSE TARGET_INCLUDES "${includeFolder}/**/*.hpp") file(GLOB_RECURSE TARGET_INCLUDES "${includeFolder}/**/*.hpp")
file(GLOB_RECURSE LIBIMHEX_INCLUDES "${CMAKE_SOURCE_DIR}/lib/libimhex/include/**/*.hpp")
set(SYSTEM_INCLUDES "<algorithm>;<array>;<atomic>;<chrono>;<cmath>;<cstddef>;<cstdint>;<cstdio>;<cstdlib>;<cstring>;<exception>;<filesystem>;<functional>;<iterator>;<limits>;<list>;<map>;<memory>;<optional>;<ranges>;<set>;<stdexcept>;<string>;<string_view>;<thread>;<tuple>;<type_traits>;<unordered_map>;<unordered_set>;<utility>;<variant>;<vector>") set(SYSTEM_INCLUDES "<algorithm>;<array>;<atomic>;<chrono>;<cmath>;<cstddef>;<cstdint>;<cstdio>;<cstdlib>;<cstring>;<exception>;<filesystem>;<functional>;<iterator>;<limits>;<list>;<map>;<memory>;<optional>;<ranges>;<set>;<stdexcept>;<string>;<string_view>;<thread>;<tuple>;<type_traits>;<unordered_map>;<unordered_set>;<utility>;<variant>;<vector>")
set(INCLUDES "${SYSTEM_INCLUDES};${TARGET_INCLUDES};${LIBIMHEX_INCLUDES}") set(INCLUDES "${SYSTEM_INCLUDES};${TARGET_INCLUDES}")
string(REPLACE ">" "$<ANGLE-R>" INCLUDES "${INCLUDES}") string(REPLACE ">" "$<ANGLE-R>" INCLUDES "${INCLUDES}")
target_precompile_headers(${target} target_precompile_headers(${target}
PUBLIC PUBLIC
"$<$<COMPILE_LANGUAGE:CXX>:${INCLUDES}>" "$<$<COMPILE_LANGUAGE:CXX>:${INCLUDES}>"
) )
endfunction() endfunction()

View File

@@ -1,149 +0,0 @@
option(IMHEX_IDE_HELPERS_OVERRIDE_XCODE_COMPILER "Enable choice of compiler for Xcode builds, despite CMake's best efforts" OFF)
option(IMHEX_IDE_HELPERS_INTRUSIVE_IDE_TWEAKS "Enable intrusive CMake tweaks to better support IDEs with folder support" OFF)
# The CMake infrastructure silently ignores the CMAKE_<>_COMPILER settings when
# using the `Xcode` generator.
#
# A particularly nasty (and potentially only) way of getting around this is to
# temporarily lie about the generator being used, while CMake determines and
# locks in the compiler to use.
#
# Needless to say, this is hacky and fragile. Use at your own risk!
if (IMHEX_IDE_HELPERS_OVERRIDE_XCODE_COMPILER AND CMAKE_GENERATOR STREQUAL "Xcode")
set(CMAKE_GENERATOR "Unknown")
enable_language(C CXX)
set(CMAKE_GENERATOR "Xcode")
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_C_COMPILER}")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_CXX_COMPILER}")
if (CLANG)
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_C_COMPILER}")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_CXX_COMPILER}")
endif()
# By default Xcode passes a `-index-store-path=<...>` parameter to the compiler
# during builds to build code completion indexes. This is not supported by
# anything other than AppleClang
set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE "NO")
endif()
# Generate a launch/build scheme for all targets
set(CMAKE_XCODE_GENERATE_SCHEME YES)
# Utility function that helps avoid messing with non-standard targets
macro(returnIfTargetIsNonTweakable target)
get_target_property(targetIsAliased ${target} ALIASED_TARGET)
get_target_property(targetIsImported ${target} IMPORTED)
if (targetIsAliased OR targetIsImported)
return()
endif()
get_target_property(targetType ${target} TYPE)
if (targetType MATCHES "INTERFACE_LIBRARY|UNKNOWN_LIBRARY")
return()
endif()
endmacro()
# Targets usually don't specify their private headers, nor group their source files
# which results in very spotty coverage by IDEs with folders support
#
# Unfortunately, CMake does not have a `target_source_group` like construct yet, therefore
# we have to play by the limitations of `source_group`.
#
# A particularly problematic part is that the function must be called within the directoryies
# scope for the grouping to take effect.
#
# See: https://discourse.cmake.org/t/topic/7388
function(tweakTargetForIDESupport target)
returnIfTargetIsNonTweakable(${target})
# Don't assume directory structure of third parties
get_target_property(targetSourceDir ${target} SOURCE_DIR)
if (targetSourceDir MATCHES "third_party")
return()
endif()
# Add headers to target
get_target_property(targetSourceDir ${target} SOURCE_DIR)
if (targetSourceDir)
file(GLOB_RECURSE targetPrivateHeaders CONFIGURE_DEPENDS "${targetSourceDir}/include/*.hpp")
target_sources(${target} PRIVATE "${targetPrivateHeaders}")
endif()
# Organize target sources into directory tree
get_target_property(sources ${target} SOURCES)
foreach(file IN LISTS sources)
get_filename_component(path "${file}" ABSOLUTE)
if (NOT path MATCHES "^${targetSourceDir}")
continue()
endif()
source_group(TREE "${targetSourceDir}" PREFIX "Source Tree" FILES "${file}")
endforeach()
endfunction()
if (IMHEX_IDE_HELPERS_INTRUSIVE_IDE_TWEAKS)
# See tweakTargetForIDESupport for rationale
function(add_library target)
_add_library(${target} ${ARGN})
tweakTargetForIDESupport(${target})
endfunction()
function(add_executable target)
_add_executable(${target} ${ARGN})
tweakTargetForIDESupport(${target})
endfunction()
endif()
# Adjust target's FOLDER property, which is an IDE only preference
function(_tweakTarget target path)
get_target_property(targetType ${target} TYPE)
if (TARGET generator-${target})
set_target_properties(generator-${target} PROPERTIES FOLDER "romfs/${target}")
endif()
if (TARGET romfs_file_packer-${target})
set_target_properties(romfs_file_packer-${target} PROPERTIES FOLDER "romfs/${target}")
endif()
if (TARGET libromfs-${target})
set_target_properties(libromfs-${target} PROPERTIES FOLDER "romfs/${target}")
endif()
if (${targetType} MATCHES "EXECUTABLE|LIBRARY")
set_target_properties(${target} PROPERTIES FOLDER "${path}")
endif()
endfunction()
macro(_tweakTargetsRecursive dir)
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
foreach(subdir IN LISTS subdirectories)
_tweakTargetsRecursive("${subdir}")
endforeach()
if(${dir} STREQUAL ${CMAKE_SOURCE_DIR})
return()
endif()
get_property(targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS)
file(RELATIVE_PATH rdir ${CMAKE_SOURCE_DIR} "${dir}/..")
foreach(target ${targets})
_tweakTarget(${target} "${rdir}")
endforeach()
endmacro()
# Tweak all targets this CMake build is aware about
function(tweakTargetsForIDESupport)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
_tweakTargetsRecursive("${CMAKE_SOURCE_DIR}")
endfunction()

View File

@@ -11,14 +11,6 @@ if (UNIX)
set(CORECLR_SUBARCH "arm64") set(CORECLR_SUBARCH "arm64")
endif() endif()
endif() endif()
if (APPLE)
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CORECLR_ARCH "osx-arm64")
set(CORECLR_SUBARCH "arm64")
else()
set(CORECLR_ARCH "osx-x64")
endif()
endif()
if (NOT DOTNET_EXECUTABLE) if (NOT DOTNET_EXECUTABLE)
set(DOTNET_EXECUTABLE dotnet) set(DOTNET_EXECUTABLE dotnet)
@@ -89,5 +81,4 @@ if (CoreClrEmbed_INCLUDE_DIR AND CoreClrEmbed_LIBRARY)
set(CoreClrEmbed_LIBRARIES "${CoreClrEmbed_LIBRARY}" CACHE STRING "CoreClrEmbed libraries" FORCE) set(CoreClrEmbed_LIBRARIES "${CoreClrEmbed_LIBRARY}" CACHE STRING "CoreClrEmbed libraries" FORCE)
set(CoreClrEmbed_SHARED_LIBRARIES "${CoreClrEmbed_SHARED_LIBRARY}" CACHE STRING "CoreClrEmbed shared libraries" FORCE) set(CoreClrEmbed_SHARED_LIBRARIES "${CoreClrEmbed_SHARED_LIBRARY}" CACHE STRING "CoreClrEmbed shared libraries" FORCE)
set(CoreClrEmbed_INCLUDE_DIRS "${CoreClrEmbed_INCLUDE_DIR}" CACHE STRING "CoreClrEmbed include directories" FORCE) set(CoreClrEmbed_INCLUDE_DIRS "${CoreClrEmbed_INCLUDE_DIR}" CACHE STRING "CoreClrEmbed include directories" FORCE)
set(CoreClrEmbed_VERSION "${CORECLR_RUNTIME_VERSION_FULL}" CACHE STRING "CoreClrEmbed version" FORCE)
endif() endif()

View File

@@ -1,60 +0,0 @@
find_path(LZ4_INCLUDE_DIR
NAMES lz4.h
HINTS "${LZ4_INCLUDEDIR}" "${LZ4_HINTS}/include"
PATHS
/usr/local/include
/usr/include
)
find_library(LZ4_LIBRARY
NAMES lz4 liblz4
HINTS "${LZ4_LIBDIR}" "${LZ4_HINTS}/lib"
PATHS
/usr/local/lib
/usr/lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR )
if( LZ4_FOUND )
include( CheckIncludeFile )
include( CMakePushCheckState )
set( LZ4_INCLUDE_DIRS ${LZ4_INCLUDE_DIR} )
set( LZ4_LIBRARIES ${LZ4_LIBRARY} )
cmake_push_check_state()
set( CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIRS} )
check_include_file( lz4frame.h HAVE_LZ4FRAME_H )
cmake_pop_check_state()
if (WIN32)
set ( LZ4_DLL_DIR "${LZ4_HINTS}/bin"
CACHE PATH "Path to LZ4 DLL"
)
file( GLOB _lz4_dll RELATIVE "${LZ4_DLL_DIR}"
"${LZ4_DLL_DIR}/lz4*.dll"
)
set ( LZ4_DLL ${_lz4_dll}
# We're storing filenames only. Should we use STRING instead?
CACHE FILEPATH "LZ4 DLL file name"
)
file( GLOB _lz4_pdb RELATIVE "${LZ4_DLL_DIR}"
"${LZ4_DLL_DIR}/lz4*.pdb"
)
set ( LZ4_PDB ${_lz4_pdb}
CACHE FILEPATH "LZ4 PDB file name"
)
mark_as_advanced( LZ4_DLL_DIR LZ4_DLL LZ4_PDB )
endif()
else()
set( LZ4_INCLUDE_DIRS )
set( LZ4_LIBRARIES )
endif()
mark_as_advanced( LZ4_LIBRARIES LZ4_INCLUDE_DIRS )
add_library( LZ4::lz4 INTERFACE IMPORTED )
set_property( TARGET LZ4::lz4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LZ4_INCLUDE_DIRS} )
set_property( TARGET LZ4::lz4 PROPERTY INTERFACE_LINK_LIBRARIES ${LZ4_LIBRARIES} )

View File

@@ -2,7 +2,11 @@ find_path(LIBMAGIC_INCLUDE_DIR magic.h)
find_library(LIBMAGIC_LIBRARY NAMES magic) find_library(LIBMAGIC_LIBRARY NAMES magic)
find_package_handle_standard_args(Magic DEFAULT_MSG if (LIBMAGIC_INCLUDE_DIR AND LIBMAGIC_LIBRARY)
set(LIBMAGIC_FOUND TRUE)
endif (LIBMAGIC_INCLUDE_DIR AND LIBMAGIC_LIBRARY)
find_package_handle_standard_args("libmagic" DEFAULT_MSG
LIBMAGIC_LIBRARY LIBMAGIC_LIBRARY
LIBMAGIC_INCLUDE_DIR LIBMAGIC_INCLUDE_DIR
) )
@@ -10,5 +14,5 @@ find_package_handle_standard_args(Magic DEFAULT_MSG
mark_as_advanced( mark_as_advanced(
LIBMAGIC_INCLUDE_DIR LIBMAGIC_INCLUDE_DIR
LIBMAGIC_LIBRARY LIBMAGIC_LIBRARY
Magic_FOUND LIBMAGIC_FOUND
) )

View File

@@ -1,4 +1,4 @@
find_library(YARA_LIBRARIES NAMES yara) find_file(libyara.a YARA_LIBRARIES)
find_file(yara.h YARA_INCLUDE_DIRS) find_file(yara.h YARA_INCLUDE_DIRS)
mark_as_advanced(YARA_LIBRARIES YARA_INCLUDE_DIRS) mark_as_advanced(YARA_LIBRARIES YARA_INCLUDE_DIRS)

View File

@@ -38,8 +38,4 @@ if (ZSTD_FOUND)
message(STATUS "Found Zstd: ${ZSTD_LIBRARY}") message(STATUS "Found Zstd: ${ZSTD_LIBRARY}")
endif() endif()
mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY) mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY)
add_library(ZSTD::zstd INTERFACE IMPORTED)
set_property(TARGET ZSTD::zstd PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIR})
set_property(TARGET ZSTD::zstd PROPERTY INTERFACE_LINK_LIBRARIES ${ZSTD_LIBRARY})

View File

@@ -1,15 +0,0 @@
find_path(LIBSSH2_INCLUDE_DIR libssh2.h)
find_library(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
if(LIBSSH2_INCLUDE_DIR)
file(STRINGS "${LIBSSH2_INCLUDE_DIR}/libssh2.h" libssh2_version_str REGEX "^#define[\t ]+LIBSSH2_VERSION[\t ]+\"(.*)\"")
string(REGEX REPLACE "^.*\"([^\"]+)\"" "\\1" LIBSSH2_VERSION "${libssh2_version_str}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibSSH2
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR
VERSION_VAR LIBSSH2_VERSION)
mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)

View File

@@ -26,9 +26,8 @@ SET(MBEDTLS_FIND_QUIETLY TRUE)
FIND_LIBRARY(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509) FIND_LIBRARY(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509)
FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509) FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509)
FIND_LIBRARY(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto) FIND_LIBRARY(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
FIND_LIBRARY(TFPSACRYPTO_LIBRARY NAMES libtfpsacrypto tfpsacrypto)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND (MBEDCRYPTO_LIBRARY OR TFPSACRYPTO_LIBRARY)) IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_FOUND TRUE) SET(MBEDTLS_FOUND TRUE)
ENDIF() ENDIF()
@@ -38,25 +37,10 @@ IF(MBEDTLS_FOUND)
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE) GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE) GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE) GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(TFPSACRYPTO_LIBRARY_FILE ${TFPSACRYPTO_LIBRARY} NAME_WE)
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE}) STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE}) STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE}) STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" TFPSACRYPTO_LIBRARY_FILE ${TFPSACRYPTO_LIBRARY_FILE}) SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
if (TFPSACRYPTO_LIBRARY)
SET(MBEDTLS_CRYPTO_LIBRARY_FILE ${TFPSACRYPTO_LIBRARY_FILE})
elseif (MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_CRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
else ()
MESSAGE(FATAL_ERROR "Could not find mbedTLS Crypto library")
endif()
if (MSVC)
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY_FILE}.lib ${MBEDX509_LIBRARY_FILE}.lib ${MBEDTLS_CRYPTO_LIBRARY_FILE}.lib)
else()
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDTLS_CRYPTO_LIBRARY_FILE}")
endif()
IF(NOT MBEDTLS_FIND_QUIETLY) IF(NOT MBEDTLS_FIND_QUIETLY)
MESSAGE(STATUS "Found mbedTLS:") MESSAGE(STATUS "Found mbedTLS:")
@@ -71,9 +55,9 @@ IF(MBEDTLS_FOUND)
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}") MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
ENDIF(NOT MBEDTLS_FIND_QUIETLY) ENDIF(NOT MBEDTLS_FIND_QUIETLY)
ELSE(MBEDTLS_FOUND) ELSE(MBEDTLS_FOUND)
IF(mbedTLS_FIND_REQUIRED) IF(MBEDTLS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find mbedTLS") MESSAGE(FATAL_ERROR "Could not find mbedTLS")
ENDIF(mbedTLS_FIND_REQUIRED) ENDIF(MBEDTLS_FIND_REQUIRED)
ENDIF(MBEDTLS_FOUND) ENDIF(MBEDTLS_FOUND)
MARK_AS_ADVANCED( MARK_AS_ADVANCED(
@@ -83,4 +67,4 @@ MARK_AS_ADVANCED(
MBEDTLS_LIBRARY MBEDTLS_LIBRARY
MBEDX509_LIBRARY MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY MBEDCRYPTO_LIBRARY
) )

View File

@@ -1,5 +1,4 @@
macro(add_imhex_plugin) macro(add_imhex_plugin)
setSDKPaths()
# Parse arguments # Parse arguments
set(options LIBRARY_PLUGIN) set(options LIBRARY_PLUGIN)
set(oneValueArgs NAME IMHEX_VERSION) set(oneValueArgs NAME IMHEX_VERSION)
@@ -29,140 +28,79 @@ macro(add_imhex_plugin)
endif() endif()
endif() endif()
if (IMHEX_PLUGIN_LIBRARY_PLUGIN)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "${SDK_PATH}/lib/plugins/${IMHEX_PLUGIN_NAME}")
endif()
# Define new project for plugin # Define new project for plugin
project(${IMHEX_PLUGIN_NAME}) project(${IMHEX_PLUGIN_NAME})
if (IMHEX_PLUGIN_IMPORTED) # Create a new shared library for the plugin source code
add_library(${IMHEX_PLUGIN_NAME} SHARED IMPORTED GLOBAL) add_library(${IMHEX_PLUGIN_NAME} ${IMHEX_PLUGIN_LIBRARY_TYPE} ${IMHEX_PLUGIN_SOURCES})
if (WIN32) # Add include directories and link libraries
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/${IMHEX_PLUGIN_NAME}${IMHEX_PLUGIN_SUFFIX}" target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/../lib${IMHEX_PLUGIN_NAME}.dll.a" target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/include") addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
elseif (APPLE) addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../../MacOS/plugins/${IMHEX_PLUGIN_NAME}${IMHEX_PLUGIN_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/include")
else()
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/${IMHEX_PLUGIN_NAME}${IMHEX_PLUGIN_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/include")
endif()
else()
# Create a new shared library for the plugin source code
add_library(${IMHEX_PLUGIN_NAME} ${IMHEX_PLUGIN_LIBRARY_TYPE} ${IMHEX_PLUGIN_SOURCES})
# Add include directories and link libraries precompileHeaders(${IMHEX_PLUGIN_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_INCLUDES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_LIBRARIES})
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE libimhex ${FMT_LIBRARIES} imgui_all_includes libwolv)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl)
addIncludesFromLibrary(${IMHEX_PLUGIN_NAME} libpl-gen)
precompileHeaders(${IMHEX_PLUGIN_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/include") # Add IMHEX_PROJECT_NAME and IMHEX_VERSION define
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}")
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PLUGIN_NAME=${IMHEX_PLUGIN_NAME})
# Add IMHEX_PROJECT_NAME and IMHEX_VERSION define # Enable required compiler flags
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}") enableUnityBuild(${IMHEX_PLUGIN_NAME})
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_VERSION="${IMHEX_VERSION_STRING}") setupCompilerFlags(${IMHEX_PLUGIN_NAME})
target_compile_definitions(${IMHEX_PLUGIN_NAME} PRIVATE IMHEX_PLUGIN_NAME=${IMHEX_PLUGIN_NAME})
# Enable required compiler flags # Configure build properties
enableUnityBuild(${IMHEX_PLUGIN_NAME}) set_target_properties(${IMHEX_PLUGIN_NAME}
setupCompilerFlags(${IMHEX_PLUGIN_NAME}) PROPERTIES
addCppCheck(${IMHEX_PLUGIN_NAME}) RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins
CXX_STANDARD 23
PREFIX ""
SUFFIX ${IMHEX_PLUGIN_SUFFIX}
)
# Configure build properties # Set rpath of plugin libraries to the plugins folder
set_target_properties(${IMHEX_PLUGIN_NAME} if (APPLE)
PROPERTIES set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
RUNTIME_OUTPUT_DIRECTORY "${IMHEX_MAIN_OUTPUT_DIRECTORY}/plugins" endif()
CXX_STANDARD 23
PREFIX ""
SUFFIX ${IMHEX_PLUGIN_SUFFIX}
)
# Set rpath of plugin libraries to the plugins folder # Setup a romfs for the plugin
if (WIN32) list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs)
if (IMHEX_PLUGIN_LIBRARY_PLUGIN) set(LIBROMFS_PROJECT_NAME ${IMHEX_PLUGIN_NAME})
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) add_subdirectory(${IMHEX_BASE_FOLDER}/lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs)
endif() target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
elseif (APPLE)
set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
endif()
# Setup a romfs for the plugin foreach(feature ${IMHEX_PLUGIN_FEATURES})
list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs) string(TOUPPER ${feature} feature)
set(LIBROMFS_PROJECT_NAME ${IMHEX_PLUGIN_NAME}) add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=0)
add_subdirectory(${IMHEX_BASE_FOLDER}/lib/external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/libromfs) endforeach()
target_link_libraries(${IMHEX_PLUGIN_NAME} PRIVATE ${LIBROMFS_LIBRARY})
set(FEATURE_DEFINE_CONTENT) # Add the new plugin to the main dependency list so it gets built by default
if (TARGET imhex_all)
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
endif()
if (IMHEX_PLUGIN_FEATURES) if (IMHEX_EXTERNAL_PLUGIN_BUILD)
list(LENGTH IMHEX_PLUGIN_FEATURES IMHEX_FEATURE_COUNT) install(TARGETS ${IMHEX_PLUGIN_NAME} DESTINATION ".")
math(EXPR IMHEX_FEATURE_COUNT "${IMHEX_FEATURE_COUNT} - 1" OUTPUT_FORMAT DECIMAL) endif()
foreach(index RANGE 0 ${IMHEX_FEATURE_COUNT} 2)
list(SUBLIST IMHEX_PLUGIN_FEATURES ${index} 2 IMHEX_PLUGIN_FEATURE)
list(GET IMHEX_PLUGIN_FEATURE 0 feature_define)
list(GET IMHEX_PLUGIN_FEATURE 1 feature_description)
string(TOUPPER ${feature_define} feature_define) # Fix rpath
add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature_define}=0) if (APPLE)
set(FEATURE_DEFINE_CONTENT "${FEATURE_DEFINE_CONTENT}{ \"${feature_description}\", IMHEX_FEATURE_ENABLED(${feature_define}) },") set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/plugins")
endforeach() elseif (UNIX)
endif() set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES INSTALL_RPATH_USE_ORIGIN ON INSTALL_RPATH "$ORIGIN/")
endif()
target_compile_options(${IMHEX_PLUGIN_NAME} PRIVATE -DIMHEX_PLUGIN_FEATURES_CONTENT=${FEATURE_DEFINE_CONTENT}) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt AND IMHEX_ENABLE_UNIT_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
# Add the new plugin to the main dependency list so it gets built by default target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_NAME}_tests)
if (TARGET imhex_all) target_compile_definitions(${IMHEX_PLUGIN_NAME}_tests PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}-tests")
add_dependencies(imhex_all ${IMHEX_PLUGIN_NAME})
endif()
if (IMHEX_EXTERNAL_PLUGIN_BUILD)
install(TARGETS ${IMHEX_PLUGIN_NAME} DESTINATION ".")
endif()
# Fix rpath
if (APPLE)
set_target_properties(
${IMHEX_PLUGIN_NAME}
PROPERTIES
INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/plugins"
)
elseif (UNIX)
set(PLUGIN_RPATH "")
list(APPEND PLUGIN_RPATH "$ORIGIN")
if (IMHEX_PLUGIN_ADD_INSTALL_PREFIX_TO_RPATH)
list(APPEND PLUGIN_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
set_target_properties(
${IMHEX_PLUGIN_NAME}
PROPERTIES
INSTALL_RPATH_USE_ORIGIN ON
INSTALL_RPATH "${PLUGIN_RPATH}"
)
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt AND IMHEX_ENABLE_UNIT_TESTS AND IMHEX_ENABLE_PLUGIN_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(${IMHEX_PLUGIN_NAME} PUBLIC ${IMHEX_PLUGIN_NAME}_tests)
target_compile_definitions(${IMHEX_PLUGIN_NAME}_tests PRIVATE IMHEX_PROJECT_NAME="${IMHEX_PLUGIN_NAME}-tests")
endif()
endif() endif()
endmacro() endmacro()
macro(add_romfs_resource input output) macro(add_romfs_resource input output)
if (NOT EXISTS ${input})
message(WARNING "Resource file ${input} does not exist")
endif()
configure_file(${input} ${CMAKE_CURRENT_BINARY_DIR}/romfs/${output} COPYONLY) configure_file(${input} ${CMAKE_CURRENT_BINARY_DIR}/romfs/${output} COPYONLY)
list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/romfs) list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/romfs)
@@ -176,4 +114,4 @@ macro (enable_plugin_feature feature)
remove_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=0) remove_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=0)
add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=1) add_definitions(-DIMHEX_PLUGIN_${IMHEX_PLUGIN_NAME}_FEATURE_${feature}=1)
endmacro() endmacro()

View File

@@ -14,11 +14,12 @@ if(CMAKE_GENERATOR)
# Being called as include(PostprocessBundle), so define a helper function. # Being called as include(PostprocessBundle), so define a helper function.
set(_POSTPROCESS_BUNDLE_MODULE_LOCATION "${CMAKE_CURRENT_LIST_FILE}") set(_POSTPROCESS_BUNDLE_MODULE_LOCATION "${CMAKE_CURRENT_LIST_FILE}")
function(postprocess_bundle out_target in_target) function(postprocess_bundle out_target in_target)
add_custom_command(TARGET ${out_target} POST_BUILD
install(CODE "set(BUNDLE_PATH ${CMAKE_INSTALL_PREFIX}/${BUNDLE_NAME})") COMMAND ${CMAKE_COMMAND} -DBUNDLE_PATH="$<TARGET_FILE_DIR:${in_target}>/../.."
install(CODE "set(CODE_SIGN_CERTIFICATE_ID ${CODE_SIGN_CERTIFICATE_ID})") -DCODE_SIGN_CERTIFICATE_ID="${CODE_SIGN_CERTIFICATE_ID}"
install(CODE "set(EXTRA_BUNDLE_LIBRARY_PATHS ${EXTRA_BUNDLE_LIBRARY_PATHS})") -DEXTRA_BUNDLE_LIBRARY_PATHS="${EXTRA_BUNDLE_LIBRARY_PATHS}"
install(SCRIPT ${_POSTPROCESS_BUNDLE_MODULE_LOCATION}) -P "${_POSTPROCESS_BUNDLE_MODULE_LOCATION}"
)
endfunction() endfunction()
return() return()
endif() endif()
@@ -41,7 +42,7 @@ file(GLOB_RECURSE plugins "${BUNDLE_PATH}/Contents/MacOS/plugins/*.hexplug")
# makes it sometimes break on libraries that do weird things with @rpath. Specify # makes it sometimes break on libraries that do weird things with @rpath. Specify
# equivalent search directories until https://gitlab.kitware.com/cmake/cmake/issues/16625 # equivalent search directories until https://gitlab.kitware.com/cmake/cmake/issues/16625
# is fixed and in our minimum CMake version. # is fixed and in our minimum CMake version.
set(extra_dirs "/usr/local/lib" "/lib" "/usr/lib" ${EXTRA_BUNDLE_LIBRARY_PATHS} "${BUNDLE_PATH}/Contents/MacOS/plugins" "${BUNDLE_PATH}/Contents/Frameworks") set(extra_dirs "/usr/local/lib" "/lib" "/usr/lib" ${EXTRA_BUNDLE_LIBRARY_PATHS} "${BUNDLE_PATH}/Contents/MacOS/plugins")
message(STATUS "Fixing up application bundle: ${extra_dirs}") message(STATUS "Fixing up application bundle: ${extra_dirs}")
# BundleUtilities is overly verbose, so disable most of its messages # BundleUtilities is overly verbose, so disable most of its messages

View File

@@ -29,45 +29,30 @@ add_subdirectory_if_exists(lib/third_party/nlohmann_json)
set(NLOHMANN_JSON_LIBRARIES nlohmann_json PARENT_SCOPE) set(NLOHMANN_JSON_LIBRARIES nlohmann_json PARENT_SCOPE)
set(NLOHMANN_JSON_LIBRARIES nlohmann_json) set(NLOHMANN_JSON_LIBRARIES nlohmann_json)
add_subdirectory_if_exists(lib/third_party/boost)
set(BOOST_LIBRARIES boost::regex PARENT_SCOPE)
set(BOOST_LIBRARIES boost::regex)
add_subdirectory(lib/external/libwolv EXCLUDE_FROM_ALL) add_subdirectory(lib/external/libwolv EXCLUDE_FROM_ALL)
set(LIBPL_ENABLE_CLI OFF CACHE BOOL "" FORCE) set(LIBPL_ENABLE_CLI OFF CACHE BOOL "" FORCE)
add_subdirectory(lib/external/pattern_language EXCLUDE_FROM_ALL) add_subdirectory(lib/external/pattern_language EXCLUDE_FROM_ALL)
set(IMHEX_PLUGIN_IMPORTED ON) find_package(CURL REQUIRED)
find_package(mbedTLS 3.4.0 REQUIRED)
set(CURL_LIBRARIES ${CURL_LIBRARIES} PARENT_SCOPE)
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARIES} PARENT_SCOPE)
add_subdirectory(lib/libimhex) add_subdirectory(lib/libimhex)
add_subdirectory(lib/trace)
add_subdirectory(lib/fonts)
add_subdirectory(lib/ui)
set(IMHEX_PLUGIN_IMPORTED OFF)
if (WIN32) if (WIN32)
set_target_properties(libimhex PROPERTIES set_target_properties(libimhex PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libimhex.dll" IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libimhex.dll"
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/liblibimhex.dll.a" IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/liblibimhex.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include") INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
set_target_properties(tracing PROPERTIES
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/libtracing.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/trace/include")
elseif (APPLE) elseif (APPLE)
file(GLOB LIBIMHEX_DYLIB "${CMAKE_CURRENT_SOURCE_DIR}/../../Frameworks/libimhex.*.dylib") file(GLOB LIBIMHEX_DYLIB "${CMAKE_CURRENT_SOURCE_DIR}/../../Frameworks/libimhex.*.dylib")
set_target_properties(libimhex PROPERTIES set_target_properties(libimhex PROPERTIES
IMPORTED_LOCATION "${LIBIMHEX_DYLIB}" IMPORTED_LOCATION "${LIBIMHEX_DYLIB}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include") INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
set_target_properties(tracing PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libtracing.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/trace/include")
else() else()
set_target_properties(libimhex PROPERTIES set_target_properties(libimhex PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../../../lib/libimhex.so" IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/../libimhex.so"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include") INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/libimhex/include")
set_target_properties(tracing PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libtracing.a"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib/trace/include")
endif() endif()

View File

@@ -1,7 +1,7 @@
#include <hex/plugin.hpp> #include <hex/plugin.hpp>
// Browse through the headers in lib/libimhex/include/hex/api/ to see what you can do with the API. // Browse through the headers in lib/libimhex/include/hex/api/ to see what you can do with the API.
// Most important ones are the things under imhex_api and content_registry // Most important ones are <hex/api/imhex_api.hpp> and <hex/api/content_registry.hpp>
// This is the main entry point of your plugin. The code in the body of this construct will be executed // This is the main entry point of your plugin. The code in the body of this construct will be executed
// when ImHex starts up and loads the plugin. // when ImHex starts up and loads the plugin.

View File

@@ -1,146 +0,0 @@
# appimage-builder recipe see https://appimage-builder.readthedocs.io for details
version: 1
AppDir:
path: .AppDir
app_info:
id: imhex
name: ImHex
icon: imhex
version: "{{VERSION}}"
exec: usr/bin/imhex
exec_args: $@
apt:
arch:
- all
- "{{ARCHITECTURE_PACKAGE}}"
allow_unauthenticated: true
sources:
- sourceline: 'deb [arch=amd64] https://us.archive.ubuntu.com/ubuntu/ noble main restricted universe multiverse'
- sourceline: 'deb [arch=arm64] https://ports.ubuntu.com/ubuntu-ports/ noble main restricted universe multiverse'
include:
- libgdk-pixbuf2.0-0
- libgdk-pixbuf2.0-common
- shared-mime-info
- librsvg2-common
- libbz2-1.0
- libcap2
- libdbus-1-3
- libfontconfig1
- libgpg-error0
- liblzma5
- libnss-mdns
- libpcre3
- libselinux1
- libtinfo6
- libmd4c-dev
- libmd4c-html0-dev
files:
include:
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libLLVM-13.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libOpenGL.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libX11.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXau.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXcomposite.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXcursor.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXdamage.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXdmcp.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXext.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXfixes.so.3"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXi.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXinerama.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXrandr.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXrender.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libXxf86vm.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libatk-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libatk-bridge-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libatspi.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libblkid.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libbrotlicommon.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libbrotlidec.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libbsd.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libcairo-gobject.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libcairo.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libcurl-gnutls.so.4"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libdatrie.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libedit.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libelf.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libepoxy.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libffi.so.8"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libfontconfig.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libfreetype.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libfribidi.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgcrypt.so.20"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgdk-3.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgdk_pixbuf-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgio-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libglfw.so.3"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libglib-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgmodule-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgmp.so.10"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgnutls.so.30"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgobject-2.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libgraphite2.so.3"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libharfbuzz.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libhogweed.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libicudata.so.70"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libicuuc.so.70"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libidn2.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libjpeg.so.8"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/liblber-2.5.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libldap-2.5.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/liblz4.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmagic.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmbedcrypto.so.7"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmbedtls.so.14"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmbedx509.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmd.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmount.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libnettle.so.8"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libp11-kit.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpango-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpangocairo-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpangoft2-1.0.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpcre2-8.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpixman-1.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libpng16.so.16"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libsasl2.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libsensors.so.5"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libstdc++.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libsystemd.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libtasn1.so.6"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libthai.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libunistring.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libuuid.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libvulkan.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libwayland-client.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libwayland-cursor.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libwayland-egl.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-dri2.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-dri3.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-present.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxcb-sync.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxkbcommon.so.0"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxml2.so.2"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libxshmfence.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libzstd.so.1"
- "/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/libmd4c.so"
exclude:
- usr/share/man
- usr/share/doc/*/README.*
- usr/share/doc/*/changelog.*
- usr/share/doc/*/NEWS.*
- usr/share/doc/*/TODO.*
runtime:
env:
APPDIR_LIBRARY_PATH: '$APPDIR/usr/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu:$APPDIR/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu:$APPDIR/usr/lib:$APPDIR/usr/lib/{{ARCHITECTURE_APPIMAGE_BUILDER}}-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders'
GTK_EXE_PREFIX: $APPDIR/usr
GTK_DATA_PREFIX: $APPDIR
XDG_DATA_DIRS: '/usr/local/share:/usr/share:$APPDIR/usr/share:$XDG_DATA_DIRS:$APPDIR/usr/local/share:$APPDIR/usr/local/lib:$APPDIR/usr/local/share'
XDG_CONFIG_DIRS: '$XDG_CONFIG_DIRS:$APPDIR/usr/local/share'
AppImage:
arch: "{{ARCHITECTURE_APPIMAGE_BUILDER}}"
comp: zstd
update-information: gh-releases-zsync|WerWolv|ImHex|latest|imhex-*-{{ARCHITECTURE_FILE_NAME}}.AppImage.zsync
file_name: imhex-{{VERSION}}-{{ARCHITECTURE_FILE_NAME}}.AppImage

View File

@@ -1,93 +0,0 @@
FROM ubuntu:24.04 as build
# Used to invalidate layer cache but not mount cache
# See https://github.com/moby/moby/issues/41715#issuecomment-733976493
ARG UNIQUEKEY 1
COPY dist/get_deps_debian.sh /tmp
RUN --mount=type=cache,target=/var/apt/cache <<EOF
# Install apt dependencies
set -xe
apt update
# general deps
apt install -y ccache git wget
# appimage tools deps
apt install -y python3-pip python3-venv python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fuse ninja-build
apt install -y squashfs-tools zsync
# imhex deps
/tmp/get_deps_debian.sh
EOF
ENV PATH="/cache/bin/:${PATH}"
# Copy Imhex source
COPY . /imhex
ARG LTO=ON
ARG BUILD_TYPE=RelWithDebInfo
ARG GIT_COMMIT_HASH
ARG GIT_BRANCH
ARG ARCHITECTURE_PACKAGE=x86_64
ARG ARCHITECTURE_FILE_NAME=amd64
ARG ARCHITECTURE_APPIMAGE_BUILDER=x86_64
WORKDIR /build
# Ubuntu sh doesnt support string substitution
SHELL ["bash", "-c"]
RUN <<EOF
# Prepare ImHex build
set -xe
CC=gcc-14 CXX=g++-14 cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GIT_COMMIT_HASH}" \
-DIMHEX_COMMIT_BRANCH="${GIT_BRANCH}" \
-DIMHEX_ENABLE_LTO=${LTO} \
-DIMHEX_BUNDLE_PLUGIN_SDK=OFF \
`# To prevent using a libdir with an architecture-specific name` \
-DCMAKE_INSTALL_LIBDIR="lib" \
/imhex
EOF
ENV CCACHE_DIR /cache/ccache
RUN --mount=type=cache,target=/cache <<EOF
# Build Imhex
set -xe
ccache -zs
DESTDIR=AppDir ninja install
ccache -s
EOF
RUN <<EOF
# Download appimage-builder
set -xe
mkdir -p /cache/bin
wget -nc https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O /cache/bin/appimagetool || true
chmod +x /cache/bin/appimagetool
python3 -m venv venv
. venv/bin/activate
pip3 install git+https://github.com/AppImageCrafters/appimage-builder@e995e8e
# Package ImHex as AppImage
export VERSION=$(cat /imhex/VERSION)
export ARCHITECTURE_PACKAGE=${ARCHITECTURE_PACKAGE}
export ARCHITECTURE_FILE_NAME=${ARCHITECTURE_FILE_NAME}
export ARCHITECTURE_APPIMAGE_BUILDER=${ARCHITECTURE_APPIMAGE_BUILDER}
appimage-builder --recipe /imhex/dist/AppImage/AppImageBuilder.yml
EOF
FROM scratch
# Copy build artifact
COPY --from=build /build/*.AppImage /build/*.AppImage.zsync ./

137
dist/AppImageBuilder.yml vendored Normal file
View File

@@ -0,0 +1,137 @@
# appimage-builder recipe see https://appimage-builder.readthedocs.io for details
version: 1
AppDir:
path: .AppDir
app_info:
id: imhex
name: ImHex
icon: imhex
version: "{{VERSION}}"
exec: usr/bin/imhex
exec_args: $@
apt:
arch:
- amd64
allow_unauthenticated: true
sources:
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy main restricted
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates main restricted
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy universe
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates universe
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy multiverse
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-updates multiverse
- sourceline: deb http://us.archive.ubuntu.com/ubuntu/ jammy-backports main restricted
universe multiverse
- sourceline: deb http://security.ubuntu.com/ubuntu jammy-security main restricted
- sourceline: deb http://security.ubuntu.com/ubuntu jammy-security universe
- sourceline: deb http://security.ubuntu.com/ubuntu jammy-security multiverse
include:
- librsvg2-common
- libbz2-1.0:amd64
- libcap2:amd64
- libdbus-1-3:amd64
- libgpg-error0:amd64
- liblzma5:amd64
- libnss-mdns:amd64
- libpcre3:amd64
- libselinux1:amd64
- libtinfo6:amd64
files:
include:
- /lib/x86_64-linux-gnu/libLLVM-13.so.1
- /lib/x86_64-linux-gnu/libOpenGL.so.0
- /lib/x86_64-linux-gnu/libX11.so.6
- /lib/x86_64-linux-gnu/libXau.so.6
- /lib/x86_64-linux-gnu/libXcomposite.so.1
- /lib/x86_64-linux-gnu/libXcursor.so.1
- /lib/x86_64-linux-gnu/libXdamage.so.1
- /lib/x86_64-linux-gnu/libXdmcp.so.6
- /lib/x86_64-linux-gnu/libXext.so.6
- /lib/x86_64-linux-gnu/libXfixes.so.3
- /lib/x86_64-linux-gnu/libXi.so.6
- /lib/x86_64-linux-gnu/libXinerama.so.1
- /lib/x86_64-linux-gnu/libXrandr.so.2
- /lib/x86_64-linux-gnu/libXrender.so.1
- /lib/x86_64-linux-gnu/libXxf86vm.so.1
- /lib/x86_64-linux-gnu/libatk-1.0.so.0
- /lib/x86_64-linux-gnu/libatk-bridge-2.0.so.0
- /lib/x86_64-linux-gnu/libatspi.so.0
- /lib/x86_64-linux-gnu/libblkid.so.1
- /lib/x86_64-linux-gnu/libbrotlicommon.so.1
- /lib/x86_64-linux-gnu/libbrotlidec.so.1
- /lib/x86_64-linux-gnu/libbsd.so.0
- /lib/x86_64-linux-gnu/libcairo-gobject.so.2
- /lib/x86_64-linux-gnu/libcairo.so.2
- /lib/x86_64-linux-gnu/libcurl-gnutls.so.4
- /lib/x86_64-linux-gnu/libdatrie.so.1
- /lib/x86_64-linux-gnu/libedit.so.2
- /lib/x86_64-linux-gnu/libelf.so.1
- /lib/x86_64-linux-gnu/libepoxy.so.0
- /lib/x86_64-linux-gnu/libffi.so.8
- /lib/x86_64-linux-gnu/libfontconfig.so.1
- /lib/x86_64-linux-gnu/libfreetype.so.6
- /lib/x86_64-linux-gnu/libfribidi.so.0
- /lib/x86_64-linux-gnu/libgcrypt.so.20
- /lib/x86_64-linux-gnu/libgdk-3.so.0
- /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
- /lib/x86_64-linux-gnu/libgio-2.0.so.0
- /lib/x86_64-linux-gnu/libglfw.so.3
- /lib/x86_64-linux-gnu/libglib-2.0.so.0
- /lib/x86_64-linux-gnu/libgmodule-2.0.so.0
- /lib/x86_64-linux-gnu/libgmp.so.10
- /lib/x86_64-linux-gnu/libgnutls.so.30
- /lib/x86_64-linux-gnu/libgobject-2.0.so.0
- /lib/x86_64-linux-gnu/libgraphite2.so.3
- /lib/x86_64-linux-gnu/libharfbuzz.so.0
- /lib/x86_64-linux-gnu/libhogweed.so.6
- /lib/x86_64-linux-gnu/libicudata.so.70
- /lib/x86_64-linux-gnu/libicuuc.so.70
- /lib/x86_64-linux-gnu/libidn2.so.0
- /lib/x86_64-linux-gnu/libjpeg.so.8
- /lib/x86_64-linux-gnu/liblber-2.5.so.0
- /lib/x86_64-linux-gnu/libldap-2.5.so.0
- /lib/x86_64-linux-gnu/liblz4.so.1
- /lib/x86_64-linux-gnu/libmagic.so.1
- /lib/x86_64-linux-gnu/libmbedcrypto.so.7
- /lib/x86_64-linux-gnu/libmbedtls.so.14
- /lib/x86_64-linux-gnu/libmbedx509.so.1
- /lib/x86_64-linux-gnu/libmd.so.0
- /lib/x86_64-linux-gnu/libmount.so.1
- /lib/x86_64-linux-gnu/libnettle.so.8
- /lib/x86_64-linux-gnu/libp11-kit.so.0
- /lib/x86_64-linux-gnu/libpango-1.0.so.0
- /lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
- /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0
- /lib/x86_64-linux-gnu/libpcre2-8.so.0
- /lib/x86_64-linux-gnu/libpixman-1.so.0
- /lib/x86_64-linux-gnu/libpng16.so.16
- /lib/x86_64-linux-gnu/libsasl2.so.2
- /lib/x86_64-linux-gnu/libsensors.so.5
- /lib/x86_64-linux-gnu/libstdc++.so.6
- /lib/x86_64-linux-gnu/libsystemd.so.0
- /lib/x86_64-linux-gnu/libtasn1.so.6
- /lib/x86_64-linux-gnu/libthai.so.0
- /lib/x86_64-linux-gnu/libunistring.so.2
- /lib/x86_64-linux-gnu/libuuid.so.1
- /lib/x86_64-linux-gnu/libvulkan.so.1
- /lib/x86_64-linux-gnu/libwayland-client.so.0
- /lib/x86_64-linux-gnu/libwayland-cursor.so.0
- /lib/x86_64-linux-gnu/libwayland-egl.so.1
- /lib/x86_64-linux-gnu/libxcb-dri2.so.0
- /lib/x86_64-linux-gnu/libxcb-dri3.so.0
- /lib/x86_64-linux-gnu/libxcb-present.so.0
- /lib/x86_64-linux-gnu/libxcb-sync.so.1
- /lib/x86_64-linux-gnu/libxkbcommon.so.0
- /lib/x86_64-linux-gnu/libxml2.so.2
- /lib/x86_64-linux-gnu/libxshmfence.so.1
- /lib/x86_64-linux-gnu/libzstd.so.1
exclude:
- usr/share/man
- usr/share/doc/*/README.*
- usr/share/doc/*/changelog.*
- usr/share/doc/*/NEWS.*
- usr/share/doc/*/TODO.*
AppImage:
arch: x86_64
update-information: gh-releases-zsync|WerWolv|ImHex|latest|imhex-*-x86_64.AppImage.zsync
file_name: imhex-{{VERSION}}-x86_64.AppImage

View File

@@ -13,13 +13,10 @@ RUN pacman -S --needed --noconfirm \
glfw-x11 \ glfw-x11 \
file \ file \
mbedtls \ mbedtls \
fontconfig \
freetype2 \ freetype2 \
curl \ curl \
dbus \ dbus \
xdg-desktop-portal \ xdg-desktop-portal
libssh2 \
md4c
# Clone ImHex # Clone ImHex
RUN git clone https://github.com/WerWolv/ImHex --recurse-submodules /root/ImHex RUN git clone https://github.com/WerWolv/ImHex --recurse-submodules /root/ImHex

6
dist/Arch/PKGBUILD vendored
View File

@@ -8,8 +8,8 @@ pkgdesc="A Hex Editor for Reverse Engineers, Programmers and people who value th
arch=("x86_64") arch=("x86_64")
url="https://github.com/WerWolv/ImHex" url="https://github.com/WerWolv/ImHex"
license=('GPL2') license=('GPL2')
depends=(glfw mbedtls fontconfig freetype2 libglvnd dbus gtk3 curl fmt yara zlib bzip2 xz zstd libssh2) depends=(glfw mbedtls freetype2 libglvnd dbus gtk3 curl fmt yara nlohmann-json zlib bzip2 xz zstd)
makedepends=(git nlohmann-json) makedepends=(git)
provides=(imhex) provides=(imhex)
conflicts=(imhex) conflicts=(imhex)
source=("$url/releases/download/v$pkgver/imhex-$pkgver-ArchLinux-x86_64.pkg.tar.zst") source=("$url/releases/download/v$pkgver/imhex-$pkgver-ArchLinux-x86_64.pkg.tar.zst")
@@ -26,5 +26,5 @@ package() {
install -d "$pkgdir/usr/share/imhex" install -d "$pkgdir/usr/share/imhex"
cp -r "$srcdir/usr/share/imhex/"{constants,encodings,includes,magic,patterns} "$pkgdir/usr/share/imhex" cp -r "$srcdir/usr/share/imhex/"{constants,encodings,includes,magic,patterns} "$pkgdir/usr/share/imhex"
cp -r "$srcdir/usr/share/"{applications,licenses,pixmaps,mime} "$pkgdir/usr/share" cp -r "$srcdir/usr/share/"{applications,licenses,pixmaps} "$pkgdir/usr/share"
} }

View File

@@ -6,12 +6,11 @@ brew "freetype2"
brew "libmagic" brew "libmagic"
brew "pkg-config" brew "pkg-config"
brew "curl" brew "curl"
brew "gcc@12"
brew "llvm" brew "llvm"
brew "glfw" brew "glfw"
brew "ninja" brew "ninja"
brew "zlib" brew "zlib"
brew "xz" brew "xz"
brew "bzip2" brew "bzip2"
brew "zstd" brew "zstd"
brew "libssh2"
brew "md4c"

View File

@@ -4,7 +4,7 @@ Section: editors
Priority: optional Priority: optional
Architecture: amd64 Architecture: amd64
License: GNU GPL-2 License: GNU GPL-2
Depends: libfontconfig1, libglfw3 | libglfw3-wayland, libmagic1, libmbedtls14, libfreetype6, libopengl0, libdbus-1-3, xdg-desktop-portal, libssh2-1, libmd4c0 Depends: libglfw3 | libglfw3-wayland, libmagic1, libmbedtls14, libfreetype6, libopengl0, libdbus-1-3, xdg-desktop-portal
Maintainer: WerWolv <hey@werwolv.net> Maintainer: WerWolv <hey@werwolv.net>
Description: ImHex Hex Editor Description: ImHex Hex Editor
A Hex Editor for Reverse Engineers, Programmers and A Hex Editor for Reverse Engineers, Programmers and

View File

@@ -20,17 +20,13 @@ DEPEND=""
RDEPEND="${DEPEND} RDEPEND="${DEPEND}
media-libs/glfw media-libs/glfw
sys-apps/file sys-apps/file
net-libs/mbedtls dev-libs/mbedtls
sys-apps/dbus
sys-apps/xdg-desktop-portal
sys-libs/zlib
app-arch/bzip2
app-arch/lzma
app-arch/zstd
app-arch/lz4
net-libs/libssh2
dev-libs/md4c
"
BDEPEND="${DEPEND}
dev-cpp/nlohmann_json dev-cpp/nlohmann_json
dbus
xdg-desktop-portal
sys-libs/zlib
app-arch/bzip2
app-arch/lzma
app-arch/zstd
" "
BDEPEND="${DEPEND}"

13
dist/ImHex.run.xml vendored
View File

@@ -1,13 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ImHex" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$CMakeCurrentBuildDir$" PASS_PARENT_ENVS_2="true" PROJECT_NAME="ImHex" TARGET_NAME="imhex_all" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="ImHex" RUN_TARGET_NAME="main">
<envs>
<env name="NO_DEBUG_BANNER" value="1" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="false" name="CMake Debug" type="CMakeListConfigurationType" factoryName="CMakeListConfigurationFactory">
<method v="2" />
</configuration>
</component>

84
dist/appimage/Dockerfile vendored Normal file
View File

@@ -0,0 +1,84 @@
FROM ubuntu:22.04 as build
# Used to invalidate layer cache but not mount cache
# See https://github.com/moby/moby/issues/41715#issuecomment-733976493
ARG UNIQUEKEY 1
COPY dist/get_deps_debian.sh /tmp
RUN --mount=type=cache,target=/var/apt/cache <<EOF
# Install apt dependencies
set -xe
apt update
# general deps
apt install -y ccache git wget
# appimage tools deps
apt install -y python3-pip python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fuse ninja-build
apt install -y squashfs-tools zsync
# imhex deps
/tmp/get_deps_debian.sh
EOF
RUN --mount=type=cache,target=/cache <<EOF
# Download appimage-builder
set -xe
mkdir -p /cache/bin
wget -nc https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /cache/bin/appimagetool || true
chmod +x /cache/bin/appimagetool
pip3 install git+https://github.com/AppImageCrafters/appimage-builder@f38699e
EOF
ENV PATH="/cache/bin/:${PATH}"
# Copy Imhex source
COPY . /imhex
ARG LTO=ON
ARG BUILD_TYPE=RelWithDebInfo
ARG GIT_COMMIT_HASH
ARG GIT_BRANCH
WORKDIR /build
SHELL ["bash", "-c"] # Ubuntu sh doesnt support string substitution
RUN <<EOF
# Prepare ImHex build
set -xe
CC=gcc-12 CXX=g++-12 cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_LONG="${GIT_COMMIT_HASH}" \
-DIMHEX_COMMIT_BRANCH="${GIT_BRANCH}" \
-DIMHEX_ENABLE_LTO=${LTO} \
-DIMHEX_PLUGINS_IN_SHARE=ON \
/imhex
EOF
ENV CCACHE_DIR /cache/ccache
RUN --mount=type=cache,target=/cache <<EOF
# Build Imhex
set -xe
ccache -zs
DESTDIR=AppDir ninja install
ccache -s
EOF
RUN <<EOF
# Package ImHex as AppImage
set -xe
export VERSION=$(cat /imhex/VERSION)
appimage-builder --recipe /imhex/dist/AppImageBuilder.yml
EOF
FROM scratch
# Copy build artifact
COPY --from=build /build/*.AppImage /build/*.AppImage.zsync ./

3
dist/cli/imhex.bat vendored
View File

@@ -1,3 +0,0 @@
@echo off
start "" "%~dp0..\imhex.exe" %*

5
dist/cli/imhex.sh vendored
View File

@@ -1,5 +0,0 @@
#!/bin/sh
script_path=$(readlink -f "$0")
script_dir=$(dirname "${script_path}")
"${script_dir}/../imhex" "$@" > /dev/null 2>&1 &

View File

@@ -18,11 +18,11 @@ docker buildx build . -f <DOCKERFILE_PATH> --progress plain --build-arg 'JOBS=4'
where `<DOCKERFILE_PATH>` should be replaced by the wanted Dockerfile base d on the build you want to do: where `<DOCKERFILE_PATH>` should be replaced by the wanted Dockerfile base d on the build you want to do:
| Wanted build | Dockerfile path | Target | | Wanted build | Dockerfile path |
|--------------|-----------------------------|--------| |--------------|-----------------------------|
| MacOS M1 | dist/macOS/arm64.Dockerfile | - | | MacOS M1 | dist/macOS/arm64.Dockerfile |
| AppImage | dist/appimage/Dockerfile | - | | AppImage | dist/appimage/Dockerfile |
| Web version | dist/web/Dockerfile | raw | | Web version | dist/web/Dockerfile |
We'll explain this command in the next section We'll explain this command in the next section
@@ -43,7 +43,6 @@ In the command saw earlier:
- `.` is the base folder that the Dockerfile will be allowed to see - `.` is the base folder that the Dockerfile will be allowed to see
- `-f <path>` is to specify the Dockerfile path - `-f <path>` is to specify the Dockerfile path
- `--progress plain` is to allow you to see the output of instructions - `--progress plain` is to allow you to see the output of instructions
- `--build-arg <key>=<value>` is to allow to specify arguments to the build (like -DKEY=VALUE in CMake) - `--build-arg <key>=<value>` is to allow to to specify arguments to the build (like -DKEY=VALUE in CMake)
- `--build-context key=<folder>` is to specify folders other than the base folder that the Dockerfile is allowed to see - `--build-context key=<folder>` is to specify folders other than the base folder that the Dockerfile is allowed to see
- `--output <path>` is the path to write the output package to. If not specified, Docker will create an image as the output (probably not what you want) - `--output <path>` is the path to write the output package to. If not specified, Docker will create an image as the output (probably not what you want)
- `--target <target>` specifies which docker target to build

View File

@@ -9,12 +9,18 @@ On Linux, ImHex is built through regular GCC (or optionally Clang).
cd ImHex cd ImHex
mkdir -p build mkdir -p build
cd build cd build
CC=gcc-14 CXX=g++-14 \ CC=gcc-12 CXX=g++-12 \
cmake -G "Ninja" \ cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_INSTALL_PREFIX="/usr" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fuse-ld=lld" \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DCMAKE_OBJC_COMPILER_LAUNCHER=ccache \
-DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
.. ..
ninja install make -j 4 install
``` ```
All paths follow the XDG Base Directories standard, and can thus be modified All paths follow the XDG Base Directories standard, and can thus be modified

View File

@@ -3,7 +3,7 @@
On macOS, ImHex is built through regular GCC and LLVM clang. On macOS, ImHex is built through regular GCC and LLVM clang.
1. Clone the repo using `git clone https://github.com/WerWolv/ImHex --recurse-submodules` 1. Clone the repo using `git clone https://github.com/WerWolv/ImHex --recurse-submodules`
2. Install all the dependencies using `brew bundle --file dist/macOS/Brewfile` 2. Install all the dependencies using `brew bundle --no-lock --file dist/Brewfile`
3. Build ImHex itself using the following commands: 3. Build ImHex itself using the following commands:
```sh ```sh
cd ImHex cd ImHex
@@ -15,10 +15,8 @@ OBJC=$(brew --prefix llvm)/bin/clang \
OBJCXX=$(brew --prefix llvm)/bin/clang++ \ OBJCXX=$(brew --prefix llvm)/bin/clang++ \
cmake -G "Ninja" \ cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="./install" \ -DCMAKE_INSTALL_PREFIX=./install \
-DIMHEX_GENERATE_PACKAGE=ON \ -DIMHEX_GENERATE_PACKAGE=ON \
.. ..
ninja install ninja install
``` ```
If your MacOS installation doesn't have graphic acceleration, you can check the [MacOS NoGPU guide](./macos_nogpu.md)

View File

@@ -1,10 +0,0 @@
### Compiling and running ImHex on macOS without a GPU
In order to run ImHex on a macOS installation without a GPU, you need a custom build of GLFW. You can build it this way:
Note: only tested on macOS x86
1. `git clone --depth 1 https://github.com/glfw/glfw`
2. `git apply {IMHEX_DIR}/dist/macOS/0001-glfw-SW.patch` (file is [here](../macOS/0001-glfw-SW.patch) in the ImHex repository. [Source](https://github.com/glfw/glfw/issues/2080).)
3. `cmake -G "Ninja" -DBUILD_SHARED_LIBS=ON ..`
4. `ninja install`, or `ninja` and figure out how to make ImHex detect the shared library

View File

@@ -14,7 +14,7 @@ mkdir build
cd build cd build
cmake -G "Ninja" \ cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="./install" \ -DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \ -DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \
.. ..
ninja install ninja install

20
dist/cppcheck.supp vendored
View File

@@ -1,20 +0,0 @@
missingIncludeSystem
constParameter
unusedFunction
preprocessorErrorDirective
checkersReport
noExplicitConstructor
unmatchedSuppression
useInitializationList
useStlAlgorithm
knownConditionTrueFalse
internalAstError
unsignedPositive
variableScope
unusedPrivateFunction
constParameterCallback
*:*/lib/third_party/*
*:*/external/pattern_language/external/*
*:*/external/disassembler/external/*
*:*/lib/libimhex/source/ui/imgui_imhex_extensions.cpp

54
dist/flake.nix vendored
View File

@@ -1,54 +0,0 @@
{
description = "ImHex";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
in {
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
default = pkgs.mkShell {
buildInputs = [
pkgs.cmake
pkgs.clang
pkgs.lld
pkgs.nghttp3
pkgs.pkg-config
pkgs.glfw
pkgs.fontconfig
pkgs.file
pkgs.mbedtls
pkgs.freetype
pkgs.dbus
pkgs.gtk3
pkgs.curl
pkgs.fmt
pkgs.yara
pkgs.nlohmann_json
pkgs.ninja
pkgs.zlib
pkgs.bzip2
pkgs.xz
pkgs.zstd
pkgs.lz4
pkgs.libssh2
pkgs.md4c
];
shellHook = ''
export CC=${pkgs.clang}/bin/clang
export CXX=${pkgs.clang}/bin/clang++
'';
};
});
};
}

View File

@@ -1,139 +0,0 @@
app-id: net.werwolv.ImHex
runtime: org.freedesktop.Platform
runtime-version: '24.08'
sdk: org.freedesktop.Sdk
command: imhex
rename-desktop-file: imhex.desktop
finish-args:
- --share=ipc
- --share=network
- --socket=wayland
- --socket=fallback-x11
- --filesystem=host
- --device=dri
modules:
- name: glfw
buildsystem: cmake-ninja
builddir: true
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DGLFW_BUILD_EXAMPLES=OFF
- -DGLFW_BUILD_TESTS=OFF
- -DGLFW_BUILD_DOCS=OFF
sources:
- type: archive
url: https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip
sha256: b5ec004b2712fd08e8861dc271428f048775200a2df719ccf575143ba749a3e9
cleanup:
- /include
- /lib/pkgconfig
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: mbedtls
buildsystem: cmake-ninja
config-opts:
- -DCMAKE_C_FLAGS=-fPIC
- -DENABLE_TESTING=OFF
- -DENABLE_PROGRAMS=OFF
sources:
- type: archive
url: https://github.com/ARMmbed/mbedtls/archive/refs/tags/v3.4.0.tar.gz
sha256: 1b899f355022e8d02c4d313196a0a16af86c5a692456fa99d302915b8cf0320a
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: fmt
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DFMT_TEST=OFF
sources:
- type: archive
url: https://github.com/fmtlib/fmt/releases/download/10.0.0/fmt-10.0.0.zip
sha256: 4943cb165f3f587f26da834d3056ee8733c397e024145ca7d2a8a96bb71ac281
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: yara
buildsystem: autotools
sources:
- type: git
url: https://github.com/VirusTotal/yara.git
tag: v4.3.1
commit: a6f6ce1d6d74a03c396660db25765f2a794d9e30
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: libssh2
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DENABLE_ZLIB_COMPRESSION=OFF
- -DENABLE_MANUAL=OFF
- -DENABLE_EXAMPLES=OFF
- -DENABLE_TESTING=OFF
sources:
- type: git
url: https://github.com/libssh2/libssh2.git
tag: libssh2-1.11.1
cleanup:
- /include
- /lib/pkgconfig
- /lib64/pkgconfig
- /lib/cmake
- /lib64/cmake
- name: md4c
buildsystem: cmake-ninja
config-opts:
- -DBUILD_SHARED_LIBS=ON
- -DMD4C_BUILD_TESTS=OFF
- -DMD4C_BUILD_EXAMPLES=OFF
- -DMD4C_BUILD_DOCS=OFF
sources:
- type: git
url: https://github.com/mity/md4c.git
tag: release-0.5.2
- name: imhex
buildsystem: cmake-ninja
builddir: true
config-opts:
- -DUSE_SYSTEM_CURL=ON
- -DUSE_SYSTEM_FMT=ON
- -DUSE_SYSTEM_YARA=ON
- -DIMHEX_OFFLINE_BUILD=ON
- -DIMHEX_BUNDLE_PLUGIN_SDK=OFF
- -DCMAKE_INSTALL_LIBDIR=lib
- -DCMAKE_INSTALL_RPATH='$ORIGIN/../lib:$ORIGIN/../lib64'
sources:
- type: dir
path: ../..
- type: git
url: https://github.com/WerWolv/ImHex-Patterns.git
tag: master
dest: ImHex-Patterns
x-checker-data:
type: git
tag-pattern: ^ImHex-v([\d.]+)$
post-install:
- mkdir -p ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps
- cp ${FLATPAK_DEST}/share/pixmaps/imhex.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/${FLATPAK_ID}.svg
- desktop-file-edit --set-key="Icon" --set-value="${FLATPAK_ID}" "${FLATPAK_DEST}/share/applications/imhex.desktop"

View File

@@ -1,69 +0,0 @@
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._c_m_a_p import CmapSubtable
import argparse
# Default PUAs
SOURCE_PUA_START = 0xEA00
SOURCE_PUA_END = 0x100F2
TARGET_PUA_START = 0xF0000
def move_pua_glyphs(input_font_path, output_font_path):
font = TTFont(input_font_path)
cmap_table = font['cmap']
glyph_set = font.getGlyphSet()
# Track moved glyphs
moved = 0
new_mapping = {}
# Collect original mappings in the PUA
for cmap in cmap_table.tables:
if cmap.isUnicode():
for codepoint, glyph_name in cmap.cmap.items():
if SOURCE_PUA_START <= codepoint <= SOURCE_PUA_END:
offset = codepoint - SOURCE_PUA_START
new_codepoint = TARGET_PUA_START + offset
new_mapping[new_codepoint] = glyph_name
moved += 1
if moved == 0:
print("No glyphs found in the source Private Use Area.")
return
# Remove old PUA entries from existing cmap subtables
for cmap in cmap_table.tables:
if cmap.isUnicode():
cmap.cmap = {
cp: gn for cp, gn in cmap.cmap.items()
if not (SOURCE_PUA_START <= cp <= SOURCE_PUA_END)
}
# Create or update a format 12 cmap subtable
found_format12 = False
for cmap in cmap_table.tables:
if cmap.format == 12 and cmap.platformID == 3 and cmap.platEncID in (10, 1):
cmap.cmap.update(new_mapping)
found_format12 = True
break
if not found_format12:
# Create a new format 12 subtable
cmap12 = CmapSubtable.newSubtable(12)
cmap12.platformID = 3
cmap12.platEncID = 10 # UCS-4
cmap12.language = 0
cmap12.cmap = new_mapping
cmap_table.tables.append(cmap12)
print(f"Moved {moved} glyphs from U+{SOURCE_PUA_START:X}U+{SOURCE_PUA_END:X} to U+{TARGET_PUA_START:X}+")
font.save(output_font_path)
print(f"Saved modified font to {output_font_path}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Move PUA glyphs in a TTF file to another Unicode range.")
parser.add_argument("input", help="Input TTF file path")
parser.add_argument("output", help="Output TTF file path")
args = parser.parse_args()
move_pua_glyphs(args.input, args.output)

View File

@@ -1,60 +0,0 @@
import argparse
from fontTools.ttLib import TTFont
import os
def unicode_to_utf8_escape(codepoint):
return ''.join([f'\\x{b:02x}' for b in chr(codepoint).encode('utf-8')])
def format_macro_name(prefix, glyph_name):
# Convert names like 'repo-forked' -> 'ICON_VS_REPO_FORKED'
return "ICON_" + prefix + "_" + glyph_name.upper().replace('-', '_')
def generate_font_header(font_path, output_path, font_macro_name, font_file_macro):
font = TTFont(font_path)
# Use cmap to get Unicode to glyph mapping
codepoint_to_names = {}
for table in font["cmap"].tables:
if table.isUnicode():
for codepoint, glyph_name in table.cmap.items():
codepoint_to_names.setdefault(codepoint, []).append(glyph_name)
if not codepoint_to_names:
print("No Unicode-mapped glyphs found in the font.")
return
# Remove any glyph that is lower than 0xFF
codepoint_to_names = {cp: names for cp, names in codepoint_to_names.items() if cp >= 0xFF}
min_cp = min(codepoint_to_names)
max_cp = max(codepoint_to_names)
with open(output_path, "w", encoding="utf-8") as out:
out.write("#pragma once\n\n")
out.write(f'#define FONT_ICON_FILE_NAME_{font_macro_name} "{font_file_macro}"\n\n')
out.write(f"#define ICON_MIN_{font_macro_name} 0x{min_cp:04x}\n")
out.write(f"#define ICON_MAX_16_{font_macro_name} 0x{max_cp:04x}\n")
out.write(f"#define ICON_MAX_{font_macro_name} 0x{max_cp:04x}\n")
written = set()
for codepoint in sorted(codepoint_to_names):
utf8 = unicode_to_utf8_escape(codepoint)
comment = f"// U+{codepoint:04X}"
glyph_names = sorted(set(codepoint_to_names[codepoint]))
for i, glyph_name in enumerate(glyph_names):
macro = format_macro_name(font_macro_name, glyph_name)
if macro in written:
continue
out.write(f"#define {macro} \"{utf8}\"\t{comment}\n")
written.add(macro)
print(f"Header generated at {output_path}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate C header file from TTF glyphs.")
parser.add_argument("font", help="Input .ttf font file")
parser.add_argument("output", help="Output .h file")
parser.add_argument("macro_name", help="Macro prefix")
args = parser.parse_args()
generate_font_header(args.font, args.output, args.macro_name, os.path.basename(args.font))

View File

@@ -1,54 +0,0 @@
import subprocess
import sys
def get_commits(branch: str, start_tag: str, end_tag: str) -> list[str]:
try:
commits_raw = subprocess.check_output([ "git", "--no-pager", "log", branch, "--no-color", "--pretty=oneline", "--abbrev-commit", f"{start_tag}..{end_tag}"], stderr=subprocess.DEVNULL).decode("UTF-8").split("\n")
except:
return []
commits = []
for line in commits_raw:
commits.append(line[9:])
return commits
def main(args: list) -> int:
if len(args) != 2:
print(f"Usage: {args[0]} prev_minor")
return 1
last_minor_version = f"v1.{args[1]}"
master_commits = get_commits("master", f"{last_minor_version}.0", "master")
for i in range(1, 100):
branch_commits = get_commits(f"releases/{last_minor_version}.X", f"{last_minor_version}.0", f"{last_minor_version}.{i}")
if len(branch_commits) == 0:
break
master_commits = [commit for commit in master_commits if commit not in branch_commits]
sorted_commits = {}
for commit in master_commits:
if commit == "":
continue
try:
category, commit_name = commit.split(":", 1)
if category not in sorted_commits:
sorted_commits[category] = []
sorted_commits[category].append(commit_name)
except:
print(f"Failed to parse commit: {commit}")
for category in sorted_commits:
print(f"## {category}\n")
for commit in sorted_commits[category]:
print(f"- {commit}")
print(f"\n")
if __name__ == "__main__":
exit(main(sys.argv))

View File

@@ -5,7 +5,6 @@ pacman -S $@ --needed \
gcc \ gcc \
lld \ lld \
glfw \ glfw \
fontconfig \
file \ file \
mbedtls \ mbedtls \
freetype2 \ freetype2 \
@@ -19,7 +18,4 @@ pacman -S $@ --needed \
zlib \ zlib \
bzip2 \ bzip2 \
xz \ xz \
zstd \ zstd
lz4 \
libssh2 \
md4c

View File

@@ -8,8 +8,8 @@ fi
apt install -y \ apt install -y \
build-essential \ build-essential \
gcc-14 \ gcc-12 \
g++-14 \ g++-12 \
lld \ lld \
${PKGCONF:-} \ ${PKGCONF:-} \
cmake \ cmake \
@@ -18,7 +18,6 @@ apt install -y \
libglm-dev \ libglm-dev \
libmagic-dev \ libmagic-dev \
libmbedtls-dev \ libmbedtls-dev \
libfontconfig-dev \
libfreetype-dev \ libfreetype-dev \
libdbus-1-dev \ libdbus-1-dev \
libcurl4-gnutls-dev \ libcurl4-gnutls-dev \
@@ -27,8 +26,4 @@ apt install -y \
zlib1g-dev \ zlib1g-dev \
libbz2-dev \ libbz2-dev \
liblzma-dev \ liblzma-dev \
libzstd-dev \ libzstd-dev
liblz4-dev \
libssh2-1-dev \
libmd4c-dev \
libmd4c-html0-dev

View File

@@ -4,7 +4,6 @@ dnf install -y \
cmake \ cmake \
dbus-devel \ dbus-devel \
file-devel \ file-devel \
fontconfig-devel \
freetype-devel \ freetype-devel \
libcurl-devel \ libcurl-devel \
gcc-c++ \ gcc-c++ \
@@ -17,6 +16,4 @@ dnf install -y \
libzstd-devel \ libzstd-devel \
zlib-devel \ zlib-devel \
bzip2-devel \ bzip2-devel \
xz-devel \ xz-devel
lz4-devel \
libssh2-devel

View File

@@ -1,23 +1,20 @@
#!/usr/bin/env sh #!/usr/bin/env sh
pacman -S --needed --noconfirm pactoys unzip git pacman -S --needed --noconfirm pactoys
pacboy -S --needed --noconfirm \ pacboy -S --needed --noconfirm \
gcc:p \ gcc:p \
lld:p \ lld:p \
cmake:p \ cmake:p \
ccache:p \ ccache:p \
glfw:p \ glfw:p \
file:p \ file:p \
curl-winssl:p \ curl-winssl:p \
mbedtls:p \ mbedtls:p \
freetype:p \ freetype:p \
dlfcn:p \ dlfcn:p \
ninja:p \ ninja:p \
capstone:p \ capstone:p \
zlib:p \ zlib:p \
bzip2:p \ bzip2:p \
xz:p \ xz:p \
zstd:p \ zstd:p
lz4:p \
libssh2-wincng:p \
md4c:p

View File

@@ -1,23 +0,0 @@
#!/usr/bin/env sh
zypper install \
cmake \
ninja \
gcc14 \
gcc14-c++ \
fontconfig-devel \
freetype2-devel \
libcurl-devel \
dbus-1-devel \
file-devel \
Mesa-libGL-devel \
libglfw-devel \
mbedtls-devel \
gtk3-devel \
libzstd-devel \
zlib-devel \
bzip3-devel \
xz-devel \
lz4-dev \
libssh2-devel \
md4c-devel

8
dist/imhex.desktop vendored
View File

@@ -1,5 +1,4 @@
[Desktop Entry] [Desktop Entry]
Version=1.0
Name=ImHex Name=ImHex
Comment=ImHex Hex Editor Comment=ImHex Hex Editor
GenericName=Hex Editor GenericName=Hex Editor
@@ -9,10 +8,3 @@ Type=Application
StartupNotify=true StartupNotify=true
Categories=Development;IDE; Categories=Development;IDE;
StartupWMClass=imhex StartupWMClass=imhex
Keywords=static-analysis;reverse-engineering;disassembler;disassembly;hacking;forensics;hex-editor;cybersecurity;security;binary-analysis;
MimeType=application/vnd.imhex.proj;
Actions=NewFile;
[Desktop Action NewFile]
Exec=imhex --new
Name=Create New File

8
dist/imhex.mime.xml vendored
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/vnd.imhex.proj">
<comment>ImHex Project</comment>
<glob pattern="*.hexproj"/>
</mime-type>
</mime-info>

239
dist/langtool.py vendored Executable file → Normal file
View File

@@ -1,203 +1,104 @@
#!/usr/bin/env python3
from pathlib import Path from pathlib import Path
import argparse import sys
import json import json
# This fixes a CJK full-width character input issue
# which makes left halves of deleted characters displayed on screen
# pylint: disable=unused-import
import re
import readline
DEFAULT_LANG = "en_US" DEFAULT_LANG = "en_US"
DEFAULT_LANG_PATH = "plugins/*/romfs/lang/"
INVALID_TRANSLATION = "" INVALID_TRANSLATION = ""
def handle_missing_key(command, lang_data, key, value):
if command == "check":
print(f"Error: Translation {lang_data['code']} is missing translation for key '{key}'")
exit(2)
elif command == "translate" or command == "create":
print(f"Key \033[1m'{key}': '{value}'\033[0m is missing in translation '{lang_data['code']}'")
new_value = input("Enter translation: ")
lang_data["translations"][key] = new_value
elif command == "update":
lang_data["translations"][key] = INVALID_TRANSLATION
def main(): def main():
parser = argparse.ArgumentParser( if len(sys.argv) < 3:
prog="langtool", print(f"Usage: {Path(sys.argv[0]).name} <check|translate|update|create> <lang folder path> <language>")
description="ImHex translate tool",
)
parser.add_argument(
"command",
choices=[
"check",
"translate",
"update",
"create",
"retranslate",
"untranslate",
"fmtzh",
],
)
parser.add_argument(
"-c", "--langdir", default=DEFAULT_LANG_PATH, help="Language folder glob"
)
parser.add_argument("-l", "--lang", default="", help="Language to translate")
parser.add_argument(
"-r", "--reflang", default="", help="Language for reference when translating"
)
parser.add_argument(
"-k", "--keys", help="Keys to re-translate (only in re/untranslate mode)"
)
args = parser.parse_args()
command = args.command
lang = args.lang
print(f"Running in {command} mode")
lang_files_glob = f"{lang}.json" if lang != "" else "*.json"
lang_folders = set(Path(".").glob(args.langdir))
if len(lang_folders) == 0:
print(f"Error: {args.langdir} matches nothing")
return 1 return 1
for lang_folder in lang_folders: command = sys.argv[1]
if not lang_folder.is_dir(): if command not in ["check", "translate", "update", "create"]:
print(f"Error: {lang_folder} is not a folder") print(f"Unknown command: {command}")
return 1 return 1
default_lang_data = {} print(f"Using langtool in {command} mode")
default_lang_path = lang_folder / Path(DEFAULT_LANG + ".json")
if not default_lang_path.exists():
print(
f"Error: Default language file {default_lang_path} does not exist in {lang_folder}"
)
return 1
with default_lang_path.open("r", encoding="utf-8") as file:
default_lang_data = json.load(file)
reference_lang_data = None lang_folder_path = Path(sys.argv[2])
reference_lang_path = lang_folder / Path(args.reflang + ".json") if not lang_folder_path.exists():
if reference_lang_path.exists(): print(f"Error: {lang_folder_path} does not exist")
with reference_lang_path.open("r", encoding="utf-8") as file: return 1
reference_lang_data = json.load(file)
if not lang_folder_path.is_dir():
print(f"Error: {lang_folder_path} is not a folder")
return 1
lang = sys.argv[3] if len(sys.argv) > 3 else ""
print(f"Processing language files in {lang_folder_path}...")
default_lang_file_path = lang_folder_path / Path(DEFAULT_LANG + ".json")
if not default_lang_file_path.exists():
print(f"Error: Default language file {default_lang_file_path} does not exist")
return 1
print(f"Using file '{default_lang_file_path.name}' as template language file")
with default_lang_file_path.open("r", encoding="utf-8") as default_lang_file:
default_lang_data = json.load(default_lang_file)
if command == "create" and lang != "": if command == "create" and lang != "":
lang_file_path = lang_folder / Path(lang + ".json") lang_file_path = lang_folder_path / Path(lang + ".json")
if lang_file_path.exists(): if lang_file_path.exists():
continue print(f"Error: Language file {lang_file_path} already exists")
return 1
exist_lang_data = None print(f"Creating new language file '{lang_file_path.name}'")
for lang_folder1 in lang_folders:
lang_file_path1 = lang_folder1 / Path(lang + ".json")
if lang_file_path1.exists():
with lang_file_path1.open("r", encoding="utf-8") as file:
exist_lang_data = json.load(file)
break
print(f"Creating new language file '{lang_file_path}'")
with lang_file_path.open("w", encoding="utf-8") as new_lang_file: with lang_file_path.open("w", encoding="utf-8") as new_lang_file:
new_lang_data = { new_lang_data = {
"code": lang,
"language": input("Enter language: "),
"country": input("Enter country: "),
"translations": {}
} }
json.dump(new_lang_data, new_lang_file, indent=4, ensure_ascii=False) json.dump(new_lang_data, new_lang_file, indent=4, ensure_ascii=False)
lang_files = set(lang_folder.glob(lang_files_glob)) for additional_lang_file_path in lang_folder_path.glob("*.json"):
if len(lang_files) == 0: if not lang == "" and not additional_lang_file_path.stem == lang:
print(f"Warn: Language file for '{lang}' does not exist in '{lang_folder}'")
for lang_file_path in lang_files:
if (
lang_file_path.stem == f"{DEFAULT_LANG}.json"
or lang_file_path.stem == f"{args.reflang}.json"
):
continue continue
print(f"\nProcessing '{lang_file_path}'") if additional_lang_file_path.name.startswith(DEFAULT_LANG):
if not (command == "update" or command == "create"): continue
print("\n----------------------------\n")
with lang_file_path.open("r+", encoding="utf-8") as target_lang_file: print(f"\nProcessing file '{additional_lang_file_path.name}'\n----------------------------\n")
lang_data = json.load(target_lang_file)
for key, value in default_lang_data.items(): with additional_lang_file_path.open("r+", encoding="utf-8") as additional_lang_file:
has_translation = ( additional_lang_data = json.load(additional_lang_file)
key in lang_data
and lang_data[key] != INVALID_TRANSLATION for key, value in default_lang_data["translations"].items():
) if key not in additional_lang_data["translations"] or additional_lang_data["translations"][key] == INVALID_TRANSLATION:
if ( handle_missing_key(command, additional_lang_data, key, value)
has_translation
and not (
(command == "retranslate" or command == "untranslate")
and re.compile(args.keys).fullmatch(key)
)
and not command == "fmtzh"
):
continue
if command == "check":
print(
f"Error: Translation {lang_file_path} is missing translation for key '{key}'"
)
elif (
command == "translate"
or command == "retranslate"
or command == "untranslate"
):
if command == "untranslate" and not has_translation:
continue
reference_tranlsation = (
" '%s'" % reference_lang_data[key]
if (
reference_lang_data
and key in reference_lang_data
)
else ""
)
print(
f"\033[1m'{key}' '{value}'{reference_tranlsation}\033[0m => ",
end="",
)
if has_translation:
translation = lang_data[key]
print(f" <= \033[1m'{translation}'\033[0m")
print() # for a new line
if command == "untranslate":
lang_data[key] = INVALID_TRANSLATION
continue
try:
new_value = input("=> ")
lang_data[key] = new_value
except KeyboardInterrupt:
break
elif command == "update" or command == "create":
lang_data[key] = INVALID_TRANSLATION
elif command == "fmtzh":
if has_translation:
lang_data[key] = fmtzh(
lang_data[key]
)
keys_to_remove = [] keys_to_remove = []
for key, value in lang_data.items(): for key, value in additional_lang_data["translations"].items():
if key not in default_lang_data: if key not in default_lang_data["translations"]:
keys_to_remove.append(key) keys_to_remove.append(key)
for key in keys_to_remove: for key in keys_to_remove:
lang_data.pop(key) additional_lang_data["translations"].pop(key)
print( print(f"Removed unused key '{key}' from translation '{additional_lang_data['code']}'")
f"Removed unused key '{key}' from translation '{lang_file_path}'"
)
target_lang_file.seek(0) additional_lang_file.seek(0)
target_lang_file.truncate() additional_lang_file.truncate()
json.dump( json.dump(additional_lang_data, additional_lang_file, indent=4, sort_keys=True, ensure_ascii=False)
lang_data,
target_lang_file,
indent=4,
sort_keys=True,
ensure_ascii=False,
)
def fmtzh(text: str) -> str: if __name__ == '__main__':
text = re.sub(r"(\.{3}|\.{6})", "……", text)
text = text.replace("!", "")
text = re.sub(r"([^\.\na-zA-Z\d])\.$", "\1", text, flags=re.M)
text = text.replace("?", "")
return text
if __name__ == "__main__":
exit(main()) exit(main())

View File

@@ -1,5 +1,5 @@
From 9c8665af4c2e2ce66555c15c05c72027bfdf0cb6 Mon Sep 17 00:00:00 2001 From 9c8665af4c2e2ce66555c15c05c72027bfdf0cb6 Mon Sep 17 00:00:00 2001
From: iTrooz <hey@itrooz.fr> From: iTrooz <itrooz@protonmail.com>
Date: Mon, 29 Aug 2022 17:29:38 +0200 Date: Mon, 29 Aug 2022 17:29:38 +0200
Subject: [PATCH] Use software rendering on MacOS Subject: [PATCH] Use software rendering on MacOS

View File

@@ -1,29 +1,18 @@
# This base image is also known as "crosscompile". See arm64.crosscompile.Dockerfile # This base image is also known as "crosscompile". See arm64.crosscompile.Dockerfile
FROM ghcr.io/werwolv/macos-crosscompile:6d89b20ac5ebedb6f680f94637591c94cb36f40b as build FROM ghcr.io/itrooz/macos-crosscompile:clang17-nosdk as build
ENV MACOSX_DEPLOYMENT_TARGET 11.0 ENV MACOSX_DEPLOYMENT_TARGET 12.1
# -- DOWNLOADING STUFF # -- DOWNLOADING STUFF
# Update vcpkg
RUN <<EOF
cp /vcpkg/triplets/community/arm-osx-mytriplet.cmake /tmp/arm-osx-mytriplet.cmake
git -C /vcpkg clean -ffdx
git -C /vcpkg checkout origin/master
git -C /vcpkg reset --hard
git -C /vcpkg pull
/vcpkg/bootstrap-vcpkg.sh
cp /tmp/arm-osx-mytriplet.cmake /vcpkg/triplets/community/arm-osx-mytriplet.cmake
EOF
## Install make ## Install make
RUN --mount=type=cache,target=/var/lib/apt/lists/ apt update && apt install -y make cmake RUN --mount=type=cache,target=/var/lib/apt/lists/ apt update && apt install -y make
## fix environment ## fix environment
### add install_name_tool for cmake command that won't have the right env set (see PostprocessBundle.cmake function postprocess_bundle()) ### add install_name_tool for cmake command that won't have the right env set (see PostprocessBundle.cmake function postprocess_bundle())
RUN cp /osxcross/build/cctools-port/cctools/misc/install_name_tool /usr/bin/install_name_tool RUN cp /osxcross/build/cctools-port/cctools/misc/install_name_tool /usr/bin/install_name_tool
### a cmake thing wants 'otool' and not '' apparently ### a cmake thing wants 'otool' and not '' apparently
RUN cp /osxcross/target/bin/aarch64-apple-darwin24-otool /usr/bin/otool RUN cp /osxcross/target/bin/aarch64-apple-darwin23-otool /usr/bin/otool
## Clone glfw ## Clone glfw
RUN <<EOF RUN <<EOF
@@ -36,19 +25,19 @@ EOF
RUN --mount=type=cache,target=/cache <<EOF RUN --mount=type=cache,target=/cache <<EOF
## Download SDK is missing (it may have been removed from the image) ## Download SDK is missing (it may have been removed from the image)
set -xe set -xe
if [ ! -d /osxcross/target/SDK/MacOSX15.0.sdk ]; then if [ ! -d /osxcross/target/SDK/MacOSX14.0.sdk ]; then
wget https://github.com/joseluisq/macosx-sdks/releases/download/15.0/MacOSX15.0.sdk.tar.xz -O /cache/MacOSX15.0.sdk.tar.xz -nc || true wget https://github.com/joseluisq/macosx-sdks/releases/download/14.0/MacOSX14.0.sdk.tar.xz -O /cache/MacOSX14.0.sdk.tar.xz -nc || true
mkdir -p /osxcross/target/SDK mkdir -p /osxcross/target/SDK
tar -C /osxcross/target/SDK -xf /cache/MacOSX15.0.sdk.tar.xz tar -C /osxcross/target/SDK -xf /cache/MacOSX14.0.sdk.tar.xz
fi fi
EOF EOF
## Download libmagic ## Download libmagic
### Clone libmagic ### Clone libmagic
RUN git clone --depth 1 --branch FILE5_46 https://github.com/file/file /mnt/file RUN git clone https://github.com/file/file /mnt/file
### Download libmagic dependencies ### Download libmagic dependencies
RUN --mount=type=cache,target=/var/lib/apt/lists/ apt update && apt install -y libtool autoconf RUN --mount=type=cache,target=/var/lib/apt/lists/ apt install -y libtool autoconf
# -- DOWNLOADING + BUILDING STUFF # -- DOWNLOADING + BUILDING STUFF
@@ -67,8 +56,6 @@ vcpkg install --triplet=arm-osx-mytriplet zlib
vcpkg install --triplet=arm-osx-mytriplet bzip2 vcpkg install --triplet=arm-osx-mytriplet bzip2
vcpkg install --triplet=arm-osx-mytriplet liblzma vcpkg install --triplet=arm-osx-mytriplet liblzma
vcpkg install --triplet=arm-osx-mytriplet zstd vcpkg install --triplet=arm-osx-mytriplet zstd
vcpkg install --triplet=arm-osx-mytriplet openssl
vcpkg install --triplet=arm-osx-mytriplet libssh2
EOF EOF
## Install glfw3 dep ## Install glfw3 dep
@@ -101,7 +88,7 @@ RUN --mount=type=cache,target=/cache <<EOF
make -j $JOBS install make -j $JOBS install
# Now, we cross-compile it and install it in the libraries folder # Now, we cross-compile it and install it in the libraries folder
CC=/osxcross/target/bin/aarch64-apple-darwin24-clang CXX=/osxcross/target/bin/aarch64-apple-darwin24-clang++ ./configure --prefix /vcpkg/installed/arm-osx-mytriplet --host $OSXCROSS_HOST CC=/osxcross/target/bin/aarch64-apple-darwin23-clang CXX=/osxcross/target/bin/aarch64-apple-darwin23-clang++ ./configure --prefix /vcpkg/installed/arm-osx-mytriplet --host $OSXCROSS_HOST
make -j $JOBS make -j $JOBS
make install make install
@@ -131,8 +118,7 @@ if [ "$CUSTOM_GLFW" ]; then
cd /mnt/glfw cd /mnt/glfw
mkdir build mkdir build
cd build cd build
CC=o64-clang CXX=o64-clang++ cmake -G "Ninja" \ CC=o64-gcc CXX=o64-g++ cmake -G "Ninja" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_SHARED_LIBS=ON \ -DBUILD_SHARED_LIBS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
@@ -140,7 +126,7 @@ if [ "$CUSTOM_GLFW" ]; then
-DCMAKE_OBJC_COMPILER_LAUNCHER=ccache \ -DCMAKE_OBJC_COMPILER_LAUNCHER=ccache \
-DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_INSTALL_PREFIX=/vcpkg/installed/arm-osx-mytriplet \ -DCMAKE_INSTALL_PREFIX=/vcpkg/installed/arm-osx-mytriplet \
-DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 \ -DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 \
.. ..
ninja -j $JOBS install ninja -j $JOBS install
@@ -151,25 +137,25 @@ EOF
# Build ImHex # Build ImHex
## Copy ImHex ## Copy ImHex
COPY --from=imhex / /mnt/ImHex COPY --from=imhex / /mnt/ImHex
## Configure ImHex build ## Patch ImHex with hacks
# COPY toolchain.cmake.2 /osxcross/target/toolchain.cmake
# Configure ImHex build
RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps \ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps \
cd /mnt/ImHex && \ cd /mnt/ImHex && \
# compilers # compilers
CC=o64-clang CXX=o64-clang++ OBJC=/osxcross/target/bin/aarch64-apple-darwin24-clang OBJCXX=/osxcross/target/bin/aarch64-apple-darwin24-clang++ \ CC=o64-clang CXX=o64-clang++ OBJC=/osxcross/target/bin/aarch64-apple-darwin23-clang OBJCXX=/osxcross/target/bin/aarch64-apple-darwin23-clang++ \
cmake -G "Ninja" \ cmake -G "Ninja" \
`# ccache flags` \ `# ccache flags` \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_OBJC_COMPILER_LAUNCHER=ccache -DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_OBJC_COMPILER_LAUNCHER=ccache -DCMAKE_OBJCXX_COMPILER_LAUNCHER=ccache \
`# MacOS cross-compiling flags` \ `# MacOS cross-compiling flags` \
-DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3 \ -DVCPKG_TARGET_TRIPLET=arm-osx-mytriplet -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/osxcross/target/toolchain.cmake -DCMAKE_OSX_SYSROOT=/osxcross/target/SDK/MacOSX14.0.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 \
`# Override compilers for code generators` \ `# Override compilers for code generators` \
-DNATIVE_CMAKE_C_COMPILER=/usr/bin/clang -DNATIVE_CMAKE_CXX_COMPILER=/usr/bin/clang++ \ -DNATIVE_CMAKE_C_COMPILER=/usr/bin/clang -DNATIVE_CMAKE_CXX_COMPILER=/usr/bin/clang++ \
`# Normal ImHex flags` \ `# Normal ImHex flags` \
-DIMHEX_GENERATE_PACKAGE=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DIMHEX_GENERATE_PACKAGE=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
`# other flags` \ `# other flags` \
-DIMHEX_STRICT_WARNINGS=OFF \ -DIMHEX_STRICT_WARNINGS=OFF \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DCMAKE_INSTALL_PREFIX=/mnt/ImHex/build/install \ -DCMAKE_INSTALL_PREFIX=/mnt/ImHex/build/install \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-B build -B build
## Build ImHex ## Build ImHex
RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps <<EOF RUN --mount=type=cache,target=/cache --mount=type=cache,target=/mnt/ImHex/build/_deps <<EOF
@@ -184,4 +170,4 @@ EOF
FROM scratch FROM scratch
COPY --from=build /mnt/ImHex/build/install/ImHex.app ImHex.app COPY --from=build /mnt/ImHex/build/install/imhex.app ImHex.app

View File

@@ -1,12 +1,12 @@
# This image is provided for reference, but a (probably more up to date) image should be available at https://github.com/iTrooz/macos-crosscompile # This image is is provided for reference, but a (probably more up to date) image should be available at https://github.com/iTrooz/macos-crosscompile
FROM ubuntu:22.04 FROM ubuntu:22.04
ENV PATH $PATH:/osxcross/target/bin ENV PATH $PATH:/osxcross/target/bin
ENV LD_LIBRARY_PATH /osxcross/target/lib ENV LD_LIBRARY_PATH /osxcross/target/lib
ENV OSXCROSS_SDK /osxcross/target/SDK/MacOSX14.0.sdk ENV OSXCROSS_SDK /osxcross/target/SDK/MacOSX14.0.sdk
ENV OSXCROSS_TARGET darwin24 ENV OSXCROSS_TARGET darwin23
ENV OSXCROSS_TARGET_DIR /osxcross/target ENV OSXCROSS_TARGET_DIR /osxcross/target
ENV OSXCROSS_HOST aarch64-apple-darwin24 ENV OSXCROSS_HOST aarch64-apple-darwin23
# -- DOWNLOADING STUFF # -- DOWNLOADING STUFF
@@ -68,6 +68,19 @@ RUN --mount=type=cache,target=/cache <<EOF
ccache -s ccache -s
EOF EOF
# Not needed, because we don't use gcc for cross-compiling anymore
# ## Install dependencies for gcc-13
# RUN apt install -y gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
# ## Build cross-compiler gcc-13
# RUN --mount=type=cache,target=/cache <<EOF
# set -xe
# ccache -zs
# cd /osxcross
# UNATTENDED=1 CC=/usr/lib/ccache/gcc CXX=/usr/lib/ccache/g++ GCC_VERSION=13.2.0 ./build_gcc.sh
# ccache -s
# EOF
ARG DELETE_SDK=1 ARG DELETE_SDK=1
RUN <<EOF RUN <<EOF

View File

@@ -1,11 +0,0 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES x86_64)
set(VCPKG_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "" FORCE)
set(VCPKG_C_FLAGS "-mmacosx-version-min=10.15")
set(VCPKG_CXX_FLAGS "-mmacosx-version-min=10.15")
set(ENV{MACOSX_DEPLOYMENT_TARGET} "10.15")

4
dist/msys2/PKGBUILD vendored
View File

@@ -20,9 +20,7 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
"${MINGW_PACKAGE_PREFIX}-zlib" "${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-bzip2" "${MINGW_PACKAGE_PREFIX}-bzip2"
"${MINGW_PACKAGE_PREFIX}-xz" "${MINGW_PACKAGE_PREFIX}-xz"
"${MINGW_PACKAGE_PREFIX}-zstd" "${MINGW_PACKAGE_PREFIX}-zstd")
"${MINGW_PACKAGE_PREFIX}-libssh2-wincng"
"${MINGW_PACKAGE_PREFIX}-md4c")
source=() source=()
sha256sums=() sha256sums=()

View File

@@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>net.werwolv.ImHex</id>
<name>ImHex</name>
<summary>Modern REing Hex Editor</summary>
<description>
<p>
ImHex is a modern Hex Editor for Reverse Engineers, Developers, Malware Analysists and Hackers who value
their retinas when working at 3 AM once again.
</p>
<p>
Features:
</p>
<ul>
<li>Featureful hex view</li>
<li>Custom C++-like pattern language for parsing and highlighting a file's content</li>
<li>Data importing and exporting</li>
<li>Data inspector allowing interpretation of data as many different types</li>
<li>Huge file support with fast and efficient loading</li>
<li>Strings search</li>
<li>File hashing support</li>
<li>Disassembler supporting many different architectures: ARM, x86, PowerPC, MIPS, and more</li>
<li>Bookmarks</li>
<li>Data analyzer</li>
<li>
Helpful tools such as an Itanium and MSVC demangler, ASCII table, Regex
replacer, mathematical expression evaluator (calculator), hexadecimal
color picker and many more
</li>
<li>Doesn't burn out your retinas when used in late-night sessions</li>
</ul>
</description>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0-only</project_license>
<developer id="net.werwolv">
<name>WerWolv</name>
</developer>
<url type="homepage">https://imhex.werwolv.net</url>
<url type="bugtracker">https://github.com/WerWolv/ImHex/issues</url>
<url type="help">https://docs.werwolv.net/imhex</url>
<url type="donation">https://github.com/sponsors/WerWolv</url>
<url type="contact">https://imhex.werwolv.net/discord</url>
<url type="vcs-browser">https://github.com/WerWolv/ImHex</url>
<url type="contribute">https://github.com/WerWolv/ImHex/blob/master/CONTRIBUTING.md</url>
<launchable type="desktop-id">imhex.desktop</launchable>
<screenshots>
<screenshot type="default" width="1920" height="1017">
<image type="source">https://raw.githubusercontent.com/flathub/net.werwolv.ImHex/master/screenshots/screenshot1.png</image>
<caption>Using a pattern to parse and highlight different sections of an ELF executable file</caption>
</screenshot>
<screenshot type="default" width="1920" height="1017">
<image type="source">https://raw.githubusercontent.com/flathub/net.werwolv.ImHex/master/screenshots/screenshot2.png</image>
<caption>Managing bookmarks, diffing two files and decrypting a region of data using the data preprocessor</caption>
</screenshot>
</screenshots>
<content_rating type="oars-1.1"/>
<branding>
<color type="primary" scheme_preference="light">#babec9</color>
<color type="primary" scheme_preference="dark">#0f0f0f</color>
</branding>
<releases>
<release version="1.0.0" date="2025-01-01">
<description></description>
</release>
</releases>
<update_contact>hey@werwolv.net</update_contact>
<recommends>
<control>keyboard</control>
<control>pointing</control>
</recommends>
</component>

22
dist/net.werwolv.ImHex.yaml vendored Normal file
View File

@@ -0,0 +1,22 @@
app-id: net.werwolv.ImHex
runtime: org.freedesktop.Platform
runtime-version: '20.08'
default-branch: stable
sdk: org.freedesktop.Sdk
command: imhex
finish-args:
- --share=ipc
- --socket=x11
- --filesystem=host
- --device=all
modules:
- name: imhex
buildsystem: cmake
config-opts:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
sources:
- type: git
url: https://github.com/WerWolv/ImHex.git

34
dist/net.werwolv.imhex.metainfo.xml vendored Normal file
View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>imhex</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0</project_license>
<name>ImHex</name>
<developer_name>WerWolv</developer_name>
<update_contact>hey@werwolv.net</update_contact>
<summary>A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM</summary>
<description>
<p>ImHex is a feature-rich Hex Editor aimed towards Reverse Engineers working with foreign data formats, malware, executables and raw memory.
Besides all the features a common Hex Editor has, ImHex also features a custom scripting language used to declare and dissect data structures, support for running YARA rules, a node-based graphical data pre-processor and support for various data sources such as files, raw disks or GDB Servers.</p>
</description>
<launchable type="desktop-id">imhex.desktop</launchable>
<url type="homepage">https://imhex.werwolv.net</url>
<screenshots>
<screenshot type="default">
<image>https://user-images.githubusercontent.com/10835354/139717326-8044769d-527b-4d88-8adf-2d4ecafdca1f.png</image>
</screenshot>
<screenshot>
<image>https://user-images.githubusercontent.com/10835354/139717323-1f8c9d52-f7eb-4f43-9f11-097ac728ed6c.png</image>
</screenshot>
</screenshots>
<provides>
<id>imhex.desktop</id>
</provides>
<categories>
<category>Development</category>
</categories>
</component>

114
dist/rpm/imhex.spec vendored
View File

@@ -1,12 +1,10 @@
%define source_date_epoch_from_changelog 0
Name: imhex Name: imhex
Version: VERSION Version: 1.26.2
Release: 0%{?dist} Release: 0%{?dist}
Summary: A hex editor for reverse engineers and programmers Summary: A hex editor for reverse engineers and programmers
License: GPL-2.0-only AND Zlib AND MIT AND Apache-2.0 License: GPL-2.0-only AND Zlib AND MIT AND Apache-2.0
# imhex is gplv2. capstone is custom. # imhex is gplv2. capstone is custom. nativefiledialog is Zlib.
# see license dir for full breakdown # see license dir for full breakdown
URL: https://imhex.werwolv.net/ URL: https://imhex.werwolv.net/
# We need the archive with deps bundled # We need the archive with deps bundled
@@ -24,41 +22,32 @@ BuildRequires: libglvnd-devel
BuildRequires: glfw-devel BuildRequires: glfw-devel
BuildRequires: json-devel BuildRequires: json-devel
BuildRequires: libcurl-devel BuildRequires: libcurl-devel
BuildRequires: libarchive-devel
BuildRequires: libzstd-devel
BuildRequires: zlib-devel
BuildRequires: bzip2-devel
BuildRequires: xz-devel
BuildRequires: llvm-devel BuildRequires: llvm-devel
BuildRequires: mbedtls-devel BuildRequires: mbedtls-devel
BuildRequires: yara-devel BuildRequires: yara-devel
BuildRequires: nativefiledialog-extended-devel BuildRequires: nativefiledialog-extended-devel
BuildRequires: lz4-devel BuildRequires: dotnet-sdk-8.0
BuildRequires: libssh2-devel BuildRequires: libzstd-devel
%if 0%{?rhel} == 9 BuildRequires: zlib-devel
BuildRequires: gcc-toolset-14 BuildRequires: bzip2-devel
BuildRequires: xz-devel
%if 0%{?rhel}
BuildRequires: gcc-toolset-12
%endif %endif
%if 0%{?fedora} || 0%{?rhel} > 9
BuildRequires: capstone-devel
%endif
BuildRequires: lunasvg-devel
Provides: bundled(gnulib) Provides: bundled(gnulib)
%if 0%{?rhel} == 10 Provides: bundled(capstone) = 5.0-rc2
Provides: bundled(capstone) = 5.0.1 Provides: bundled(imgui)
%endif
Provides: bundled(imgui) = 1.90.8
Provides: bundled(libromfs) Provides: bundled(libromfs)
Provides: bundled(microtar) Provides: bundled(microtar)
Provides: bundled(libpl) = %{version}
Provides: bundled(xdgpp) Provides: bundled(xdgpp)
# working on packaging this, bundling for now as to now delay updates
Provides: bundled(miniaudio) = 0.11.11
# ftbfs on these arches. armv7hl might compile when capstone 5.x
# is released upstream and we can build against it
# [7:02 PM] WerWolv: We're not supporting 32 bit anyways soooo # [7:02 PM] WerWolv: We're not supporting 32 bit anyways soooo
# [11:38 AM] WerWolv: Officially supported are x86_64 and aarch64 # [11:38 AM] WerWolv: Officially supported are x86_64 and aarch64
ExclusiveArch: x86_64 %{arm64} ExclusiveArch: x86_64 %{arm64} ppc64le
%description %description
ImHex is a Hex Editor, a tool to display, decode and analyze binary data to ImHex is a Hex Editor, a tool to display, decode and analyze binary data to
@@ -72,31 +61,14 @@ displayed, a disassembler, diffing support, bookmarks and much much more. At the
same time ImHex is completely free and open source under the GPLv2 language. same time ImHex is completely free and open source under the GPLv2 language.
%package devel
Summary: Development files for %{name}
License: GPL-2.0-only
%description devel
%{summary}
%prep %prep
%autosetup -n ImHex -p1 %autosetup -n ImHex
# remove bundled libs we aren't using # remove bundled libs we aren't using
rm -rf lib/third_party/{curl,fmt,llvm,nlohmann_json,yara} rm -rf lib/third_party/{fmt,nlohmann_json,yara}
%if 0%{?fedora} || 0%{?rhel} > 9
rm -rf lib/third_party/capstone
%endif
# rhel 9 doesn't support all of the new appstream metainfo tags
%if 0%{?rhel} && 0%{?rhel} < 10
sed -i -e '/url type="vcs-browser"/d' \
-e '/url type="contribute"/d' \
dist/net.werwolv.ImHex.metainfo.xml
%endif
%build %build
%if 0%{?rhel} == 9 %if 0%{?rhel}
. /opt/rh/gcc-toolset-14/enable . /opt/rh/gcc-toolset-12/enable
%set_build_flags %set_build_flags
CXXFLAGS+=" -std=gnu++2b" CXXFLAGS+=" -std=gnu++2b"
%endif %endif
@@ -106,27 +78,23 @@ CXXFLAGS+=" -std=gnu++2b"
-D IMHEX_OFFLINE_BUILD=ON \ -D IMHEX_OFFLINE_BUILD=ON \
-D USE_SYSTEM_NLOHMANN_JSON=ON \ -D USE_SYSTEM_NLOHMANN_JSON=ON \
-D USE_SYSTEM_FMT=ON \ -D USE_SYSTEM_FMT=ON \
-D USE_SYSTEM_CURL=ON \
-D USE_SYSTEM_LLVM=ON \
-D USE_SYSTEM_MD4C=OFF \
%if 0%{?fedora} || 0%{?rhel} > 9
-D USE_SYSTEM_CAPSTONE=ON \
%endif
-D USE_SYSTEM_LUNASVG=ON \
-D USE_SYSTEM_YARA=ON \ -D USE_SYSTEM_YARA=ON \
-D USE_SYSTEM_NFD=ON \ -D USE_SYSTEM_NFD=ON \
-D IMHEX_ENABLE_UNIT_TESTS=ON \ -D IMHEX_USE_GTK_FILE_PICKER=ON \
%if 0%{?rhel} -D IMHEX_BUNDLE_DOTNET=OFF \
-D IMHEX_BUILD_HARDENING=OFF # when capstone >= 5.x is released we should be able to build against \
%endif # system libs of it \
# disable built-in build hardening because it is already # -D USE_SYSTEM_CAPSTONE=ON
# done in rhel buildroots. adding the flags again from
# upstream generates build errors
%cmake_build %cmake_build
%check %check
%if 0%{?rhel}
. /opt/rh/gcc-toolset-12/enable
%set_build_flags
CXXFLAGS+=" -std=gnu++2b"
%endif
# build binaries required for tests # build binaries required for tests
%cmake_build --target unit_tests %cmake_build --target unit_tests
%ctest --exclude-regex '(Helpers/StoreAPI|Helpers/TipsAPI|Helpers/ContentAPI)' %ctest --exclude-regex '(Helpers/StoreAPI|Helpers/TipsAPI|Helpers/ContentAPI)'
@@ -138,15 +106,15 @@ CXXFLAGS+=" -std=gnu++2b"
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop
# this is a symlink for the old appdata name that we don't need # this is a symlink for the old appdata name that we don't need
rm -f %{buildroot}%{_metainfodir}/net.werwolv.ImHex.appdata.xml rm -f %{buildroot}%{_metainfodir}/net.werwolv.%{name}.appdata.xml
# AppData # AppData
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/net.werwolv.ImHex.metainfo.xml appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/net.werwolv.%{name}.metainfo.xml
# install licenses # install licenses
%if 0%{?rhel} == 9 cp -a lib/third_party/nativefiledialog/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/nativefiledialog-LICENSE
cp -a lib/third_party/capstone/LICENSES/LICENSE.TXT %{buildroot}%{_datadir}/licenses/%{name}/capstone-LICENSE cp -a lib/third_party/capstone/LICENSE.TXT %{buildroot}%{_datadir}/licenses/%{name}/capstone-LICENSE
%endif cp -a lib/third_party/capstone/suite/regress/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/capstone-regress-LICENSE
cp -a lib/third_party/microtar/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/microtar-LICENSE cp -a lib/third_party/microtar/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/microtar-LICENSE
cp -a lib/third_party/xdgpp/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/xdgpp-LICENSE cp -a lib/third_party/xdgpp/LICENSE %{buildroot}%{_datadir}/licenses/%{name}/xdgpp-LICENSE
@@ -155,16 +123,12 @@ cp -a lib/third_party/xdgpp/LICENSE %{buildroot
%license %{_datadir}/licenses/%{name}/ %license %{_datadir}/licenses/%{name}/
%doc README.md %doc README.md
%{_bindir}/imhex %{_bindir}/imhex
%{_datadir}/imhex/imhex %{_bindir}/imhex-updater
%{_datadir}/pixmaps/%{name}.* %{_datadir}/pixmaps/%{name}.png
%{_datadir}/applications/%{name}.desktop %{_datadir}/applications/%{name}.desktop
%{_libdir}/libimhex.so.* %{_libdir}/libimhex.so*
%{_libdir}/%{name}/ %{_libdir}/%{name}/
%{_metainfodir}/net.werwolv.ImHex.metainfo.xml %{_metainfodir}/net.werwolv.%{name}.metainfo.xml
%exclude %{_bindir}/imhex-updater
%{_datadir}/mime/packages/%{name}.xml
%files devel %changelog
%{_libdir}/libimhex.so
%{_datadir}/%{name}/sdk/

View File

@@ -1,92 +0,0 @@
name: imhex
title: ImHex
base: core24
version: ${IMHEX_VERSION_STRING}
summary: Hex editor for reverse engineering
description: ImHex is a hex editor for reverse engineering, reverse engineering, and analyzing binary files. It provides a powerful and flexible interface for working with binary data, including features like pattern matching, scripting, and a customizable user interface.
grade: stable
confinement: classic
contact: https://github.com/WerWolv/ImHex/discussions
issues: https://github.com/WerWolv/ImHex/issues
source-code: https://github.com/WerWolv/ImHex
website: https://imhex.werwolv.net
donation: https://github.com/sponsors/WerWolv
license: GPL-2.0-only
icon: resources/icon.svg
adopt-info: imhex
platforms:
amd64:
arm64:
apps:
imhex:
command: usr/local/bin/imhex
desktop: usr/local/share/applications/imhex.desktop
environment:
LD_LIBRARY_PATH: '$SNAP/usr/local/lib:$SNAP/usr/local/lib/imhex:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH'
XDG_DATA_DIRS: '$XDG_DATA_DIRS:$SNAP/usr/local/share:$SNAP/usr/local/lib:$SNAP/usr/local/share'
XDG_CONFIG_DIRS: '$XDG_CONFIG_DIRS:$SNAP/usr/local/share'
XDG_DATA_HOME: '$XDG_DATA_HOME:$SNAP_DATA'
parts:
imhex:
plugin: cmake
source: .
build-environment:
- CC: /usr/bin/gcc-14
- CXX: /usr/bin/g++-14
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_C_COMPILER_LAUNCHER=${CCACHE}
- -DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE}
- -DIMHEX_PATTERNS_PULL_MASTER=ON
- -DIMHEX_BUNDLE_PLUGIN_SDK=OFF
cmake-generator: Ninja
build-packages:
- cmake
- ninja-build
- gcc-14
- g++-14
- git
- pkg-config
- libglfw3-dev
- libmagic-dev
- libmbedtls-dev
- libfontconfig-dev
- libfreetype-dev
- libdbus-1-dev
- libcurl4-gnutls-dev
- libgtk-3-dev
- zlib1g-dev
- libbz2-dev
- liblzma-dev
- libzstd-dev
- liblz4-dev
- libssh2-1-dev
- libmd4c-dev
- libmd4c-html0-dev
stage-packages:
- libglfw3
- libmagic1
- libmbedtls14
- libfontconfig1
- libfreetype6
- libdbus-1-3
- libcurl4-gnutls-dev
- libgtk-3-0
- zlib1g
- libbz2-1.0
- liblzma5
- libzstd1
- liblz4-1
- libssh2-1
prime:
- -usr/include/*
- -usr/local/include/*
- -usr/lib/**/*.a
- -usr/local/lib/**/*.a
- -usr/lib/**/*.la
- -usr/local/lib/**/*.la
- -usr/share/doc/*
- -usr/share/man/*

18
dist/vcpkg.json vendored
View File

@@ -1,18 +0,0 @@
{
"name": "vcpkg",
"version": "1.0.0",
"builtin-baseline": "66c0373dc7fca549e5803087b9487edfe3aca0a1",
"dependencies": [
"libmagic",
"freetype",
"mbedtls",
"zlib",
"bzip2",
"liblzma",
"zstd",
"glfw3",
"curl",
"libssh2",
"md4c"
]
}

34
dist/web/Dockerfile vendored
View File

@@ -1,24 +1,23 @@
FROM emscripten/emsdk:4.0.21 AS build FROM emscripten/emsdk:3.1.51 as build
# Used to invalidate layer cache but not mount cache # Used to invalidate layer cache but not mount cache
# See https://github.com/moby/moby/issues/41715#issuecomment-733976493 # See https://github.com/moby/moby/issues/41715#issuecomment-733976493
ARG UNIQUEKEY=1 ARG UNIQUEKEY 1
RUN apt update RUN apt update
RUN apt install -y git ccache autoconf automake libtool pkg-config ninja-build RUN apt install -y git ccache autoconf automake libtool cmake pkg-config
RUN <<EOF RUN <<EOF
# Install vcpkg # Install vcpkg
# Note: we are a patch on the libmagic port # Note: we are a patch on the libmagic port
set -xe set -xe
git clone --depth 1 https://github.com/microsoft/vcpkg /vcpkg git clone https://github.com/microsoft/vcpkg /vcpkg
/vcpkg/bootstrap-vcpkg.sh /vcpkg/bootstrap-vcpkg.sh
sed -i 's/vcpkg_install_make(${EXTRA_ARGS})/vcpkg_install_make(${EXTRA_ARGS} SUBPATH src)/g' /vcpkg/ports/libmagic/portfile.cmake sed -i 's/vcpkg_install_make(${EXTRA_ARGS})/vcpkg_install_make(${EXTRA_ARGS} SUBPATH src)/g' /vcpkg/ports/libmagic/portfile.cmake
EOF EOF
# Patch vcpkg build instructions to add -pthread flag # Patch vcpkg build instructions to add -pthread
# Even dependencies must be built with -pthread to be able to use USE_PTHREADS=1
RUN <<EOF RUN <<EOF
set -xe set -xe
@@ -28,7 +27,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
' >> /emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake ' >> /emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
EOF EOF
ENV VCPKG_DEFAULT_BINARY_CACHE=/cache/vcpkg ENV VCPKG_DEFAULT_BINARY_CACHE /cache/vcpkg
RUN --mount=type=cache,target=/cache <<EOF RUN --mount=type=cache,target=/cache <<EOF
# Install dependencies with vcpkg # Install dependencies with vcpkg
set -xe set -xe
@@ -46,34 +45,29 @@ EOF
# Build ImHex # Build ImHex
ARG JOBS=4 ARG JOBS=4
ENV CCACHE_DIR=/cache/ccache ENV CCACHE_DIR /cache/ccache
RUN mkdir /build RUN mkdir /build
WORKDIR /build WORKDIR /build
ARG BUILD_TYPE=Release
RUN --mount=type=cache,target=/cache \ RUN --mount=type=cache,target=/cache \
--mount=type=bind,source=.,target=/imhex <<EOF --mount=type=bind,source=.,target=/imhex <<EOF
set -xe set -xe
ccache -zs ccache -zs
/vcpkg/downloads/tools/cmake-*/cmake-*/bin/cmake /imhex \ cmake /imhex \
-G "Ninja" \
-DIMHEX_OFFLINE_BUILD=ON \ -DIMHEX_OFFLINE_BUILD=ON \
-DIMHEX_STATIC_LINK_PLUGINS=ON \ -DIMHEX_STATIC_LINK_PLUGINS=ON \
-DIMHEX_EXCLUDE_PLUGINS="script_loader;remote" \ -DIMHEX_EXCLUDE_PLUGINS="script_loader" \
-DIMHEX_COMPRESS_DEBUG_INFO=OFF \
-DNATIVE_CMAKE_C_COMPILER=gcc \ -DNATIVE_CMAKE_C_COMPILER=gcc \
-DNATIVE_CMAKE_CXX_COMPILER=g++ \ -DNATIVE_CMAKE_CXX_COMPILER=g++ \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DLIBROMFS_COMPRESS_RESOURCES=OFF \ -DCMAKE_BUILD_TYPE=Release
-DIMHEX_ENABLE_PLUGIN_TESTS=OFF \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
ninja -j $JOBS make -j $JOBS
cp /imhex/dist/web/source/* /build cp /imhex/dist/web/source/* /build
ccache -s ccache -s
@@ -83,12 +77,13 @@ EOF
# See https://stackoverflow.com/questions/41701849/cannot-modify-accept-encoding-with-fetch https://github.com/AnthumChris/fetch-progress-indicators/issues/13 # See https://stackoverflow.com/questions/41701849/cannot-modify-accept-encoding-with-fetch https://github.com/AnthumChris/fetch-progress-indicators/issues/13
RUN du -b /build/imhex.wasm | cut -f1 > imhex.wasm.size RUN du -b /build/imhex.wasm | cut -f1 > imhex.wasm.size
FROM scratch AS raw FROM scratch as raw
COPY --from=build [ \ COPY --from=build [ \
# ImHex \ # ImHex \
"/build/imhex.wasm", \ "/build/imhex.wasm", \
"/build/imhex.wasm.size", \ "/build/imhex.wasm.size", \
"/build/imhex.js", \ "/build/imhex.js", \
"/build/imhex.worker.js", \
\ \
# Static files \ # Static files \
"/build/index.html", \ "/build/index.html", \
@@ -96,7 +91,7 @@ COPY --from=build [ \
"/build/wasm-config.js", \ "/build/wasm-config.js", \
"/build/enable-threads.js", \ "/build/enable-threads.js", \
"/build/favicon.ico", \ "/build/favicon.ico", \
"/build/icon.svg", \ "/build/icon.png", \
"/build/manifest.json", \ "/build/manifest.json", \
"/build/robots.txt", \ "/build/robots.txt", \
"/build/sitemap.xml", \ "/build/sitemap.xml", \
@@ -107,4 +102,3 @@ COPY --from=build [ \
FROM nginx FROM nginx
COPY --from=raw . /usr/share/nginx/html COPY --from=raw . /usr/share/nginx/html
RUN chmod -R 755 /usr/share/nginx/html

View File

@@ -1,9 +0,0 @@
FROM python:3.12-slim
WORKDIR /imhex
COPY ./out/ .
EXPOSE 9090
CMD [ "python", "/imhex/start_imhex_web.py" ]

View File

@@ -1,4 +1,5 @@
# docker compose -f dist/web/compose.yml up --build # docker compose -f dist/web/compose.yml up --build
version: '3'
services: services:
imhex_web: imhex_web:
image: imhex_web:latest image: imhex_web:latest

2
dist/web/serve.py vendored
View File

@@ -10,6 +10,6 @@ class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
if __name__ == '__main__': if __name__ == '__main__':
os.chdir(".") os.chdir(".")
httpd = http.server.HTTPServer(("0.0.0.0", 9090), MyHttpRequestHandler) httpd = http.server.HTTPServer(("localhost", 9090), MyHttpRequestHandler)
print(f"Serving {os.getcwd()} on http://{httpd.server_address[0]}:{httpd.server_address[1]}") print(f"Serving {os.getcwd()} on http://{httpd.server_address[0]}:{httpd.server_address[1]}")
httpd.serve_forever() httpd.serve_forever()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 122 KiB

BIN
dist/web/source/icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

View File

@@ -1,11 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" version="1">
<rect style="opacity:0.2" width="55" height="10" x="5" y="-60" rx="1.41" transform="rotate(90)"/>
<rect style="fill:#2b50a1" width="55" height="10" x="4" y="-60" rx="1.41" transform="rotate(90)"/>
<rect style="fill:#2b50a1" width="55" height="10" x="4" y="-14" rx="1.41" transform="rotate(90)"/>
<rect style="fill:#2b50a1" width="55" height="10" x="4" y="-33" rx="1.41" transform="rotate(90)"/>
<path style="opacity:0.2" d="M 5.3808594,5 C 4.6158118,5 4,5.6158118 4,6.3808594 V 13.619141 C 4,14.384188 4.6158118,15 5.3808594,15 H 31.619141 C 32.384188,15 33,14.384188 33,13.619141 V 6.3808594 C 33,5.6158118 32.384188,5 31.619141,5 Z M 40.400391,5 C 39.624791,5 39,5.6247906 39,6.4003906 V 13.599609 C 39,14.375209 39.624791,15 40.400391,15 H 58.599609 C 59.375209,15 60,14.375209 60,13.599609 V 6.4003906 C 60,5.6247906 59.375209,5 58.599609,5 Z M 5.3808594,50 C 4.6158118,50 4,50.615812 4,51.380859 v 7.238282 C 4,59.384188 4.6158118,60 5.3808594,60 H 31.619141 C 32.384188,60 33,59.384188 33,58.619141 V 51.380859 C 33,50.615812 32.384188,50 31.619141,50 Z"/>
<rect style="fill:#3a6be0" width="29" height="10" x="4" y="4" rx="1.381"/>
<rect style="fill:#3a6be0" width="21" height="10" x="39" y="4" rx="1.4"/>
<rect style="fill:#3a6be0" width="29" height="10" x="4" y="49" rx="1.381"/>
<path style="fill:#ffffff;opacity:0.1" d="M 5.3808594 4 C 4.6158118 4 4 4.6158118 4 5.3808594 L 4 6.3808594 C 4 5.6158118 4.6158118 5 5.3808594 5 L 31.619141 5 C 32.384188 5 33 5.6158118 33 6.3808594 L 33 5.3808594 C 33 4.6158118 32.384188 4 31.619141 4 L 5.3808594 4 z M 40.400391 4 C 39.624791 4 39 4.6247906 39 5.4003906 L 39 6.4003906 C 39 5.6247906 39.624791 5 40.400391 5 L 58.599609 5 C 59.375209 5 60 5.6247906 60 6.4003906 L 60 5.4003906 C 60 4.6247906 59.375209 4 58.599609 4 L 40.400391 4 z M 5.3808594 49 C 4.6158118 49 4 49.615812 4 50.380859 L 4 51.380859 C 4 50.615812 4.6158118 50 5.3808594 50 L 31.619141 50 C 32.384188 50 33 50.615812 33 51.380859 L 33 50.380859 C 33 49.615812 32.384188 49 31.619141 49 L 5.3808594 49 z"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -11,21 +11,21 @@
<meta name="title" content="ImHex"> <meta name="title" content="ImHex">
<meta name="description" content="Free and extremely powerful Online Hex Editor for your Web Browser. ImHex is a free and open source Hex Editor for Reverse Engineers and Developers and Data Analysts."> <meta name="description" content="Free and extremely powerful Online Hex Editor for your Web Browser. ImHex is a free and open source Hex Editor for Reverse Engineers and Developers and Data Analysts.">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="apple-touch-icon" href="icon.svg"> <link rel="apple-touch-icon" href="icon.png">
<!-- Open Graph / Facebook --> <!-- Open Graph / Facebook -->
<meta property="og:type" content="website"> <meta property="og:type" content="website">
<meta property="og:url" content="https://web.imhex.werwolv.net/"> <meta property="og:url" content="https://imhex.werwolv.net/">
<meta property="og:title" content="ImHex Web - Online Hex Editor"> <meta property="og:title" content="ImHex Web - Online Hex Editor">
<meta property="og:image" content="splash_wasm.png"> <meta property="og:image" content="https://imhex.werwolv.net/assets/splash_wasm.png">
<!-- Twitter --> <!-- Twitter -->
<meta property="twitter:card" content="summary_large_image"> <meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://web.imhex.werwolv.net/"> <meta property="twitter:url" content="https://imhex.werwolv.net/">
<meta property="twitter:title" content="ImHex Web - Online Hex Editor"> <meta property="twitter:title" content="ImHex Web - Online Hex Editor">
<meta property="twitter:description" <meta property="twitter:description"
content="A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM."> content="A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.">
<meta property="twitter:image" content="splash_wasm.png"> <meta property="twitter:image" content="https://imhex.werwolv.net/assets/splash_wasm.png">
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
@@ -37,8 +37,8 @@
"email": "hey@werwolv.net", "email": "hey@werwolv.net",
"founder": "WerWolv", "founder": "WerWolv",
"slogan": "A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.", "slogan": "A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.",
"url": "https://web.imhex.werwolv.net", "url": "https://imhex.werwolv.net",
"logo": "https://web.imhex.werwolv.net/icon.svg" "logo": "https://imhex.werwolv.net/assets/logos/logo.png"
} }
</script> </script>
@@ -62,7 +62,7 @@
</head> </head>
<body> <body>
<div id="loading" class="centered"> <div id="loading" class="centered">
<img src="https://raw.githubusercontent.com/WerWolv/ImHex/master/plugins/builtin/romfs/assets/dark/banner.svg" id="logo" alt="ImHex Logo"> <img src="https://raw.githubusercontent.com/WerWolv/ImHex/master/plugins/builtin/romfs/assets/dark/banner.png" id="logo" alt="ImHex Logo">
<h1>A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.</h1> <h1>A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.</h1>
<h2>Available both natively and on the web</h2> <h2>Available both natively and on the web</h2>
<h5>ImHex runs directly in your web browser with the help of Emscripten and WebAssembly.</h5> <h5>ImHex runs directly in your web browser with the help of Emscripten and WebAssembly.</h5>
@@ -96,9 +96,7 @@
</div> </div>
</div> </div>
<div id="canvas-wrapper" class="imhex-web-canvas-wrapper"> <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
<canvas class="imhex-web-canvas canvas-fixed" id="canvas" ></canvas>
</div>
<script src="wasm-config.js"></script> <script src="wasm-config.js"></script>
<script async src="imhex.js"></script> <script async src="imhex.js"></script>

View File

@@ -10,8 +10,8 @@
], ],
"icons": [ "icons": [
{ {
"src": "icon.svg", "src": "icon.png",
"type": "image/svg", "type": "image/png",
"sizes": "640x640" "sizes": "640x640"
} }
], ],

View File

@@ -57,11 +57,6 @@
<loc>https://web.imhex.werwolv.net?lang=it-IT</loc> <loc>https://web.imhex.werwolv.net?lang=it-IT</loc>
<lastmod>2024-01-02T11:44:00+00:00</lastmod> <lastmod>2024-01-02T11:44:00+00:00</lastmod>
</url> </url>
<url>
<title>Русский</title>
<loc>https://web.imhex.werwolv.net?lang=ru-RU</loc>
<lastmod>2024-01-02T11:44:00+00:00</lastmod>
</url>
</urlset> </urlset>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 KiB

View File

@@ -137,7 +137,7 @@ a:hover {
:root { :root {
--progress: 0%; --progress: 25%;
} }
.progress-bar-container { .progress-bar-container {
@@ -174,34 +174,4 @@ a:hover {
.progress-moved .progress-bar { .progress-moved .progress-bar {
width: var(--progress); width: var(--progress);
background-color: #3864cb; background-color: #3864cb;
}
#logo {
height: 25%;
margin-top: 50px;
}
.canvas-fixed {
position: absolute;
top: 0;
left: 0;
}
.imhex-web-canvas {
width: 100%;
height: 100%;
display: block;
overflow: hidden;
image-rendering: smooth;
margin: 0;
padding: 0;
z-index: 1;
}
.imhex-web-canvas-wrapper {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
background-size: 100% 100%;
} }

View File

@@ -9,9 +9,8 @@ fetch("imhex.wasm.size").then(async (resp) => {
// inspired from: https://github.com/WordPress/wordpress-playground/pull/46 (but had to be modified) // inspired from: https://github.com/WordPress/wordpress-playground/pull/46 (but had to be modified)
function monkeyPatch(progressFun) { function monkeyPatch(progressFun) {
const _instantiateStreaming = WebAssembly.instantiateStreaming; const _instantiateStreaming = WebAssembly.instantiateStreaming;
WebAssembly.instantiateStreaming = async (responsePromise, ...args) => { WebAssembly.instantiateStreaming = (response, ...args) => {
// Do not collect wasm content length here see above // Do not collect wasm content length here see above
let response = await responsePromise
const file = response.url.substring( const file = response.url.substring(
new URL(response.url).origin.length + 1 new URL(response.url).origin.length + 1
); );
@@ -59,14 +58,8 @@ monkeyPatch((file, done) => {
const mibTotal = (wasmSize / 1024**2).toFixed(1); const mibTotal = (wasmSize / 1024**2).toFixed(1);
let root = document.querySelector(':root'); let root = document.querySelector(':root');
if (root != null) { root.style.setProperty("--progress", `${percent}%`)
root.style.setProperty("--progress", `${percent}%`) document.getElementById("progress-bar-content").innerHTML = `${percent}% &nbsp;[${mibNow} MiB / ${mibTotal} MiB]`;
let progressBar = document.getElementById("progress-bar-content");
if (progressBar != null) {
progressBar.innerHTML = `${percent}% &nbsp;[${mibNow} MiB / ${mibTotal} MiB]`;
}
}
}); });
function glfwSetCursorCustom(wnd, shape) { function glfwSetCursorCustom(wnd, shape) {
@@ -106,17 +99,11 @@ var notWorkingTimer = setTimeout(() => {
}, 5000); }, 5000);
var Module = { var Module = {
preRun: () => { preRun: [],
ENV.IMHEX_SKIP_SPLASH_SCREEN = "1"; postRun: [],
},
postRun: function() {
},
onRuntimeInitialized: function() { onRuntimeInitialized: function() {
// Triggered when the wasm module is loaded and ready to use. // Triggered when the wasm module is loaded and ready to use.
let loading = document.getElementById("loading"); document.getElementById("loading").style.display = "none"
if (loading != null)
document.getElementById("loading").style.display = "none"
document.getElementById("canvas").style.display = "initial" document.getElementById("canvas").style.display = "initial"
clearTimeout(notWorkingTimer); clearTimeout(notWorkingTimer);
@@ -124,65 +111,24 @@ var Module = {
print: (function() { })(), print: (function() { })(),
printErr: function(text) { }, printErr: function(text) { },
canvas: (function() { canvas: (function() {
const canvas = document.getElementById('canvas'); let canvas = document.getElementById('canvas');
canvas.addEventListener("webglcontextlost", function(e) { // As a default initial behavior, pop up an alert when webgl context is lost. To make your
alert('WebGL context lost, please reload the page'); // application robust, you may want to override this behavior before shipping!
e.preventDefault(); // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
}, false); canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
// Turn long touches into right-clicks return canvas;
let timer = null;
canvas.addEventListener('touchstart', event => {
timer = setTimeout(() => {
let eventArgs = {
bubbles: true,
cancelable: true,
view: window,
screenX: event.touches[0].screenX,
screenY: event.touches[0].screenY,
clientX: event.touches[0].clientX,
clientY: event.touches[0].clientY,
button: 2,
buttons: 2,
relatedTarget: event.target,
region: event.region
}
canvas.dispatchEvent(new MouseEvent('mousedown', eventArgs));
canvas.dispatchEvent(new MouseEvent('mouseup', eventArgs));
}, 400);
});
canvas.addEventListener('touchend', event => {
if (timer) {
clearTimeout(timer);
timer = null;
}
});
if (typeof WebGL2RenderingContext !== 'undefined') {
let gl = canvas.getContext('webgl2', { stencil: true });
if (!gl) {
console.error('WebGL 2 not available, falling back to WebGL');
gl = canvas.getContext('webgl', { stencil: true });
}
if (!gl) {
alert('WebGL not available with stencil buffer');
}
return canvas;
} else {
alert('WebGL 2 not supported by this browser');
}
})(), })(),
setStatus: function(text) { }, setStatus: function(text) { },
totalDependencies: 0, totalDependencies: 0,
monitorRunDependencies: function(left) { monitorRunDependencies: function(left) {
}, },
instantiateWasm: async function(imports, successCallback) { instantiateWasm: function(imports, successCallback) {
imports.env.glfwSetCursor = glfwSetCursorCustom imports.env.glfwSetCursor = glfwSetCursorCustom
imports.env.glfwCreateStandardCursor = glfwCreateStandardCursorCustom imports.env.glfwCreateStandardCursor = glfwCreateStandardCursorCustom
let result = await instantiateAsync(null, findWasmBinary(), imports); instantiateAsync(wasmBinary, wasmBinaryFile, imports, (result) => {
successCallback(result.instance, result.module) successCallback(result.instance, result.module)
});
}, },
arguments: [] arguments: []
}; };
@@ -193,15 +139,19 @@ const urlParams = new URLSearchParams(queryString);
if (urlParams.has("lang")) { if (urlParams.has("lang")) {
Module["arguments"].push("--language"); Module["arguments"].push("--language");
Module["arguments"].push(urlParams.get("lang")); Module["arguments"].push(urlParams.get("lang"));
} else if (urlParams.has("save-editor")) {
Module["arguments"].push("--save-editor");
Module["arguments"].push("gist");
Module["arguments"].push(urlParams.get("save-editor"));
} }
// Prevent some default browser shortcuts from preventing ImHex ones to work window.addEventListener('resize', js_resizeCanvas, false);
document.addEventListener('keydown', e => { function js_resizeCanvas() {
if (e.ctrlKey) { let canvas = document.getElementById('canvas');
if (e.which == 83) e.preventDefault(); canvas.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 0);
canvas.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 0);
canvas.classList.add("canvas_full_screen")
if (GLFW.active && GLFW.active.windowPosFunc) {
getWasmTableEntry(GLFW.active.windowPosFunc)(GLFW.active.id, GLFW.active.x, GLFW.active.y);
} }
})
GLFW.onWindowSizeChanged();
}

View File

@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(libimhex) project(libimhex)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(LIBIMHEX_SOURCES set(LIBIMHEX_SOURCES
source/api/imhex_api.cpp source/api/imhex_api.cpp
@@ -36,18 +37,8 @@ set(LIBIMHEX_SOURCES
source/helpers/logger.cpp source/helpers/logger.cpp
source/helpers/tar.cpp source/helpers/tar.cpp
source/helpers/debugging.cpp source/helpers/debugging.cpp
source/helpers/default_paths.cpp
source/helpers/imgui_hooks.cpp
source/helpers/semantic_version.cpp
source/helpers/keys.cpp
source/helpers/udp_server.cpp
source/helpers/scaling.cpp
source/helpers/binary_pattern.cpp
source/test/tests.cpp
source/providers/provider.cpp source/providers/provider.cpp
source/providers/cached_provider.cpp
source/providers/memory_provider.cpp source/providers/memory_provider.cpp
source/providers/undo/stack.cpp source/providers/undo/stack.cpp
@@ -55,19 +46,21 @@ set(LIBIMHEX_SOURCES
source/ui/view.cpp source/ui/view.cpp
source/ui/popup.cpp source/ui/popup.cpp
source/ui/toast.cpp source/ui/toast.cpp
source/ui/banner.cpp
source/mcp/client.cpp
source/mcp/server.cpp
source/subcommands/subcommands.cpp source/subcommands/subcommands.cpp
) )
if (APPLE) if (APPLE)
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} set(OSX_11_0_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk)
source/helpers/utils_macos.m if (NOT CMAKE_OSX_SYSROOT)
source/helpers/macos_menu.m if (IS_DIRECTORY ${OSX_11_0_SDK_PATH})
) set(CMAKE_OSX_SYSROOT ${OSX_11_0_SDK_PATH})
else ()
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
endif ()
endif ()
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} source/helpers/utils_macos.m)
endif () endif ()
if (IMHEX_EXTERNAL_PLUGIN_BUILD) if (IMHEX_EXTERNAL_PLUGIN_BUILD)
@@ -80,21 +73,10 @@ else()
add_library(libimhex SHARED ${LIBIMHEX_SOURCES}) add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
endif() endif()
if (IMHEX_ENABLE_CXX_MODULES)
target_sources(libimhex
PUBLIC
FILE_SET cxx_modules TYPE CXX_MODULES
FILES
include/hex.cppm
)
endif()
set(LIBIMHEX_LIBRARY_TYPE PUBLIC) set(LIBIMHEX_LIBRARY_TYPE PUBLIC)
target_compile_definitions(libimhex PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") target_compile_definitions(libimhex PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
endif() endif()
addCppCheck(libimhex)
if (DEFINED IMHEX_COMMIT_HASH_LONG AND DEFINED IMHEX_COMMIT_BRANCH) if (DEFINED IMHEX_COMMIT_HASH_LONG AND DEFINED IMHEX_COMMIT_BRANCH)
set(GIT_COMMIT_HASH_LONG "${IMHEX_COMMIT_HASH_LONG}") set(GIT_COMMIT_HASH_LONG "${IMHEX_COMMIT_HASH_LONG}")
@@ -129,60 +111,38 @@ endif ()
addDefineToSource(source/api/imhex_api.cpp "IMHEX_VERSION=\"${IMHEX_VERSION_STRING}\"") addDefineToSource(source/api/imhex_api.cpp "IMHEX_VERSION=\"${IMHEX_VERSION_STRING}\"")
string(TIMESTAMP IMHEX_BUILD_DATE UTC)
addDefineToSource(source/api/imhex_api.cpp "IMHEX_BUILD_DATE=\"${IMHEX_BUILD_DATE}\"")
enableUnityBuild(libimhex) enableUnityBuild(libimhex)
setupCompilerFlags(libimhex) setupCompilerFlags(libimhex)
include(GenerateExportHeader) include(GenerateExportHeader)
generate_export_header(libimhex) generate_export_header(libimhex)
target_include_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} include ${XDGPP_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS}) target_include_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIR} ${MAGIC_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${LIBBACKTRACE_INCLUDE_DIRS})
target_link_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${MBEDTLS_LIBRARY_DIR} ${MAGIC_LIBRARY_DIRS})
if (NOT EMSCRIPTEN)
# curl is only used in non-emscripten builds
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${CURL_LIBRARIES})
endif()
if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD) if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
if (WIN32) if (WIN32)
set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
if (NOT MSVC) target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
endif()
target_link_libraries(libimhex PRIVATE Netapi32.lib)
target_compile_definitions(libimhex PRIVATE EXPORT_SYMBOLS=1)
elseif (APPLE) elseif (APPLE)
find_library(FOUNDATION NAMES Foundation) find_library(FOUNDATION NAMES Foundation)
find_library(USERNOTIFICATIONS NAMES UserNotifications) target_link_libraries(libimhex PUBLIC ${FOUNDATION})
target_link_libraries(libimhex PUBLIC ${FOUNDATION} ${USERNOTIFICATIONS})
endif () endif ()
target_link_libraries(libimhex PRIVATE libpl microtar ${NFD_LIBRARIES} magic) target_link_libraries(libimhex PRIVATE microtar libwolv ${NFD_LIBRARIES} magic dl ${JTHREAD_LIBRARIES})
target_link_libraries(libimhex PUBLIC libwolv libpl_includes libpl-gen ${IMGUI_LIBRARIES} ${JTHREAD_LIBRARIES}) target_link_libraries(libimhex PUBLIC libpl ${IMGUI_LIBRARIES})
if (IMHEX_ENABLE_IMGUI_TEST_ENGINE)
target_link_libraries(libimhex PUBLIC imgui_test_engine)
endif()
if (NOT WIN32)
target_link_libraries(libimhex PRIVATE dl)
endif()
if (NOT EMSCRIPTEN)
# curl is only used in non-emscripten builds
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} CURL::libcurl)
endif()
target_include_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${MBEDTLS_INCLUDE_DIR} ${LIBBACKTRACE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS})
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${MBEDTLS_LIBRARIES})
target_link_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${MBEDTLS_LIBRARY_DIR} ${MAGIC_LIBRARY_DIRS})
precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include") precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include")
endif() endif()
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES} ${BOOST_LIBRARIES} tracing) target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES})
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE) set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
add_dependencies(imhex_all libimhex) add_dependencies(imhex_all libimhex)
install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}" PERMISSIONS ${LIBRARY_PERMISSIONS})
set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set_target_properties(libimhex PROPERTIES PREFIX "")

View File

@@ -1,58 +0,0 @@
module;
#include <cmath>
#include <map>
#include <string>
#include <string_view>
#include <vector>
#include <exception>
#include <algorithm>
#include <locale>
#include <array>
#include <filesystem>
#include <functional>
#include <memory>
#include <list>
#include <atomic>
#include <ranges>
#include <fstream>
#include <thread>
#include <future>
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <wolv/io/file.hpp>
#include <imgui.h>
#include <imgui_internal.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <hex/helpers/auto_reset.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/providers/provider.hpp>
#include <hex/providers/provider_data.hpp>
#include <hex/data_processor/node.hpp>
#include <hex/data_processor/link.hpp>
#include <hex/data_processor/attribute.hpp>
#include <pl/pattern_language.hpp>
export module hex;
#define HEX_MODULE_EXPORT
#include <hex/api/imhex_api/bookmarks.hpp>
#include <hex/api/imhex_api/hex_editor.hpp>
#include <hex/api/imhex_api/fonts.hpp>
#include <hex/api/imhex_api/messaging.hpp>
#include <hex/api/imhex_api/provider.hpp>
#include <hex/api/imhex_api/system.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/api/layout_manager.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/plugin_manager.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/api/theme_manager.hpp>
#include <hex/api/tutorial_manager.hpp>
#include <hex/api/workspace_manager.hpp>

View File

@@ -1,9 +1,4 @@
#pragma once #pragma once
#include <hex/helpers/types.hpp> #include <hex/helpers/types.hpp>
#include <hex/helpers/intrinsics.hpp>
#if defined(HEX_MODULE_EXPORT)
#define EXPORT_MODULE export
#else
#define EXPORT_MODULE
#endif

View File

@@ -14,9 +14,8 @@
#include <imgui.h> #include <imgui.h>
#include <hex/ui/imgui_imhex_extensions.h> #include <hex/ui/imgui_imhex_extensions.h>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/helpers/auto_reset.hpp>
EXPORT_MODULE namespace hex { namespace hex {
class AchievementManager; class AchievementManager;
@@ -145,17 +144,62 @@ EXPORT_MODULE namespace hex {
* @brief Returns the icon of the achievement * @brief Returns the icon of the achievement
* @return Icon of the achievement * @return Icon of the achievement
*/ */
[[nodiscard]] const char* getIcon() const { [[nodiscard]] const ImGuiExt::Texture &getIcon() const {
return m_icon.c_str(); if (m_iconData.empty())
return m_icon;
if (m_icon.isValid())
return m_icon;
m_icon = ImGuiExt::Texture(m_iconData.data(), m_iconData.size(), ImGuiExt::Texture::Filter::Linear);
return m_icon;
} }
/** /**
* @brief Sets the icon of the achievement * @brief Sets the icon of the achievement
* @param icon Icon glyph * @param data Icon data
* @return Reference to the achievement * @return Reference to the achievement
*/ */
Achievement& setIcon(std::string icon) { Achievement& setIcon(std::span<const std::byte> data) {
m_icon = std::move(icon); m_iconData.reserve(data.size());
for (auto &byte : data)
m_iconData.emplace_back(static_cast<u8>(byte));
return *this;
}
/**
* @brief Sets the icon of the achievement
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(std::span<const u8> data) {
m_iconData.assign(data.begin(), data.end());
return *this;
}
/**
* @brief Sets the icon of the achievement
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(std::vector<u8> data) {
m_iconData = std::move(data);
return *this;
}
/**
* @brief Sets the icon of the achievement
* @param data Icon data
* @return Reference to the achievement
*/
Achievement& setIcon(const std::vector<std::byte> &data) {
m_iconData.reserve(data.size());
for (auto &byte : data)
m_iconData.emplace_back(static_cast<u8>(byte));
return *this; return *this;
} }
@@ -239,7 +283,8 @@ EXPORT_MODULE namespace hex {
std::function<void(Achievement &)> m_clickCallback; std::function<void(Achievement &)> m_clickCallback;
std::string m_icon; std::vector<u8> m_iconData;
mutable ImGuiExt::Texture m_icon;
u32 m_progress = 0; u32 m_progress = 0;
u32 m_maxProgress = 1; u32 m_maxProgress = 1;
@@ -250,7 +295,6 @@ EXPORT_MODULE namespace hex {
}; };
class AchievementManager { class AchievementManager {
static bool s_initialized;
public: public:
AchievementManager() = delete; AchievementManager() = delete;
@@ -265,15 +309,11 @@ EXPORT_MODULE namespace hex {
} }
[[nodiscard]] bool isUnlockable() const { [[nodiscard]] bool isUnlockable() const {
return std::ranges::all_of(this->parents, [](const auto &parent) { return std::all_of(this->parents.begin(), this->parents.end(), [](auto &parent) { return parent->achievement->isUnlocked(); });
return parent->achievement->isUnlocked();
});
} }
[[nodiscard]] bool isVisible() const { [[nodiscard]] bool isVisible() const {
return std::ranges::all_of(this->visibilityParents, [](const auto &parent) { return std::all_of(this->visibilityParents.begin(), this->visibilityParents.end(), [](auto &parent) { return parent->achievement->isUnlocked(); });
return parent->achievement->isUnlocked();
});
} }
[[nodiscard]] bool isUnlocked() const { [[nodiscard]] bool isUnlocked() const {
@@ -320,7 +360,7 @@ EXPORT_MODULE namespace hex {
* @brief Returns all registered achievements * @brief Returns all registered achievements
* @return All achievements * @return All achievements
*/ */
static const std::unordered_map<UnlocalizedString, std::unordered_map<UnlocalizedString, std::unique_ptr<Achievement>>>& getAchievements(); static const std::unordered_map<std::string, std::unordered_map<std::string, std::unique_ptr<Achievement>>>& getAchievements();
/** /**
* @brief Returns all achievement start nodes * @brief Returns all achievement start nodes
@@ -328,14 +368,14 @@ EXPORT_MODULE namespace hex {
* @param rebuild Whether to rebuild the list of start nodes * @param rebuild Whether to rebuild the list of start nodes
* @return All achievement start nodes * @return All achievement start nodes
*/ */
static const std::unordered_map<UnlocalizedString, std::vector<AchievementNode*>>& getAchievementStartNodes(bool rebuild = true); static const std::unordered_map<std::string, std::vector<AchievementNode*>>& getAchievementStartNodes(bool rebuild = true);
/** /**
* @brief Returns all achievement nodes * @brief Returns all achievement nodes
* @param rebuild Whether to rebuild the list of nodes * @param rebuild Whether to rebuild the list of nodes
* @return All achievement nodes * @return All achievement nodes
*/ */
static const std::unordered_map<UnlocalizedString, std::list<AchievementNode>>& getAchievementNodes(bool rebuild = true); static const std::unordered_map<std::string, std::list<AchievementNode>>& getAchievementNodes(bool rebuild = true);
/** /**
* @brief Loads the progress of all achievements from the achievements save file * @brief Loads the progress of all achievements from the achievements save file
@@ -364,4 +404,4 @@ EXPORT_MODULE namespace hex {
static Achievement& addAchievementImpl(std::unique_ptr<Achievement> &&newAchievement); static Achievement& addAchievementImpl(std::unique_ptr<Achievement> &&newAchievement);
}; };
} }

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More