diff --git a/.travis/common/post-upload.sh b/.ci/common/post-upload.sh similarity index 54% rename from .travis/common/post-upload.sh rename to .ci/common/post-upload.sh index 7b3904d..5cc6a6d 100755 --- a/.travis/common/post-upload.sh +++ b/.ci/common/post-upload.sh @@ -6,9 +6,7 @@ cp README.md "$REV_NAME" cp dist/threeSDumper.gm9 "$REV_NAME/dist" -tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$REV_NAME" -7z a "$REV_NAME.7z" $REV_NAME +7z a "$REV_NAME.zip" $REV_NAME -# move the compiled archive into the artifacts directory to be uploaded by travis releases -mv "$ARCHIVE_NAME" artifacts/ -mv "$REV_NAME.7z" artifacts/ +# move the compiled archive into the artifacts directory to be uploaded by gh action releases +mv "$REV_NAME.zip" artifacts/ diff --git a/.travis/common/pre-upload.sh b/.ci/common/pre-upload.sh similarity index 54% rename from .travis/common/pre-upload.sh rename to .ci/common/pre-upload.sh index 3c2fc79..650fbd2 100755 --- a/.travis/common/pre-upload.sh +++ b/.ci/common/pre-upload.sh @@ -2,5 +2,10 @@ GITDATE="`git show -s --date=short --format='%ad' | sed 's/-//g'`" GITREV="`git show -s --format='%h'`" +if [[ $GITHUB_REF == refs/tags/* ]]; then + GITNAME="${GITHUB_REF:10}" +else + GITNAME="${GITDATE}-${GITREV}" +fi mkdir -p artifacts diff --git a/.ci/linux-clang-format/docker.sh b/.ci/linux-clang-format/docker.sh new file mode 100755 index 0000000..c8195a7 --- /dev/null +++ b/.ci/linux-clang-format/docker.sh @@ -0,0 +1,32 @@ +#!/bin/bash -ex + +if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \ + dist/*.svg dist/*.xml; then + echo Trailing whitespace found, aborting + exit 1 +fi + +# Default clang-format points to default 3.5 version one +CLANG_FORMAT=clang-format-10 +$CLANG_FORMAT --version + +# Check everything +files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" + +# Turn off tracing for this because it's too verbose +set +x + +for f in $files_to_lint; do + d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) + if ! [ -z "$d" ]; then + echo "!!! $f not compliant to coding style, here is the fix:" + echo "$d" + fail=1 + fi +done + +set -x + +if [ "$fail" = 1 ]; then + exit 1 +fi diff --git a/.travis/linux/docker.sh b/.ci/linux-fresh/docker.sh similarity index 92% rename from .travis/linux/docker.sh rename to .ci/linux-fresh/docker.sh index 4ddedf4..d866e11 100755 --- a/.travis/linux/docker.sh +++ b/.ci/linux-fresh/docker.sh @@ -1,7 +1,5 @@ #!/bin/bash -ex -cd /threeSD - mkdir build && cd build cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ ninja diff --git a/.ci/linux-fresh/upload.sh b/.ci/linux-fresh/upload.sh new file mode 100755 index 0000000..7ecc0ea --- /dev/null +++ b/.ci/linux-fresh/upload.sh @@ -0,0 +1,12 @@ +#!/bin/bash -ex + +. .ci/common/pre-upload.sh + +REV_NAME="threeSD-linux-${GITNAME}" + +mkdir "$REV_NAME" +cp build/bin/threeSD "$REV_NAME" + +mkdir "$REV_NAME/dist" + +. .ci/common/post-upload.sh diff --git a/.ci/linux-mingw/docker.sh b/.ci/linux-mingw/docker.sh new file mode 100755 index 0000000..6b3d074 --- /dev/null +++ b/.ci/linux-mingw/docker.sh @@ -0,0 +1,25 @@ +#!/bin/bash -ex + +# override CI ccache size +mkdir -p "$HOME/.ccache/" +echo 'max_size = 3.0G' > "$HOME/.ccache/ccache.conf" + +mkdir build && cd build +cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DCMAKE_BUILD_TYPE=Release -DCOMPILE_WITH_DWARF=OFF +ninja + +ccache -s + +echo 'Prepare binaries...' +cd .. +mkdir package + +QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/' +find build/ -name "threeSD.exe" -exec cp {} 'package' \; + +# copy Qt plugins +mkdir package/platforms +cp "${QT_PLATFORM_DLL_PATH}/qwindows.dll" package/platforms/ +cp -rv "${QT_PLATFORM_DLL_PATH}/../imageformats/" package/ + +python3 .ci/linux-mingw/scan_dll.py package/*.exe package/imageformats/*.dll "package/" diff --git a/.ci/linux-mingw/scan_dll.py b/.ci/linux-mingw/scan_dll.py new file mode 100644 index 0000000..54f7828 --- /dev/null +++ b/.ci/linux-mingw/scan_dll.py @@ -0,0 +1,122 @@ +try: + import lief +except ImportError: + import pefile +import sys +import re +import os +import queue +import shutil + +# constant definitions +KNOWN_SYS_DLLS = ['WINMM.DLL', 'MSVCRT.DLL', 'VERSION.DLL', 'MPR.DLL', + 'DWMAPI.DLL', 'UXTHEME.DLL', 'DNSAPI.DLL', 'IPHLPAPI.DLL'] +# below is for Ubuntu 18.04 with specified PPA enabled, if you are using +# other distro or different repositories, change the following accordingly +DLL_PATH = [ + '/usr/x86_64-w64-mingw32/bin/', + '/usr/x86_64-w64-mingw32/lib/', + '/usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/' +] + +missing = [] + + +def parse_imports_lief(filename): + results = [] + pe = lief.parse(filename) + for entry in pe.imports: + name = entry.name + if name.upper() not in KNOWN_SYS_DLLS and not re.match(string=name, pattern=r'.*32\.DLL'): + results.append(name) + return results + + +def parse_imports(file_name): + if globals().get('lief'): + return parse_imports_lief(file_name) + + results = [] + pe = pefile.PE(file_name, fast_load=True) + pe.parse_data_directories() + + for entry in pe.DIRECTORY_ENTRY_IMPORT: + current = entry.dll.decode() + current_u = current.upper() # b/c Windows is often case insensitive + # here we filter out system dlls + # dll w/ names like *32.dll are likely to be system dlls + if current_u.upper() not in KNOWN_SYS_DLLS and not re.match(string=current_u, pattern=r'.*32\.DLL'): + results.append(current) + + return results + + +def parse_imports_recursive(file_name, path_list=[]): + q = queue.Queue() # create a FIFO queue + # file_name can be a string or a list for the convience + if isinstance(file_name, str): + q.put(file_name) + elif isinstance(file_name, list): + for i in file_name: + q.put(i) + full_list = [] + while q.qsize(): + current = q.get_nowait() + print('> %s' % current) + deps = parse_imports(current) + # if this dll does not have any import, ignore it + if not deps: + continue + for dep in deps: + # the dependency already included in the list, skip + if dep in full_list: + continue + # find the requested dll in the provided paths + full_path = find_dll(dep) + if not full_path: + missing.append(dep) + continue + full_list.append(dep) + q.put(full_path) + path_list.append(full_path) + return full_list + + +def find_dll(name): + for path in DLL_PATH: + for root, _, files in os.walk(path): + for f in files: + if name.lower() == f.lower(): + return os.path.join(root, f) + + +def deploy(name, dst, dry_run=False): + dlls_path = [] + parse_imports_recursive(name, dlls_path) + for dll_entry in dlls_path: + if not dry_run: + shutil.copy(dll_entry, dst) + else: + print('[Dry-Run] Copy %s to %s' % (dll_entry, dst)) + print('Deploy completed.') + return dlls_path + + +def main(): + if len(sys.argv) < 3: + print('Usage: %s [files to examine ...] [target deploy directory]') + return 1 + to_deploy = sys.argv[1:-1] + tgt_dir = sys.argv[-1] + if not os.path.isdir(tgt_dir): + print('%s is not a directory.' % tgt_dir) + return 1 + print('Scanning dependencies...') + deploy(to_deploy, tgt_dir) + if missing: + print('Following DLLs are not found: %s' % ('\n'.join(missing))) + return 0 + + +if __name__ == '__main__': + main() diff --git a/.ci/linux-mingw/upload.sh b/.ci/linux-mingw/upload.sh new file mode 100755 index 0000000..ad26021 --- /dev/null +++ b/.ci/linux-mingw/upload.sh @@ -0,0 +1,13 @@ +#!/bin/bash -ex + +. .ci/common/pre-upload.sh + +REV_NAME="threeSD-windows-mingw-${GITNAME}" + +mkdir "$REV_NAME" +# get around the permission issues +cp -r package/* "$REV_NAME" + +mkdir "$REV_NAME/dist" + +. .ci/common/post-upload.sh diff --git a/.travis/macos/build.sh b/.ci/macos/build.sh similarity index 100% rename from .travis/macos/build.sh rename to .ci/macos/build.sh diff --git a/.ci/macos/deps.sh b/.ci/macos/deps.sh new file mode 100755 index 0000000..2577d71 --- /dev/null +++ b/.ci/macos/deps.sh @@ -0,0 +1,7 @@ +#!/bin/sh -ex + +brew update +brew unlink python@2 || true +rm '/usr/local/bin/2to3' || true +brew install qt5 sdl2 p7zip ccache llvm ninja || true +pip3 install macpack diff --git a/.travis/macos/upload.sh b/.ci/macos/upload.sh similarity index 65% rename from .travis/macos/upload.sh rename to .ci/macos/upload.sh index 1da4a55..441a2a5 100755 --- a/.travis/macos/upload.sh +++ b/.ci/macos/upload.sh @@ -1,19 +1,10 @@ #!/bin/bash -ex -. .travis/common/pre-upload.sh +. .ci/common/pre-upload.sh -# Find out what release we are building -if [ -z $TRAVIS_TAG ]; then - REV_NAME="threeSD-macos-${GITDATE}-${GITREV}" -else - REV_NAME="threeSD-macos-${TRAVIS_TAG}" -fi - -ARCHIVE_NAME="${REV_NAME}.tar.gz" -COMPRESSION_FLAGS="-czvf" +REV_NAME="threeSD-macos-${GITNAME}" mkdir "$REV_NAME" - cp -r build/bin/threeSD.app "$REV_NAME" # move libs into folder for deployment @@ -29,4 +20,4 @@ find "$REV_NAME" -exec otool -L {} \; mkdir "$REV_NAME/dist" -. .travis/common/post-upload.sh +. .ci/common/post-upload.sh diff --git a/.ci/windows-msvc/build.sh b/.ci/windows-msvc/build.sh new file mode 100755 index 0000000..45ae96f --- /dev/null +++ b/.ci/windows-msvc/build.sh @@ -0,0 +1,8 @@ +#!/bin/sh -ex + +mkdir build && cd build +cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MSVCCache.cmake" -DUSE_CCACHE=ON -DWARNINGS_AS_ERRORS=OFF -DUSE_BUNDLED_QT=1 + +ninja +# show the caching efficiency +buildcache -s diff --git a/.ci/windows-msvc/deps.sh b/.ci/windows-msvc/deps.sh new file mode 100755 index 0000000..769c9a7 --- /dev/null +++ b/.ci/windows-msvc/deps.sh @@ -0,0 +1,10 @@ +#!/bin/sh -ex + +BUILDCACHE_VERSION="0.22.3" + +choco install wget ninja +# Install buildcache +wget "https://github.com/mbitsnbites/buildcache/releases/download/v${BUILDCACHE_VERSION}/buildcache-win-mingw.zip" +7z x 'buildcache-win-mingw.zip' +mv ./buildcache/bin/buildcache.exe "/c/ProgramData/chocolatey/bin" +rm -rf ./buildcache/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..05fd48f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,119 @@ +name: threeSD-ci + +on: + push: + branches: [ "*" ] + tags: [ "*" ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + image: ["linux-clang-format", "linux-fresh", "linux-mingw"] + container: citraemu/build-environments:${{ matrix.image }} + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set up cache + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-${{ matrix.image }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ matrix.image }}- + - name: Query tag name + uses: little-core-labs/get-git-tag@v3.0.2 + id: tagName + - name: Build + run: ./.ci/${{ matrix.image }}/docker.sh + - name: Pack + run: ./.ci/${{ matrix.image }}/upload.sh + if: ${{ matrix.image != 'linux-clang-format' }} + env: + NAME: ${{ matrix.image }} + - name: Upload + uses: actions/upload-artifact@v2 + if: ${{ matrix.image != 'linux-mingw' && matrix.image != 'linux-clang-format' }} + with: + name: ${{ matrix.image }} + path: artifacts/ + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set up cache + uses: actions/cache@v2 + with: + path: ~/Library/Caches/ccache + key: ${{ runner.os }}-macos-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-macos- + - name: Query tag name + uses: little-core-labs/get-git-tag@v3.0.2 + id: tagName + - name: Install dependencies + run: ./.ci/macos/deps.sh + - name: Build + run: ./.ci/macos/build.sh + env: + MACOSX_DEPLOYMENT_TARGET: "10.13" + - name: Pack + run: ./.ci/macos/upload.sh + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: macos + path: artifacts/ + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set up cache + uses: actions/cache@v2 + with: + path: ~/.buildcache + key: ${{ runner.os }}-win-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-win- + - name: Install dependencies + run: ./.ci/windows-msvc/deps.sh + shell: bash + - name: Set up MSVC + uses: ilammy/msvc-dev-cmd@v1 + - name: Build + run: ./.ci/windows-msvc/build.sh + shell: bash + env: + ENABLE_COMPATIBILITY_REPORTING: "ON" + release: + runs-on: ubuntu-latest + needs: [build, macos] + if: ${{ startsWith(github.ref, 'refs/tags/') }} + steps: + - uses: actions/download-artifact@v2 + - name: Query tag name + uses: little-core-labs/get-git-tag@v3.0.2 + id: tagName + - name: Create release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tagName.outputs.tag }} + release_name: ${{ steps.tagName.outputs.tag }} + draft: false + prerelease: false + - name: Upload artifacts + uses: alexellis/upload-assets@0.2.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + asset_paths: '["./**/*.zip"]' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f64a1af..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: cpp -matrix: - include: - - os: linux - env: NAME="linux build" - sudo: required - dist: trusty - services: docker - addons: - apt: - packages: - - p7zip-full - install: "./.travis/linux/deps.sh" - script: "./.travis/linux/build.sh" - after_success: "./.travis/linux/upload.sh" - cache: ccache - - os: osx - env: NAME="macos build" - sudo: false - osx_image: xcode10.2 - install: "./.travis/macos/deps.sh" - script: "./.travis/macos/build.sh" - after_success: "./.travis/macos/upload.sh" - cache: ccache - -deploy: - provider: releases - api_key: - secure: m5ZWgdaBW7fCjP7eGh15E3uP0xkufPxi1MFifEAmjFjUm54d0yUhghoUxp/o9LUMrpRfveHyieJJzyBzCxr7ZhTs//4bPuQDpK7d1LMGobCvpnftwWRNG/cDBn57pc/Ixn9M0qPP8GAhTXg9hrmaUllRUOhUTxxlBB6Ew7ecEVMcqnZyYnTQTeaoYgiZENICpM43v9Pl7ew38qrEO4x6B3CqwGnYUEUuKxS/jRQBlbFQ7rdVj14AsJjDzI8WWuZfJwy21NtFqCnRnlObVY/YSEgSJgsD9JT6RSa7Q9AAAghVqFAv+kSf7vbpIdOIEWx4RSWAD1qFnPUsU+6/0QATbbt6s2McVRBBowQhwwg1nhWVkFDADV0fC9NgosVXsInqmk8ISHEvGa0tmG5gTnFVTcLtKlGJ2tsHMSQiOwqVaRxfui7NdoHIRhryP9DMlEGHMlsk82iSyM1cJXTeRewbXpIWPMY0yEG5VErC+v8uvfyt1LFqMMZvaGPjhrvup1zd0h3t699grAv+mFyq+RHYOMwn1SPLNdFt6LnUeam55ibBSijkhqGYWzY6LErdNmVNk81wUY9HksP1j0oKj9Xe3aLSclbsXv7UE0PruV2N762dykBloQYHl2s4zyt/wb/3tdF6uOhShwD5ZDs9Z73Op8q9wWFwE8v/4uZpCP/rTnw= - file_glob: true - file: "artifacts/*.7z" - skip_cleanup: true - draft: true - on: - branch: master - repo: zhaowenlan1779/threeSD - tags: true diff --git a/.travis/linux/build.sh b/.travis/linux/build.sh deleted file mode 100755 index 29da4df..0000000 --- a/.travis/linux/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -ex -mkdir -p "$HOME/.ccache" -docker run -v $(pwd):/threeSD -v "$HOME/.ccache":/root/.ccache citraemu/build-environments:linux-fresh /bin/bash -ex /threeSD/.travis/linux/docker.sh diff --git a/.travis/linux/deps.sh b/.travis/linux/deps.sh deleted file mode 100755 index 1db4ac5..0000000 --- a/.travis/linux/deps.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -ex - -docker pull citraemu/build-environments:linux-fresh diff --git a/.travis/linux/upload.sh b/.travis/linux/upload.sh deleted file mode 100755 index 18a48f1..0000000 --- a/.travis/linux/upload.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -ex - -. .travis/common/pre-upload.sh - -# Find out what release we are building -if [ -z $TRAVIS_TAG ]; then - REV_NAME="threeSD-linux-${GITDATE}-${GITREV}" -else - REV_NAME="threeSD-linux-${TRAVIS_TAG}" -fi - -ARCHIVE_NAME="${REV_NAME}.tar.xz" -COMPRESSION_FLAGS="-cJvf" - -mkdir "$REV_NAME" - -cp build/bin/threeSD "$REV_NAME" - -mkdir "$REV_NAME/dist" - -. .travis/common/post-upload.sh diff --git a/.travis/macos/deps.sh b/.travis/macos/deps.sh deleted file mode 100755 index 79774e7..0000000 --- a/.travis/macos/deps.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -ex - -brew update -brew unlink python@2 -brew install qt5 sdl2 p7zip ccache -pip3 install macpack diff --git a/CMakeLists.txt b/CMakeLists.txt index ceae51b..6434308 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ message(STATUS "Target architecture: ${ARCHITECTURE}") # =========================== if (MSVC) add_compile_options(/std:c++latest) + add_definitions(-D_HAS_DEPRECATED_RESULT_OF) else() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/CMakeModules/MSVCCache.cmake b/CMakeModules/MSVCCache.cmake new file mode 100644 index 0000000..2c8b201 --- /dev/null +++ b/CMakeModules/MSVCCache.cmake @@ -0,0 +1,12 @@ +# buildcache wrapper +OPTION(USE_CCACHE "Use buildcache for compilation" OFF) +IF(USE_CCACHE) + FIND_PROGRAM(CCACHE buildcache) + IF (CCACHE) + MESSAGE(STATUS "Using buildcache found in PATH") + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) + ELSE(CCACHE) + MESSAGE(WARNING "USE_CCACHE enabled, but no buildcache executable found") + ENDIF(CCACHE) +ENDIF(USE_CCACHE) diff --git a/CMakeModules/MinGWCross.cmake b/CMakeModules/MinGWCross.cmake new file mode 100644 index 0000000..7bcc5a3 --- /dev/null +++ b/CMakeModules/MinGWCross.cmake @@ -0,0 +1,54 @@ +SET(MINGW_PREFIX /usr/x86_64-w64-mingw32/) +SET(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_SYSTEM_PROCESSOR x86_64) +# Actually a hack, w/o this will cause some strange errors +SET(CMAKE_HOST_WIN32 TRUE) + + +SET(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX}) +SET(SDL2_PATH ${MINGW_PREFIX}) +SET(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-) + +# Specify the cross compiler +SET(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc-posix) +SET(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++-posix) +SET(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres) + +# Mingw tools +SET(STRIP ${MINGW_TOOL_PREFIX}strip) +SET(WINDRES ${MINGW_TOOL_PREFIX}windres) +SET(ENV{PKG_CONFIG} ${MINGW_TOOL_PREFIX}pkg-config) + +# ccache wrapper +OPTION(USE_CCACHE "Use ccache for compilation" OFF) +IF(USE_CCACHE) + FIND_PROGRAM(CCACHE ccache) + IF (CCACHE) + MESSAGE(STATUS "Using ccache found in PATH") + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) + ELSE(CCACHE) + MESSAGE(WARNING "USE_CCACHE enabled, but no ccache found") + ENDIF(CCACHE) +ENDIF(USE_CCACHE) + +# Search for programs in the build host directories +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + + +# Echo modified cmake vars to screen for debugging purposes +IF(NOT DEFINED ENV{MINGW_DEBUG_INFO}) + MESSAGE("") + MESSAGE("Custom cmake vars: (blank = system default)") + MESSAGE("-----------------------------------------") + MESSAGE("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}") + MESSAGE("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}") + MESSAGE("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}") + MESSAGE("* WINDRES : ${WINDRES}") + MESSAGE("* ENV{PKG_CONFIG} : $ENV{PKG_CONFIG}") + MESSAGE("* STRIP : ${STRIP}") + MESSAGE("* USE_CCACHE : ${USE_CCACHE}") + MESSAGE("") + # So that the debug info only appears once + SET(ENV{MINGW_DEBUG_INFO} SHOWN) +ENDIF() diff --git a/README.md b/README.md index 1a60eb2..89b77d5 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,3 @@ Please refer to the [wiki](https://github.com/zhaowenlan1779/threeSD/wiki/Quicks * Clear all the `TODO`s in the code * Wireless transfer (probably FTP?) * but: slow, complex -* MSVC build doesn't work for its crappy preprocessor, but this shouldn't really matter diff --git a/appveyor.yml b/appveyor.yml index e9e4bf0..3735670 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,6 @@ environment: CHERE_INVOKING: 1 matrix: - BUILD_TYPE: mingw - - BUILD_TYPE: msvc platform: - x64 @@ -21,71 +20,42 @@ configuration: install: - git submodule update --init --recursive - ps: | - if ($env:BUILD_TYPE -eq 'mingw') { - $dependencies = "mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-qt5-static" - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S $dependencies" - # (HACK) Link these libs to really static link qt - C:\msys64\usr\bin\bash -lc "rm /mingw64/lib/libzstd.dll.a && link /mingw64/lib/libzstd.a /mingw64/lib/libzstd.dll.a" - C:\msys64\usr\bin\bash -lc "rm /mingw64/lib/libz.dll.a && link /mingw64/lib/libz.a /mingw64/lib/libz.dll.a" - # (HACK) ignore errors - 0 - } - + $dependencies = "mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-qt5-static" + C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S $dependencies" + # (HACK) Link these libs to really static link qt + C:\msys64\usr\bin\bash -lc "rm /mingw64/lib/libzstd.dll.a && link /mingw64/lib/libzstd.a /mingw64/lib/libzstd.dll.a" + C:\msys64\usr\bin\bash -lc "rm /mingw64/lib/libz.dll.a && link /mingw64/lib/libz.a /mingw64/lib/libz.dll.a" + # (HACK) ignore errors + 0 before_build: - mkdir %BUILD_TYPE%_build - cd %BUILD_TYPE%_build - - ps: | - if ($env:BUILD_TYPE -eq 'msvc') { - # redirect stderr and change the exit code to prevent powershell from cancelling the build if cmake prints a warning - cmd /C 'cmake -G "Visual Studio 16 2019" -DUSE_BUNDLED_QT=OFF -DQt5_DIR=C:\Qt\5.14\msvc2017_64\lib\cmake\qt5 -DWARNINGS_AS_ERRORS=OFF .. 2>&1 && exit 0' - } else { - C:\msys64\usr\bin\bash.exe -lc "cmake -G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=Release -DMINGW_STATIC_BUILD=ON -DCOMPILE_WITH_DWARF=OFF .. 2>&1" - } + - C:\msys64\usr\bin\bash.exe -lc "cmake -G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=Release -DMINGW_STATIC_BUILD=ON -DCOMPILE_WITH_DWARF=OFF .. 2>&1" - cd .. build_script: - - ps: | - if ($env:BUILD_TYPE -eq 'msvc') { - # https://www.appveyor.com/docs/build-phase - msbuild msvc_build/threeSD.sln /maxcpucount /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - } else { - C:\msys64\usr\bin\bash.exe -lc 'mingw32-make -j4 -C mingw_build/ 2>&1' - } - + - C:\msys64\usr\bin\bash.exe -lc 'mingw32-make -j4 -C mingw_build/ 2>&1' after_build: - ps: | mkdir release mkdir release\dist - if ($env:BUILD_TYPE -eq 'msvc') { - Remove-Item -Force .\msvc_build\bin\release\*.pdb - Remove-Item -Force .\msvc_build\bin\release\platforms\*.pdb - Remove-Item -Force .\msvc_build\bin\release\styles\*.pdb - Copy-Item .\msvc_build\bin\release\* -Destination release -Recurse - } else { - C:\msys64\usr\bin\bash.exe -lc 'strip ./mingw_build/bin/threeSD.exe' - Copy-Item .\mingw_build\bin\threeSD.exe -Destination release - } - + C:\msys64\usr\bin\bash.exe -lc 'strip ./mingw_build/bin/threeSD.exe' + Copy-Item .\mingw_build\bin\threeSD.exe -Destination release Copy-Item .\license.txt -Destination release Copy-Item .\README.md -Destination release Copy-Item .\dist\threeSDumper.gm9 -Destination release\dist - $GITDATE = $(git show -s --date=short --format='%ad') -replace "-","" $GITREV = $(git show -s --format='%h') - if ($env:APPVEYOR_REPO_TAG_NAME) { - $BUILD_SEVENZIP = "threeSD-windows-$env:APPVEYOR_REPO_TAG_NAME.7z" -replace " ", "" + $BUILD_ZIP = "threeSD-windows-$env:APPVEYOR_REPO_TAG_NAME.zip" -replace " ", "" } else { - $BUILD_SEVENZIP = "threeSD-windows-$GITDATE-$GITREV.7z" -replace " ", "" + $BUILD_ZIP = "threeSD-windows-$GITDATE-$GITREV.zip" -replace " ", "" } - $env:BUILD_SEVENZIP = $BUILD_SEVENZIP - - 7z a $BUILD_SEVENZIP release - - + $env:BUILD_ZIP = $BUILD_SEVENZIP + 7z a $BUILD_ZIP release artifacts: - - path: $(BUILD_SEVENZIP) + - path: $(BUILD_ZIP) name: build deploy: @@ -93,7 +63,6 @@ deploy: auth_token: secure: 4xdt1ZdE/ZgP2amG5Jr073yvbitMmdV0ts48wKBKEWpR6PJwDG3bR0Attvm9Mgv8 artifact: build - draft: true on: branch: master APPVEYOR_REPO_NAME: zhaowenlan1779/threeSD diff --git a/src/core/decryptor.h b/src/core/decryptor.h index 602c172..a9a0286 100644 --- a/src/core/decryptor.h +++ b/src/core/decryptor.h @@ -31,8 +31,9 @@ public: * @param destination Path to the destination file. * @return true on success, false otherwise */ - bool DecryptAndWriteFile(const std::string& source, const std::string& destination, - const ProgressCallback& callback = [](std::size_t, std::size_t) {}); + bool DecryptAndWriteFile( + const std::string& source, const std::string& destination, + const ProgressCallback& callback = [](std::size_t, std::size_t) {}); void Abort(); diff --git a/src/core/ncch/ncch_container.h b/src/core/ncch/ncch_container.h index 7d6d3ee..851fc11 100644 --- a/src/core/ncch/ncch_container.h +++ b/src/core/ncch/ncch_container.h @@ -272,8 +272,9 @@ public: * Decrypts this NCCH and write to the destination file. * @return ResultStatus result of function. */ - ResultStatus DecryptToFile(std::shared_ptr dest_file, - const ProgressCallback& callback = [](std::size_t, std::size_t) {}); + ResultStatus DecryptToFile( + std::shared_ptr dest_file, + const ProgressCallback& callback = [](std::size_t, std::size_t) {}); /** * Aborts DecryptToFile. Simply aborts the decryptor. diff --git a/src/core/quick_decryptor.h b/src/core/quick_decryptor.h index de9f670..125be6d 100644 --- a/src/core/quick_decryptor.h +++ b/src/core/quick_decryptor.h @@ -38,11 +38,11 @@ public: * @param ctr AES CTR for decryption * @param aes_seek_pos The position to seek to for decryption. */ - bool DecryptAndWriteFile(std::shared_ptr source, std::size_t size, - std::shared_ptr destination, - const ProgressCallback& callback = [](std::size_t, std::size_t) {}, - bool decrypt = false, Core::Key::AESKey key = {}, - Core::Key::AESKey ctr = {}, std::size_t aes_seek_pos = 0); + bool DecryptAndWriteFile( + std::shared_ptr source, std::size_t size, + std::shared_ptr destination, + const ProgressCallback& callback = [](std::size_t, std::size_t) {}, bool decrypt = false, + Core::Key::AESKey key = {}, Core::Key::AESKey ctr = {}, std::size_t aes_seek_pos = 0); void DataReadLoop(); void DataDecryptLoop();