diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 716755e..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!contrib/build-deps/verify-packages.sh -!contrib/QTBUG-92199-fix.patch -!contrib/patches/ \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index ac8ec46..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: build - -on: [push, pull_request] - -jobs: - docker-linux-static: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - uses: satackey/action-docker-layer-caching@v0.0.11 - if: "!startsWith(github.ref, 'refs/tags/v')" - continue-on-error: true - with: - key: docker-linux-static-{hash} - restore-keys: | - docker-linux-static- - - name: prepare build environment - run: docker build -t feather:linux -f Dockerfile.linux --build-arg THREADS=3 . - - name: build - run: docker run --rm -v /home/runner/work/feather/feather:/feather -w /feather feather:linux sh -c 'WITH_SCANNER=Off make release-static -j3' - - name: sha256sum - run: shasum -a256 /home/runner/work/feather/feather/build/release/bin/feather - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.job }} - path: | - /home/runner/work/feather/feather/build/release/bin/feather - - docker-linux-appimage: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - uses: satackey/action-docker-layer-caching@v0.0.11 - if: "!startsWith(github.ref, 'refs/tags/v')" - continue-on-error: true - with: - key: docker-linux-static-{hash} - restore-keys: | - docker-linux-static- - - name: prepare build environment - run: docker build -t feather:linux -f Dockerfile.linux --build-arg THREADS=3 . - - name: build - run: docker run --rm -v $PWD:/feather -w /feather feather:linux sh -c 'make release-static -j3' - - name: build AppImage - run: docker run --rm -v $PWD:/feather -w /feather/build feather:linux ../contrib/build-appimage.sh - - name: sha256sum - run: shasum -a256 /home/runner/work/feather/feather/build/feather.AppImage - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.job }} - path: | - /home/runner/work/feather/feather/build/feather.AppImage - - docker-windows-static: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - uses: satackey/action-docker-layer-caching@v0.0.11 - if: "!startsWith(github.ref, 'refs/tags/v')" - continue-on-error: true - with: - key: docker-linux-static-{hash} - restore-keys: | - docker-linux-static- - - name: prepare build environment - run: docker build -f Dockerfile.windows --tag feather:win --build-arg THREADS=3 . - - name: build - run: docker run --rm -v $PWD:/feather -w /feather feather:win sh -c 'make release-static-windows root=/depends target=x86_64-w64-mingw32 tag=win-x64 -j3' - - name: sha256sum - run: shasum -a256 /home/runner/work/feather/feather/build/x86_64-w64-mingw32/release/bin/feather.exe - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.job }} - path: | - /home/runner/work/feather/feather/build/x86_64-w64-mingw32/release/bin/feather.exe - - macos: - runs-on: macOS-latest - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - name: install dependencies - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install qt@5 libsodium libzip qrencode unbound cmake boost hidapi openssl expat libunwind-headers protobuf pkgconfig zbar - - name: install polyseed - run: git clone https://github.com/tevador/polyseed.git && cd polyseed && git reset --hard e38516561c647522e2e2608f13eabdeab61d9a5d && cmake . && make && make install - - name: build - run: CMAKE_PREFIX_PATH=/usr/local/opt/qt@5/ make mac-release -j3 - - name: create .tar - run: tar -cf feather.tar feather.app - working-directory: build/bin - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.job }} - path: build/bin/feather.tar - - macos-qt6: - runs-on: macOS-latest - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - - name: install dependencies - run: HOMEBREW_NO_AUTO_UPDATE=1 brew install qt libsodium libzip qrencode unbound cmake boost hidapi openssl expat libunwind-headers protobuf pkgconfig zbar - - name: install polyseed - run: git clone https://github.com/tevador/polyseed.git && cd polyseed && git reset --hard e38516561c647522e2e2608f13eabdeab61d9a5d && cmake . && make && make install - - name: build - run: make mac-release -j3 - - name: create .tar - run: tar -cf feather.tar feather.app - working-directory: build/bin - - uses: actions/upload-artifact@v2 - with: - name: ${{ github.job }} - path: build/bin/feather.tar \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5f92865..b0aa1d1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ cmake-build-debug/* *.user *.stash build/* -build*/ +guix-* CMakeCache.txt CMakeFiles cmake_install.cmake @@ -17,3 +17,5 @@ feather.AppDir/* src/assets/tor/* !src/assets/tor/.gitkeep guix-build-* +contrib/installers/windows/setup.nsi +githash.txt diff --git a/BUILDING.md b/BUILDING.md deleted file mode 100644 index 32c24de..0000000 --- a/BUILDING.md +++ /dev/null @@ -1,154 +0,0 @@ -# Building Feather - -Release binaries (except macOS) are built using Docker. If you are looking to build Feather without Docker, -see [HACKING.MD](https://github.com/feather-wallet/feather/blob/master/HACKING.md). - -## Docker - -Builds with Docker are done in 3 steps: - -1. Cloning this repository (+submodules) -2. Creating a base image containing the build environment -3. Building Feather using the base image - -### Linux x86-64 (reproducible) - -The instructions in this section are for 64-bit AMD/Intel processors. For ARM64 platforms see the next section. - -Binaries produced in this section are reproducible and their digests should match those of release binaries. - -#### 1. Clone - -Replace `master` with the desired version tag (e.g. `1.0.1`) to build the release binary. - -```bash -git clone https://github.com/feather-wallet/feather.git -cd feather -git checkout master -git submodule update --init --recursive -``` - -#### 2. Base image - -```bash -docker build -t feather:linux -f Dockerfile.linux --build-arg THREADS=8 . -``` - -Building the base image takes a while. You only need to build the base image once per release. - -#### 3. Build - -##### Standalone static binary - -If you're re-running a build make sure to `rm -rf build/` first. - -```bash -docker run --rm -it -v $PWD:/feather -w /feather feather:linux sh -c 'WITH_SCANNER=Off make release-static -j8' -``` - -The resulting binary can be found in `./build/bin/`. - -##### AppImage - -```bash -rm -rf build -docker run --rm -it -v $PWD:/feather -w /feather feather:linux sh -c 'make release-static -j8' -docker run --rm -it -v $PWD:/feather -w /feather/build feather:linux ../contrib/build-appimage.sh -``` - -The resulting AppImage will be located in `./build`. - -### Linux ARM64 (reproducible) - -This section describes how to build Feather for ARM64 based platforms (including Raspberry Pi 3 and later, running 64-bit Rasbian). - -Binaries produced in this section are not yet reproducible. - -#### 1. Clone - -Replace `master` with the desired version tag (e.g. `1.0.1`) to build the release binary. - -```bash -git clone https://github.com/feather-wallet/feather.git -cd feather -git checkout master -git submodule update --init --recursive -``` - -#### 2. Base image - -```bash -docker build --tag feather:linux-arm64 --platform linux/arm64 -f Dockerfile.linux --build-arg THREADS=8 . -``` - -Building the base image takes a while (especially when emulated on x86-64). You only need to build the base image once per release. - -#### 3. Build - -##### Standalone static binary - -```bash -docker run --platform linux/arm64/v8 --rm -it -v $PWD:/feather -w /feather feather:linux-arm64 sh -c 'WITH_SCANNER=Off make release-static-linux-arm64 -j8' -``` - -Note: If you intend to run Feather on a Raspberry Pi or any device without AES hardware acceleration, use the following command instead: - -```bash -docker run --platform linux/arm64/v8 --rm -it -v $PWD:/feather -w /feather feather:linux-arm64 sh -c 'WITH_SCANNER=Off make release-static-linux-arm64-rpi -j8' -``` - -The resulting binary can be found in `./build/bin/`. - -##### AppImage - -##### ARMv8-a (with AES hardware acceleration) - -```bash -rm -rf build -docker run --rm -it -v $PWD:/feather --platform linux/arm64/v8 -w /feather feather:linux-arm64 sh -c 'make release-static-linux-arm64 -j8' -docker run --rm -it -v $PWD:/feather --platform linux/arm64/v8 -w /feather/build feather:linux-arm64 ../contrib/build-appimage-arm64.sh -``` - -##### Raspberry Pi - -```bash -rm -rf build -docker run --rm -it -v $PWD:/feather --platform linux/arm64/v8 -w /feather feather:linux-arm64 sh -c 'make release-static-linux-arm64-rpi -j8' -docker run --rm -it -v $PWD:/feather --platform linux/arm64/v8 -w /feather/build feather:linux-arm64 ../contrib/build-appimage-arm64.sh -``` - -The resulting AppImage will be located in `./build`. - -### Windows (reproducible) - -#### 1. Clone - -```bash -git clone --branch master --recursive https://github.com/feather-wallet/feather.git -cd feather -``` - -Replace `master` with the desired version tag (e.g. `1.0.1`) to build the release binary. - -#### 2. Base image - - -```bash -docker build -f Dockerfile.windows --tag feather:win --build-arg THREADS=4 . -``` - -Building the base image takes a while. You only need to build the base image once. - -#### 3. Build - -```bash -docker run --rm -it -v $PWD:/feather -w /feather feather:win sh -c 'make release-static-windows root=/depends target=x86_64-w64-mingw32 tag=win-x64 -j4' -``` - -If you're re-running a build make sure to `rm -rf build/` first. - -The resulting binary can be found in `./build/x86_64-w64-mingw32/release/bin/`. - -### macOS - -Docker builds for macOS are not currently supported. To build Feather on macOS follow the steps in [HACKING.md](HACKING.md). diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f8b343..fc109b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,46 +1,51 @@ -cmake_minimum_required(VERSION 3.20) -project(feather) +cmake_minimum_required(VERSION 3.18) -message(STATUS "Initiating compile using CMake ${CMAKE_VERSION}") +project(feather + VERSION "2.2.0" + DESCRIPTION "A free Monero desktop wallet" + LANGUAGES CXX C ASM +) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(VERSION_MAJOR "2") -set(VERSION_MINOR "1") -set(VERSION_REVISION "2") -set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}") - -option(STATIC "Link libraries statically, requires static Qt") +set(PACKAGE_NAME ${PROJECT_NAME}) +set(PACKAGE_BUGREPORT "https://github.com/feather-wallet/feather/issues") +set(PACKAGE_URL "https://featherwallet.org/") +set(COPYRIGHT_YEAR "2023") +set(COPYRIGHT_HOLDERS "The Monero Project") +# Configurable options +option(STATIC "Link libraries statically, requires static Qt" OFF) option(SELF_CONTAINED "Disable when building Feather for packages" OFF) option(LOCALMONERO "Include LocalMonero module" ON) option(XMRIG "Include XMRig module" ON) -option(TOR_DIR "Path to Tor binary to embed inside Feather" OFF) +option(TOR_DIR "Directory containing Tor binaries to embed inside Feather" OFF) option(CHECK_UPDATES "Enable checking for application updates" OFF) option(PLATFORM_INSTALLER "Built-in updater fetches installer (windows-only)" OFF) option(USE_DEVICE_TREZOR "Trezor support compilation" ON) option(DONATE_BEG "Prompt donation window every once in a while" ON) -option(WITH_SCANNER "Enable webcam QR scanner" OFF) +option(WITH_SCANNER "Enable webcam QR scanner" ON) list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckIncludeFile) include(CheckSymbolExists) +include(SelectLibraryConfigurations) if(DEBUG) set(CMAKE_VERBOSE_MAKEFILE ON) endif() -set(BUILD_GUI_DEPS ON) -option(ARCH "Target architecture" "native") -set(BUILD_64 ON) -set(USE_SINGLE_BUILDDIR ON) - check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H) check_symbol_exists(prctl "sys/prctl.h" HAVE_PRCTL) +# Monero configuration +set(BUILD_GUI_DEPS ON) +set(BUILD_64 ON) +set(USE_SINGLE_BUILDDIR ON) + if(STATIC) message(STATUS "Initiating static build, turning on manual submodules") set(MANUAL_SUBMODULES 1) @@ -49,16 +54,19 @@ if(STATIC) set(Boost_USE_STATIC_RUNTIME ON) endif() -add_subdirectory(monero) +include(CMakePackageConfigHelpers) +include(VersionFeather) + +#### Dependencies +# Monero +add_subdirectory(monero EXCLUDE_FROM_ALL) set_property(TARGET wallet_merged PROPERTY FOLDER "monero") get_directory_property(ARCH_WIDTH DIRECTORY "monero" DEFINITION ARCH_WIDTH) get_directory_property(UNBOUND_LIBRARY DIRECTORY "monero" DEFINITION UNBOUND_LIBRARY) get_directory_property(DEVICE_TREZOR_READY DIRECTORY "monero" DEFINITION DEVICE_TREZOR_READY) get_directory_property(TREZOR_DEP_LIBS DIRECTORY "monero" DEFINITION TREZOR_DEP_LIBS) -include(CMakePackageConfigHelpers) -include(VersionFeather) - +# Easylogging include_directories(${EASYLOGGING_INCLUDE}) link_directories(${EASYLOGGING_LIBRARY_DIRS}) @@ -69,22 +77,20 @@ message(STATUS "libsodium: libraries at ${SODIUM_LIBRARY}") # QrEncode find_package(QREncode REQUIRED) -# Qr scanner +# ZBAR find_package(ZBAR REQUIRED) message(STATUS "libzbar: include dir at ${ZBAR_INCLUDE_DIR}") message(STATUS "libzbar: libraries at ${ZBAR_LIBRARIES}") -# Tevador 14 word Monero seed -add_subdirectory(contrib/monero-seed) - -# Polyseed 16 word mnemonic seeds +# Polyseed find_package(Polyseed REQUIRED) if(Polyseed_SUBMODULE) - add_subdirectory(src/third-party/polyseed) + add_subdirectory(src/third-party/polyseed EXCLUDE_FROM_ALL) endif() # libzip -find_package(zlib CONFIG) +set(ZLIB_USE_STATIC_LIBS "ON") +find_package(ZLIB REQUIRED) find_path(LIBZIP_INCLUDE_DIRS zip.h) find_library(LIBZIP_LIBRARIES zip) @@ -98,6 +104,8 @@ endif() if(MINGW) set(Boost_THREADAPI win32) endif() + +set(Boost_USE_MULTITHREADED ON) find_package(Boost 1.58 REQUIRED COMPONENTS system filesystem @@ -107,24 +115,14 @@ find_package(Boost 1.58 REQUIRED COMPONENTS regex serialization program_options - locale) + locale + ) if(UNIX AND NOT APPLE) if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") # https://github.com/monero-project/monero-gui/issues/3142#issuecomment-705940446 set(CMAKE_SKIP_RPATH ON) endif() - - find_package(X11 REQUIRED) - message(STATUS "X11_FOUND = ${X11_FOUND}") - message(STATUS "X11_INCLUDE_DIR = ${X11_INCLUDE_DIR}") - message(STATUS "X11_LIBRARIES = ${X11_LIBRARIES}") - include_directories(${X11_INCLUDE_DIR}) - link_directories(${X11_LIBRARIES}) - if(STATIC) - find_library(XCB_LIBRARY xcb) - message(STATUS "Found xcb library: ${XCB_LIBRARY}") - endif() endif() include(TorQrcGenerator) @@ -155,19 +153,6 @@ else() message(STATUS "Skipping Tor inclusion because -DTOR_DIR=Off") endif() -if(MINGW) - string(REGEX MATCH "^[^/]:/[^/]*" msys2_install_path "${CMAKE_C_COMPILER}") - message(STATUS "MSYS location: ${msys2_install_path}") - set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw${ARCH_WIDTH}/include") - # This is necessary because otherwise CMake will make Boost libraries -lfoo - # rather than a full path. Unfortunately, this makes the shared libraries get - # linked due to a bug in CMake which misses putting -static flags around the - # -lfoo arguments. - set(DEFLIB ${msys2_install_path}/mingw${ARCH_WIDTH}/lib) - list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${DEFLIB}) - list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES ${DEFLIB}) -endif() - message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIRS}") message(STATUS "Using Boost libraries at ${Boost_LIBRARIES}") @@ -175,11 +160,6 @@ include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj") set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi;crypt32;bcrypt) - if(DEPENDS) - set(ICU_LIBRARIES iconv) - else() - set(ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv) - endif() elseif(APPLE) set(EXTRA_LIBRARIES "-framework AppKit") elseif(OPENBSD) @@ -200,13 +180,7 @@ list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS}) if(APPLE) cmake_policy(SET CMP0042 NEW) -endif() - -if (APPLE AND NOT IOS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -std=c++11") -endif() - -if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -DGTEST_HAS_TR1_TUPLE=0") endif() @@ -217,7 +191,7 @@ add_c_flag_if_supported(-Wformat-security C_SECURITY_FLAGS) add_cxx_flag_if_supported(-Wformat-security CXX_SECURITY_FLAGS) # -fstack-protector -if (NOT OPENBSD AND NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1))) +if (NOT OPENBSD) add_c_flag_if_supported(-fstack-protector C_SECURITY_FLAGS) add_cxx_flag_if_supported(-fstack-protector CXX_SECURITY_FLAGS) add_c_flag_if_supported(-fstack-protector-strong C_SECURITY_FLAGS) @@ -229,7 +203,7 @@ if (NOT OPENBSD AND NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE add_c_flag_if_supported(-fcf-protection=full C_SECURITY_FLAGS) add_cxx_flag_if_supported(-fcf-protection=full CXX_SECURITY_FLAGS) endif() -if (NOT WIN32 AND NOT OPENBSD) +if (NOT WIN32 AND NOT OPENBSD AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") add_c_flag_if_supported(-fstack-clash-protection C_SECURITY_FLAGS) add_cxx_flag_if_supported(-fstack-clash-protection CXX_SECURITY_FLAGS) endif() @@ -269,18 +243,13 @@ if (WIN32) endif() if(STATIC) - add_linker_flag_if_supported(-static-libgcc STATIC_FLAGS) - add_linker_flag_if_supported(-static-libstdc++ STATIC_FLAGS) +# add_linker_flag_if_supported(-static-libgcc STATIC_FLAGS) +# add_linker_flag_if_supported(-static-libstdc++ STATIC_FLAGS) if(MINGW) add_linker_flag_if_supported(-static STATIC_FLAGS) endif() endif() -# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that -# is fixed in the code (Issue #847), force compiler to be conservative. -add_c_flag_if_supported(-fno-strict-aliasing C_SECURITY_FLAGS) -add_cxx_flag_if_supported(-fno-strict-aliasing CXX_SECURITY_FLAGS) - add_c_flag_if_supported(-fPIC C_SECURITY_FLAGS) add_cxx_flag_if_supported(-fPIC CXX_SECURITY_FLAGS) @@ -293,3 +262,48 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${CXX_SECURITY_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LD_SECURITY_FLAGS} ${STATIC_FLAGS}") add_subdirectory(src) + +configure_file("${CMAKE_SOURCE_DIR}/contrib/installers/windows/setup.nsi.in" "${CMAKE_SOURCE_DIR}/contrib/installers/windows/setup.nsi" @ONLY) + +if(APPLE AND CMAKE_CROSSCOMPILING) + set(macos_app "feather.app") + configure_file(contrib/macdeploy/background.tiff contrib/macdeploy/background.tiff COPYONLY) + configure_file(contrib/macdeploy/Info.plist.in ${macos_app}/Contents/Info.plist @ONLY) + configure_file(src/assets/images/appicons/appicon.icns ${macos_app}/Contents/Resources/appicon.icns COPYONLY) + + set(xorrisofs_options) + if(DEFINED ENV{SOURCE_DATE_EPOCH}) + set(xorrisofs_options -volume_date all_file_dates =$ENV{SOURCE_DATE_EPOCH}) + endif() + add_custom_target(deploy + COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --config "$" --prefix "${CMAKE_BINARY_DIR}/release" --strip + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS" + COMMAND "${CMAKE_COMMAND}" -E rename "${CMAKE_BINARY_DIR}/bin/$" "${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS/feather" + COMMAND PYTHONPATH=${PYTHONPATH} INSTALL_NAME_TOOL=${CMAKE_INSTALL_NAME_TOOL} OTOOL=${OTOOL} STRIP=${CMAKE_STRIP} ${CMAKE_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${PACKAGE_NAME} + COMMAND xorrisofs -D -l -V "${PACKAGE_NAME}" -no-pad -r -dir-mode 0755 -o ${PACKAGE_NAME}.dmg ${CMAKE_BINARY_DIR}/dist -- ${xorrisofs_options} + VERBATIM + ) +endif() + +SET(CPACK_GENERATOR "DEB") +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "tobtoht") #required +INCLUDE(CPack) + +message("\n") +message("Configure summary") +message("=================") + +if(CMAKE_CROSSCOMPILING) + set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}") +else() + set(cross_status "FALSE") +endif() +message("Cross compiling ....................... ${cross_status}") +get_directory_property(definitions COMPILE_DEFINITIONS) +message("Preprocessor defined macros ........... ${definitions}") +message("C compiler ............................ ${CMAKE_C_COMPILER}") +message("CFLAGS ................................ ${CMAKE_C_FLAGS}") +message("C++ compiler .......................... ${CMAKE_CXX_COMPILER}") +message("CXXFLAGS .............................. ${CMAKE_CXX_FLAGS}") +message("LDFLAGS for executables ............... ${CMAKE_EXE_LINKER_FLAGS}") +message("\n") diff --git a/Dockerfile.linux b/Dockerfile.linux deleted file mode 100644 index 65c5b81..0000000 --- a/Dockerfile.linux +++ /dev/null @@ -1,324 +0,0 @@ -FROM ubuntu:bionic-20210723 - -ARG THREADS=4 - -ENV CFLAGS="-fPIC" -ENV CPPFLAGS="-fPIC" -ENV CXXFLAGS="-fPIC" -ENV SOURCE_DATE_EPOCH=1397818193 -ENV DEBIAN_FRONTEND=noninteractive - -# Feather build flags -ENV CHECK_UPDATES=ON -ENV WITH_SCANNER=ON - -COPY --from=featherwallet/feather-deps:linux-1.0.0 /deps /deps -COPY --from=featherwallet/feather-deps:linux-1.0.0 /var/cache/apt/archives /archives - -RUN apt-get update && \ - apt-get install -y gpg xz-utils ca-certificates wget && \ - rm -rf /var/lib/apt/lists/* - -COPY contrib/build-deps/verify-packages.sh . -RUN bash verify-packages.sh && \ - cd /archives && \ - dpkg -i --force-depends *.deb && \ - rm -rf /deps /archives - -# OpenSSL: Required for CMake, Qt 5.15, libwallet, Tor -ENV OPENSSL_ROOT_DIR=/usr/local/openssl/ -RUN git clone -b OpenSSL_1_1_1p --depth 1 https://github.com/openssl/openssl.git && \ - cd openssl && \ - git reset --hard 8aaca20cf9996257d1ce2e6f4d3059b3698dde3d && \ - ./config no-shared no-dso --prefix=/usr/local/openssl && \ - make -j$THREADS && \ - make -j$THREADS install_sw && \ - rm -rf $(pwd) - -# CMake: Required to build libqrencode, monero-seed, libzip -RUN git clone -b v3.22.2 --depth 1 https://github.com/Kitware/CMake && \ - cd CMake && \ - git reset --hard 8428e39ed9cddb3b7f1a6f7a58cb8617503183d2 && \ - ./bootstrap && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# freetype2: Required for Qt 5.15, fontconfig -RUN git clone -b VER-2-10-2 --depth 1 https://git.savannah.gnu.org/git/freetype/freetype2.git && \ - cd freetype2 && \ - git reset --hard 132f19b779828b194b3fede187cee719785db4d8 && \ - ./autogen.sh && \ - ./configure --disable-shared --enable-static --with-zlib=no && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# expat: Required for fontconfig -RUN git clone -b R_2_2_9 --depth 1 https://github.com/libexpat/libexpat && \ - cd libexpat/expat && \ - git reset --hard a7bc26b69768f7fb24f0c7976fae24b157b85b13 && \ - ./buildconf.sh && \ - ./configure --disable-shared --enable-static && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# fontconfig: Required for Qt 5.15 -RUN git clone -b 2.13.92 --depth 1 https://gitlab.freedesktop.org/fontconfig/fontconfig && \ - cd fontconfig && \ - git reset --hard b1df1101a643ae16cdfa1d83b939de2497b1bf27 && \ - ./autogen.sh --disable-shared --enable-static --sysconfdir=/etc --localstatedir=/var && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -COPY contrib/QTBUG-92199-fix.patch . - -ENV QT_VERSION=v5.15.5-lts-lgpl -RUN git clone git://code.qt.io/qt/qt5.git -b ${QT_VERSION} --depth 1 && \ - cd qt5 && \ - git clone git://code.qt.io/qt/qtbase.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtimageformats.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtmultimedia.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtsvg.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qttools.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qttranslations.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtx11extras.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtwebsockets.git -b ${QT_VERSION} --depth 1 && \ - sed -ri s/\(Libs:.*\)/\\1\ -lexpat/ /usr/local/lib/pkgconfig/fontconfig.pc && \ - sed -ri s/\(Libs:.*\)/\\1\ -lz/ /usr/local/lib/pkgconfig/freetype2.pc && \ - sed -i s/\\/usr\\/X11R6\\/lib64/\\/usr\\/local\\/lib/ qtbase/mkspecs/linux-g++-64/qmake.conf && \ - cd qtbase && cat ../../QTBUG-92199-fix.patch && git apply ../../QTBUG-92199-fix.patch - -RUN cd qt5 && \ - if [ "$(uname -m)" = "aarch64" ]; then \ - export LIBDIR="/usr/lib/aarch64-linux-gnu"; \ - export QT_PLATFORM="linux-aarch64-gnu-g++"; \ - else \ - export LIBDIR="/usr/lib/x86_64-linux-gnu"; \ - export QT_PLATFORM="linux-g++-64"; \ - fi && \ - rm $LIBDIR/libX11.a && \ - rm $LIBDIR/libX11-xcb.a && \ - OPENSSL_LIBS="-lssl -lcrypto -lpthread -ldl" \ - ./configure --prefix=/usr -platform $QT_PLATFORM -opensource -confirm-license -release -static -no-avx \ - -no-opengl -qpa xcb --xcb -xcb-xlib -feature-xlib -openssl-linked -I /usr/local/openssl/include \ - -L /usr/local/openssl/lib -system-freetype -fontconfig -glib \ - -no-dbus -no-sql-sqlite -no-use-gold-linker -no-kms \ - -qt-harfbuzz -qt-libjpeg -qt-libpng -qt-pcre -qt-zlib \ - -skip qt3d -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d \ - -skip qtdoc -skip qtquickcontrols -skip qtquickcontrols2 -skip qtspeech -skip qtgamepad \ - -skip qtlocation -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing -optimize-size \ - -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttools \ - -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebview \ - -skip qtwinextras -skip qtx11extras -skip gamepad -skip serialbus -skip location -skip webengine \ - -skip qtdeclarative -gstreamer \ - -no-feature-cups -no-feature-ftp -no-feature-pdf -no-feature-animation \ - -nomake examples -nomake tests -nomake tools && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# boost: Required for libwallet -RUN wget https://downloads.sourceforge.net/project/boost/boost/1.73.0/boost_1_73_0.tar.bz2 && \ - echo "4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402 boost_1_73_0.tar.bz2" | sha256sum -c && \ - tar -xvf boost_1_73_0.tar.bz2 && \ - rm boost_1_73_0.tar.bz2 && \ - cd boost_1_73_0 && \ - ./bootstrap.sh && \ - ./b2 --with-atomic --with-system --with-filesystem --with-thread --with-date_time --with-chrono --with-regex --with-serialization --with-program_options --with-locale variant=release link=static runtime-link=static cflags="${CFLAGS}" cxxflags="${CXXFLAGS}" install -a --prefix=/usr && \ - rm -rf $(pwd) - -# libusb: Required for libwallet -RUN git clone -b v1.0.24 --depth 1 https://github.com/libusb/libusb && \ - cd libusb && \ - git reset --hard c6a35c56016ea2ab2f19115d2ea1e85e0edae155 && \ - ./autogen.sh --disable-shared --enable-static && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# hidapi: Required for libwallet -RUN git clone -b hidapi-0.10.1 --depth 1 https://github.com/libusb/hidapi && \ - cd hidapi && \ - git reset --hard f6d0073fcddbdda24549199445e844971d3c9cef && \ - ./bootstrap && \ - ./configure --disable-shared --enable-static && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# libsodium: Required for libwallet -RUN git clone -b 1.0.18-RELEASE --depth 1 https://github.com/jedisct1/libsodium.git && \ - cd libsodium && \ - git reset --hard 940ef42797baa0278df6b7fd9e67c7590f87744b && \ - ./autogen.sh && \ - ./configure --disable-shared --enable-static && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# protobuf: Required for libwallet -RUN git clone -b v3.10.0 --depth 1 https://github.com/protocolbuffers/protobuf && \ - cd protobuf && \ - git reset --hard 6d4e7fd7966c989e38024a8ea693db83758944f1 && \ - ./autogen.sh && \ - ./configure --enable-static --disable-shared && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# unbound: Required for libwallet -RUN git clone -b release-1.13.2 --depth 1 https://github.com/NLnetLabs/unbound.git && \ - cd unbound && \ - git reset --hard 8e538dcaa8df2d0fab8ff3dcf94ac1f972450b66 && \ - ./configure --disable-shared --enable-static --without-pyunbound --with-libexpat=/usr/local/ --with-ssl=/usr/local/openssl --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only --with-pic && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# squashfs-tools: Used to create Feather AppImage -RUN git clone https://github.com/plougher/squashfs-tools.git && \ - cd squashfs-tools/squashfs-tools && \ - git reset --hard 38fa0720526222827da44b3b6c3f7eb63e8f5c2f && \ - make && \ - make install && \ - rm -rf $(pwd) - -# patchelf: Required by linuxdeployqt -RUN git clone -b 0.12 --depth 1 https://github.com/NixOS/patchelf.git && \ - cd patchelf && \ - git reset --hard 8d3a16e97294e3c5521c61b4c8835499c9918264 && \ - ./bootstrap.sh && \ - ./configure && \ - make -j$THREADS && \ - make install && \ - rm -rf $(pwd) - -# linuxdeployqt: Used to create Feather AppImage -# build from source because latest release does not allow glibc 2.27 -RUN git clone https://github.com/probonopd/linuxdeployqt.git && \ - cd linuxdeployqt && \ - git reset --hard b4697483c98120007019c3456914cfd1dba58384 && \ - qmake && \ - make -j$THREADS && \ - make install && \ - rm -rf $(pwd) - -# libevent: Required for Tor -RUN wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz && \ - echo "92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb libevent-2.1.12-stable.tar.gz" | sha256sum -c && \ - tar -zxvf libevent-2.1.12-stable.tar.gz && \ - cd libevent-2.1.12-stable && \ - PKG_CONFIG_PATH=/usr/local/openssl/lib/pkgconfig/ \ - ./configure --prefix=/usr/local/libevent \ - --disable-shared \ - --enable-static \ - --with-pic && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# zlib: Required for Tor -RUN git clone -b v1.2.11 --depth 1 https://github.com/madler/zlib && \ - cd zlib && \ - git reset --hard cacf7f1d4e3d44d871b605da3b647f07d718623f && \ - ./configure --static --prefix=/usr/local/zlib && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# Tor: Optional for Feather (-DTOR_DIR) -# Binary can be embedded in Feather -# TOR_VERSION is used by CMAKE to determine embedded version -ENV TOR_VERSION=0.4.7.8 -ENV TOR_DIR=/usr/local/tor/bin/ -RUN git clone -b tor-0.4.7.8 --depth 1 https://git.torproject.org/tor.git && \ - cd tor && \ - git reset --hard 7528524aee3ffe3c9b7c69fa18f659e1993f59a3 && \ - ./autogen.sh && \ - ./configure \ - --disable-asciidoc \ - --disable-manpage \ - --disable-html-manual \ - --disable-system-torrc \ - --disable-module-relay \ - --disable-lzma \ - --disable-zstd \ - --enable-static-tor \ - --with-libevent-dir=/usr/local/libevent \ - --with-openssl-dir=/usr/local/openssl \ - --with-zlib-dir=/usr/local/zlib \ - --disable-tool-name-check \ - --enable-fatal-warnings \ - --prefix=/usr/local/tor && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) && \ - strip -s -D /usr/local/tor/bin/tor && \ - rm /usr/local/tor/bin/tor?* - -# libqrencode: Required for Feather -# Used to display QR Codes -RUN git clone -b v4.1.1 --depth 1 https://github.com/fukuchi/libqrencode.git && \ - cd libqrencode && \ - git reset --hard 715e29fd4cd71b6e452ae0f4e36d917b43122ce8 && \ - cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr . && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# libzip: Required for Feather -# Used to unzip updates downloaded by the built-in updater -RUN git clone -b v1.7.3 --depth 1 https://github.com/nih-at/libzip.git && \ - cd libzip && \ - git reset --hard 66e496489bdae81bfda8b0088172871d8fda0032 && \ - cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr . && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# libgpg-error: Required for libgcrypt -RUN git clone -b libgpg-error-1.38 --depth 1 git://git.gnupg.org/libgpg-error.git && \ - cd libgpg-error && \ - git reset --hard 71d278824c5fe61865f7927a2ed1aa3115f9e439 && \ - ./autogen.sh && \ - ./configure --disable-shared --enable-static --disable-doc --disable-tests && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# libgcrypt: Required for Feather -# Used in src/openpgp to verify updates downloaded by the built-in updater -RUN git clone -b libgcrypt-1.8.5 --depth 1 git://git.gnupg.org/libgcrypt.git && \ - cd libgcrypt && \ - git reset --hard 56606331bc2a80536db9fc11ad53695126007298 && \ - ./autogen.sh && \ - ./configure --disable-shared --enable-static --disable-doc && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# zbar: Optional for Feather (-DWITH_SCANNER) -# Used to scan for QR Codes -RUN git clone -b stable-0.21 --recursive https://github.com/mchehab/zbar.git && \ - cd zbar && \ - git reset --hard 505f1a87b32cb7bb0edbaf37e20ccdd46bbae2a3 && \ - autoreconf -vfi && \ - ./configure --enable-static --disable-shared --without-imagemagick --with-gtk=no --with-python=no --enable-doc=no && \ - make -j$THREADS && \ - make install && \ - rm -rf $(pwd) - -# polyseed: Required for Feather -RUN git clone https://github.com/tevador/polyseed.git && \ - cd polyseed && \ - git reset --hard 4945d8239d6b26dc12723ca2aaa9f8110ceff5af && \ - mkdir build && \ - cd build && \ - cmake .. && \ - make && \ - make install && \ - rm /usr/local/lib/libpolyseed.so* && \ - rm -rf $(pwd) \ No newline at end of file diff --git a/Dockerfile.windows b/Dockerfile.windows deleted file mode 100644 index 230ca0e..0000000 --- a/Dockerfile.windows +++ /dev/null @@ -1,189 +0,0 @@ -FROM ubuntu:20.04 - -ARG THREADS=1 -ARG QT_VERSION=v5.15.5-lts-lgpl -ENV SOURCE_DATE_EPOCH=1397818193 -ENV DEBIAN_FRONTEND=noninteractive - -# Feather build flags -ENV CHECK_UPDATES=ON -ENV WITH_SCANNER=ON - -ENV OPENSSL_ROOT_DIR=/usr/local/openssl/ - -RUN apt update && \ - apt install -y \ - curl wget zip automake build-essential gcc-mingw-w64 g++-mingw-w64 gettext git libtool pkg-config \ - python \ -# zbar - autopoint && \ - rm -rf /var/lib/apt/lists/* - -RUN update-alternatives --set x86_64-w64-mingw32-g++ $(which x86_64-w64-mingw32-g++-posix) && \ - update-alternatives --set x86_64-w64-mingw32-gcc $(which x86_64-w64-mingw32-gcc-posix) - -# The version from ubuntu repo is too old -RUN git clone -b v3.22.2 --depth 1 https://github.com/Kitware/CMake && \ - cd CMake && \ - git reset --hard 8428e39ed9cddb3b7f1a6f7a58cb8617503183d2 && \ - ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -RUN git clone -b master https://github.com/monero-project/monero && \ - cd monero && \ - git reset --hard 9aab19f349433687c7aaf2c1cbc5751e5912c0aa && \ - cp -a contrib/depends / && \ - cd .. && \ - rm -rf monero - -RUN make -j$THREADS -C /depends HOST=x86_64-w64-mingw32 NO_QT=1 - -COPY contrib/QTBUG-92199-fix.patch . -RUN git clone git://code.qt.io/qt/qt5.git -b ${QT_VERSION} --depth 1 && \ - cd qt5 && \ - git clone git://code.qt.io/qt/qtbase.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtimageformats.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtmultimedia.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtsvg.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qttools.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qttranslations.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtxmlpatterns.git -b ${QT_VERSION} --depth 1 && \ - git clone git://code.qt.io/qt/qtwebsockets.git -b ${QT_VERSION} --depth 1 && \ - cd qtbase && cat ../../QTBUG-92199-fix.patch && git apply ../../QTBUG-92199-fix.patch && cd .. && \ - OPENSSL_LIBS="-lssl -lcrypto -lws2_32" \ - ./configure --prefix=/depends/x86_64-w64-mingw32 -xplatform win32-g++ \ - -device-option CROSS_COMPILE=/usr/bin/x86_64-w64-mingw32- \ - -I $(pwd)/qtbase/src/3rdparty/angle/include \ - -opensource -confirm-license -release -static -static-runtime -no-opengl \ - -no-avx -openssl-linked -I /depends/x86_64-w64-mingw32/include -L /depends/x86_64-w64-mingw32/lib \ - -qt-freetype -qt-harfbuzz -qt-libjpeg -qt-libpng -qt-pcre -qt-zlib \ - -skip gamepad -skip location -skip qt3d -skip qtactiveqt -skip qtandroidextras \ - -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdoc \ - -skip qtgamepad -skip qtlocation -skip qtmacextras -skip qtnetworkauth -skip qtpurchasing \ - -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport \ - -skip qtspeech -skip qttools -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel \ - -skip qtwebengine -skip qtwebview -skip qtwinextras -skip qtx11extras \ - -skip qtdeclarative -skip qtquickcontrols -skip qtquickcontrols2 \ - -skip serialbus -skip webengine \ - -nomake examples -nomake tests -nomake tools && \ - make -j$THREADS && \ - make -j$THREADS install && \ - cd qttools/src/linguist/lrelease && \ - ../../../../qtbase/bin/qmake && \ - make -j$THREADS && \ - make -j$THREADS install && \ - cd ../../../.. && \ - rm -rf $(pwd) - -RUN git clone -b libgpg-error-1.38 --depth 1 git://git.gnupg.org/libgpg-error.git && \ - cd libgpg-error && \ - git reset --hard 71d278824c5fe61865f7927a2ed1aa3115f9e439 && \ - ./autogen.sh && \ - ./configure --disable-shared --enable-static --disable-doc --disable-tests \ - --host=x86_64-w64-mingw32 --prefix=/depends/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - cd .. && \ - rm -rf libgpg-error - -RUN git clone -b libgcrypt-1.8.5 --depth 1 git://git.gnupg.org/libgcrypt.git && \ - cd libgcrypt && \ - git reset --hard 56606331bc2a80536db9fc11ad53695126007298 && \ - ./autogen.sh && \ - ./configure --disable-shared --enable-static --disable-doc \ - --host=x86_64-w64-mingw32 --prefix=/depends/x86_64-w64-mingw32 \ - --with-gpg-error-prefix=/depends/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - cd .. && \ - rm -rf libgcrypt - -# zlib -> libpng -RUN git clone -b v1.2.11 --depth 1 https://github.com/madler/zlib && \ - cd zlib && \ - git reset --hard cacf7f1d4e3d44d871b605da3b647f07d718623f && \ - CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar ./configure --static --prefix=/usr/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# libpng -> libqrencode -RUN git clone -b libpng16 --depth 1 https://github.com/glennrp/libpng.git && \ - cd libpng && \ - git reset --hard a37d4836519517bdce6cb9d956092321eca3e73b && \ - CPPFLAGS="-I/depends/x86_64-w64-mingw32/include" LDFLAGS="-L/depends/x86_64-w64-mingw32/lib" \ - ./configure --host=x86_64-w64-mingw32 --prefix=/depends/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -RUN git clone -b v4.0.2 --depth 1 https://github.com/fukuchi/libqrencode.git && \ - cd libqrencode && \ - git reset --hard 59ee597f913fcfda7a010a6e106fbee2595f68e4 && \ - ./autogen.sh && \ - CPPFLAGS="-I/depends/x86_64-w64-mingw32/include" LDFLAGS="-L/depends/x86_64-w64-mingw32/lib" \ - ./configure --disable-shared --enable-static --host=x86_64-w64-mingw32 --prefix=/depends/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -RUN wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz && \ - echo "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04 libiconv-1.16.tar.gz" | sha256sum -c && \ - tar -xzf libiconv-1.16.tar.gz && \ - rm libiconv-1.16.tar.gz && \ - cd libiconv-1.16 && \ - ./configure --enable-static --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -# TOR_VERSION is used by CMAKE to determine embedded version -ENV TOR_VERSION=0.4.7.8 -ENV TOR_DIR=/tor/Tor/ -RUN wget https://dist.torproject.org/torbrowser/11.0.15/tor-win64-0.4.7.8.zip && \ - echo "14115567eb9674c79481509ac97d4a7b76c80a36966dd9864989a96670440757 tor-win64-0.4.7.8.zip" | sha256sum -c && \ - unzip tor-win64-0.4.7.8.zip -d tor && \ - rm tor-win64-0.4.7.8.zip - -RUN git clone https://github.com/nih-at/libzip.git && \ - cd libzip && \ - git reset --hard 66e496489bdae81bfda8b0088172871d8fda0032 && \ - cmake -DCMAKE_INSTALL_PREFIX=/depends/x86_64-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=/depends/x86_64-w64-mingw32/share/toolchain.cmake \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_PREFIX_PATH=/usr/x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make -j$THREADS install && \ - rm -rf $(pwd) - -RUN git clone -b 0.23.92 --depth 1 --recursive https://github.com/mchehab/zbar.git && \ - cd zbar && \ - git reset --hard aac86d5f08d64ab4c3da78188eb622fa3cb07182 && \ - autoreconf -vfi && \ - ./configure --enable-static --disable-shared --without-imagemagick --disable-video --without-xv --with-gtk=no --with-python=no --enable-doc=no --host=x86_64-w64-mingw32 && \ - make -j$THREADS && \ - make install && \ - rm -rf $(pwd) - -COPY contrib/patches/polyseed/force-static-mingw.patch . -COPY contrib/patches/polyseed/no_shared.patch . - -# polyseed: Required for Feather -RUN git clone https://github.com/tevador/polyseed.git && \ - cd polyseed && \ - git reset --hard 4945d8239d6b26dc12723ca2aaa9f8110ceff5af && \ - git apply ../force-static-mingw.patch && \ - git apply ../no_shared.patch && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=/depends/x86_64-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=/depends/x86_64-w64-mingw32/share/toolchain.cmake \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_PREFIX_PATH=/usr/x86_64-w64-mingw32 .. && \ - make && \ - make install && \ - rm -rf $(pwd) - -RUN git config --global --add safe.directory /feather/monero \ No newline at end of file diff --git a/HACKING.md b/HACKING.md index 3f3ce5a..d708a8c 100644 --- a/HACKING.md +++ b/HACKING.md @@ -16,7 +16,7 @@ https://www.qt.io/download (under open-source). #### Arch Linux ```bash -pacman -S git cmake base-devel ccache unbound boost qrencode zbar qt6-base qt6-svg qt6-websockets libzip hidapi protobuf +pacman -S git cmake base-devel ccache unbound boost qrencode zbar qt6-base qt6-svg qt6-websockets qt6-multimedia libzip hidapi protobuf ``` #### Ubuntu 22.04 @@ -77,9 +77,8 @@ We recommend using Jetbrains Clion for Feather development. It integrates nicely debugger. To pass CMake flags to CLion, go to `File->Settings->Build->CMake`, set Build Type to `Debug` and set your -preferred CMake options/definitions. Add `-DARCH=x86-64` to the CMake options. If you installed Qt using the online -installer you may have to add `-DCMAKE_PREFIX_PATH=/path/to/qt/installation` in the CMake options. More CMake options -are documented below. +preferred CMake options. If you installed Qt using the online installer you may have to add +`-DCMAKE_PREFIX_PATH=/path/to/qt/installation` in the CMake options. More CMake options are documented below. Run CMake (`View -> Tool Windows -> CMake`). Click on the 🔃 (`Reload CMake Project`) button. @@ -95,8 +94,12 @@ After the target is configured, `Run -> Run 'feather'` or press Shift + F10 to b To build Feather without an IDE: -- Linux: `make release` -- macOS: `make mac-release` +```bash +mkdir build && \ +cd build && \ +cmake .. && \ +cmake --build . -j $(nproc) +``` ### CMake diff --git a/LICENSE b/LICENSE index 4c43b8e..59d66ad 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2022, The Monero Project +Copyright (c) 2020-2023, The Monero Project All rights reserved. diff --git a/Makefile b/Makefile deleted file mode 100644 index 16a5384..0000000 --- a/Makefile +++ /dev/null @@ -1,99 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# SPDX-FileCopyrightText: 2020-2022 The Monero Project - -CMAKEFLAGS = \ - -DTOR_DIR=$(or ${TOR_DIR}, Off) \ - -DTOR_VERSION=$(or ${TOR_VERSION}, Off) \ - -DCHECK_UPDATES=$(or ${CHECK_UPDATES}, Off) \ - -DWITH_SCANNER=$(or ${WITH_SCANNER}, Off) \ - -DREPRODUCIBLE=$(or ${SOURCE_DATE_EPOCH}, Off) - -release: - mkdir -p build/release && \ - cd build/release && \ - cmake \ - -DARCH=x86-64 \ - -D BUILD_TAG="linux-x64" \ - -D CMAKE_BUILD_TYPE=Release \ - $(CMAKEFLAGS) \ - ../.. && \ - $(MAKE) - -release-static: - mkdir -p build/release && \ - cd build/release && \ - cmake \ - -DARCH=x86-64 \ - -D BUILD_TAG="linux-x64" \ - -D CMAKE_BUILD_TYPE=Release \ - -D STATIC=On \ - $(CMAKEFLAGS) \ - ../.. && \ - $(MAKE) - -release-static-linux-arm64: - mkdir -p build/release && \ - cd build/release && \ - cmake \ - -D ARCH="armv8-a" \ - -D BUILD_TAG="linux-armv8" \ - -D CMAKE_BUILD_TYPE=Release \ - -D STATIC=On \ - $(CMAKEFLAGS) \ - ../.. && \ - $(MAKE) - -release-static-linux-arm64-rpi: - mkdir -p build/release && \ - cd build/release && \ - cmake \ - -D ARCH="armv8-a" \ - -D NO_AES=On \ - -D BUILD_TAG="linux-armv8-noaes" \ - -D CMAKE_BUILD_TYPE=Release \ - -D STATIC=On \ - $(CMAKEFLAGS) \ - ../.. && \ - $(MAKE) - -release-static-windows: - mkdir -p build/$(target)/release && \ - cd build/$(target)/release && \ - cmake \ - -DARCH=x86-64 \ - -D BUILD_TAG=$(tag) \ - -D CMAKE_BUILD_TYPE=Release \ - -D STATIC=ON \ - -D CMAKE_TOOLCHAIN_FILE=$(root)/$(target)/share/toolchain.cmake \ - $(CMAKEFLAGS) \ - ../../.. && \ - $(MAKE) - -release-static-windows-installer: - mkdir -p build/$(target)/release && \ - cd build/$(target)/release && \ - cmake \ - -D PLATFORM_INSTALLER=On \ - -DARCH=x86-64 \ - -D BUILD_TAG=$(tag) \ - -D CMAKE_BUILD_TYPE=Release \ - -D STATIC=ON \ - -D CMAKE_TOOLCHAIN_FILE=$(root)/$(target)/share/toolchain.cmake \ - $(CMAKEFLAGS) \ - -D TOR_DIR=Off \ - -D TOR_VERSION=Off \ - ../../.. && \ - $(MAKE) - -mac-release: - mkdir -p build && \ - cd build && \ - cmake \ - -DARCH=native \ - -D BUILD_TAG="mac-x64" \ - -D CMAKE_BUILD_TYPE=Release \ - -D STATIC=Off \ - $(CMAKEFLAGS) \ - .. && \ - $(MAKE) && \ - $(MAKE) deploy diff --git a/README.md b/README.md index 3fef8f5..4cbfe8c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Feather is a free, open-source Monero wallet for Linux, Tails, macOS and Windows. It is written in C++ with the Qt framework. -Copyright (c) 2020-2022, The Monero Project. +Copyright (c) 2020-2023, The Monero Project. ## Resources @@ -24,11 +24,11 @@ Donations help pay for hosting, build servers, domain names, e-mail and other re `47ntfT2Z5384zku39pTM6hGcnLnvpRYW2Azm87GiAAH2bcTidtq278TL6HmwyL8yjMeERqGEBs3cqC8vvHPJd1cWQrGC65f` -## Building from source +## Deterministic builds -See [BUILDING.md](https://github.com/feather-wallet/feather/blob/master/BUILDING.md) for information on how to build from source. +See [contrib/guix/README.md](https://github.com/feather-wallet/feather/blob/master/contrib/guix/README.md) for more information. -## Developers +## Development If you are looking to set up a development environment for Feather, see [HACKING.md](https://github.com/feather-wallet/feather/blob/master/HACKING.md). diff --git a/cmake/Deploy.cmake b/cmake/Deploy.cmake deleted file mode 100644 index 726195b..0000000 --- a/cmake/Deploy.cmake +++ /dev/null @@ -1,28 +0,0 @@ -if(APPLE OR (WIN32 AND NOT STATIC)) - add_custom_target(deploy) - get_target_property(_qmake_executable Qt::qmake IMPORTED_LOCATION) - get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) - - if(APPLE AND NOT IOS) - find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}") - add_custom_command(TARGET deploy - POST_BUILD - COMMAND "${MACDEPLOYQT_EXECUTABLE}" "$/../.." -always-overwrite - COMMENT "Running macdeployqt..." - ) - - # workaround for a Qt bug that requires manually adding libqsvg.dylib to bundle - find_file(_qt_svg_dylib "libqsvg.dylib" PATHS "${CMAKE_PREFIX_PATH}/plugins/imageformats" NO_DEFAULT_PATH) - if(_qt_svg_dylib) - add_custom_command(TARGET deploy - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${_qt_svg_dylib} $/../PlugIns/imageformats/ - COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_PREFIX_PATH}/lib/QtGui.framework/Versions/5/QtGui" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $/../PlugIns/imageformats/libqsvg.dylib - COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_PREFIX_PATH}/lib/QtWidgets.framework/Versions/5/QtWidgets" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $/../PlugIns/imageformats/libqsvg.dylib - COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_PREFIX_PATH}/lib/QtSvg.framework/Versions/5/QtSvg" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $/../PlugIns/imageformats/libqsvg.dylib - COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_PREFIX_PATH}/lib/QtCore.framework/Versions/5/QtCore" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $/../PlugIns/imageformats/libqsvg.dylib - COMMENT "Copying libqsvg.dylib, running install_name_tool" - ) - endif() - endif() -endif() \ No newline at end of file diff --git a/cmake/FindZBAR.cmake b/cmake/FindZBAR.cmake index 94f26df..290f333 100644 --- a/cmake/FindZBAR.cmake +++ b/cmake/FindZBAR.cmake @@ -9,14 +9,6 @@ if(PkgConfig_FOUND) endif() endif() -if(NOT ZBAR_LIBRARIES AND ANDROID) - find_library(ZBARJNI_LIBRARY NAMES zbarjni) - find_library(ICONV_LIBRARY NAMES iconv) - if(ZBARJNI_LIBRARY AND ICONV_LIBRARY) - set(ZBAR_LIBRARIES ${ZBARJNI_LIBRARY} ${ICONV_LIBRARY}) - endif() -endif() - if(NOT ZBAR_INCLUDE_DIR) find_path(ZBAR_H_PATH zbar.h) if(ZBAR_H_PATH) diff --git a/cmake/FindZLIB.cmake b/cmake/FindZLIB.cmake index c86758f..29a6381 100644 --- a/cmake/FindZLIB.cmake +++ b/cmake/FindZLIB.cmake @@ -87,7 +87,7 @@ if(NOT ZLIB_LIBRARY) find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) endforeach() - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + include(SelectLibraryConfigurations) select_library_configurations(ZLIB) endif() @@ -116,7 +116,7 @@ if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}") endif() -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR VERSION_VAR ZLIB_VERSION_STRING) @@ -151,4 +151,6 @@ if(ZLIB_FOUND) IMPORTED_LOCATION "${ZLIB_LIBRARY}") endif() endif() + + message(STATUS "Found zlib libraries ${ZLIB_LIBRARIES}") endif() \ No newline at end of file diff --git a/cmake/GenVersion.cmake b/cmake/GenVersion.cmake index 220a03a..c23acf2 100644 --- a/cmake/GenVersion.cmake +++ b/cmake/GenVersion.cmake @@ -1,5 +1,5 @@ # Copyright (c) 2014-2019, The Monero Project -# +# # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are diff --git a/cmake/VersionFeather.cmake b/cmake/VersionFeather.cmake index f94567f..dae2705 100644 --- a/cmake/VersionFeather.cmake +++ b/cmake/VersionFeather.cmake @@ -1,5 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -# SPDX-FileCopyrightText: 2020-2022 The Monero Project +# SPDX-FileCopyrightText: 2020-2023 The Monero Project find_package(Git QUIET) diff --git a/cmake/config-feather.h.cmake b/cmake/config-feather.h.cmake index 1e9f3f4..55fa424 100644 --- a/cmake/config-feather.h.cmake +++ b/cmake/config-feather.h.cmake @@ -1,7 +1,7 @@ #ifndef FEATHER_VERSION_H #define FEATHER_VERSION_H -#define FEATHER_VERSION "@VERSION@" +#define FEATHER_VERSION "@PROJECT_VERSION@" #define FEATHER_COMMIT "@FEATHER_COMMIT@" #define TOR_VERSION "@TOR_VERSION@" diff --git a/contrib/AppImage/AppRun b/contrib/AppImage/AppRun index def250b..dc50855 100644 --- a/contrib/AppImage/AppRun +++ b/contrib/AppImage/AppRun @@ -3,9 +3,6 @@ HERE="$(dirname "$(readlink -f "${0}")")" echo $HERE -export GST_PLUGIN_SCANNER=$(readlink -f $(dirname "$0")/usr/lib/gst-plugin-scanner) -export GST_PLUGIN_SYSTEM_PATH=$(readlink -f $(dirname "$0")/usr/lib) # Tails 5.8 sets QT_QPA_PLATFORM to wayland which breaks our app export QT_QPA_PLATFORM=xcb - ${APPDIR}/usr/bin/feather $* diff --git a/contrib/AppImage/build-appimage.sh b/contrib/AppImage/build-appimage.sh new file mode 100755 index 0000000..fde0a82 --- /dev/null +++ b/contrib/AppImage/build-appimage.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -e +unset SOURCE_DATE_EPOCH + +APPDIR="$PWD/feather.AppDir" + +mkdir -p "$APPDIR" +mkdir -p "$APPDIR/usr/share/applications/" +mkdir -p "$APPDIR/usr/bin" +mkdir -p "$APPDIR/usr/lib" +mkdir -p "$APPDIR/usr/plugins" + +cp "src/assets/feather.desktop" "$APPDIR/usr/share/applications/feather.desktop" +cp "src/assets/images/appicons/64x64.png" "$APPDIR/feather.png" +cp "build/bin/feather" "$APPDIR/usr/bin/feather" +chmod +x "$APPDIR/usr/bin/feather" + +export LD_LIBRARY_PATH=/feather/contrib/depends/x86_64-linux-gnu/lib/:/gnu/store:/gnu/store/yk91cxchassi5ykxsyd4vci32vncgjkf-gcc-cross-x86_64-linux-gnu-10.3.0-lib/x86_64-linux-gnu/lib + +# linuxdeployqt glibc moaning bypass +mkdir -p "$APPDIR/usr/share/doc/libc6" +touch "$APPDIR/usr/share/doc/libc6/copyright" + +# TODO: linuxdeployqt can't build ARM appimages on x86_64, skip this step for ARM builds +case "$HOST" in + x86_64*) + linuxdeployqt feather.AppDir/usr/share/applications/feather.desktop -verbose=2 -bundle-non-qt-libs -unsupported-allow-new-glibc + rm "$APPDIR/AppRun" + ;; +esac + +cp "contrib/AppImage/AppRun" "$APPDIR/" +chmod +x "$APPDIR/AppRun" + +find feather.AppDir/ -exec touch -h -a -m -t 202101010100.00 {} \; + +# Manually create AppImage (reproducibly) + +mksquashfs feather.AppDir feather.squashfs -info -root-owned -no-xattrs -noappend -fstime 0 +# mksquashfs writes a timestamp to the header +printf '\x00\x00\x00\x00' | dd conv=notrunc of=feather.squashfs bs=1 seek=$((0x8)) + +rm -f feather.AppImage + +cat /feather/contrib/depends/${HOST}/runtime >> feather.AppImage +cat feather.squashfs >> feather.AppImage +chmod a+x feather.AppImage diff --git a/contrib/AppImage/gst-plugin-scanner.sh b/contrib/AppImage/gst-plugin-scanner.sh deleted file mode 100644 index 4fbc252..0000000 --- a/contrib/AppImage/gst-plugin-scanner.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# Wrapper to launch gst-plugin-scanner inside the AppImage. - -HERE="$(dirname "$(readlink -f "${0}")")" -export PATH="${HERE}:${PATH}" - -binary=$(find "$HERE" -name "gst-plugin-scanner-x86_64" | head -n 1) -LD_LINUX=$(find "$HERE/../../../" -name 'ld-*.so.*' | head -n 1) -if [ -e "$LD_LINUX" ] ; then - case $line in - "ld-linux"*) exec "${LD_LINUX}" --inhibit-cache "${binary}" "$@" ;; - *) exec "${LD_LINUX}" "${binary}" "$@" ;; - esac -else - exec "${binary}" "$@" -fi \ No newline at end of file diff --git a/contrib/QTBUG-92199-fix.patch b/contrib/QTBUG-92199-fix.patch deleted file mode 100644 index 6be407a..0000000 --- a/contrib/QTBUG-92199-fix.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp -index 2ab9756f8d..a9d6ecd51a 100644 ---- a/src/widgets/styles/qstylesheetstyle.cpp -+++ b/src/widgets/styles/qstylesheetstyle.cpp -@@ -1465,7 +1465,6 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q - p->setBrush(cg, w->foregroundRole(), pal->foreground); - p->setBrush(cg, QPalette::WindowText, pal->foreground); - p->setBrush(cg, QPalette::Text, pal->foreground); -- p->setBrush(cg, QPalette::PlaceholderText, pal->foreground); - } - if (pal->selectionBackground.style() != Qt::NoBrush) - p->setBrush(cg, QPalette::Highlight, pal->selectionBackground); -diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp -index 26868a763c..82527849b0 100644 ---- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp -+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp -@@ -126,7 +126,6 @@ private slots: - void QTBUG15910_crashNullWidget(); - void QTBUG36933_brokenPseudoClassLookup(); - void styleSheetChangeBeforePolish(); -- void placeholderColor(); - //at the end because it mess with the style. - void widgetStyle(); - void appStyle(); -@@ -2230,21 +2229,6 @@ void tst_QStyleSheetStyle::highdpiImages() - QHighDpiScaling::updateHighDpiScaling(); // reset to normal - } - --void tst_QStyleSheetStyle::placeholderColor() --{ -- const QColor red(Qt::red); -- qApp->setStyleSheet("* { color: red; }"); -- QLineEdit le1; -- QLineEdit le2; -- le2.setEnabled(false); -- le1.ensurePolished(); -- QCOMPARE(le1.palette().placeholderText(), red); -- le2.ensurePolished(); -- QCOMPARE(le2.palette().placeholderText(), red); -- le2.setEnabled(true); -- QCOMPARE(le2.palette().placeholderText(), red); --} -- - QTEST_MAIN(tst_QStyleSheetStyle) - #include "tst_qstylesheetstyle.moc" - diff --git a/contrib/build-appimage-arm64.sh b/contrib/build-appimage-arm64.sh deleted file mode 100755 index e30eeaa..0000000 --- a/contrib/build-appimage-arm64.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -# TODO: Merge with build-appimage.sh - -set -e -unset SOURCE_DATE_EPOCH - -# Temporary workaround for linuxdeployqt issue on arm64 -if [ "$(uname -m)" = "aarch64" ]; then - pushd / - apt update - apt install -y qt5-default - git clone https://github.com/probonopd/linuxdeployqt.git - cd linuxdeployqt - git reset --hard b4697483c98120007019c3456914cfd1dba58384 - qmake - make -j$THREADS - make install - rm -rf $(pwd) - popd -fi - -APPDIR="$PWD/feather.AppDir" -rm -rf $APPDIR -mkdir -p "$APPDIR" -mkdir -p "$APPDIR/usr/share/applications/" -mkdir -p "$APPDIR/usr/bin" -mkdir -p "$APPDIR/usr/lib" -mkdir -p "$APPDIR/usr/plugins" - -cp "$PWD/../src/assets/feather.desktop" "$APPDIR/usr/share/applications/feather.desktop" -cp "$PWD/../src/assets/images/appicons/64x64.png" "$APPDIR/feather.png" -cp "$PWD/release/bin/feather" "$APPDIR/usr/bin/feather" -chmod +x "$APPDIR/usr/bin/feather" - -export LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/:/usr/local/lib/$LD_LIBRARY_PATH -linuxdeployqt feather.AppDir/usr/share/applications/feather.desktop -verbose=2 -bundle-non-qt-libs - -pushd feather.AppDir/usr/plugins -ln -s ../lib/ gstreamer -popd - -GST_PLUGINS=("libgstcamerabin.so libgstcoreelements.so libgstvolume.so libgstapp.so libgstvideoconvert.so - libgstvideoscale.so libgstvideo4linux2.so libgstencoding.so libgstmultifile.so libgstmatroska.so - libgstvpx.so libgstjpegformat.so libgstjpeg.so libgstautodetect.so libgstaudiotestsrc.so - libgstvorbis.so libgstaudiorate.so libgstaudioconvert.so libgstaudioresample.so libgstvideocrop.so") - -for plugin in ${GST_PLUGINS[*]}; do - cp /usr/lib/aarch64-linux-gnu/gstreamer-1.0/$plugin feather.AppDir/usr/plugins/gstreamer/ - - # linuxdeployqt doesn't set RUNPATH on libs that are only loaded at runtime - patchelf --set-rpath "\$ORIGIN" feather.AppDir/usr/plugins/gstreamer/$plugin -done - -cp /usr/lib/aarch64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner feather.AppDir/usr/plugins/gstreamer/ - -# Need second deploy for gstreamer dependencies -linuxdeployqt feather.AppDir/usr/share/applications/feather.desktop -verbose=2 -bundle-non-qt-libs - -rm "$APPDIR/AppRun" -cp "$PWD/../contrib/AppImage/AppRun" "$APPDIR/" -chmod +x "$APPDIR/AppRun" - -find feather.AppDir/ -exec touch -h -a -m -t 202101010100.00 {} \; - -# Manually create AppImage (reproducibly) - -# download runtime -wget -nc https://github.com/AppImage/AppImageKit/releases/download/13/runtime-aarch64 -echo "d2624ce8cc2c64ef76ba986166ad67f07110cdbf85112ace4f91611bc634c96a runtime-aarch64" | sha256sum -c - -mksquashfs feather.AppDir feather.squashfs -info -root-owned -no-xattrs -noappend -fstime 0 -# mksquashfs writes a timestamp to the header -printf '\x00\x00\x00\x00' | dd conv=notrunc of=feather.squashfs bs=1 seek=$((0x8)) - -rm -f feather.AppImage -cat runtime-aarch64 >> feather.AppImage -cat feather.squashfs >> feather.AppImage -chmod a+x feather.AppImage diff --git a/contrib/build-appimage.sh b/contrib/build-appimage.sh deleted file mode 100755 index 2b7035b..0000000 --- a/contrib/build-appimage.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -set -e -unset SOURCE_DATE_EPOCH - -APPDIR="$PWD/feather.AppDir" -rm -rf $APPDIR -mkdir -p "$APPDIR" -mkdir -p "$APPDIR/usr/share/applications/" -mkdir -p "$APPDIR/usr/bin" -mkdir -p "$APPDIR/usr/lib" -mkdir -p "$APPDIR/usr/plugins" - -cp "$PWD/../src/assets/feather.desktop" "$APPDIR/usr/share/applications/feather.desktop" -cp "$PWD/../src/assets/images/appicons/64x64.png" "$APPDIR/feather.png" -cp "$PWD/release/bin/feather" "$APPDIR/usr/bin/feather" -chmod +x "$APPDIR/usr/bin/feather" - -export LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu/:/usr/local/lib/$LD_LIBRARY_PATH -linuxdeployqt feather.AppDir/usr/share/applications/feather.desktop -verbose=2 -bundle-non-qt-libs - -pushd feather.AppDir/usr/plugins -ln -s ../lib/ gstreamer -popd - -GST_PLUGINS=("libgstcamerabin.so libgstcoreelements.so libgstvolume.so libgstapp.so libgstvideoconvert.so - libgstvideoscale.so libgstvideo4linux2.so libgstencoding.so libgstmultifile.so libgstmatroska.so - libgstvpx.so libgstjpegformat.so libgstjpeg.so libgstautodetect.so libgstaudiotestsrc.so - libgstvorbis.so libgstaudiorate.so libgstaudioconvert.so libgstaudioresample.so libgstvideocrop.so") - -for plugin in ${GST_PLUGINS[*]}; do - cp /usr/lib/x86_64-linux-gnu/gstreamer-1.0/$plugin feather.AppDir/usr/plugins/gstreamer/ - - # linuxdeployqt doesn't set RUNPATH on libs that are only loaded at runtime - patchelf --set-rpath "\$ORIGIN" feather.AppDir/usr/plugins/gstreamer/$plugin -done - -cp /usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner feather.AppDir/usr/plugins/gstreamer/ - -# Need second deploy for gstreamer dependencies -linuxdeployqt feather.AppDir/usr/share/applications/feather.desktop -verbose=2 -bundle-non-qt-libs - -rm "$APPDIR/AppRun" -cp "$PWD/../contrib/AppImage/AppRun" "$APPDIR/" -chmod +x "$APPDIR/AppRun" - -find feather.AppDir/ -exec touch -h -a -m -t 202101010100.00 {} \; - -# Manually create AppImage (reproducibly) - -# download runtime -wget -nc https://github.com/AppImage/AppImageKit/releases/download/13/runtime-x86_64 -echo "328e0d745c5c6817048c27bc3e8314871703f8f47ffa81a37cb06cd95a94b323 runtime-x86_64" | sha256sum -c - -mksquashfs feather.AppDir feather.squashfs -info -root-owned -no-xattrs -noappend -fstime 0 -# mksquashfs writes a timestamp to the header -printf '\x00\x00\x00\x00' | dd conv=notrunc of=feather.squashfs bs=1 seek=$((0x8)) - -rm -f feather.AppImage -cat runtime-x86_64 >> feather.AppImage -cat feather.squashfs >> feather.AppImage -chmod a+x feather.AppImage diff --git a/contrib/build-deps/Dockerfile.linux-builddeps b/contrib/build-deps/Dockerfile.linux-builddeps deleted file mode 100644 index f32105d..0000000 --- a/contrib/build-deps/Dockerfile.linux-builddeps +++ /dev/null @@ -1,61 +0,0 @@ -FROM ubuntu:18.04 - -ENV DEBIAN_FRONTEND=noninteractive - -WORKDIR /deps - -RUN sed -i '/bionic-backports/d' /etc/apt/sources.list - -RUN apt-get update && \ - apt-get install -y wget xz-utils nano gpg xz-utils ca-certificates - -COPY get-packages.sh . -RUN bash get-packages.sh - -RUN apt-get install -y --no-install-recommends --no-install-suggests --reinstall --download-only \ -# build tools - software-properties-common python3 build-essential automake libtool-bin git \ -# ninja - unzip \ -# GStreamer plugins - libjpeg-dev libvpx-dev libvorbis-dev \ -# fontconfig - autopoint gettext gperf libpng-dev \ -# libxkbcommon - bison \ -# Qt 5.15 -# https://doc.qt.io/qt-5/linux-requirements.html - libx11-dev \ - libx11-xcb-dev \ - libxext-dev \ - libxfixes-dev \ - libxi-dev \ - libxrender-dev \ - libxcb1-dev \ - libxcb-keysyms1-dev \ - libxcb-image0-dev \ - libxcb-icccm4-dev \ - libxcb-xfixes0-dev \ - libxcb-render-util0-dev \ - libxcb-xinerama0-dev \ - libxcb-randr0-dev \ - libxcb-sync-dev \ - libxkbcommon-dev \ - libxkbcommon-x11-dev \ - xutils-dev \ - libxcb-util-dev \ - libxcb-xinput-dev \ -# libwallet -# libudev.so is included in AppImage - libudev1 libudev-dev \ -# GStreamer - gstreamer1.0-plugins-good \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ -# git dependency - libpsl5 - -# Verify packages -RUN ln -s /var/cache/apt/archives /archives -COPY verify-packages.sh . -RUN bash verify-packages.sh \ No newline at end of file diff --git a/contrib/build-deps/get-packages.sh b/contrib/build-deps/get-packages.sh deleted file mode 100644 index 03635c4..0000000 --- a/contrib/build-deps/get-packages.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -base_uri="http://archive.ubuntu.com/ubuntu/dists" -arch="amd64" -if [ "$(uname -m)" = "aarch64" ]; then - base_uri="http://ports.ubuntu.com/ubuntu-ports/dists" - arch="arm64" -fi - -for target in bionic bionic-updates bionic-security -do - mkdir "$target" - pushd "$target" - target_uri="$base_uri/$target/" - wget "$target_uri/Release" - wget "$target_uri/Release.gpg" - for repo in main multiverse restricted universe - do - mkdir "$repo" - pushd "$repo" - wget "$target_uri/$repo/binary-$arch/Packages.xz" - popd - done - popd -done \ No newline at end of file diff --git a/contrib/build-deps/verify-packages.sh b/contrib/build-deps/verify-packages.sh deleted file mode 100644 index 81872aa..0000000 --- a/contrib/build-deps/verify-packages.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -e - -arch="amd64" -if [ "$(uname -m)" = "aarch64" ]; then - arch="arm64" -fi - -cd /deps -for target in bionic bionic-updates bionic-security -do - pushd "$target" - - # Verify Releases - gpg --no-default-keyring --keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg --verify Release.gpg Release - - for repo in main multiverse restricted universe - do - pushd "$repo" - - # Verify Packages.xz - sha256=`cat ../Release | grep "$repo/binary-$arch/Packages.xz" | tail -n 1 | awk '{print $1}'` - echo "$sha256 Packages.xz" | sha256sum -c - - xz -d -c Packages.xz >> ../../Packages-all - popd - done - popd -done - -# Verify individual .deb files -cd /archives -for deb in *.deb; do - file_name=`echo $deb | sed 's/[0-9]*%3a//g'` # --download-only uses this version format sometimes, not sure what that is all about - sha256=`sed -n "/\/${file_name}$"'/{:start /SHA256: /!{N;b start};//p}' /deps/Packages-all | tail -n 1 | awk '{print $2}'` - echo "$sha256 $deb" | sha256sum -c -done \ No newline at end of file diff --git a/contrib/depends/.gitignore b/contrib/depends/.gitignore new file mode 100644 index 0000000..d1985d7 --- /dev/null +++ b/contrib/depends/.gitignore @@ -0,0 +1,14 @@ +SDKs/ +work/ +built/ +sources/ +config.site +x86_64-* +i686-* +mips-* +arm-* +aarch64-* +powerpc-* +riscv32-* +riscv64-* +s390x-* diff --git a/contrib/depends/Makefile b/contrib/depends/Makefile new file mode 100644 index 0000000..70ed3f8 --- /dev/null +++ b/contrib/depends/Makefile @@ -0,0 +1,291 @@ +.NOTPARALLEL : + +# Pattern rule to print variables, e.g. make print-top_srcdir +print-%: FORCE + @echo '$*'='$($*)' + +# When invoking a sub-make, keep only the command line variable definitions +# matching the pattern in the filter function. +# +# e.g. invoking: +# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS +# +# with the following in the Makefile: +# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES)) +# +# will print: +# MAKEOVERRIDES = A=1 +# MAKEFLAGS = -- A=1 +# +# this is because as the GNU make manual says: +# The command line variable definitions really appear in the variable +# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable. +# +# and since the GNU make manual also says: +# variables defined on the command line are passed to the sub-make through +# MAKEFLAGS +# +# this means that sub-makes will be invoked as if: +# $(MAKE) A=1 blah blah +MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES)) +SOURCES_PATH ?= $(BASEDIR)/sources +WORK_PATH = $(BASEDIR)/work +BASE_CACHE ?= $(BASEDIR)/built +SDK_PATH ?= $(BASEDIR)/SDKs +FALLBACK_DOWNLOAD_PATH ?= https://featherwallet.org/files/sources + +BUILD = $(shell ./config.guess) +HOST ?= $(BUILD) +PATCHES_PATH = $(BASEDIR)/patches +BASEDIR = $(CURDIR) +HASH_LENGTH:=11 +DOWNLOAD_CONNECT_TIMEOUT:=30 +DOWNLOAD_RETRIES:=3 +HOST_ID_SALT ?= salt +BUILD_ID_SALT ?= salt + +host:=$(BUILD) +ifneq ($(HOST),) +host:=$(HOST) +endif + +ifneq ($(DEBUG),) +release_type=Debug +else +release_type=Release +endif + +ifneq ($(TESTS),) +build_tests=ON +release_type=Debug +else +build_tests=OFF +endif + +base_build_dir=$(WORK_PATH)/build +base_staging_dir=$(WORK_PATH)/staging +base_download_dir=$(WORK_PATH)/download +canonical_host:=$(shell ./config.sub $(HOST)) +build:=$(shell ./config.sub $(BUILD)) + +build_arch =$(firstword $(subst -, ,$(build))) +build_vendor=$(word 2,$(subst -, ,$(build))) +full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build)) +build_os:=$(findstring linux,$(full_build_os)) +build_os+=$(findstring darwin,$(full_build_os)) +build_os:=$(strip $(build_os)) +ifeq ($(build_os),) +build_os=$(full_build_os) +endif + +host_arch=$(firstword $(subst -, ,$(canonical_host))) +host_vendor=$(word 2,$(subst -, ,$(canonical_host))) +full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host)) +host_os:=$(findstring android,$(full_host_os)) +ifeq ($(host_os),) +host_os:=$(findstring linux,$(full_host_os)) +endif +host_os+=$(findstring darwin,$(full_host_os)) +host_os+=$(findstring freebsd,$(full_host_os)) +host_os+=$(findstring mingw32,$(full_host_os)) +host_os:=$(strip $(host_os)) +ifeq ($(host_os),) +host_os=$(full_host_os) +endif + +$(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host) +$(host_arch)_$(host_os)_host=$(host) +host_prefix=$($(host_arch)_$(host_os)_prefix) +build_prefix=$(host_prefix)/native +ifeq ($(host_os),mingw32) +host_cmake=Windows +endif +ifeq ($(host_os),linux) +host_cmake=Linux +endif +ifeq ($(host_os),freebsd) +host_cmake=FreeBSD +endif +ifeq ($(host_os),darwin) +host_cmake=Darwin +endif +ifeq ($(host_os),android) +host_cmake=Android +endif + +AT_$(V):= +AT_:=@ +AT:=$(AT_$(V)) +build_host=$(build) + +all: install + +include hosts/$(host_os).mk +include hosts/default.mk +include builders/$(build_os).mk +include builders/default.mk +include packages/packages.mk + +# Previously, we directly invoked the well-known programs using $(shell ...) +# to construct build_id_string. However, that was problematic because: +# +# 1. When invoking a shell, GNU Make special-cases exit code 127 (command not +# found) by not capturing the output but instead passing it through. This is +# not done for any other exit code. +# +# 2. Characters like '#' (from these programs' output) would end up in make +# variables like build_id_string, which would be wrongly interpreted by make +# when these variables were used. +# +# Therefore, we should avoid having arbitrary strings in make variables where +# possible. The gen_id script used here hashes the output to construct a +# "make-safe" id. +# +# Also note that these lines need to be: +# +# 1. After including {hosts,builders}/*.mk, since they rely on the tool +# variables (e.g. build_CC, host_STRIP, etc.) to be set. +# +# 2. Before including packages/*.mk (excluding packages/packages.mk), since +# they rely on the build_id variables +# +build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))') +$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(host_AR)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))') + + +qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages) $(qt_$(host_arch)_$(host_os)_packages) $(qrencode_packages_) +tor_packages_$(NO_TOR) = $(tor_packages) $(tor_$(host_os)_packages) + +packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(tor_packages_) +native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) + +all_packages = $(packages) $(native_packages) + +meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk + +$(host_arch)_$(host_os)_native_binutils?=$($(host_os)_native_binutils) +$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain) + +include funcs.mk + +CONF_PKGS := cmake-conf mxe-conf + +build-only-$(1)_$(3): CMAKE_RUNRESULT_FILE = $(PREFIX)/share/cmake/modules/TryRunResults.cmake +build-only-$(1)_$(3): CMAKE_TOOLCHAIN_FILE = $(PREFIX)/$(3)/share/cmake/mxe-conf.cmake +build-only-$(1)_$(3): CMAKE_TOOLCHAIN_DIR = $(PREFIX)/$(3)/share/cmake/mxe-conf.d +build-only-$(1)_$(3): CMAKE_STATIC_BOOL = $(if $(findstring shared,$(3)),OFF,ON) +build-only-$(1)_$(3): CMAKE_SHARED_BOOL = $(if $(findstring shared,$(3)),ON,OFF) + + +toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin) +final_build_id_long+=$(shell $(build_SHA256SUM) toolchain.cmake.in) +final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)) +$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) + rm -rf $(@D) + mkdir -p $(@D) + echo copying packages: $^ + echo to: $(@D) + cd $(@D); $(foreach package,$^, $(build_TAR) xf $($(package)_cached); ) + touch $@ + +# $PATH is not preserved between ./configure and make by convention. Its +# modification and overriding at ./configure time is (as I understand it) +# supposed to be captured by the AC_{PROG_{,OBJ}CXX,PATH_{PROG,TOOL}} macros, +# which will expand the program names to their full absolute paths. The notable +# exception is command line overriding: ./configure CC=clang, which skips the +# program name expansion step, and works because the user implicitly indicates +# with CC=clang that clang will be available in $PATH at all times, and is most +# likely part of the user's system. +# +# Therefore, when we "seed the autoconf cache"/"override well-known program +# vars" by setting AR= in our config.site, either one of two things needs +# to be true for the build system to work correctly: +# +# 1. If we refer to the program by name (e.g. AR=riscv64-gnu-linux-ar), the +# tool needs to be available in $PATH at all times. +# +# 2. If the tool is _**not**_ expected to be available in $PATH at all times +# (such as is the case for our native_cctools binutils tools), it needs to +# be referred to by its absolute path, such as would be output by the +# AC_PATH_{PROG,TOOL} macros. +# +# Minor note: it is also okay to refer to tools by their absolute path even if +# we expect them to be available in $PATH at all times, more specificity does +# not hurt. +$(host_prefix)/share/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_$(final_build_id) + @mkdir -p $(@D) + sed -e 's|@HOST@|$(host)|' \ + -e 's|@CC@|$(host_CC)|' \ + -e 's|@CXX@|$(host_CXX)|' \ + -e 's|@AR@|$(toolchain_path)$(host_AR)|' \ + -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \ + -e 's|@NM@|$(toolchain_path)$(host_NM)|' \ + -e 's|@STRIP@|$(toolchain_path)$(host_STRIP)|' \ + -e 's|@CMAKE_INSTALL_NAME_TOOL@|$(host_INSTALL_NAME_TOOL)|' \ + -e 's|@OTOOL@|$(host_OTOOL)|' \ + -e 's|@build_os@|$(build_os)|' \ + -e 's|@host_os@|$(host_os)|' \ + -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \ + -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ + -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ + -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ + -e 's|@allow_host_packages@|$(ALLOW_HOST_PACKAGES)|' \ + -e 's|@debug@|$(DEBUG)|' \ + -e 's|@release_type@|$(release_type)|' \ + -e 's|@build_tests@|$(build_tests)|' \ + -e 's|@depends@|$(host_cmake)|' \ + -e 's|@prefix@|$($(host_arch)_$(host_os)_prefix)|'\ + -e 's|@arch@|$(host_arch)|'\ + -e 's|@guix_ldflags@|$(guix_ldflags)|'\ + -e 's|@tor_version@|$(tor_$(host_os)_version)|'\ + $< > $@ + touch $@ + +define check_or_remove_cached + mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \ + $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \ + ( rm -f $($(package)_cached_checksum); \ + if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi ) +endef + +define check_or_remove_sources + mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \ + test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \ + ( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \ + rm -f $($(package)_all_sources) $($(1)_fetched))) || true +endef + +check-packages: + @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));) +check-sources: + @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));) + +$(host_prefix)/share/config.site: check-packages +$(host_prefix)/share/toolchain.cmake: check-packages + +check-packages: check-sources + +clean-all: clean + @rm -rf $(SOURCES_PATH) x86_64* i686* mips* arm* aarch64* + +clean: + @rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) *.log + +install: check-packages $(host_prefix)/share/config.site +install: check-packages $(host_prefix)/share/toolchain.cmake + +download-one: check-sources $(all_sources) + +download-osx: + @$(MAKE) -s HOST=x86_64-apple-darwin download-one +download-linux: + @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one +download-win: + @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one +download: download-osx download-linux download-win + +$(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package)))) + +.PHONY: install cached clean clean-all download-one download-osx download-linux download-win download check-packages check-sources +.PHONY: FORCE +$(V).SILENT: diff --git a/contrib/depends/builders/darwin.mk b/contrib/depends/builders/darwin.mk new file mode 100644 index 0000000..8ed82b2 --- /dev/null +++ b/contrib/depends/builders/darwin.mk @@ -0,0 +1,30 @@ +build_darwin_CC:=$(shell xcrun -f clang) -isysroot$(shell xcrun --show-sdk-path) +build_darwin_CXX:=$(shell xcrun -f clang++) -isysroot$(shell xcrun --show-sdk-path) +build_darwin_AR:=$(shell xcrun -f ar) +build_darwin_RANLIB:=$(shell xcrun -f ranlib) +build_darwin_STRIP:=$(shell xcrun -f strip) +build_darwin_OTOOL:=$(shell xcrun -f otool) +build_darwin_NM:=$(shell xcrun -f nm) +build_darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool) +build_darwin_DSYMUTIL:=$(shell xcrun -f dsymutil) +build_darwin_SHA256SUM=shasum -a 256 +build_darwin_DOWNLOAD=curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o + +#darwin host on darwin builder. overrides darwin host preferences. +darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION) -isysroot$(shell xcrun --show-sdk-path) +darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++ -isysroot$(shell xcrun --show-sdk-path) +darwin_AR:=$(shell xcrun -f ar) +darwin_RANLIB:=$(shell xcrun -f ranlib) +darwin_STRIP:=$(shell xcrun -f strip) +darwin_LIBTOOL:=$(shell xcrun -f libtool) +darwin_OTOOL:=$(shell xcrun -f otool) +darwin_NM:=$(shell xcrun -f nm) +darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool) +darwin_DSYMUTIL:=$(shell xcrun -f dsymutil) +darwin_native_binutils= +darwin_native_toolchain= + +x86_64_darwin_CFLAGS += -arch x86_64 +x86_64_darwin_CXXFLAGS += -arch x86_64 +aarch64_darwin_CFLAGS += -arch arm64 +aarch64_darwin_CXXFLAGS += -arch arm64 diff --git a/contrib/depends/builders/default.mk b/contrib/depends/builders/default.mk new file mode 100644 index 0000000..a8b6b97 --- /dev/null +++ b/contrib/depends/builders/default.mk @@ -0,0 +1,21 @@ +default_build_CC = gcc +default_build_CXX = g++ +default_build_AR = ar +default_build_TAR = tar +default_build_RANLIB = ranlib +default_build_STRIP = strip +default_build_NM = nm +default_build_OTOOL = otool +default_build_INSTALL_NAME_TOOL = install_name_tool + +define add_build_tool_func +build_$(build_os)_$1 ?= $$(default_build_$1) +build_$(build_arch)_$(build_os)_$1 ?= $$(build_$(build_os)_$1) +build_$1=$$(build_$(build_arch)_$(build_os)_$1) +endef +$(foreach var,CC CXX AR TAR RANLIB NM STRIP SHA256SUM DOWNLOAD OTOOL INSTALL_NAME_TOOL DSYMUTIL,$(eval $(call add_build_tool_func,$(var)))) +define add_build_flags_func +build_$(build_arch)_$(build_os)_$1 += $(build_$(build_os)_$1) +build_$1=$$(build_$(build_arch)_$(build_os)_$1) +endef +$(foreach flags, CFLAGS CXXFLAGS ARFLAGS LDFLAGS, $(eval $(call add_build_flags_func,$(flags)))) diff --git a/contrib/depends/builders/linux.mk b/contrib/depends/builders/linux.mk new file mode 100644 index 0000000..b03f424 --- /dev/null +++ b/contrib/depends/builders/linux.mk @@ -0,0 +1,2 @@ +build_linux_SHA256SUM = sha256sum +build_linux_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o diff --git a/contrib/depends/config.guess b/contrib/depends/config.guess new file mode 100755 index 0000000..f50dcdb --- /dev/null +++ b/contrib/depends/config.guess @@ -0,0 +1,1480 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2018 Free Software Foundation, Inc. + +timestamp='2018-02-24' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2018 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > "$dummy.c" ; + for c in cc gcc c89 c99 ; do + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "$UNAME_SYSTEM" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval "$set_cc_for_build" + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "$UNAME_VERSION" in + Debian*) + release='-gnu' + ;; + *) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "$machine-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" + exit ;; + *:ekkoBSD:*:*) + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" + exit ;; + *:SolidBSD:*:*) + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:MirBSD:*:*) + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo "$UNAME_MACHINE"-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo "$UNAME_MACHINE"-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix"$UNAME_RELEASE" + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux"$UNAME_RELEASE" + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval "$set_cc_for_build" + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos"$UNAME_RELEASE" + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos"$UNAME_RELEASE" + ;; + sun4) + echo sparc-sun-sunos"$UNAME_RELEASE" + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos"$UNAME_RELEASE" + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint"$UNAME_RELEASE" + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint"$UNAME_RELEASE" + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint"$UNAME_RELEASE" + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten"$UNAME_RELEASE" + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten"$UNAME_RELEASE" + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix"$UNAME_RELEASE" + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix"$UNAME_RELEASE" + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix"$UNAME_RELEASE" + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos"$UNAME_RELEASE" + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + then + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] + then + echo m88k-dg-dgux"$UNAME_RELEASE" + else + echo m88k-dg-dguxbcs"$UNAME_RELEASE" + fi + else + echo i586-dg-dgux"$UNAME_RELEASE" + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + fi + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + fi + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ "$HP_ARCH" = hppa2.0w ] + then + eval "$set_cc_for_build" + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" + exit ;; + 3050*:HI-UX:*:*) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo "$UNAME_MACHINE"-unknown-osf1mk + else + echo "$UNAME_MACHINE"-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi"$UNAME_RELEASE" + exit ;; + *:BSD/OS:*:*) + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case "$UNAME_PROCESSOR" in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; + i*:CYGWIN*:*) + echo "$UNAME_MACHINE"-pc-cygwin + exit ;; + *:MINGW64*:*) + echo "$UNAME_MACHINE"-pc-mingw64 + exit ;; + *:MINGW*:*) + echo "$UNAME_MACHINE"-pc-mingw32 + exit ;; + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys + exit ;; + i*:PW*:*) + echo "$UNAME_MACHINE"-pc-pw32 + exit ;; + *:Interix*:*) + case "$UNAME_MACHINE" in + x86) + echo i586-pc-interix"$UNAME_RELEASE" + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix"$UNAME_RELEASE" + exit ;; + IA64) + echo ia64-unknown-interix"$UNAME_RELEASE" + exit ;; + esac ;; + i*:UWIN*:*) + echo "$UNAME_MACHINE"-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" + exit ;; + *:GNU:*:*) + # the GNU system + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" + exit ;; + i*86:Minix:*:*) + echo "$UNAME_MACHINE"-pc-minix + exit ;; + aarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arm*:Linux:*:*) + eval "$set_cc_for_build" + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + else + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + cris:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + crisv32:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + frv:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + hexagon:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; + ia64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m32r*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m68*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } + ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-"$LIBC" + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-"$LIBC" + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-"$LIBC" + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-"$LIBC" + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-"$LIBC" + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-"$LIBC" + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" + exit ;; + sh64*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + sh*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + tile*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + vax:Linux:*:*) + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" + exit ;; + x86_64:Linux:*:*) + if objdump -f /bin/sh | grep -q elf32-x86-64; then + echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 + else + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + fi + exit ;; + xtensa*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo "$UNAME_MACHINE"-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo "$UNAME_MACHINE"-unknown-stop + exit ;; + i*86:atheos:*:*) + echo "$UNAME_MACHINE"-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo "$UNAME_MACHINE"-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos"$UNAME_RELEASE" + exit ;; + i*86:*DOS:*:*) + echo "$UNAME_MACHINE"-pc-msdosdjgpp + exit ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + else + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + else + echo "$UNAME_MACHINE"-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos"$UNAME_RELEASE" + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos"$UNAME_RELEASE" + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos"$UNAME_RELEASE" + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos"$UNAME_RELEASE" + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv"$UNAME_RELEASE" + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo "$UNAME_MACHINE"-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo "$UNAME_MACHINE"-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux"$UNAME_RELEASE" + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv"$UNAME_RELEASE" + else + echo mips-unknown-sysv"$UNAME_RELEASE" + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux"$UNAME_RELEASE" + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux"$UNAME_RELEASE" + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux"$UNAME_RELEASE" + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux"$UNAME_RELEASE" + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody"$UNAME_RELEASE" + exit ;; + *:Rhapsody:*:*) + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval "$set_cc_for_build" + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = 386; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo "$UNAME_MACHINE"-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux"$UNAME_RELEASE" + exit ;; + *:DragonFly:*:*) + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "$UNAME_MACHINE" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" + exit ;; + i*86:rdos:*:*) + echo "$UNAME_MACHINE"-pc-rdos + exit ;; + i*86:AROS:*:*) + echo "$UNAME_MACHINE"-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; +esac + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-functions 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/contrib/depends/config.sub b/contrib/depends/config.sub new file mode 100755 index 0000000..1d8e98b --- /dev/null +++ b/contrib/depends/config.sub @@ -0,0 +1,1801 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2018 Free Software Foundation, Inc. + +timestamp='2018-02-22' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2018 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo "$1" + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo "$1" | sed 's/-[^-]*$//'` + if [ "$basic_machine" != "$1" ] + then os=`echo "$1" | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-pc + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2*) + basic_machine=m68k-bull + os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=-linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + x64) + basic_machine=x86_64-pc + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases that might get confused + # with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # es1800 is here to avoid being matched by es* (a different OS) + -es1800*) + os=-ose + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ + | -midnightbsd*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -xray | -os68k* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4*) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=-eabi + ;; + *) + os=-elf + ;; + esac + ;; + -nacl*) + ;; + -ios) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + pru-*) + os=-elf + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` + ;; +esac + +echo "$basic_machine$os" +exit + +# Local variables: +# eval: (add-hook 'write-file-functions 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/contrib/depends/funcs.mk b/contrib/depends/funcs.mk new file mode 100644 index 0000000..15bbf1a --- /dev/null +++ b/contrib/depends/funcs.mk @@ -0,0 +1,303 @@ +define int_vars +#Set defaults for vars which may be overridden per-package +$(1)_cc=$$($$($(1)_type)_CC) +$(1)_cxx=$$($$($(1)_type)_CXX) +$(1)_objc=$$($$($(1)_type)_OBJC) +$(1)_objcxx=$$($$($(1)_type)_OBJCXX) +$(1)_ar=$$($$($(1)_type)_AR) +$(1)_ranlib=$$($$($(1)_type)_RANLIB) +$(1)_libtool=$$($$($(1)_type)_LIBTOOL) +$(1)_nm=$$($$($(1)_type)_NM) +$(1)_cflags=$$($$($(1)_type)_CFLAGS) \ + $$($$($(1)_type)_$$(release_type)_CFLAGS) +$(1)_cxxflags=$$($$($(1)_type)_CXXFLAGS) \ + $$($$($(1)_type)_$$(release_type)_CXXFLAGS) +$(1)_arflags=$($($(1)_type)_ARFLAGS) $($($(1)_type)_$(release_type)_ARFLAGS) +$(1)_ldflags=$$($$($(1)_type)_LDFLAGS) \ + $$($$($(1)_type)_$$(release_type)_LDFLAGS) \ + -L$$($($(1)_type)_prefix)/lib +$(1)_cppflags=$$($$($(1)_type)_CPPFLAGS) \ + $$($$($(1)_type)_$$(release_type)_CPPFLAGS) \ + -I$$($$($(1)_type)_prefix)/include +$(1)_recipe_hash:= +endef + +define int_get_all_dependencies +$(sort $(foreach dep,$(2),$(2) $(call int_get_all_dependencies,$(1),$($(dep)_dependencies)))) +endef + +define fetch_file_inner + ( mkdir -p $$($(1)_download_dir) && echo Fetching $(3) from $(2) && \ + $(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(2)/$(3)" && \ + echo "$(5) $$($(1)_download_dir)/$(4).temp" > $$($(1)_download_dir)/.$(4).hash && \ + $(build_SHA256SUM) -c $$($(1)_download_dir)/.$(4).hash && \ + mv $$($(1)_download_dir)/$(4).temp $$($(1)_source_dir)/$(4) && \ + rm -rf $$($(1)_download_dir) ) +endef + +define fetch_file + ( test -f $$($(1)_source_dir)/$(4) || \ + ( $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5)) || \ + $(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5)))) +endef + +define int_get_build_recipe_hash +$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) | cut -d" " -f1)) +$(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1)) +endef + +define int_get_build_id +$(eval $(1)_dependencies += $($(1)_$(host_arch)_$(host_os)_dependencies) $($(1)_$(host_os)_dependencies)) +$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($($(1)_type)_native_toolchain) $($($(1)_type)_native_binutils) $($(1)_dependencies))) +$(foreach dep,$($(1)_all_dependencies),$(eval $(1)_build_id_deps+=$(dep)-$($(dep)_version)-$($(dep)_recipe_hash))) +$(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps) $($($(1)_type)_id)) +$(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))) +final_build_id_long+=$($(package)_build_id_long) + +#compute package-specific paths +$(1)_build_subdir?=. +$(1)_download_file?=$($(1)_file_name) +$(1)_source_dir:=$(SOURCES_PATH) +$(1)_source:=$$($(1)_source_dir)/$($(1)_file_name) +$(1)_staging_dir=$(base_staging_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id) +$(1)_staging_prefix_dir:=$$($(1)_staging_dir)$($($(1)_type)_prefix) +$(1)_extract_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id) +$(1)_download_dir:=$(base_download_dir)/$(1)-$($(1)_version) +$(1)_build_dir:=$$($(1)_extract_dir)/$$($(1)_build_subdir) +$(1)_cached_checksum:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz.hash +$(1)_patch_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)/.patches-$($(1)_build_id) +$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/ +$(1)_cached:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz +$(1)_build_log:=$(BASEDIR)/$(1)-$($(1)_version)-$($(1)_build_id).log +$(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources) + +#stamps +$(1)_fetched=$(SOURCES_PATH)/download-stamps/.stamp_fetched-$(1)-$($(1)_file_name).hash +$(1)_extracted=$$($(1)_extract_dir)/.stamp_extracted +$(1)_preprocessed=$$($(1)_extract_dir)/.stamp_preprocessed +$(1)_cleaned=$$($(1)_extract_dir)/.stamp_cleaned +$(1)_built=$$($(1)_build_dir)/.stamp_built +$(1)_configured=$$($(1)_build_dir)/.stamp_configured +$(1)_staged=$$($(1)_staging_dir)/.stamp_staged +$(1)_postprocessed=$$($(1)_staging_prefix_dir)/.stamp_postprocessed +$(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) + + +#default commands +# The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior +$(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) --no-same-owner --strip-components=1 -xf $$($(1)_source) +$(1)_preprocess_cmds ?= true +$(1)_build_cmds ?= +$(1)_config_cmds ?= +$(1)_stage_cmds ?= +$(1)_set_vars ?= + + +all_sources+=$$($(1)_fetched) +endef +#$(foreach dep_target,$($(1)_all_dependencies),$(eval $(1)_dependency_targets=$($(dep_target)_cached))) + + +define int_config_attach_build_config +$(eval $(call $(1)_set_vars,$(1))) +$(1)_cflags+=$($(1)_cflags_$(release_type)) +$(1)_cflags+=$($(1)_cflags_$(host_arch)) $($(1)_cflags_$(host_arch)_$(release_type)) +$(1)_cflags+=$($(1)_cflags_$(host_os)) $($(1)_cflags_$(host_os)_$(release_type)) +$(1)_cflags+=$($(1)_cflags_$(host_arch)_$(host_os)) $($(1)_cflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_cxxflags+=$($(1)_cxxflags_$(release_type)) +$(1)_cxxflags+=$($(1)_cxxflags_$(host_arch)) $($(1)_cxxflags_$(host_arch)_$(release_type)) +$(1)_cxxflags+=$($(1)_cxxflags_$(host_os)) $($(1)_cxxflags_$(host_os)_$(release_type)) +$(1)_cxxflags+=$($(1)_cxxflags_$(host_arch)_$(host_os)) $($(1)_cxxflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_arflags+=$($(1)_arflags_$(release_type)) +$(1)_arflags+=$($(1)_arflags_$(host_arch)) $($(1)_arflags_$(host_arch)_$(release_type)) +$(1)_arflags+=$($(1)_arflags_$(host_os)) $($(1)_arflags_$(host_os)_$(release_type)) +$(1)_arflags+=$($(1)_arflags_$(host_arch)_$(host_os)) $($(1)_arflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_cppflags+=$($(1)_cppflags_$(release_type)) +$(1)_cppflags+=$($(1)_cppflags_$(host_arch)) $($(1)_cppflags_$(host_arch)_$(release_type)) +$(1)_cppflags+=$($(1)_cppflags_$(host_os)) $($(1)_cppflags_$(host_os)_$(release_type)) +$(1)_cppflags+=$($(1)_cppflags_$(host_arch)_$(host_os)) $($(1)_cppflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_ldflags+=$($(1)_ldflags_$(release_type)) +$(1)_ldflags+=$($(1)_ldflags_$(host_arch)) $($(1)_ldflags_$(host_arch)_$(release_type)) +$(1)_ldflags+=$($(1)_ldflags_$(host_os)) $($(1)_ldflags_$(host_os)_$(release_type)) +$(1)_ldflags+=$($(1)_ldflags_$(host_arch)_$(host_os)) $($(1)_ldflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_build_opts+=$$($(1)_build_opts_$(release_type)) +$(1)_build_opts+=$$($(1)_build_opts_$(host_arch)) $$($(1)_build_opts_$(host_arch)_$(release_type)) +$(1)_build_opts+=$$($(1)_build_opts_$(host_os)) $$($(1)_build_opts_$(host_os)_$(release_type)) +$(1)_build_opts+=$$($(1)_build_opts_$(host_arch)_$(host_os)) $$($(1)_build_opts_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_config_opts+=$$($(1)_config_opts_$(release_type)) +$(1)_config_opts+=$$($(1)_config_opts_$(host_arch)) $$($(1)_config_opts_$(host_arch)_$(release_type)) +$(1)_config_opts+=$$($(1)_config_opts_$(host_os)) $$($(1)_config_opts_$(host_os)_$(release_type)) +$(1)_config_opts+=$$($(1)_config_opts_$(host_arch)_$(host_os)) $$($(1)_config_opts_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_config_env+=$$($(1)_config_env_$(release_type)) +$(1)_config_env+=$($(1)_config_env_$(host_arch)) $($(1)_config_env_$(host_arch)_$(release_type)) +$(1)_config_env+=$($(1)_config_env_$(host_os)) $($(1)_config_env_$(host_os)_$(release_type)) +$(1)_config_env+=$($(1)_config_env_$(host_arch)_$(host_os)) $($(1)_config_env_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_build_env+=$$($(1)_build_env_$(release_type)) +$(1)_build_env+=$($(1)_build_env_$(host_arch)) $($(1)_build_env_$(host_arch)_$(release_type)) +$(1)_build_env+=$($(1)_build_env_$(host_os)) $($(1)_build_env_$(host_os)_$(release_type)) +$(1)_build_env+=$($(1)_build_env_$(host_arch)_$(host_os)) $($(1)_build_env_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_config_env+=PKG_CONFIG_LIBDIR=$($($(1)_type)_prefix)/lib/pkgconfig +$(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig +$(1)_config_env+=CMAKE_MODULE_PATH=$($($(1)_type)_prefix)/lib/cmake +$(1)_config_env+=PATH=$(build_prefix)/bin:$(PATH) +$(1)_build_env+=PATH=$(build_prefix)/bin:$(PATH) +$(1)_stage_env+=PATH=$(build_prefix)/bin:$(PATH) + +# Setting a --build type that differs from --host will explicitly enable +# cross-compilation mode. Note that --build defaults to the output of +# config.guess, which is what we set it too here. This also quells autoconf +# warnings, "If you wanted to set the --build type, don't use --host.", +# when using versions older than 2.70. +$(1)_autoconf=./configure --build=$(BUILD) --host=$($($(1)_type)_host) --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)" +ifneq ($($(1)_nm),) +$(1)_autoconf += NM="$$($(1)_nm)" +endif +ifneq ($($(1)_ranlib),) +$(1)_autoconf += RANLIB="$$($(1)_ranlib)" +endif +ifneq ($($(1)_ar),) +$(1)_autoconf += AR="$$($(1)_ar)" +endif +ifneq ($($(1)_arflags),) +$(1)_autoconf += ARFLAGS="$$($(1)_arflags)" +endif +ifneq ($($(1)_cflags),) +$(1)_autoconf += CFLAGS="$$($(1)_cflags)" +endif +ifneq ($($(1)_cxxflags),) +$(1)_autoconf += CXXFLAGS="$$($(1)_cxxflags)" +endif +ifneq ($($(1)_cppflags),) +$(1)_autoconf += CPPFLAGS="$$($(1)_cppflags)" +endif +ifneq ($($(1)_ldflags),) +$(1)_autoconf += LDFLAGS="$$($(1)_ldflags)" +endif + +$(1)_cmake=env CC="$$($(1)_cc)" \ + CFLAGS="$$($(1)_cppflags) $$($(1)_cflags)" \ + CXX="$$($(1)_cxx)" \ + CXXFLAGS="$$($(1)_cppflags) $$($(1)_cxxflags)" \ + LDFLAGS="$$($(1)_ldflags)" \ + cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" $$($(1)_cmake_opts) +ifeq ($($(1)_type),build) +$(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib" +else +ifneq ($(host),$(build)) +$(1)_cmake += -DCMAKE_SYSTEM_NAME=$($(host_os)_cmake_system) +$(1)_cmake += -DCMAKE_C_COMPILER_TARGET=$(host) +$(1)_cmake += -DCMAKE_CXX_COMPILER_TARGET=$(host) +endif +endif +endef + +define int_add_cmds +ifneq ($(LOG),) +$(1)_logging = >>$$($(1)_build_log) 2>&1 || { if test -f $$($(1)_build_log); then cat $$($(1)_build_log); fi; exit 1; } +endif + +$($(1)_fetched): + mkdir -p $$(@D) $(SOURCES_PATH) + rm -f $$@ + touch $$@ + cd $$(@D); $($(1)_fetch_cmds) + cd $($(1)_source_dir); $(foreach source,$($(1)_all_sources),$(build_SHA256SUM) $(source) >> $$(@);) + touch $$@ +$($(1)_extracted): | $($(1)_fetched) + echo Extracting $(1)... + mkdir -p $$(@D) + cd $$(@D); $($(1)_extract_cmds) + touch $$@ +$($(1)_preprocessed): | $($(1)_extracted) + echo Preprocessing $(1)... + mkdir -p $$(@D) $($(1)_patch_dir) + $(foreach patch,$($(1)_patches),cd $(PATCHES_PATH)/$(1); cp $(patch) $($(1)_patch_dir) ;) + cd $$(@D); $(call $(1)_preprocess_cmds, $(1)) + touch $$@ +$($(1)_configured): | $($(1)_dependencies) $($(1)_preprocessed) + echo Configuring $(1)... + rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), $(build_TAR) --no-same-owner -xf $($(package)_cached); ) + mkdir -p $$(@D) + $(AT)+cd $$(@D); export $($(1)_config_env); $(call $(1)_config_cmds, $(1)) + touch $$@ +$($(1)_built): | $($(1)_configured) + echo Building $(1)... + mkdir -p $$(@D) + $(AT)+cd $$(@D); export $($(1)_build_env); $(call $(1)_build_cmds, $(1)) + touch $$@ +$($(1)_staged): | $($(1)_built) + echo Staging $(1)... + mkdir -p $($(1)_staging_dir)/$(host_prefix) + $(AT)cd $($(1)_build_dir); export $($(1)_stage_env); $(call $(1)_stage_cmds, $(1)) + rm -rf $($(1)_extract_dir) + touch $$@ +$($(1)_postprocessed): | $($(1)_staged) + echo Postprocessing $(1)... + cd $($(1)_staging_prefix_dir); $($(1)_postprocess_cmds) + touch $$@ +$($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed) + echo Caching $(1)... + cd $$($(1)_staging_dir)/$(host_prefix); find . | sort | $(build_TAR) --no-recursion -czf $$($(1)_staging_dir)/$$(@F) -T - + mkdir -p $$(@D) + rm -rf $$(@D) && mkdir -p $$(@D) + mv $$($(1)_staging_dir)/$$(@F) $$(@) + rm -rf $($(1)_staging_dir) + if test -f $($(1)_build_log); then mv $($(1)_build_log) $$(@D); fi +$($(1)_cached_checksum): $($(1)_cached) + cd $$(@D); $(build_SHA256SUM) $$( $$(@) + +.PHONY: $(1) +$(1): | $($(1)_cached_checksum) +.SECONDARY: $($(1)_cached) $($(1)_postprocessed) $($(1)_staged) $($(1)_built) $($(1)_configured) $($(1)_preprocessed) $($(1)_extracted) $($(1)_fetched) + +endef + +stages = fetched extracted preprocessed configured built staged postprocessed cached cached_checksum + +define ext_add_stages +$(foreach stage,$(stages), + $(1)_$(stage): $($(1)_$(stage)) + .PHONY: $(1)_$(stage)) +endef + +# These functions create the build targets for each package. They must be +# broken down into small steps so that each part is done for all packages +# before moving on to the next step. Otherwise, a package's info +# (build-id for example) would only be available to another package if it +# happened to be computed already. + +#set the type for host/build packages. +$(foreach native_package,$(native_packages),$(eval $(native_package)_type=build)) +$(foreach package,$(packages),$(eval $(package)_type=$(host_arch)_$(host_os))) + +#set overridable defaults +$(foreach package,$(all_packages),$(eval $(call int_vars,$(package)))) + +#include package files +$(foreach native_package,$(native_packages),$(eval include packages/$(native_package).mk)) +$(foreach package,$(packages),$(eval include packages/$(package).mk)) + +#compute a hash of all files that comprise this package's build recipe +$(foreach package,$(all_packages),$(eval $(call int_get_build_recipe_hash,$(package)))) + +#generate a unique id for this package, incorporating its dependencies as well +$(foreach package,$(all_packages),$(eval $(call int_get_build_id,$(package)))) + +#compute final vars after reading package vars +$(foreach package,$(all_packages),$(eval $(call int_config_attach_build_config,$(package)))) + +#create build targets +$(foreach package,$(all_packages),$(eval $(call int_add_cmds,$(package)))) + +#special exception: if a toolchain package exists, all non-native packages depend on it +$(foreach package,$(packages),$(eval $($(package)_extracted): |$($($(host_arch)_$(host_os)_native_toolchain)_cached) $($($(host_arch)_$(host_os)_native_binutils)_cached) )) diff --git a/contrib/depends/gen_id b/contrib/depends/gen_id new file mode 100755 index 0000000..6ecbcd9 --- /dev/null +++ b/contrib/depends/gen_id @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +# Usage: env [ CC=... ] [ C_STANDARD=...] [ CXX=... ] [CXX_STANDARD=...] \ +# [ AR=... ] [ RANLIB=... ] [ STRIP=... ] [ DEBUG=... ] \ +# [ LTO=... ] ./build-id [ID_SALT]... +# +# Prints to stdout a SHA256 hash representing the current toolset, used by +# depends/Makefile as a build id for caching purposes (detecting when the +# toolset has changed and the cache needs to be invalidated). +# +# If the DEBUG environment variable is non-empty and the system has `tee` +# available in its $PATH, the pre-image to the SHA256 hash will be printed to +# stderr. This is to help developers debug caching issues in depends. + +# This script explicitly does not `set -e` because id determination is mostly +# opportunistic: it is fine that things fail, as long as they fail consistently. + +# Command variables (CC/CXX/AR) which can be blank are invoked with `bash -c`, +# because the "command not found" error message printed by shells often include +# the line number, like so: +# +# ./depends/gen_id: line 43: --version: command not found +# +# By invoking with `bash -c`, we ensure that the line number is always 1 + +( + # Redirect stderr to stdout + exec 2>&1 + + echo "BEGIN ALL" + + # Include any ID salts supplied via command line + echo "BEGIN ID SALT" + echo "$@" + echo "END ID SALT" + + # GCC only prints COLLECT_LTO_WRAPPER when invoked with just "-v", but we want + # the information from "-v -E -" as well, so just include both. + echo "BEGIN CC" + bash -c "${CC} -v" + bash -c "${CC} -v -E -xc -o /dev/null - < /dev/null" + bash -c "${CC} -v -E -xobjective-c -o /dev/null - < /dev/null" + echo "C_STANDARD=${C_STANDARD}" + echo "END CC" + + echo "BEGIN CXX" + bash -c "${CXX} -v" + bash -c "${CXX} -v -E -xc++ -o /dev/null - < /dev/null" + bash -c "${CXX} -v -E -xobjective-c++ -o /dev/null - < /dev/null" + echo "CXX_STANDARD=${CXX_STANDARD}" + echo "END CXX" + + echo "BEGIN AR" + bash -c "${AR} --version" + env | grep '^AR_' + echo "ZERO_AR_DATE=${ZERO_AR_DATE}" + echo "END AR" + + echo "BEGIN RANLIB" + bash -c "${RANLIB} --version" + env | grep '^RANLIB_' + echo "END RANLIB" + + echo "BEGIN STRIP" + bash -c "${STRIP} --version" + env | grep '^STRIP_' + echo "END STRIP" + + echo "END ALL" +) | if [ -n "$DEBUG" ] && command -v tee > /dev/null 2>&1; then + # When debugging and `tee` is available, output the preimage to stderr + # in addition to passing through stdin to stdout + tee >(cat 1>&2) + else + # Otherwise, passthrough stdin to stdout + cat + fi | ${SHA256SUM} - | cut -d' ' -f1 diff --git a/contrib/depends/hosts/darwin.mk b/contrib/depends/hosts/darwin.mk new file mode 100644 index 0000000..9415abc --- /dev/null +++ b/contrib/depends/hosts/darwin.mk @@ -0,0 +1,122 @@ +OSX_MIN_VERSION=10.15 +OSX_SDK_VERSION=11.0 +XCODE_VERSION=12.2 +XCODE_BUILD_ID=12B45b +LD64_VERSION=609 + +OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers + +darwin_native_binutils=native_cctools + +ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),) +# FORCE_USE_SYSTEM_CLANG is empty, so we use our depends-managed, pinned clang +# from llvm.org + +# Clang is a dependency of native_cctools when FORCE_USE_SYSTEM_CLANG is empty +darwin_native_toolchain=native_cctools + +clang_prog=$(build_prefix)/bin/clang +clangxx_prog=$(clang_prog)++ + +clang_resource_dir=$(build_prefix)/lib/clang/$(native_clang_version) +else +# FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's +# system + +darwin_native_toolchain= + +# We can't just use $(shell command -v clang) because GNU Make handles builtins +# in a special way and doesn't know that `command` is a POSIX-standard builtin +# prior to 1af314465e5dfe3e8baa839a32a72e83c04f26ef, first released in v4.2.90. +# At the time of writing, GNU Make v4.2.1 is still being used in supported +# distro releases. +# +# Source: https://lists.gnu.org/archive/html/bug-make/2017-11/msg00017.html +clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang") +clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++") + +clang_resource_dir=$(shell clang -print-resource-dir) +endif + +cctools_TOOLS=AR RANLIB STRIP NM LIBTOOL OTOOL INSTALL_NAME_TOOL DSYMUTIL + +# Make-only lowercase function +lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) + +# For well-known tools provided by cctools, make sure that their well-known +# variable is set to the full path of the tool, just like how AC_PATH_{TOO,PROG} +# would. +$(foreach TOOL,$(cctools_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/$$(host)-$(call lc,$(TOOL)))) + +# Flag explanations: +# +# -mlinker-version +# +# Ensures that modern linker features are enabled. See here for more +# details: https://github.com/bitcoin/bitcoin/pull/19407. +# +# -B$(build_prefix)/bin +# +# Explicitly point to our binaries (e.g. cctools) so that they are +# ensured to be found and preferred over other possibilities. +# +# -stdlib=libc++ -stdlib++-isystem$(OSX_SDK)/usr/include/c++/v1 +# +# Forces clang to use the libc++ headers from our SDK and completely +# forget about the libc++ headers from the standard directories +# +# -Xclang -*system \ +# -Xclang -*system \ +# -Xclang -*system ... +# +# Adds path_a, path_b, and path_c to the bottom of clang's list of +# include search paths. This is used to explicitly specify the list of +# system include search paths and its ordering, rather than rely on +# clang's autodetection routine. This routine has been shown to: +# 1. Fail to pickup libc++ headers in $SYSROOT/usr/include/c++/v1 +# when clang was built manually (see: https://github.com/bitcoin/bitcoin/pull/17919#issuecomment-656785034) +# 2. Fail to pickup C headers in $SYSROOT/usr/include when +# C_INCLUDE_DIRS was specified at configure time (see: https://gist.github.com/dongcarl/5cdc6990b7599e8a5bf6d2a9c70e82f9) +# +# Talking directly to cc1 with -Xclang here grants us access to specify +# more granular categories for these system include search paths, and we +# can use the correct categories that these search paths would have been +# placed in if the autodetection routine had worked correctly. (see: +# https://gist.github.com/dongcarl/5cdc6990b7599e8a5bf6d2a9c70e82f9#the-treatment) +# +# Furthermore, it places these search paths after any "non-Xclang" +# specified search paths. This prevents any additional clang options or +# environment variables from coming after or in between these system +# include search paths, as that would be wrong in general but would also +# break #include_next's. +# +darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \ + -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \ + -u LIBRARY_PATH \ + $(clang_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \ + -B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \ + -isysroot$(OSX_SDK) \ + -Xclang -internal-externc-isystem$(clang_resource_dir)/include \ + -Xclang -internal-externc-isystem$(OSX_SDK)/usr/include +darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \ + -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \ + -u LIBRARY_PATH \ + $(clangxx_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \ + -B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \ + -isysroot$(OSX_SDK) \ + -stdlib=libc++ \ + -stdlib++-isystem$(OSX_SDK)/usr/include/c++/v1 \ + -Xclang -internal-externc-isystem$(clang_resource_dir)/include \ + -Xclang -internal-externc-isystem$(OSX_SDK)/usr/include + +darwin_CFLAGS=-pipe +darwin_CXXFLAGS=$(darwin_CFLAGS) +darwin_ARFLAGS=cr + +darwin_release_CFLAGS=-O2 +darwin_release_CXXFLAGS=$(darwin_release_CFLAGS) + +darwin_debug_CFLAGS=-O1 +darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS) + +darwin_cmake_system=Darwin diff --git a/contrib/depends/hosts/default.mk b/contrib/depends/hosts/default.mk new file mode 100644 index 0000000..caed1cb --- /dev/null +++ b/contrib/depends/hosts/default.mk @@ -0,0 +1,40 @@ +ifneq ($(host),$(build)) +host_toolchain:=$(host)- +endif + +default_host_CC = $(host_toolchain)gcc +default_host_CXX = $(host_toolchain)g++ +default_host_AR = $(host_toolchain)ar +default_host_RANLIB = $(host_toolchain)ranlib +default_host_STRIP = $(host_toolchain)strip +default_host_LIBTOOL = $(host_toolchain)libtool +default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool +default_host_OTOOL = $(host_toolchain)otool +default_host_NM = $(host_toolchain)nm +default_host_OBJCOPY = $(host_toolchain)objcopy + +define add_host_tool_func +ifneq ($(filter $(origin $1),undefined default),) +# Do not consider the well-known var $1 if it is undefined or is taking a value +# that is predefined by "make" (e.g. the make variable "CC" has a predefined +# value of "cc") +$(host_os)_$1?=$$(default_host_$1) +$(host_arch)_$(host_os)_$1?=$$($(host_os)_$1) +$(host_arch)_$(host_os)_$(release_type)_$1?=$$($(host_os)_$1) +else +$(host_os)_$1=$(or $($1),$($(host_os)_$1),$(default_host_$1)) +$(host_arch)_$(host_os)_$1=$(or $($1),$($(host_arch)_$(host_os)_$1),$$($(host_os)_$1)) +$(host_arch)_$(host_os)_$(release_type)_$1=$(or $($1),$($(host_arch)_$(host_os)_$(release_type)_$1),$$($(host_os)_$1)) +endif +host_$1=$$($(host_arch)_$(host_os)_$1) +endef + +define add_host_flags_func +$(host_arch)_$(host_os)_$1 += $($(host_os)_$1) +$(host_arch)_$(host_os)_$(release_type)_$1 += $($(host_os)_$(release_type)_$1) +host_$1 = $$($(host_arch)_$(host_os)_$1) +host_$(release_type)_$1 = $$($(host_arch)_$(host_os)_$(release_type)_$1) +endef + +$(foreach tool,CC CXX AR RANLIB STRIP LIBTOOL NM OBJCOPY OTOOL INSTALL_NAME_TOOL DSYMUTIL,$(eval $(call add_host_tool_func,$(tool)))) +$(foreach flags,CFLAGS CXXFLAGS ARFLAGS CPPFLAGS LDFLAGS, $(eval $(call add_host_flags_func,$(flags)))) diff --git a/contrib/depends/hosts/linux.mk b/contrib/depends/hosts/linux.mk new file mode 100644 index 0000000..a373325 --- /dev/null +++ b/contrib/depends/hosts/linux.mk @@ -0,0 +1,33 @@ +linux_CFLAGS=-pipe +linux_CXXFLAGS=$(linux_CFLAGS) +linux_ARFLAGS=cr + +linux_release_CFLAGS=-O2 +linux_release_CXXFLAGS=$(linux_release_CFLAGS) + +linux_debug_CFLAGS=-O1 +linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) + +linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_LIBCPP_DEBUG=1 + +ifeq (86,$(findstring 86,$(build_arch))) +i686_linux_CC=gcc -m32 +i686_linux_CXX=g++ -m32 +i686_linux_AR=ar +i686_linux_RANLIB=ranlib +i686_linux_NM=nm +i686_linux_STRIP=strip + +x86_64_linux_CC=gcc -m64 +x86_64_linux_CXX=g++ -m64 +x86_64_linux_AR=ar +x86_64_linux_RANLIB=ranlib +x86_64_linux_NM=nm +x86_64_linux_STRIP=strip +else +i686_linux_CC=$(default_host_CC) -m32 +i686_linux_CXX=$(default_host_CXX) -m32 +x86_64_linux_CC=$(default_host_CC) -m64 +x86_64_linux_CXX=$(default_host_CXX) -m64 +endif +linux_cmake_system=Linux diff --git a/contrib/depends/hosts/mingw32.mk b/contrib/depends/hosts/mingw32.mk new file mode 100644 index 0000000..1985f38 --- /dev/null +++ b/contrib/depends/hosts/mingw32.mk @@ -0,0 +1,17 @@ +ifneq ($(shell $(SHELL) $(.SHELLFLAGS) "command -v $(host)-g++-posix"),) +mingw32_CXX := $(host)-g++-posix +endif + +mingw32_CFLAGS=-pipe +mingw32_CXXFLAGS=$(mingw32_CFLAGS) +mingw32_ARFLAGS=cr + +mingw32_release_CFLAGS=-O2 +mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS) + +mingw32_debug_CFLAGS=-O1 +mingw32_debug_CXXFLAGS=$(mingw32_debug_CFLAGS) + +mingw32_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC + +mingw32_cmake_system=Windows \ No newline at end of file diff --git a/contrib/depends/packages/appimage_runtime.mk b/contrib/depends/packages/appimage_runtime.mk new file mode 100644 index 0000000..3f49889 --- /dev/null +++ b/contrib/depends/packages/appimage_runtime.mk @@ -0,0 +1,24 @@ +# TODO: we're not actually using the sources downloaded here. Perhaps host patches in a github repo. +package=appimage_runtime +$(package)_version=13 +$(package)_download_path=https://github.com/AppImage/AppImageKit/archive/refs/tags/ +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=51b837c78dd99ecc1cf3dd283f4a98a1be665b01457da0edc1ff736d12974b1a +$(package)_dependencies=native_cmake libsquashfuse libappimage liblzma +$(package)_patches=CMakeLists.txt runtime.c notify.c + +define $(package)_preprocess_cmds + cp -v $($(package)_patch_dir)/* . +endef + +define $(package)_config_cmds + $($(package)_cmake) -DCMAKE_INSTALL_PREFIX=$(host_prefix) -DHOST=$(host) -DGLIBC_DYNAMIC_LINKER=$(GLIBC_DYNAMIC_LINKER) . +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + cp -a runtime $($(package)_staging_prefix_dir)/runtime +endef diff --git a/contrib/depends/packages/boost.mk b/contrib/depends/packages/boost.mk new file mode 100644 index 0000000..e77e278 --- /dev/null +++ b/contrib/depends/packages/boost.mk @@ -0,0 +1,48 @@ +package=boost +$(package)_version=1_68_0 +$(package)_download_path=https://downloads.sourceforge.net/project/boost/boost/1.68.0/ +$(package)_file_name=$(package)_$($(package)_version).tar.bz2 +$(package)_sha256_hash=7f6130bc3cf65f56a618888ce9d5ea704fa10b462be126ad053e80e553d6d8b7 +$(package)_dependencies=libiconv +$(package)_patches=fix_aroptions.patch fix_arm_arch.patch fix_coalesce.patch + +define $(package)_set_vars +$(package)_config_opts_release=variant=release +$(package)_config_opts_debug=variant=debug +$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam +$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 +$(package)_config_opts_linux=threadapi=pthread runtime-link=shared +$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android +$(package)_config_opts_darwin=--toolset=darwin runtime-link=static +$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static +$(package)_config_opts_x86_64_mingw32=address-model=64 +$(package)_config_opts_i686_mingw32=address-model=32 +$(package)_config_opts_i686_linux=address-model=32 architecture=x86 +$(package)_toolset_$(host_os)=gcc +$(package)_archiver_$(host_os)=$($(package)_ar) +$(package)_toolset_darwin=darwin +$(package)_archiver_darwin=$($(package)_libtool) +$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization,locale +$(package)_cxxflags=-std=c++17 +$(package)_cxxflags_linux=-fPIC +$(package)_cxxflags_freebsd=-fPIC +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/fix_aroptions.patch &&\ + patch -p1 < $($(package)_patch_dir)/fix_arm_arch.patch &&\ + patch -p1 < $($(package)_patch_dir)/fix_coalesce.patch &&\ + echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$($(package)_arflags)\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam +endef + +define $(package)_config_cmds + ./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries) +endef + +define $(package)_build_cmds + ./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage +endef + +define $(package)_stage_cmds + ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install +endef \ No newline at end of file diff --git a/contrib/depends/packages/eudev.mk b/contrib/depends/packages/eudev.mk new file mode 100644 index 0000000..0f60a80 --- /dev/null +++ b/contrib/depends/packages/eudev.mk @@ -0,0 +1,30 @@ +package=eudev +$(package)_version=v3.2.6 +$(package)_download_path=https://github.com/gentoo/eudev/archive/ +$(package)_download_file=$($(package)_version).tar.gz +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=a96ecb8637667897b8bd4dee4c22c7c5f08b327be45186e912ce6bc768385852 + +define $(package)_set_vars + $(package)_config_opts=--disable-gudev --disable-introspection --disable-hwdb --disable-manpages --disable-shared +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmd + $(MAKE) +endef + +define $(package)_preprocess_cmds + cd $($(package)_build_subdir); autoreconf -f -i +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/contrib/depends/packages/expat.mk b/contrib/depends/packages/expat.mk new file mode 100644 index 0000000..ef888cb --- /dev/null +++ b/contrib/depends/packages/expat.mk @@ -0,0 +1,31 @@ +package=expat +$(package)_version=2.4.8 +$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$($(package)_version))/ +$(package)_file_name=$(package)-$($(package)_version).tar.xz +$(package)_sha256_hash=f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25 + +# -D_DEFAULT_SOURCE defines __USE_MISC, which exposes additional +# definitions in endian.h, which are required for a working +# endianess check in configure when building with -flto. +define $(package)_set_vars + $(package)_config_opts=--disable-shared --without-docbook --without-tests --without-examples + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking + $(package)_config_opts += --without-xmlwf --with-pic + $(package)_cppflags += -D_DEFAULT_SOURCE +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share lib/cmake lib/*.la +endef \ No newline at end of file diff --git a/contrib/depends/packages/fontconfig.mk b/contrib/depends/packages/fontconfig.mk new file mode 100644 index 0000000..27df9c2 --- /dev/null +++ b/contrib/depends/packages/fontconfig.mk @@ -0,0 +1,32 @@ +package=native_fontconfig +$(package)_version=2.12.6 +$(package)_download_path=https://www.freedesktop.org/software/fontconfig/release/ +$(package)_file_name=fontconfig-$($(package)_version).tar.bz2 +$(package)_sha256_hash=cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017 +$(package)_dependencies=freetype expat +$(package)_patches=gperf_header_regen.patch + +define $(package)_set_vars + $(package)_config_opts=--disable-docs --disable-static --disable-libxml2 --disable-iconv + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/gperf_header_regen.patch +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf var lib/*.la +endef diff --git a/contrib/depends/packages/freetype.mk b/contrib/depends/packages/freetype.mk new file mode 100644 index 0000000..a9662dc --- /dev/null +++ b/contrib/depends/packages/freetype.mk @@ -0,0 +1,29 @@ +package=native_freetype +$(package)_version=2.11.0 +$(package)_download_path=https://download.savannah.gnu.org/releases/freetype +$(package)_file_name=freetype-$($(package)_version).tar.xz +$(package)_sha256_hash=8bee39bd3968c4804b70614a0a3ad597299ad0e824bc8aad5ce8aaf48067bde7 + +define $(package)_set_vars + $(package)_config_opts = --without-zlib --without-png --without-harfbuzz --without-bzip2 --enable-static --disable-shared + $(package)_config_opts += --enable-option-checking --without-brotli + $(package)_config_opts += --with-pic +endef + +define $(package)_config_cmds + printenv && \ + echo "$($(package)_autoconf)" && \ + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man lib/*.la +endef diff --git a/contrib/depends/packages/hidapi.mk b/contrib/depends/packages/hidapi.mk new file mode 100644 index 0000000..3ab98ec --- /dev/null +++ b/contrib/depends/packages/hidapi.mk @@ -0,0 +1,40 @@ +package=hidapi +$(package)_version=0.11.0 +$(package)_download_path=https://github.com/libusb/hidapi/archive +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=391d8e52f2d6a5cf76e2b0c079cfefe25497ba1d4659131297081fc0cd744632 +$(package)_linux_dependencies=libusb eudev +$(package)_patches=missing_win_include.patch + +define $(package)_set_vars +$(package)_config_opts=--enable-static --disable-shared +$(package)_config_opts+=--prefix=$(host_prefix) +#$(package)_config_opts_darwin+=RANLIB="$(host_prefix)/native/bin/x86_64-apple-darwin-ranlib" AR="$(host_prefix)/native/bin/x86_64-apple-darwin-ar" CC="$(host_prefix)/native/bin/$($(package)_cc)" +$(package)_config_opts_linux+=libudev_LIBS="-L$(host_prefix)/lib -ludev" +$(package)_config_opts_linux+=libudev_CFLAGS=-I$(host_prefix)/include +$(package)_config_opts_linux+=libusb_LIBS="-L$(host_prefix)/lib -lusb-1.0" +$(package)_config_opts_linux+=libusb_CFLAGS=-I$(host_prefix)/include/libusb-1.0 +$(package)_config_opts_linux+=--with-pic +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/missing_win_include.patch +endef + +define $(package)_config_cmds + ./bootstrap &&\ + $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef + diff --git a/contrib/depends/packages/icu4c.mk b/contrib/depends/packages/icu4c.mk new file mode 100644 index 0000000..f74f20b --- /dev/null +++ b/contrib/depends/packages/icu4c.mk @@ -0,0 +1,28 @@ +package=icu4c +$(package)_version=55.2 +$(package)_download_path=https://github.com/unicode-org/icu/releases/download/release-55-2/ +$(package)_file_name=$(package)-55_2-src.tgz +$(package)_sha256_hash=eda2aa9f9c787748a2e2d310590720ca8bcc6252adf6b4cfb03b65bef9d66759 +$(package)_patches=icu-001-dont-build-static-dynamic-twice.patch no-timestamp-in-makefile.patch + +define $(package)_set_vars + $(package)_build_opts=CFLAGS="$($(package)_cflags) $($(package)_cppflags) -DU_USING_ICU_NAMESPACE=0 -DU_STATIC_IMPLEMENTATION -DU_COMBINED_IMPLEMENTATION -fPIC -DENABLE_STATIC=YES -DPGKDATA_MODE=static" +endef + +define $(package)_config_cmds + patch -p1 < $($(package)_patch_dir)/icu-001-dont-build-static-dynamic-twice.patch && \ + patch -p1 < $($(package)_patch_dir)/no-timestamp-in-makefile.patch && \ + mkdir builda &&\ + mkdir buildb &&\ + cd builda &&\ + sh ../source/runConfigureICU Linux &&\ + make &&\ + cd ../buildb &&\ + sh ../source/runConfigureICU MinGW --enable-static=yes --disable-shared --disable-layout --disable-layoutex --disable-tests --disable-samples --prefix=$(host_prefix) --with-cross-build=`pwd`/../builda &&\ + $(MAKE) $($(package)_build_opts) +endef + +define $(package)_stage_cmds + cd buildb &&\ + $(MAKE) $($(package)_build_opts) DESTDIR=$($(package)_staging_dir) install lib/* +endef diff --git a/contrib/depends/packages/ldns.mk b/contrib/depends/packages/ldns.mk new file mode 100644 index 0000000..90c63e8 --- /dev/null +++ b/contrib/depends/packages/ldns.mk @@ -0,0 +1,34 @@ +package=ldns +$(package)_version=1.7.1 +$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/ +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=8ac84c16bdca60e710eea75782356f3ac3b55680d40e1530d7cea474ac208229 +$(package)_dependencies=openssl + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --enable-static --with-drill + $(package)_config_opts+=--with-ssl=$(host_prefix) + $(package)_config_opts_release=--disable-debug-mode + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install-h install-lib +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef + diff --git a/contrib/depends/packages/libXau.mk b/contrib/depends/packages/libXau.mk new file mode 100644 index 0000000..7a24a0a --- /dev/null +++ b/contrib/depends/packages/libXau.mk @@ -0,0 +1,34 @@ +package=libXau +$(package)_version=1.0.9 +$(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=libXau-$($(package)_version).tar.bz2 +$(package)_sha256_hash=ccf8cbf0dbf676faa2ea0a6d64bcc3b6746064722b606c8c52917ed00dcb73ec +$(package)_dependencies=xproto + +# When updating this package, check the default value of +# --disable-xthreads. It is currently enabled. +define $(package)_set_vars + $(package)_config_opts=--disable-shared --disable-lint-library --without-lint + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking + $(package)_config_opts += --with-pic +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share lib/*.la +endef diff --git a/contrib/depends/packages/libappimage.mk b/contrib/depends/packages/libappimage.mk new file mode 100644 index 0000000..14beef6 --- /dev/null +++ b/contrib/depends/packages/libappimage.mk @@ -0,0 +1,25 @@ +package=libappimage +$(package)_version=v0.1.x-legacy +$(package)_download_path=https://github.com/AppImageCommunity/libappimage/archive/refs/heads/ +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=fef3962bfb75f986f24c530a6230e95b8c79e46da3dd581543f1b615d45e7389 +$(package)_dependencies=native_cmake liblzma libfuse libarchive +$(package)_patches=no-unneeded-deps.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/no-unneeded-deps.patch +endef + +define $(package)_config_cmds + $($(package)_cmake) -DCMAKE_INSTALL_PREFIX=$(host_prefix) -DCMAKE_C_COMPILER= -DUSE_SYSTEM_XZ=ON -DUSE_SYSTEM_SQUASHFUSE=ON -DUSE_SYSTEM_LIBARCHIVE=ON -DBUILD_TESTING=OFF . +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install && \ + cp src/libappimage_hashlib/include/hashlib.h $($(package)_staging_prefix_dir)/include/ && \ + cp src/libappimage_hashlib/include/md5.h $($(package)_staging_prefix_dir)/include/ +endef diff --git a/contrib/depends/packages/libarchive.mk b/contrib/depends/packages/libarchive.mk new file mode 100644 index 0000000..d4ef21c --- /dev/null +++ b/contrib/depends/packages/libarchive.mk @@ -0,0 +1,26 @@ +# Needed for libappimage +package=libarchive +$(package)_version=3.3.1 +$(package)_download_path=https://www.libarchive.org/downloads/ +$(package)_file_name=libarchive-$($(package)_version).tar.gz +$(package)_sha256_hash=29ca5bd1624ca5a007aa57e16080262ab4379dbf8797f5c52f7ea74a3b0424e7 + +define $(package)_set_vars + $(package)_config_opts=--with-pic --disable-shared --enable-static --disable-bsdtar --disable-bsdcat + $(package)_config_opts+=--disable-bsdcpio --with-zlib --without-bz2lib --without-iconv --without-lz4 --without-lzma + $(package)_config_opts+=--without-lzo2 --without-nettle --without-openssl --without-xml2 --without-expat + $(package)_config_opts+=--prefix=$(host_prefix) + $(package)_config_opts+=--libdir=$(host_prefix)/lib +endef + +define $(package)_config_cmds + $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/libevent.mk b/contrib/depends/packages/libevent.mk new file mode 100644 index 0000000..5527151 --- /dev/null +++ b/contrib/depends/packages/libevent.mk @@ -0,0 +1,22 @@ +package=libevent +$(package)_version=2.1.12 +$(package)_download_path=https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/ +$(package)_file_name=libevent-$($(package)_version)-stable.tar.gz +$(package)_sha256_hash=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb +$(package)_dependencies=openssl + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --enable-static --with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/libfuse.mk b/contrib/depends/packages/libfuse.mk new file mode 100644 index 0000000..9457ea7 --- /dev/null +++ b/contrib/depends/packages/libfuse.mk @@ -0,0 +1,23 @@ +# Needed for libsquashfuse +package=libfuse +$(package)_version=2.9.9 +$(package)_download_path=https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/ +$(package)_file_name=fuse-$($(package)_version).tar.gz +$(package)_sha256_hash=d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5 +$(package)_patches = arm64.patch + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_preprocess_cmds + patch -p1 -i $($(package)_patch_dir)/arm64.patch +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/libgcrypt.mk b/contrib/depends/packages/libgcrypt.mk new file mode 100644 index 0000000..05ebad7 --- /dev/null +++ b/contrib/depends/packages/libgcrypt.mk @@ -0,0 +1,36 @@ +package=libgcrypt +$(package)_version=1.8.9 +$(package)_download_path=https://www.gnupg.org/ftp/gcrypt/libgcrypt/ +$(package)_file_name=libgcrypt-$($(package)_version).tar.bz2 +$(package)_sha256_hash=2bda4790aa5f0895d3407cf7bf6bd7727fd992f25a45a63d92fef10767fa3769 +$(package)_dependencies=libgpg-error +$(package)_patches=gost-sb.h no_gen_gost-sb.patch + +define $(package)_set_vars + $(package)_build_opts=CFLAGS="-fPIE" +endef + +# TODO: do a native compile first to eliminate the need for this patch +define $(package)_preprocess_cmds + mv $($(package)_patch_dir)/gost-sb.h cipher/gost-sb.h && \ + patch -p1 < $($(package)_patch_dir)/no_gen_gost-sb.patch +endef + +# TODO: building on linux with $($(package)_autoconf) fails for mysterious reasons +ifeq ($(host_os),linux) +define $(package)_config_cmds + CFLAGS='-fPIE' CXXFLAGS='-fPIE' ./configure --host=$(host) --enable-digests="sha256 blake2" --enable-ciphers=aes --disable-amd64-as-feature-detection --disable-asm --disable-avx-support --disable-avx2-support --disable-sse41-support --disable-shared --enable-static --disable-doc --with-libgpg-error-prefix=$(host_prefix) --prefix=$(host_prefix) +endef +else +define $(package)_config_cmds + $($(package)_autoconf) --disable-shared --enable-static --disable-doc --with-libgpg-error-prefix=$(host_prefix) +endef +endif + +define $(package)_build_cmds + $(MAKE) $($(package)_build_opts) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/libgpg-error.mk b/contrib/depends/packages/libgpg-error.mk new file mode 100644 index 0000000..7eae42d --- /dev/null +++ b/contrib/depends/packages/libgpg-error.mk @@ -0,0 +1,21 @@ +package=libgpg-error +$(package)_version=1.45 +$(package)_download_path=https://www.gnupg.org/ftp/gcrypt/libgpg-error/ +$(package)_file_name=libgpg-error-1.45.tar.bz2 +$(package)_sha256_hash=570f8ee4fb4bff7b7495cff920c275002aea2147e9a1d220c068213267f80a26 + +define $(package)_set_vars + $(package)_build_opts=CFLAGS="-fPIE" +endef + +define $(package)_config_cmds + $($(package)_autoconf) --enable-static --disable-shared +endef + +define $(package)_build_cmds + $(MAKE) $($(package)_build_opts) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/libiconv.mk b/contrib/depends/packages/libiconv.mk new file mode 100644 index 0000000..de6c577 --- /dev/null +++ b/contrib/depends/packages/libiconv.mk @@ -0,0 +1,29 @@ +package=libiconv +$(package)_version=1.17 +$(package)_download_path=https://ftp.gnu.org/gnu/libiconv +$(package)_file_name=libiconv-$($(package)_version).tar.gz +$(package)_sha256_hash=8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313 + +define $(package)_set_vars + $(package)_config_opts=--disable-nls + $(package)_config_opts=--enable-static + $(package)_config_opts=--disable-shared + $(package)_config_opts_linux=--with-pic + $(package)_config_opts_freebsd=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) AR_FLAGS=$($(package)_arflags) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/contrib/depends/packages/liblzma.mk b/contrib/depends/packages/liblzma.mk new file mode 100644 index 0000000..81edf61 --- /dev/null +++ b/contrib/depends/packages/liblzma.mk @@ -0,0 +1,24 @@ +# Needed for libappimage +package=liblzma +$(package)_version=5.2.3 +$(package)_download_path=https://netcologne.dl.sourceforge.net/project/lzmautils/ +$(package)_file_name=xz-$($(package)_version).tar.gz +$(package)_sha256_hash=71928b357d0a09a12a4b4c5fafca8c31c19b0e7d3b8ebb19622e96f26dbf28cb + +define $(package)_set_vars + $(package)_config_opts=--with-pic --disable-shared --enable-static --disable-xz --disable-xzdec + $(package)_config_opts+=--prefix=$(host_prefix) + $(package)_config_opts+=--libdir=$(host_prefix)/lib +endef + +define $(package)_config_cmds + $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/libsquashfuse.mk b/contrib/depends/packages/libsquashfuse.mk new file mode 100644 index 0000000..67a2e96 --- /dev/null +++ b/contrib/depends/packages/libsquashfuse.mk @@ -0,0 +1,45 @@ +# Needed for libappimage +package=libsquashfuse +$(package)_version=1f980303b89c779eabfd0a0fdd36d6a7a311bf92 +$(package)_download_path=https://github.com/vasi/squashfuse/archive/ +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=8cef1539bd9c9efd3c407004fdd7a3bbef44102a5966b892819a275d609013a3 +$(package)_dependencies=liblzma libfuse zlib +$(package)_patches=squashfuse.patch squashfuse_dlopen.patch squashfuse_dlopen.c squashfuse_dlopen.h + +# for some reason, a first run may fail, but it seems just running it a second time fixes the issues +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/squashfuse.patch && \ + patch -p1 < $($(package)_patch_dir)/squashfuse_dlopen.patch && \ + cp -v $($(package)_patch_dir)/squashfuse_dlopen.c $($(package)_patch_dir)/squashfuse_dlopen.h . && \ + libtoolize --force && \ + ./autogen.sh || true && \ + ./autogen.sh && \ + sed -i "/PKG_CHECK_MODULES.*/,/,:./d" configure && \ + sed -i "s/typedef off_t sqfs_off_t/typedef int64_t sqfs_off_t/g" common.h +endef + +define $(package)_set_vars + $(package)_config_opts=--disable-demo --disable-high-level --without-lzo --without-lz4 + $(package)_config_opts+=--prefix=$(host_prefix) + $(package)_config_opts+=--libdir=$(host_prefix)/lib +endef + +define $(package)_config_cmds + $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) && \ + ls .libs +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install && \ + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + mkdir -p $($(package)_staging_prefix_dir)/include && \ + cp .libs/libfuseprivate.a $($(package)_staging_prefix_dir)/lib/ && \ + cp .libs/libsquashfuse.a $($(package)_staging_prefix_dir)/lib/ && \ + cp .libs/libsquashfuse_ll.a $($(package)_staging_prefix_dir)/lib/ && \ + find . -name "*.h" -exec cp --parents '{}' $($(package)_staging_prefix_dir)/include/ \; +endef diff --git a/contrib/depends/packages/libusb.mk b/contrib/depends/packages/libusb.mk new file mode 100644 index 0000000..452e6c7 --- /dev/null +++ b/contrib/depends/packages/libusb.mk @@ -0,0 +1,40 @@ +package=libusb +$(package)_version=1.0.22 +$(package)_download_path=https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-$($(package)_version)/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=75aeb9d59a4fdb800d329a545c2e6799f732362193b465ea198f2aa275518157 + +define $(package)_preprocess_cmds + autoreconf -i +endef + +define $(package)_set_vars + $(package)_config_opts=--disable-shared + $(package)_config_opts_linux=--with-pic --disable-udev + $(package)_config_opts_mingw32=--disable-udev + $(package)_config_opts_darwin=--disable-udev +endef + +ifneq ($(host_os),darwin) + define $(package)_config_cmds + cp -f $(BASEDIR)/config.guess config.guess &&\ + cp -f $(BASEDIR)/config.sub config.sub &&\ + $($(package)_autoconf) + endef +else + define $(package)_config_cmds + $($(package)_autoconf) + endef +endif + +define $(package)_build_cmd + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + cp -f lib/libusb-1.0.a lib/libusb.a +endef diff --git a/contrib/depends/packages/libxcb.mk b/contrib/depends/packages/libxcb.mk new file mode 100644 index 0000000..77ff2d5 --- /dev/null +++ b/contrib/depends/packages/libxcb.mk @@ -0,0 +1,41 @@ +package=libxcb +$(package)_version=1.14 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=libxcb-$($(package)_version).tar.xz +$(package)_sha256_hash=a55ed6db98d43469801262d81dc2572ed124edc3db31059d4e9916eb9f844c34 +$(package)_dependencies=xcb_proto libXau +$(package)_patches = remove_pthread_stubs.patch + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen --without-launchd +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +# Disable unneeded extensions. +# More info is available from: https://doc.qt.io/qt-5.15/linux-requirements.html +$(package)_config_opts += --disable-composite --disable-damage --disable-dpms +$(package)_config_opts += --disable-dri2 --disable-dri3 --disable-glx +$(package)_config_opts += --disable-present --disable-record --disable-resource +$(package)_config_opts += --disable-screensaver --disable-xevie --disable-xfree86-dri +$(package)_config_opts += --disable-xinput --disable-xprint --disable-selinux +$(package)_config_opts += --disable-xtest --disable-xv --disable-xvmc +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub build-aux && \ + patch -p1 -i $($(package)_patch_dir)/remove_pthread_stubs.patch +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share lib/*.la +endef \ No newline at end of file diff --git a/contrib/depends/packages/libxcb_util.mk b/contrib/depends/packages/libxcb_util.mk new file mode 100644 index 0000000..6f1b9cd --- /dev/null +++ b/contrib/depends/packages/libxcb_util.mk @@ -0,0 +1,32 @@ +package=libxcb_util +$(package)_version=0.4.0 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-$($(package)_version).tar.bz2 +$(package)_sha256_hash=46e49469cb3b594af1d33176cd7565def2be3fa8be4371d62271fabb5eae50e9 +$(package)_dependencies=libxcb + +define $(package)_set_vars +$(package)_config_opts = --disable-shared --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +$(package)_config_opts += --with-pic +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/libxcb_util_image.mk b/contrib/depends/packages/libxcb_util_image.mk new file mode 100644 index 0000000..d12d67e --- /dev/null +++ b/contrib/depends/packages/libxcb_util_image.mk @@ -0,0 +1,31 @@ +package=libxcb_util_image +$(package)_version=0.4.0 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-image-$($(package)_version).tar.bz2 +$(package)_sha256_hash=2db96a37d78831d643538dd1b595d7d712e04bdccf8896a5e18ce0f398ea2ffc +$(package)_dependencies=libxcb libxcb_util + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts+= --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/libxcb_util_keysyms.mk b/contrib/depends/packages/libxcb_util_keysyms.mk new file mode 100644 index 0000000..d4f72de --- /dev/null +++ b/contrib/depends/packages/libxcb_util_keysyms.mk @@ -0,0 +1,31 @@ +package=libxcb_util_keysyms +$(package)_version=0.4.0 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-keysyms-$($(package)_version).tar.bz2 +$(package)_sha256_hash=0ef8490ff1dede52b7de533158547f8b454b241aa3e4dcca369507f66f216dd9 +$(package)_dependencies=libxcb xproto + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/libxcb_util_render.mk b/contrib/depends/packages/libxcb_util_render.mk new file mode 100644 index 0000000..28f1fb0 --- /dev/null +++ b/contrib/depends/packages/libxcb_util_render.mk @@ -0,0 +1,31 @@ +package=libxcb_util_render +$(package)_version=0.3.9 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-renderutil-$($(package)_version).tar.bz2 +$(package)_sha256_hash=c6e97e48fb1286d6394dddb1c1732f00227c70bd1bedb7d1acabefdd340bea5b +$(package)_dependencies=libxcb + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/libxcb_util_wm.mk b/contrib/depends/packages/libxcb_util_wm.mk new file mode 100644 index 0000000..3b905ba --- /dev/null +++ b/contrib/depends/packages/libxcb_util_wm.mk @@ -0,0 +1,31 @@ +package=libxcb_util_wm +$(package)_version=0.4.1 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-wm-$($(package)_version).tar.bz2 +$(package)_sha256_hash=28bf8179640eaa89276d2b0f1ce4285103d136be6c98262b6151aaee1d3c2a3f +$(package)_dependencies=libxcb + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/libxkbcommon.mk b/contrib/depends/packages/libxkbcommon.mk new file mode 100644 index 0000000..4c8e68f --- /dev/null +++ b/contrib/depends/packages/libxkbcommon.mk @@ -0,0 +1,36 @@ +package=libxkbcommon +$(package)_version=0.8.4 +$(package)_download_path=https://xkbcommon.org/download/ +$(package)_file_name=libxkbcommon-$($(package)_version).tar.xz +$(package)_sha256_hash=60ddcff932b7fd352752d51a5c4f04f3d0403230a584df9a2e0d5ed87c486c8b +$(package)_dependencies=libxcb + +# This package explicitly enables -Werror=array-bounds, which causes build failures +# with GCC 12.1+. Work around that by turning errors back into warnings. +# This workaround would be dropped if the package was updated, as that would require +# a different build system (Meson) +define $(package)_set_vars +$(package)_config_opts = --enable-option-checking --disable-dependency-tracking +$(package)_config_opts += --disable-static --disable-docs +$(package)_cflags += -Wno-error=array-bounds +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub build-aux +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/contrib/depends/packages/libzip.mk b/contrib/depends/packages/libzip.mk new file mode 100644 index 0000000..b06dc5d --- /dev/null +++ b/contrib/depends/packages/libzip.mk @@ -0,0 +1,23 @@ +package=libzip +$(package)_version=1.9.2 +$(package)_download_path=https://libzip.org/download/ +$(package)_file_name=libzip-1.9.2.tar.gz +$(package)_sha256_hash=fd6a7f745de3d69cf5603edc9cb33d2890f0198e415255d0987a0cf10d824c6f +$(package)_dependencies=zlib native_cmake +$(package)_patches += no-clonefile.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/no-clonefile.patch +endef + +define $(package)_config_cmds + $($(package)_cmake) -DZLIB_ROOT=$(host_prefix) -DENABLE_BZIP2=Off -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=$(host_prefix) . +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_cctools.mk b/contrib/depends/packages/native_cctools.mk new file mode 100644 index 0000000..8ebfab9 --- /dev/null +++ b/contrib/depends/packages/native_cctools.mk @@ -0,0 +1,39 @@ +package=native_cctools +$(package)_version=2ef2e931cf641547eb8a68cfebde61003587c9fd +$(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=6b73269efdf5c58a070e7357b66ee760501388549d6a12b423723f45888b074b +$(package)_build_subdir=cctools +$(package)_dependencies=native_libtapi +$(package)_patches=no-build-date.patch + +define $(package)_set_vars + $(package)_config_opts=--target=$(host) + $(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib + ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),) + $(package)_config_opts+=--enable-lto-support --with-llvm-config=$(build_prefix)/bin/llvm-config + endif + $(package)_cc=$(clang_prog) + $(package)_cxx=$(clangxx_prog) +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/no-build-date.patch && \ + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub cctools +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_clang.mk b/contrib/depends/packages/native_clang.mk new file mode 100644 index 0000000..245269a --- /dev/null +++ b/contrib/depends/packages/native_clang.mk @@ -0,0 +1,25 @@ +package=native_clang +$(package)_version=10.0.1 +$(package)_download_path=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version) +ifneq (,$(findstring aarch64,$(BUILD))) +$(package)_file_name=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz +$(package)_sha256_hash=90dc69a4758ca15cd0ffa45d07fbf5bf4309d47d2c7745a9f0735ecffde9c31f +else +$(package)_file_name=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-16.04.tar.xz +$(package)_sha256_hash=48b83ef827ac2c213d5b64f5ad7ed082c8bcb712b46644e0dc5045c6f462c231 +endif + +define $(package)_preprocess_cmds + rm -f $($(package)_extract_dir)/lib/libc++abi.so* +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include && \ + mkdir -p $($(package)_staging_prefix_dir)/bin && \ + cp bin/clang $($(package)_staging_prefix_dir)/bin/ && \ + cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ && \ + cp bin/dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \ + cp bin/llvm-config $($(package)_staging_prefix_dir)/bin/ && \ + cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \ + cp -r lib/clang/$($(package)_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_version)/include/ +endef diff --git a/contrib/depends/packages/native_cmake.mk b/contrib/depends/packages/native_cmake.mk new file mode 100644 index 0000000..f5c8cf7 --- /dev/null +++ b/contrib/depends/packages/native_cmake.mk @@ -0,0 +1,18 @@ +package=native_cmake +$(package)_version=3.23.2 +$(package)_version_dot=v3.23 +$(package)_download_path=https://cmake.org/files/$($(package)_version_dot)/ +$(package)_file_name=cmake-$($(package)_version).tar.gz +$(package)_sha256_hash=f316b40053466f9a416adf981efda41b160ca859e97f6a484b447ea299ff26aa + +define $(package)_config_cmds + ./bootstrap --prefix=$(build_prefix) -- -DCMAKE_USE_OPENSSL=OFF +endef + +define $(package)_build_cmd + +$(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_ds_store.mk b/contrib/depends/packages/native_ds_store.mk new file mode 100644 index 0000000..980e062 --- /dev/null +++ b/contrib/depends/packages/native_ds_store.mk @@ -0,0 +1,15 @@ +package=native_ds_store +$(package)_version=1.3.0 +$(package)_download_path=https://github.com/dmgbuild/ds_store/archive/ +$(package)_file_name=v$($(package)_version).tar.gz +$(package)_sha256_hash=76b3280cd4e19e5179defa23fb594a9dd32643b0c80d774bd3108361d94fb46d +$(package)_install_libdir=$(build_prefix)/lib/python3/dist-packages + +define $(package)_build_cmds + python3 setup.py build +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_install_libdir) && \ + python3 setup.py install --root=$($(package)_staging_dir) --prefix=$(build_prefix) --install-lib=$($(package)_install_libdir) +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_expat.mk b/contrib/depends/packages/native_expat.mk new file mode 100644 index 0000000..f19635b --- /dev/null +++ b/contrib/depends/packages/native_expat.mk @@ -0,0 +1,32 @@ +package=native_expat +$(package)_version=2.4.8 +$(package)_download_path=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$($(package)_version))/ +$(package)_file_name=expat-$($(package)_version).tar.xz +$(package)_sha256_hash=f79b8f904b749e3e0d20afeadecf8249c55b2e32d4ebb089ae378df479dcaf25 + +# -D_DEFAULT_SOURCE defines __USE_MISC, which exposes additional +# definitions in endian.h, which are required for a working +# endianess check in configure when building with -flto. +define $(package)_set_vars + $(package)_config_opts=--disable-shared --without-docbook --without-tests --without-examples + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking + $(package)_config_opts += --without-xmlwf --with-pic + $(package)_cppflags += -D_DEFAULT_SOURCE +endef + +define $(package)_config_cmds + echo "$($(package)_autoconf)" && \ + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share lib/cmake lib/*.la +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_fontconfig.mk b/contrib/depends/packages/native_fontconfig.mk new file mode 100644 index 0000000..184ef21 --- /dev/null +++ b/contrib/depends/packages/native_fontconfig.mk @@ -0,0 +1,32 @@ +package=native_fontconfig +$(package)_version=2.12.6 +$(package)_download_path=https://www.freedesktop.org/software/fontconfig/release/ +$(package)_file_name=fontconfig-$($(package)_version).tar.bz2 +$(package)_sha256_hash=cf0c30807d08f6a28ab46c61b8dbd55c97d2f292cf88f3a07d3384687f31f017 +$(package)_dependencies=native_freetype native_expat +$(package)_patches=gperf_header_regen.patch + +define $(package)_set_vars + $(package)_config_opts=--disable-docs --disable-static --disable-libxml2 --disable-iconv + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/gperf_header_regen.patch +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf var lib/*.la +endef diff --git a/contrib/depends/packages/native_freetype.mk b/contrib/depends/packages/native_freetype.mk new file mode 100644 index 0000000..a9662dc --- /dev/null +++ b/contrib/depends/packages/native_freetype.mk @@ -0,0 +1,29 @@ +package=native_freetype +$(package)_version=2.11.0 +$(package)_download_path=https://download.savannah.gnu.org/releases/freetype +$(package)_file_name=freetype-$($(package)_version).tar.xz +$(package)_sha256_hash=8bee39bd3968c4804b70614a0a3ad597299ad0e824bc8aad5ce8aaf48067bde7 + +define $(package)_set_vars + $(package)_config_opts = --without-zlib --without-png --without-harfbuzz --without-bzip2 --enable-static --disable-shared + $(package)_config_opts += --enable-option-checking --without-brotli + $(package)_config_opts += --with-pic +endef + +define $(package)_config_cmds + printenv && \ + echo "$($(package)_autoconf)" && \ + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man lib/*.la +endef diff --git a/contrib/depends/packages/native_libXau.mk b/contrib/depends/packages/native_libXau.mk new file mode 100644 index 0000000..146c3b7 --- /dev/null +++ b/contrib/depends/packages/native_libXau.mk @@ -0,0 +1,34 @@ +package=native_libXau +$(package)_version=1.0.9 +$(package)_download_path=https://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=libXau-$($(package)_version).tar.bz2 +$(package)_sha256_hash=ccf8cbf0dbf676faa2ea0a6d64bcc3b6746064722b606c8c52917ed00dcb73ec +$(package)_dependencies=native_xproto + +# When updating this package, check the default value of +# --disable-xthreads. It is currently enabled. +define $(package)_set_vars + $(package)_config_opts=--disable-shared --disable-lint-library --without-lint + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking + $(package)_config_opts += --with-pic +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share lib/*.la +endef diff --git a/contrib/depends/packages/native_libtapi.mk b/contrib/depends/packages/native_libtapi.mk new file mode 100644 index 0000000..6b06aa7 --- /dev/null +++ b/contrib/depends/packages/native_libtapi.mk @@ -0,0 +1,19 @@ +package=native_libtapi +$(package)_version=664b8414f89612f2dfd35a9b679c345aa5389026 +$(package)_download_path=https://github.com/tpoechtrager/apple-libtapi/archive +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=62e419c12d1c9fad67cc1cd523132bc00db050998337c734c15bc8d73cc02b61 + +ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),) +$(package)_dependencies=native_clang +endif + +define $(package)_build_cmds + CC=$(clang_prog) CXX=$(clangxx_prog) INSTALLPREFIX=$($(package)_staging_prefix_dir) ./build.sh +endef + +define $(package)_stage_cmds + ./install.sh && \ + mkdir -p $($(package)_staging_prefix_dir)/include/llvm-c && \ + cp src/llvm/include/llvm-c/lto.h $($(package)_staging_prefix_dir)/include/llvm-c +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_libxcb.mk b/contrib/depends/packages/native_libxcb.mk new file mode 100644 index 0000000..cede1e0 --- /dev/null +++ b/contrib/depends/packages/native_libxcb.mk @@ -0,0 +1,41 @@ +package=native_libxcb +$(package)_version=1.14 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=libxcb-$($(package)_version).tar.xz +$(package)_sha256_hash=a55ed6db98d43469801262d81dc2572ed124edc3db31059d4e9916eb9f844c34 +$(package)_dependencies=native_xcb_proto native_libXau +$(package)_patches = remove_pthread_stubs.patch + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen --without-launchd +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +# Disable unneeded extensions. +# More info is available from: https://doc.qt.io/qt-5.15/linux-requirements.html +$(package)_config_opts += --disable-composite --disable-damage --disable-dpms +$(package)_config_opts += --disable-dri2 --disable-dri3 --disable-glx +$(package)_config_opts += --disable-present --disable-record --disable-resource +$(package)_config_opts += --disable-screensaver --disable-xevie --disable-xfree86-dri +$(package)_config_opts += --disable-xinput --disable-xprint --disable-selinux +$(package)_config_opts += --disable-xtest --disable-xv --disable-xvmc +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub build-aux && \ + patch -p1 -i $($(package)_patch_dir)/remove_pthread_stubs.patch +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share lib/*.la +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_libxcb_util.mk b/contrib/depends/packages/native_libxcb_util.mk new file mode 100644 index 0000000..07010b8 --- /dev/null +++ b/contrib/depends/packages/native_libxcb_util.mk @@ -0,0 +1,32 @@ +package=native_libxcb_util +$(package)_version=0.4.0 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-$($(package)_version).tar.bz2 +$(package)_sha256_hash=46e49469cb3b594af1d33176cd7565def2be3fa8be4371d62271fabb5eae50e9 +$(package)_dependencies=native_libxcb + +define $(package)_set_vars +$(package)_config_opts = --disable-shared --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +$(package)_config_opts += --with-pic +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/native_libxcb_util_image.mk b/contrib/depends/packages/native_libxcb_util_image.mk new file mode 100644 index 0000000..1251921 --- /dev/null +++ b/contrib/depends/packages/native_libxcb_util_image.mk @@ -0,0 +1,31 @@ +package=native_libxcb_util_image +$(package)_version=0.4.0 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-image-$($(package)_version).tar.bz2 +$(package)_sha256_hash=2db96a37d78831d643538dd1b595d7d712e04bdccf8896a5e18ce0f398ea2ffc +$(package)_dependencies=native_libxcb native_libxcb_util + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts+= --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/native_libxcb_util_keysyms.mk b/contrib/depends/packages/native_libxcb_util_keysyms.mk new file mode 100644 index 0000000..1dbbea8 --- /dev/null +++ b/contrib/depends/packages/native_libxcb_util_keysyms.mk @@ -0,0 +1,31 @@ +package=native_libxcb_util_keysyms +$(package)_version=0.4.0 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-keysyms-$($(package)_version).tar.bz2 +$(package)_sha256_hash=0ef8490ff1dede52b7de533158547f8b454b241aa3e4dcca369507f66f216dd9 +$(package)_dependencies=native_libxcb native_xproto + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/native_libxcb_util_render.mk b/contrib/depends/packages/native_libxcb_util_render.mk new file mode 100644 index 0000000..3706c75 --- /dev/null +++ b/contrib/depends/packages/native_libxcb_util_render.mk @@ -0,0 +1,31 @@ +package=native_libxcb_util_render +$(package)_version=0.3.9 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-renderutil-$($(package)_version).tar.bz2 +$(package)_sha256_hash=c6e97e48fb1286d6394dddb1c1732f00227c70bd1bedb7d1acabefdd340bea5b +$(package)_dependencies=native_libxcb + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/native_libxcb_util_wm.mk b/contrib/depends/packages/native_libxcb_util_wm.mk new file mode 100644 index 0000000..89b31d0 --- /dev/null +++ b/contrib/depends/packages/native_libxcb_util_wm.mk @@ -0,0 +1,31 @@ +package=native_libxcb_util_wm +$(package)_version=0.4.1 +$(package)_download_path=https://xcb.freedesktop.org/dist +$(package)_file_name=xcb-util-wm-$($(package)_version).tar.bz2 +$(package)_sha256_hash=28bf8179640eaa89276d2b0f1ce4285103d136be6c98262b6151aaee1d3c2a3f +$(package)_dependencies=native_libxcb + +define $(package)_set_vars +$(package)_config_opts=--disable-static --disable-devel-docs --without-doxygen +$(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc lib/*.la +endef diff --git a/contrib/depends/packages/native_libxkbcommon.mk b/contrib/depends/packages/native_libxkbcommon.mk new file mode 100644 index 0000000..55a12c7 --- /dev/null +++ b/contrib/depends/packages/native_libxkbcommon.mk @@ -0,0 +1,36 @@ +package=native_libxkbcommon +$(package)_version=0.8.4 +$(package)_download_path=https://xkbcommon.org/download/ +$(package)_file_name=libxkbcommon-$($(package)_version).tar.xz +$(package)_sha256_hash=60ddcff932b7fd352752d51a5c4f04f3d0403230a584df9a2e0d5ed87c486c8b +$(package)_dependencies=native_libxcb + +# This package explicitly enables -Werror=array-bounds, which causes build failures +# with GCC 12.1+. Work around that by turning errors back into warnings. +# This workaround would be dropped if the package was updated, as that would require +# a different build system (Meson) +define $(package)_set_vars +$(package)_config_opts = --enable-option-checking --disable-dependency-tracking +$(package)_config_opts += --disable-static --disable-docs +$(package)_cflags += -Wno-error=array-bounds +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub build-aux +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/contrib/depends/packages/native_linuxdeployqt.mk b/contrib/depends/packages/native_linuxdeployqt.mk new file mode 100644 index 0000000..2c2ae69 --- /dev/null +++ b/contrib/depends/packages/native_linuxdeployqt.mk @@ -0,0 +1,18 @@ +package=native_linuxdeployqt +$(package)_version=8 +$(package)_download_path=https://github.com/probonopd/linuxdeployqt/archive/refs/tags/ +$(package)_file_name=8.tar.gz +$(package)_sha256_hash=5597279392431aef16997c4b6892b5aa044392f7e8869439ebea33945a8bdbad +$(package)_dependencies=qt + +define $(package)_config_cmds + qmake +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) INSTALL_ROOT=$($(package)_staging_dir) install +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_mac_alias.mk b/contrib/depends/packages/native_mac_alias.mk new file mode 100644 index 0000000..5d9891e --- /dev/null +++ b/contrib/depends/packages/native_mac_alias.mk @@ -0,0 +1,15 @@ +package=native_mac_alias +$(package)_version=2.2.0 +$(package)_download_path=https://github.com/dmgbuild/mac_alias/archive/ +$(package)_file_name=v$($(package)_version).tar.gz +$(package)_sha256_hash=421e6d7586d1f155c7db3e7da01ca0dacc9649a509a253ad7077b70174426499 +$(package)_install_libdir=$(build_prefix)/lib/python3/dist-packages + +define $(package)_build_cmds + python3 setup.py build +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_install_libdir) && \ + python3 setup.py install --root=$($(package)_staging_dir) --prefix=$(build_prefix) --install-lib=$($(package)_install_libdir) +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_patchelf.mk b/contrib/depends/packages/native_patchelf.mk new file mode 100644 index 0000000..8abb753 --- /dev/null +++ b/contrib/depends/packages/native_patchelf.mk @@ -0,0 +1,17 @@ +package=native_patchelf +$(package)_version=0.14.5 +$(package)_download_path=https://github.com/NixOS/patchelf/releases/download/$($(package)_version)/ +$(package)_file_name=patchelf-$($(package)_version).tar.gz +$(package)_sha256_hash=113ada3f1ace08f0a7224aa8500f1fa6b08320d8f7df05ff58585286ec5faa6f + +define $(package)_config_cmds + ./configure --prefix=$(build_prefix) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_protobuf.mk b/contrib/depends/packages/native_protobuf.mk new file mode 100644 index 0000000..7e193d3 --- /dev/null +++ b/contrib/depends/packages/native_protobuf.mk @@ -0,0 +1,27 @@ +package=native_protobuf +$(package)_version=3.6.1 +$(package)_download_path=https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/ +$(package)_file_name=protobuf-cpp-3.6.1.tar.gz +$(package)_sha256_hash=b3732e471a9bb7950f090fd0457ebd2536a9ba0891b7f3785919c654fe2a2529 +$(package)_cxxflags=-std=c++11 + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --prefix=$(build_prefix) + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) -C src +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) -C src install +endef + +define $(package)_postprocess_cmds + rm lib/libprotoc.a +endef diff --git a/contrib/depends/packages/native_qt.mk b/contrib/depends/packages/native_qt.mk new file mode 100644 index 0000000..143b94d --- /dev/null +++ b/contrib/depends/packages/native_qt.mk @@ -0,0 +1,221 @@ +package=native_qt +$(package)_version=6.4.1 +$(package)_download_path=https://download.qt.io/official_releases/qt/6.4/$($(package)_version)/submodules +$(package)_suffix=everywhere-src-$($(package)_version).tar.xz +$(package)_file_name=qtbase-$($(package)_suffix) +$(package)_sha256_hash=532ad71cc0f9c8f7cb92766c47bc3d23263c60876becd9053802f9727af24fae +$(package)_dependencies=native_cmake native_libxcb native_libxkbcommon native_libxcb_util native_libxcb_util_render native_libxcb_util_keysyms native_libxcb_util_image native_libxcb_util_wm +$(package)_qt_libs=corelib network widgets gui plugins testlib +$(package)_linguist_tools = lrelease lupdate lconvert +$(package)_patches = dont_hardcode_pwd.patch +$(package)_patches += fast_fixed_dtoa_no_optimize.patch +$(package)_patches += guix_cross_lib_path.patch +$(package)_patches += mac-qmake.conf +$(package)_patches += no_pthread_cond_clockwait.patch +$(package)_patches += no-renameat2.patch +$(package)_patches += no-statx.patch +$(package)_patches += no-xlib.patch +$(package)_patches += qtbase-moc-ignore-gcc-macro.patch +$(package)_patches += rcc_hardcode_timestamp.patch +$(package)_patches += root_CMakeLists.txt +$(package)_patches += Use-consistent-ordering-in-QShader.patch +$(package)_patches += QShader_map.patch + +$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) +$(package)_qttranslations_sha256_hash=44dbc6f1d256d2048c96fa665c240e0075c2e67188c93986a39ede3556a16a12 + +$(package)_qttools_file_name=qttools-$($(package)_suffix) +$(package)_qttools_sha256_hash=9e20562c6b04c21fbdb4ed89e59226169ffeaafaab8f45f7d81ea49b0e4b0933 + +$(package)_qtsvg_file_name=qtsvg-$($(package)_suffix) +$(package)_qtsvg_sha256_hash=5e5345c5941567db883f9daf8ab25108c6f3a527453b1a13c62290849bce9ce5 + +$(package)_qtmultimedia_file_name=qtmultimedia-$($(package)_suffix) +$(package)_qtmultimedia_sha256_hash=c086d43a026e6090971fd7a697ef8370c5c455115240609cd08d5e2f840dbaaf + +$(package)_qtshadertools_file_name=qtshadertools-$($(package)_suffix) +$(package)_qtshadertools_sha256_hash=6bc1748326088c87f562fa3a68140e33fde162fd1333fbfecb775aeb66114504 + +$(package)_extra_sources = $($(package)_qttranslations_file_name) +$(package)_extra_sources += $($(package)_qttools_file_name) +$(package)_extra_sources += $($(package)_qtsvg_file_name) +$(package)_extra_sources += $($(package)_qtmultimedia_file_name) +$(package)_extra_sources += $($(package)_qtshadertools_file_name) + +define $(package)_set_vars +$(package)_config_opts_release = -release +$(package)_config_opts_debug = -debug +$(package)_config_opts_debug += -optimized-tools +$(package)_config_opts += -libexecdir $(build_prefix)/qt-host/bin +$(package)_config_opts += -c++std c++17 +$(package)_config_opts += -confirm-license +$(package)_config_opts += -no-cups +$(package)_config_opts += -no-egl +$(package)_config_opts += -no-eglfs +$(package)_config_opts += -no-evdev +$(package)_config_opts += -no-gif +$(package)_config_opts += -no-glib +$(package)_config_opts += -no-icu +$(package)_config_opts += -no-ico +$(package)_config_opts += -no-kms +$(package)_config_opts += -no-linuxfb +#$(package)_config_opts += -no-libjpeg # Needed +#$(package)_config_opts += -no-libproxy # Needed +$(package)_config_opts += -no-libudev +$(package)_config_opts += -no-mtdev +$(package)_config_opts += -no-openssl +#$(package)_config_opts += -openssl-linked +$(package)_config_opts += -no-openvg +$(package)_config_opts += -no-reduce-relocations +$(package)_config_opts += -no-schannel +$(package)_config_opts += -no-sctp +$(package)_config_opts += -no-securetransport +$(package)_config_opts += -no-system-proxies +$(package)_config_opts += -no-use-gold-linker +$(package)_config_opts += -no-zstd +$(package)_config_opts += -nomake examples +$(package)_config_opts += -nomake tests +$(package)_config_opts += -opensource +$(package)_config_opts += -pkg-config +$(package)_config_opts += -prefix $(build_prefix)/qt-host +$(package)_config_opts += -qt-libpng +$(package)_config_opts += -qt-pcre +$(package)_config_opts += -qt-harfbuzz +$(package)_config_opts += -qt-zlib +$(package)_config_opts += -static +$(package)_config_opts += -no-feature-colordialog +#$(package)_config_opts += -no-feature-concurrent # Needed +$(package)_config_opts += -no-feature-dial +$(package)_config_opts += -no-feature-fontcombobox +$(package)_config_opts += -no-feature-http +$(package)_config_opts += -no-feature-image_heuristic_mask +$(package)_config_opts += -no-feature-keysequenceedit +$(package)_config_opts += -no-feature-lcdnumber +$(package)_config_opts += -no-feature-networkdiskcache +#$(package)_config_opts += -no-feature-networkproxy # Needed +$(package)_config_opts += -no-feature-pdf +$(package)_config_opts += -no-feature-printdialog +$(package)_config_opts += -no-feature-printer +$(package)_config_opts += -no-feature-printpreviewdialog +$(package)_config_opts += -no-feature-printpreviewwidget +$(package)_config_opts += -no-feature-sessionmanager +#$(package)_config_opts += -no-feature-socks5 # Needed +$(package)_config_opts += -no-feature-sql +$(package)_config_opts += -no-feature-syntaxhighlighter +#$(package)_config_opts += -no-feature-textbrowser # Needed +$(package)_config_opts += -no-feature-textmarkdownwriter +$(package)_config_opts += -no-feature-textodfwriter +$(package)_config_opts += -no-feature-topleveldomain +#$(package)_config_opts += -no-feature-udpsocket # Neede +$(package)_config_opts += -no-feature-undocommand +$(package)_config_opts += -no-feature-undogroup +$(package)_config_opts += -no-feature-undostack +$(package)_config_opts += -no-feature-undoview +$(package)_config_opts += -no-feature-vnc +#$(package)_config_opts += -no-feature-wizard # Needed +$(package)_config_opts += -no-feature-fontconfig + +$(package)_config_opts += -xcb +$(package)_config_opts += -no-xcb-xlib +$(package)_config_opts += -no-feature-xlib +#$(package)_config_opts += -feature-ffmpeg +#$(package)_config_opts += -feature-pulseaudio + +# https://bugreports.qt.io/browse/QTBUG-99957 +$(package)_config_opts += -no-pch + +$(package)_config_opts += -no-opengl +$(package)_config_opts += -no-feature-vulkan +ifneq ($(LTO),) +$(package)_config_opts += -ltcg +endif +$(package)_config_opts += -platform linux-g++ -xplatform bitcoin-linux-g++ +ifneq (,$(findstring -stdlib=libc++,$($(1)_cxx))) +$(package)_config_opts_x86_64 = -xplatform linux-clang-libc++ +endif + +$(package)_config_opts_aarch64_android += -android-arch arm64-v8a +$(package)_config_opts_armv7a_android += -android-arch armeabi-v7a +$(package)_config_opts_x86_64_android += -android-arch x86_64 + +endef + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttranslations_file_name),$($(package)_qttranslations_file_name),$($(package)_qttranslations_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttools_file_name),$($(package)_qttools_file_name),$($(package)_qttools_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtsvg_file_name),$($(package)_qtsvg_file_name),$($(package)_qtsvg_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtmultimedia_file_name),$($(package)_qtmultimedia_file_name),$($(package)_qtmultimedia_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtshadertools_file_name),$($(package)_qtshadertools_file_name),$($(package)_qtshadertools_sha256_hash)) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qttranslations_sha256_hash) $($(package)_source_dir)/$($(package)_qttranslations_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qttools_sha256_hash) $($(package)_source_dir)/$($(package)_qttools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtsvg_sha256_hash) $($(package)_source_dir)/$($(package)_qtsvg_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtmultimedia_sha256_hash) $($(package)_source_dir)/$($(package)_qtmultimedia_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtshadertools_sha256_hash) $($(package)_source_dir)/$($(package)_qtshadertools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir qtbase && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \ + mkdir qttranslations && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \ + mkdir qttools && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools && \ + mkdir qtsvg && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtsvg_file_name) -C qtsvg && \ + mkdir qtmultimedia && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtmultimedia_file_name) -C qtmultimedia && \ + mkdir qtshadertools && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtshadertools_file_name) -C qtshadertools +endef + +define $(package)_preprocess_cmds + cp $($(package)_patch_dir)/root_CMakeLists.txt CMakeLists.txt && \ + patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \ + patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \ + patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \ + patch -p1 -i $($(package)_patch_dir)/rcc_hardcode_timestamp.patch && \ + patch -p1 -i $($(package)_patch_dir)/fast_fixed_dtoa_no_optimize.patch && \ + patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \ + patch -p1 -i $($(package)_patch_dir)/no-statx.patch && \ + patch -p1 -i $($(package)_patch_dir)/no-renameat2.patch && \ + patch -p1 -i $($(package)_patch_dir)/no_pthread_cond_clockwait.patch && \ + cd qtbase && \ + patch -p1 -i $($(package)_patch_dir)/Use-consistent-ordering-in-QShader.patch && \ + patch -p1 -i $($(package)_patch_dir)/QShader_map.patch && \ + cd .. && \ + mkdir -p qtbase/mkspecs/macx-clang-linux &&\ + cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ + cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ + cp -r qtbase/mkspecs/linux-arm-gnueabi-g++ qtbase/mkspecs/bitcoin-linux-g++ && \ + sed -i.old "s|arm-linux-gnueabi-gcc|$($($(package)_type)_CC)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-g++|$($($(package)_type)_CXX)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-ar|$($($(package)_type)_AR)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-objcopy|$($($(package)_type)_OBJCOPY)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-nm|$($($(package)_type)_NM)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-strip|$($($(package)_type)_STRIP)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + sed -i.old "s|QMAKE_CC = \$$$$\$$$${CROSS_COMPILE}clang|QMAKE_CC = $($(package)_cc)|" qtbase/mkspecs/common/clang.conf && \ + sed -i.old "s|QMAKE_CXX = \$$$$\$$$${CROSS_COMPILE}clang++|QMAKE_CXX = $($(package)_cxx)|" qtbase/mkspecs/common/clang.conf +endef + +define $(package)_config_cmds + export PKG_CONFIG_SYSROOT_DIR=/ && \ + export PKG_CONFIG_LIBDIR=$(build_prefix)/lib/pkgconfig && \ + export QT_MAC_SDK_NO_VERSION_CHECK=1 && \ + cd qtbase && \ + ./configure -top-level $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + DESTDIR=$($(package)_staging_dir) cmake --install . +endef diff --git a/contrib/depends/packages/native_squashfs-tools.mk b/contrib/depends/packages/native_squashfs-tools.mk new file mode 100644 index 0000000..b6ea9e8 --- /dev/null +++ b/contrib/depends/packages/native_squashfs-tools.mk @@ -0,0 +1,15 @@ +package=native_squashfs-tools +$(package)_version=4.5.1 +$(package)_download_path=https://github.com/plougher/squashfs-tools/archive/refs/tags +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=277b6e7f75a4a57f72191295ae62766a10d627a4f5e5f19eadfbc861378deea7 + +define $(package)_build_cmds + cd squashfs-tools && \ + $(MAKE) +endef + +define $(package)_stage_cmds + cd squashfs-tools && \ + $(MAKE) INSTALL_DIR=$($(package)_staging_dir)$(build_prefix) INSTALL_MANPAGES_DIR="" install +endef \ No newline at end of file diff --git a/contrib/depends/packages/native_xcb_proto.mk b/contrib/depends/packages/native_xcb_proto.mk new file mode 100644 index 0000000..cc80531 --- /dev/null +++ b/contrib/depends/packages/native_xcb_proto.mk @@ -0,0 +1,21 @@ +package=native_xcb_proto +$(package)_version=1.14.1 +$(package)_download_path=https://xorg.freedesktop.org/archive/individual/proto +$(package)_file_name=xcb-proto-$($(package)_version).tar.xz +$(package)_sha256_hash=f04add9a972ac334ea11d9d7eb4fc7f8883835da3e4859c9afa971efdf57fcc3 + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf lib/python*/site-packages/xcbgen/__pycache__ +endef diff --git a/contrib/depends/packages/native_xproto.mk b/contrib/depends/packages/native_xproto.mk new file mode 100644 index 0000000..2d1077c --- /dev/null +++ b/contrib/depends/packages/native_xproto.mk @@ -0,0 +1,26 @@ +package=native_xproto +$(package)_version=7.0.31 +$(package)_download_path=https://xorg.freedesktop.org/releases/individual/proto +$(package)_file_name=xproto-$($(package)_version).tar.bz2 +$(package)_sha256_hash=c6f9747da0bd3a95f86b17fb8dd5e717c8f3ab7f0ece3ba1b247899ec1ef7747 + +define $(package)_set_vars + $(package)_config_opts=--without-fop --without-xmlto --without-xsltproc --disable-specs + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/openssl.mk b/contrib/depends/packages/openssl.mk new file mode 100644 index 0000000..ffa195c --- /dev/null +++ b/contrib/depends/packages/openssl.mk @@ -0,0 +1,70 @@ +package=openssl +$(package)_version=1.1.1q +$(package)_download_path=https://www.openssl.org/source +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca + +define $(package)_set_vars +$(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" +$(package)_config_env_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib +$(package)_build_env_android=ANDROID_NDK_HOME="$(host_prefix)/native" +$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl +$(package)_config_opts+=no-capieng +$(package)_config_opts+=no-dso +$(package)_config_opts+=no-dtls1 +$(package)_config_opts+=no-ec_nistp_64_gcc_128 +$(package)_config_opts+=no-gost +$(package)_config_opts+=no-heartbeats +$(package)_config_opts+=no-md2 +$(package)_config_opts+=no-rc5 +$(package)_config_opts+=no-rdrand +$(package)_config_opts+=no-rfc3779 +$(package)_config_opts+=no-sctp +$(package)_config_opts+=no-shared +$(package)_config_opts+=no-ssl-trace +$(package)_config_opts+=no-ssl2 +$(package)_config_opts+=no-ssl3 +$(package)_config_opts+=no-unit-test +$(package)_config_opts+=no-weak-ssl-ciphers +$(package)_config_opts+=no-zlib +$(package)_config_opts+=no-zlib-dynamic +$(package)_config_opts+=$($(package)_cflags) $($(package)_cppflags) +$(package)_config_opts_linux=-fPIC -Wa,--noexecstack +$(package)_config_opts_freebsd=-fPIC -Wa,--noexecstack +$(package)_config_opts_x86_64_linux=linux-x86_64 +$(package)_config_opts_i686_linux=linux-generic32 +$(package)_config_opts_arm_linux=linux-generic32 +$(package)_config_opts_aarch64_linux=linux-generic64 +$(package)_config_opts_arm_android=--static android-arm +$(package)_config_opts_aarch64_android=--static android-arm64 +$(package)_config_opts_aarch64_darwin=darwin64-arm64-cc +$(package)_config_opts_riscv64_linux=linux-generic64 +$(package)_config_opts_mipsel_linux=linux-generic32 +$(package)_config_opts_mips_linux=linux-generic32 +$(package)_config_opts_powerpc_linux=linux-generic32 +$(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc +$(package)_config_opts_x86_64_mingw32=mingw64 +$(package)_config_opts_i686_mingw32=mingw +$(package)_config_opts_x86_64_freebsd=BSD-x86_64 +endef + +define $(package)_preprocess_cmds + printenv && \ + sed -i.old 's|"engines", "apps", "test", "util", "tools", "fuzz"|"engines", "tools"|' Configure +endef + +define $(package)_config_cmds + ./Configure $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) build_libs +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install_sw +endef + +define $(package)_postprocess_cmds + rm -rf share bin etc +endef diff --git a/contrib/depends/packages/packages.mk b/contrib/depends/packages/packages.mk new file mode 100644 index 0000000..6e487c0 --- /dev/null +++ b/contrib/depends/packages/packages.mk @@ -0,0 +1,19 @@ +packages := boost openssl libiconv ldns unbound qrencode zbar sodium polyseed hidapi protobuf libusb zlib libgpg-error libgcrypt expat libzip +native_packages := native_cmake native_expat native_libxcb native_xcb_proto native_libXau native_xproto native_freetype native_fontconfig native_libxkbcommon native_libxcb_util native_libxcb_util_render native_libxcb_util_keysyms native_libxcb_util_image native_libxcb_util_wm native_qt native_protobuf + +linux_packages := eudev liblzma libarchive libfuse libsquashfuse libappimage appimage_runtime +linux_native_packages = native_patchelf + +darwin_packages := +darwin_native_packages = native_cctools native_libtapi native_clang native_ds_store native_mac_alias + +mingw32_packages = icu4c +mingw32_native_packages = + +qt_linux_packages := libxcb xcb_proto libXau xproto libxkbcommon libxcb_util libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm freetype fontconfig qt +qt_darwin_packages := qt +qt_mingw32_packages := qt + +tor_linux_packages := libevent tor_linux +tor_darwin_packages := tor_darwin +tor_mingw32_packages := tor_mingw32 \ No newline at end of file diff --git a/contrib/depends/packages/polyseed.mk b/contrib/depends/packages/polyseed.mk new file mode 100644 index 0000000..726aa71 --- /dev/null +++ b/contrib/depends/packages/polyseed.mk @@ -0,0 +1,25 @@ +package=polyseed +$(package)_version=1.0.0 +$(package)_download_path=https://github.com/tevador/polyseed/archive/refs/tags/ +$(package)_file_name=v$($(package)_version).tar.gz +$(package)_sha256_hash=45f1e6c08575286581079e6e26d341a3a33abe1f1ee2d026bd098cf632ea2349 +$(package)_dependencies=native_cmake +$(package)_patches=no_shared.patch force-static-mingw.patch 32-bit.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/no_shared.patch && \ + patch -p1 < $($(package)_patch_dir)/force-static-mingw.patch && \ + patch -p1 < $($(package)_patch_dir)/32-bit.patch +endef + +define $(package)_config_cmds + $($(package)_cmake) -DCMAKE_INSTALL_PREFIX=$(host_prefix) -DCMAKE_C_COMPILER= . +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/protobuf.mk b/contrib/depends/packages/protobuf.mk new file mode 100644 index 0000000..81fa78a --- /dev/null +++ b/contrib/depends/packages/protobuf.mk @@ -0,0 +1,31 @@ +package=protobuf +$(package)_version=$(native_$(package)_version) +$(package)_download_path=$(native_$(package)_download_path) +$(package)_file_name=$(native_$(package)_file_name) +$(package)_sha256_hash=$(native_$(package)_sha256_hash) +$(package)_dependencies=native_$(package) +$(package)_cxxflags=-std=c++11 + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) -C src libprotobuf.la +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) -C src install-libLTLIBRARIES install-nobase_includeHEADERS &&\ + $(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA +endef + +define $(package)_postprocess_cmds + rm lib/libprotoc.a &&\ + rm lib/*.la +endef + diff --git a/contrib/depends/packages/qrencode.mk b/contrib/depends/packages/qrencode.mk new file mode 100644 index 0000000..b375a84 --- /dev/null +++ b/contrib/depends/packages/qrencode.mk @@ -0,0 +1,33 @@ +package=qrencode +$(package)_version=3.4.4 +$(package)_download_path=https://fukuchi.org/works/qrencode/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=efe5188b1ddbcbf98763b819b146be6a90481aac30cfc8d858ab78a19cde1fa5 + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --without-tools --without-tests --disable-sdltest + $(package)_config_opts += --disable-gprof --disable-gcov --disable-mudflap + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking + $(package)_config_opts_linux=--with-pic + $(package)_config_opts_android=--with-pic +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub use +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/contrib/depends/packages/qt.mk b/contrib/depends/packages/qt.mk new file mode 100644 index 0000000..0045c1a --- /dev/null +++ b/contrib/depends/packages/qt.mk @@ -0,0 +1,360 @@ +package=qt +$(package)_version=6.4.1 +$(package)_download_path=https://download.qt.io/official_releases/qt/6.4/$($(package)_version)/submodules +$(package)_suffix=everywhere-src-$($(package)_version).tar.xz +$(package)_file_name=qtbase-$($(package)_suffix) +$(package)_sha256_hash=532ad71cc0f9c8f7cb92766c47bc3d23263c60876becd9053802f9727af24fae +$(package)_darwin_dependencies=native_cctools native_qt openssl +$(package)_mingw32_dependencies=openssl native_cmake native_qt native_freetype native_fontconfig native_libxkbcommon +$(package)_linux_dependencies=openssl native_qt native_cmake native_freetype native_fontconfig libxcb libxkbcommon libxcb_util libxcb_util_render libxcb_util_keysyms libxcb_util_image libxcb_util_wm +$(package)_qt_libs=corelib network widgets gui plugins testlib +$(package)_linguist_tools = lrelease lupdate lconvert +$(package)_patches = aarch64Toolchain.cmake +$(package)_patches += dont_hardcode_pwd.patch +$(package)_patches += fast_fixed_dtoa_no_optimize.patch +$(package)_patches += gnueabihfToolchain.cmake +$(package)_patches += guix_cross_lib_path.patch +$(package)_patches += ___isOSVersionAtLeast_hack.patch +$(package)_patches += mac-qmake.conf +$(package)_patches += MacToolchain.cmake +$(package)_patches += no_pthread_cond_clockwait.patch +$(package)_patches += no-renameat2.patch +$(package)_patches += no-statx.patch +$(package)_patches += no_wraprt_on_apple.patch +$(package)_patches += no-xlib.patch +$(package)_patches += qtbase-moc-ignore-gcc-macro.patch +$(package)_patches += qtmultimedia-fixes.patch +$(package)_patches += rcc_hardcode_timestamp.patch +$(package)_patches += root_CMakeLists.txt +$(package)_patches += windows_func_fix.patch +$(package)_patches += WindowsToolchain.cmake +$(package)_patches += Use-consistent-ordering-in-QShader.patch +$(package)_patches += QShader_map.patch + +$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) +$(package)_qttranslations_sha256_hash=44dbc6f1d256d2048c96fa665c240e0075c2e67188c93986a39ede3556a16a12 + +$(package)_qttools_file_name=qttools-$($(package)_suffix) +$(package)_qttools_sha256_hash=9e20562c6b04c21fbdb4ed89e59226169ffeaafaab8f45f7d81ea49b0e4b0933 + +$(package)_qtsvg_file_name=qtsvg-$($(package)_suffix) +$(package)_qtsvg_sha256_hash=5e5345c5941567db883f9daf8ab25108c6f3a527453b1a13c62290849bce9ce5 + +$(package)_qtwebsockets_file_name=qtwebsockets-$($(package)_suffix) +$(package)_qtwebsockets_sha256_hash=537789ea56403ea8a15e115d7f503c3ead630192e97ec99464810fcdb5d67a24 + +$(package)_qtmultimedia_file_name=qtmultimedia-$($(package)_suffix) +$(package)_qtmultimedia_sha256_hash=c086d43a026e6090971fd7a697ef8370c5c455115240609cd08d5e2f840dbaaf + +$(package)_qtshadertools_file_name=qtshadertools-$($(package)_suffix) +$(package)_qtshadertools_sha256_hash=6bc1748326088c87f562fa3a68140e33fde162fd1333fbfecb775aeb66114504 + +$(package)_extra_sources = $($(package)_qttranslations_file_name) +$(package)_extra_sources += $($(package)_qttools_file_name) +$(package)_extra_sources += $($(package)_qtsvg_file_name) +$(package)_extra_sources += $($(package)_qtwebsockets_file_name) +$(package)_extra_sources += $($(package)_qtmultimedia_file_name) +$(package)_extra_sources += $($(package)_qtshadertools_file_name) + +define $(package)_set_vars +$(package)_config_opts_release = -release +$(package)_config_opts_debug = -debug +$(package)_config_opts_debug += -optimized-tools +$(package)_config_opts += -libexecdir $(build_prefix)/bin +$(package)_config_opts += -confirm-license +$(package)_config_opts += -no-cups +$(package)_config_opts += -no-egl +$(package)_config_opts += -no-eglfs +$(package)_config_opts += -no-evdev +$(package)_config_opts += -no-gif +$(package)_config_opts += -no-glib +$(package)_config_opts += -no-icu +$(package)_config_opts += -no-ico +$(package)_config_opts += -no-kms +$(package)_config_opts += -no-linuxfb +#$(package)_config_opts += -no-libjpeg # Needed +#$(package)_config_opts += -no-libproxy # Needed +$(package)_config_opts += -no-libudev +$(package)_config_opts += -no-mtdev +#$(package)_config_opts += -no-openssl # Needed +$(package)_config_opts_mingw32 += -openssl-linked +$(package)_config_opts_linux += -openssl-linked +$(package)_config_opts += -no-openvg +$(package)_config_opts += -no-reduce-relocations +$(package)_config_opts += -no-schannel +$(package)_config_opts += -no-sctp +$(package)_config_opts += -no-securetransport +$(package)_config_opts += -no-system-proxies +$(package)_config_opts += -no-use-gold-linker +$(package)_config_opts += -no-zstd +$(package)_config_opts += -nomake examples +$(package)_config_opts += -nomake tests +$(package)_config_opts += -opensource +$(package)_config_opts += -pkg-config +$(package)_config_opts += -prefix $(host_prefix) +$(package)_config_opts += -qt-libpng +$(package)_config_opts += -qt-pcre +$(package)_config_opts += -qt-harfbuzz +$(package)_config_opts += -qt-zlib +$(package)_config_opts += -static +$(package)_config_opts += -no-feature-colordialog +#$(package)_config_opts += -no-feature-concurrent # Needed +$(package)_config_opts += -no-feature-dial +$(package)_config_opts += -no-feature-fontcombobox +$(package)_config_opts += -no-feature-http +$(package)_config_opts += -no-feature-image_heuristic_mask +$(package)_config_opts += -no-feature-keysequenceedit +$(package)_config_opts += -no-feature-lcdnumber +$(package)_config_opts += -no-feature-networkdiskcache +#$(package)_config_opts += -no-feature-networkproxy # Needed +$(package)_config_opts += -no-feature-pdf +$(package)_config_opts += -no-feature-printdialog +$(package)_config_opts += -no-feature-printer +$(package)_config_opts += -no-feature-printpreviewdialog +$(package)_config_opts += -no-feature-printpreviewwidget +$(package)_config_opts += -no-feature-printsupport +$(package)_config_opts += -no-feature-sessionmanager +#$(package)_config_opts += -no-feature-socks5 # Needed +$(package)_config_opts += -no-feature-sql +$(package)_config_opts += -no-feature-syntaxhighlighter +#$(package)_config_opts += -no-feature-textbrowser # Needed +$(package)_config_opts += -no-feature-textmarkdownwriter +$(package)_config_opts += -no-feature-textodfwriter +$(package)_config_opts += -no-feature-topleveldomain +#$(package)_config_opts += -no-feature-udpsocket # Neede +$(package)_config_opts += -no-feature-undocommand +$(package)_config_opts += -no-feature-undogroup +$(package)_config_opts += -no-feature-undostack +$(package)_config_opts += -no-feature-undoview +$(package)_config_opts += -no-feature-vnc +#$(package)_config_opts += -no-feature-wizard # Needed + +$(package)_config_opts_darwin = -no-dbus +$(package)_config_opts_darwin += -no-opengl +$(package)_config_opts_darwin += -no-pch +$(package)_config_opts_darwin += -no-freetype +$(package)_config_opts_darwin += QMAKE_MACOSX_DEPLOYMENT_TARGET=$(OSX_MIN_VERSION) + +ifneq ($(build_os),darwin) +$(package)_config_opts_darwin += -xplatform macx-clang-linux +$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(OSX_SDK) +$(package)_config_opts_darwin += -device-option MAC_SDK_VERSION=$(OSX_SDK_VERSION) +$(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-" +$(package)_config_opts_darwin += -device-option MAC_TARGET=$(host) +$(package)_config_opts_darwin += -device-option XCODE_VERSION=$(XCODE_VERSION) +$(package)_config_opts_darwin += -qt-host-path $(build_prefix)/qt-host +endif + +ifneq ($(build_arch),$(host_arch)) +$(package)_config_opts_aarch64_darwin += -device-option QMAKE_APPLE_DEVICE_ARCHS=arm64 +$(package)_config_opts_x86_64_darwin += -device-option QMAKE_APPLE_DEVICE_ARCHS=x86_64 +endif + +$(package)_config_opts_darwin += -no-feature-ffmpeg +$(package)_config_opts_darwin += -- -DCMAKE_TOOLCHAIN_FILE=MacToolchain.cmake -DCMAKE_LIBRARY_PATH=$(HOME)/.guix-profile/lib + +$(package)_config_opts_linux = -xcb +$(package)_config_opts_linux += -no-xcb-xlib +$(package)_config_opts_linux += -no-feature-xlib +#$(package)_config_opts_linux += -feature-ffmpeg +#$(package)_config_opts_linux += -feature-pulseaudio + +# https://bugreports.qt.io/browse/QTBUG-99957 +$(package)_config_opts_linux += -no-pch + +$(package)_config_opts_linux += -system-freetype +$(package)_config_opts_linux += -fontconfig +$(package)_config_opts_linux += -no-opengl +$(package)_config_opts_linux += -no-feature-vulkan +$(package)_config_opts_linux += -dbus-runtime +ifneq ($(LTO),) +$(package)_config_opts_linux += -ltcg +endif +$(package)_config_opts_linux += -platform linux-g++ -xplatform bitcoin-linux-g++ +ifneq (,$(findstring -stdlib=libc++,$($(1)_cxx))) +$(package)_config_opts_x86_64_linux = -xplatform linux-clang-libc++ +endif + +$(package)_config_opts_arm_linux += -qt-host-path $(build_prefix)/qt-host +$(package)_config_opts_arm_linux += -- -DCMAKE_TOOLCHAIN_FILE=gnueabihfToolchain.cmake -DCMAKE_LIBRARY_PATH=$(HOME)/.guix-profile/lib + +$(package)_config_opts_aarch64_linux += -qt-host-path $(build_prefix)/qt-host +$(package)_config_opts_aarch64_linux += -- -DCMAKE_TOOLCHAIN_FILE=aarch64Toolchain.cmake -DCMAKE_LIBRARY_PATH=$(HOME)/.guix-profile/lib + +$(package)_config_opts_mingw32 += -no-opengl +$(package)_config_opts_mingw32 += -no-dbus +$(package)_config_opts_mingw32 += -no-freetype +$(package)_config_opts_mingw32 += -xplatform win32-g++ +$(package)_config_opts_mingw32 += -device-option CROSS_COMPILE="$(host)-" +$(package)_config_opts_mingw32 += -pch +$(package)_config_opts_mingw32 += -qt-host-path $(build_prefix)/qt-host +$(package)_config_opts_mingw32 += -no-feature-ffmpeg +$(package)_config_opts_mingw32 += -wmf +$(package)_config_opts_mingw32 += -- -DCMAKE_TOOLCHAIN_FILE=WindowsToolchain.cmake -DCMAKE_LIBRARY_PATH=$(HOME)/.guix-profile/lib + +$(package)_config_opts_android = -xplatform android-clang +$(package)_config_opts_android += -android-sdk $(ANDROID_SDK) +$(package)_config_opts_android += -android-ndk $(ANDROID_NDK) +$(package)_config_opts_android += -android-ndk-platform android-$(ANDROID_API_LEVEL) +$(package)_config_opts_android += -egl +$(package)_config_opts_android += -no-dbus +$(package)_config_opts_android += -opengl es2 +$(package)_config_opts_android += -qt-freetype +$(package)_config_opts_android += -no-fontconfig +$(package)_config_opts_android += -L $(host_prefix)/lib +$(package)_config_opts_android += -I $(host_prefix)/include +$(package)_config_opts_android += -pch +$(package)_config_opts_android += -no-feature-vulkan + +$(package)_config_opts_aarch64_android += -android-arch arm64-v8a +$(package)_config_opts_armv7a_android += -android-arch armeabi-v7a +$(package)_config_opts_x86_64_android += -android-arch x86_64 + +$(package)_openssl_flags_$(host_os)="-lssl -lcrypto -lpthread -ldl" +$(package)_openssl_flags_mingw32="-lssl -lcrypto -lws2_32" +endef + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttranslations_file_name),$($(package)_qttranslations_file_name),$($(package)_qttranslations_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttools_file_name),$($(package)_qttools_file_name),$($(package)_qttools_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtsvg_file_name),$($(package)_qtsvg_file_name),$($(package)_qtsvg_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtwebsockets_file_name),$($(package)_qtwebsockets_file_name),$($(package)_qtwebsockets_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtmultimedia_file_name),$($(package)_qtmultimedia_file_name),$($(package)_qtmultimedia_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qtshadertools_file_name),$($(package)_qtshadertools_file_name),$($(package)_qtshadertools_sha256_hash)) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qttranslations_sha256_hash) $($(package)_source_dir)/$($(package)_qttranslations_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qttools_sha256_hash) $($(package)_source_dir)/$($(package)_qttools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtsvg_sha256_hash) $($(package)_source_dir)/$($(package)_qtsvg_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtwebsockets_sha256_hash) $($(package)_source_dir)/$($(package)_qtwebsockets_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtmultimedia_sha256_hash) $($(package)_source_dir)/$($(package)_qtmultimedia_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qtshadertools_sha256_hash) $($(package)_source_dir)/$($(package)_qtshadertools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir qtbase && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \ + mkdir qttranslations && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \ + mkdir qttools && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools && \ + mkdir qtsvg && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtsvg_file_name) -C qtsvg && \ + mkdir qtwebsockets && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtwebsockets_file_name) -C qtwebsockets && \ + mkdir qtmultimedia && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtmultimedia_file_name) -C qtmultimedia && \ + mkdir qtshadertools && \ + $(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qtshadertools_file_name) -C qtshadertools +endef + +define $(package)_preprocess_cmds + cp $($(package)_patch_dir)/root_CMakeLists.txt CMakeLists.txt && \ + patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \ + patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \ + patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \ + patch -p1 -i $($(package)_patch_dir)/rcc_hardcode_timestamp.patch && \ + patch -p1 -i $($(package)_patch_dir)/fast_fixed_dtoa_no_optimize.patch && \ + patch -p1 -i $($(package)_patch_dir)/guix_cross_lib_path.patch && \ + patch -p1 -i $($(package)_patch_dir)/no-statx.patch && \ + patch -p1 -i $($(package)_patch_dir)/no-renameat2.patch && \ + patch -p1 -i $($(package)_patch_dir)/no_pthread_cond_clockwait.patch && \ + patch -p1 -i $($(package)_patch_dir)/windows_func_fix.patch && \ + patch -p1 -i $($(package)_patch_dir)/no_wraprt_on_apple.patch && \ + patch -p1 -i $($(package)_patch_dir)/___isOSVersionAtLeast_hack.patch && \ + mv $($(package)_patch_dir)/WindowsToolchain.cmake . && \ + mv $($(package)_patch_dir)/MacToolchain.cmake . && \ + mv $($(package)_patch_dir)/aarch64Toolchain.cmake . && \ + mv $($(package)_patch_dir)/gnueabihfToolchain.cmake . && \ + cd qtbase && \ + patch -p1 -i $($(package)_patch_dir)/Use-consistent-ordering-in-QShader.patch && \ + patch -p1 -i $($(package)_patch_dir)/QShader_map.patch && \ + cd .. && \ + cd qtmultimedia && \ + patch -p1 -i $($(package)_patch_dir)/qtmultimedia-fixes.patch && \ + cd .. && \ + mkdir -p qtbase/mkspecs/macx-clang-linux &&\ + cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ + cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ + cp -r qtbase/mkspecs/linux-arm-gnueabi-g++ qtbase/mkspecs/bitcoin-linux-g++ && \ + sed -i.old "s|arm-linux-gnueabi-gcc|$($($(package)_type)_CC)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-g++|$($($(package)_type)_CXX)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-ar|$($($(package)_type)_AR)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-objcopy|$($($(package)_type)_OBJCOPY)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-nm|$($($(package)_type)_NM)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + sed -i.old "s|arm-linux-gnueabi-strip|$($($(package)_type)_STRIP)|" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \ + echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + sed -i.old "s|QMAKE_CC = \$$$$\$$$${CROSS_COMPILE}clang|QMAKE_CC = $($(package)_cc)|" qtbase/mkspecs/common/clang.conf && \ + sed -i.old "s|QMAKE_CXX = \$$$$\$$$${CROSS_COMPILE}clang++|QMAKE_CXX = $($(package)_cxx)|" qtbase/mkspecs/common/clang.conf +endef + +# TODO: this is a mess, but i'm tired of rebuilding Qt so it is what it is +# TODO: find a better way to make WMF libraries available to Qt without polluting the environment +ifeq ($(host_os),darwin) +define $(package)_config_cmds + export OPENSSL_LIBS=${$(package)_openssl_flags_$(host_os)} \ + export PKG_CONFIG_SYSROOT_DIR=/ && \ + export PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig && \ + export QT_MAC_SDK_NO_VERSION_CHECK=1 && \ + cd qtbase && \ + env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH ./configure -top-level $($(package)_config_opts) --debug-find-pkg=Threads -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON +endef +else ifeq ($(host_os),mingw32) +define $(package)_config_cmds + cp $(HOME)/.guix-profile/lib/libstrmiids.a \ + $(HOME)/.guix-profile/lib/libamstrmid.a \ + $(HOME)/.guix-profile/lib/libdmoguids.a \ + $(HOME)/.guix-profile/lib/libuuid.a \ + $(HOME)/.guix-profile/lib/libmsdmo.a \ + $(HOME)/.guix-profile/lib/libole32.a \ + $(HOME)/.guix-profile/lib/liboleaut32.a \ + $(HOME)/.guix-profile/lib/libmf.a \ + $(HOME)/.guix-profile/lib/libmfuuid.a \ + $(HOME)/.guix-profile/lib/libmfplat.a \ + $(HOME)/.guix-profile/lib/libmfcore.a \ + $(HOME)/.guix-profile/lib/libpropsys.a \ + /feather/contrib/depends/x86_64-w64-mingw32/lib/ && \ + export OPENSSL_LIBS=${$(package)_openssl_flags_$(host_os)} \ + export PKG_CONFIG_SYSROOT_DIR=/ && \ + export PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig && \ + export QT_MAC_SDK_NO_VERSION_CHECK=1 && \ + export V=1 && \ + export VERBOSE=1 && \ + cd qtbase && \ + ./configure -top-level $($(package)_config_opts) -DCMAKE_LIBRARY_PATH=$(HOME)/.guix-profile/lib --debug-find-pkg=WMF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON +endef +else +define $(package)_config_cmds + export OPENSSL_LIBS=${$(package)_openssl_flags_$(host_os)} \ + export PKG_CONFIG_SYSROOT_DIR=/ && \ + export PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig && \ + export QT_MAC_SDK_NO_VERSION_CHECK=1 && \ + cd qtbase && \ + ./configure -top-level $($(package)_config_opts) +endef +endif + +ifeq ($(host_os),darwin) +define $(package)_build_cmds + export LD_LIBRARY_PATH=${build_prefix}/lib/ && \ + env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH -u LIBRARY_PATH $(MAKE) +endef +else ifeq ($(host_os),mingw32) +define $(package)_build_cmds + export LD_LIBRARY_PATH=${build_prefix}/lib/ && \ + $(MAKE) +endef +else +define $(package)_build_cmds + export LD_LIBRARY_PATH=${build_prefix}/lib/ && \ + $(MAKE) +endef +endif + +define $(package)_stage_cmds + DESTDIR=$($(package)_staging_dir) cmake --install . +endef diff --git a/contrib/depends/packages/sodium.mk b/contrib/depends/packages/sodium.mk new file mode 100644 index 0000000..b581bbd --- /dev/null +++ b/contrib/depends/packages/sodium.mk @@ -0,0 +1,33 @@ +package=sodium +$(package)_version=1.0.18 +$(package)_download_path=https://download.libsodium.org/libsodium/releases/ +$(package)_file_name=libsodium-$($(package)_version).tar.gz +$(package)_sha256_hash=6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1 +$(package)_patches=disable-glibc-getrandom-getentropy.patch fix-whitespace.patch + +define $(package)_set_vars + $(package)_config_opts=--enable-static --disable-shared + $(package)_config_opts+=--prefix=$(host_prefix) +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/disable-glibc-getrandom-getentropy.patch &&\ + autoconf &&\ + patch -p1 < $($(package)_patch_dir)/fix-whitespace.patch +endef + +define $(package)_config_cmds + $($(package)_autoconf) AR_FLAGS=$($(package)_arflags) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm lib/*.la +endef diff --git a/contrib/depends/packages/tor_darwin.mk b/contrib/depends/packages/tor_darwin.mk new file mode 100644 index 0000000..4f88af8 --- /dev/null +++ b/contrib/depends/packages/tor_darwin.mk @@ -0,0 +1,14 @@ +package=tor_darwin +$(package)_version=0.4.7.12 +$(package)_download_path=https://dist.torproject.org/torbrowser/12.0.1/ +$(package)_file_name=TorBrowser-12.0.1-macos_ALL.dmg +$(package)_sha256_hash=b4b52e1e5a2a0c4e1c68cf36dc8054fd1eb826d43f2622b56ef65e0f9f5db845 +$(package)_extract_cmds=mkdir -p $$($(1)_extract_dir) && \ + echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && \ + $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && \ + 7z x $$($(1)_source) + +define $(package)_stage_cmds + mv Tor\ Browser.app/Contents/MacOS/Tor/tor.real Tor\ Browser.app/Contents/MacOS/Tor/tor && \ + cp -a Tor\ Browser.app/Contents/MacOS/Tor $($(package)_staging_prefix_dir)/Tor/ +endef \ No newline at end of file diff --git a/contrib/depends/packages/tor_linux.mk b/contrib/depends/packages/tor_linux.mk new file mode 100644 index 0000000..b1be8a7 --- /dev/null +++ b/contrib/depends/packages/tor_linux.mk @@ -0,0 +1,34 @@ +package=tor_linux +$(package)_version=0.4.7.12 +$(package)_download_path=https://dist.torproject.org/ +$(package)_file_name=tor-$($(package)_version).tar.gz +$(package)_sha256_hash=3b5d969712c467851bd028f314343ef15a97ea457191e93ffa97310b05b9e395 +$(package)_dependencies=libevent openssl zlib + +define $(package)_set_vars + $(package)_config_opts=--disable-asciidoc --disable-manpage --disable-html-manual --disable-system-torrc + $(package)_config_opts+=--disable-module-relay --disable-lzma --disable-zstd --enable-static-tor + $(package)_config_opts+=--with-libevent-dir=$(host_prefix) --with-openssl-dir=$(host_prefix) + $(package)_config_opts+=--with-zlib-dir=$(host_prefix) --disable-tool-name-check --enable-fatal-warnings + $(package)_config_opts+=--prefix=$(host_prefix) + $(package)_cflags+=-O2 + $(package)_cxxflags+=-O2 +endef + +define $(package)_config_cmds + $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + $(host_toolchain)strip -s -D bin/tor && \ + mkdir $($(package)_staging_prefix_dir)/Tor/ && \ + cp bin/tor $($(package)_staging_prefix_dir)/Tor +endef \ No newline at end of file diff --git a/contrib/depends/packages/tor_mingw32.mk b/contrib/depends/packages/tor_mingw32.mk new file mode 100644 index 0000000..cc0a13e --- /dev/null +++ b/contrib/depends/packages/tor_mingw32.mk @@ -0,0 +1,10 @@ +package=tor_mingw32 +$(package)_version=0.4.7.12 +$(package)_download_path=https://dist.torproject.org/torbrowser/12.0.1/ +$(package)_file_name=tor-expert-bundle-12.0.1-windows-x86_64.tar.gz +$(package)_sha256_hash=f53cfbc4f4454a265f10a853219b40067ef73feffc4a7d67472b61dbab9129ba + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/Tor/ && \ + cp tor.exe $($(package)_staging_prefix_dir)/Tor/ +endef \ No newline at end of file diff --git a/contrib/depends/packages/unbound.mk b/contrib/depends/packages/unbound.mk new file mode 100644 index 0000000..2c14856 --- /dev/null +++ b/contrib/depends/packages/unbound.mk @@ -0,0 +1,25 @@ +package=unbound +$(package)_version=1.13.2 +$(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/ +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=0a13b547f3b92a026b5ebd0423f54c991e5718037fd9f72445817f6a040e1a83 +$(package)_dependencies=openssl expat ldns + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --enable-static --without-pyunbound --prefix=$(host_prefix) --with-libexpat=$(host_prefix) --with-ssl=$(host_prefix) --with-libevent=no --without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only + $(package)_config_opts_linux=--with-pic + $(package)_config_opts_w64=--enable-static-exe --sysconfdir=/etc --prefix=$(host_prefix) --target=$(host_prefix) + $(package)_build_opts_mingw32=LDFLAGS="$($(package)_ldflags) -lpthread" +endef + +define $(package)_config_cmds + $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) $($(package)_build_opts) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/xcb_proto.mk b/contrib/depends/packages/xcb_proto.mk new file mode 100644 index 0000000..9be8225 --- /dev/null +++ b/contrib/depends/packages/xcb_proto.mk @@ -0,0 +1,21 @@ +package=xcb_proto +$(package)_version=1.14.1 +$(package)_download_path=https://xorg.freedesktop.org/archive/individual/proto +$(package)_file_name=xcb-proto-$($(package)_version).tar.xz +$(package)_sha256_hash=f04add9a972ac334ea11d9d7eb4fc7f8883835da3e4859c9afa971efdf57fcc3 + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf lib/python*/site-packages/xcbgen/__pycache__ +endef diff --git a/contrib/depends/packages/xproto.mk b/contrib/depends/packages/xproto.mk new file mode 100644 index 0000000..f18bf02 --- /dev/null +++ b/contrib/depends/packages/xproto.mk @@ -0,0 +1,26 @@ +package=xproto +$(package)_version=7.0.31 +$(package)_download_path=https://xorg.freedesktop.org/releases/individual/proto +$(package)_file_name=xproto-$($(package)_version).tar.bz2 +$(package)_sha256_hash=c6f9747da0bd3a95f86b17fb8dd5e717c8f3ab7f0ece3ba1b247899ec1ef7747 + +define $(package)_set_vars + $(package)_config_opts=--without-fop --without-xmlto --without-xsltproc --disable-specs + $(package)_config_opts += --disable-dependency-tracking --enable-option-checking +endef + +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/contrib/depends/packages/zbar.mk b/contrib/depends/packages/zbar.mk new file mode 100644 index 0000000..b0b6c2d --- /dev/null +++ b/contrib/depends/packages/zbar.mk @@ -0,0 +1,31 @@ +package=zbar +$(package)_version=0.23.92 +$(package)_download_path=https://github.com/mchehab/zbar/archive/refs/tags/ +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=dffc16695cb6e42fa318a4946fd42866c0f5ab735f7eaf450b108d1c3a19b4ba +$(package)_dependencies=libiconv + +define $(package)_set_vars + $(package)_build_opts=CFLAGS="-fPIE" + $(package)_build_opts+=CXXFLAGS="-fPIE" +endef + +define $(package)_preprocess_cmds + autoreconf -vfi +endef + +define $(package)_set_vars + $(package)_config_opts=--prefix=$(host_prefix) --disable-shared --without-imagemagick --disable-video --without-xv --with-gtk=no --with-python=no --enable-doc=no --host=$(host) +endef + +define $(package)_config_cmds + CFLAGS="-fPIE" CXXFLAGS="-fPIE" $($(package)_autoconf) $($(package)_config_opts) +endef + +define $(package)_build_cmds + CFLAGS="-fPIE" CXXFLAGS="-fPIE" $(MAKE) $($(package)_build_opts) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef \ No newline at end of file diff --git a/contrib/depends/packages/zlib.mk b/contrib/depends/packages/zlib.mk new file mode 100644 index 0000000..977a2cc --- /dev/null +++ b/contrib/depends/packages/zlib.mk @@ -0,0 +1,25 @@ +package=zlib +$(package)_version=1.2.13 +$(package)_download_path=https://github.com/madler/zlib/releases/download/v$($(package)_version)/ +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30 + +define $(package)_config_cmds + CC="$($(package)_cc)" \ + CXX="$($(package)_cxx)" \ + AR="$($(package)_ar)" \ + RANLIB="$($(package)_ranlib)" \ + LIBTOOL="$($(package)_libtool)" \ + LDLAGS="$($(package)_ldflags)" \ + CFLAGS="-fPIE" \ + CXXFLAGS="-fPIE" \ + ./configure --static --prefix=$(host_prefix) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef \ No newline at end of file diff --git a/contrib/depends/patches/appimage_runtime/CMakeLists.txt b/contrib/depends/patches/appimage_runtime/CMakeLists.txt new file mode 100644 index 0000000..5459d98 --- /dev/null +++ b/contrib/depends/patches/appimage_runtime/CMakeLists.txt @@ -0,0 +1,137 @@ +cmake_minimum_required(VERSION 3.2) +project(appimage_runtime) + +# DISCLAIMER: +# Feather builds should be bootstrappable. For this reason we cannot use the runtime binaries provided by the AppImage devs. +# This directory exists to allow the AppImage runtime to be compiled from source using the depends build system. +# We strongly discourage other projects from copying this code, as it WILL NOT produce a standard runtime. +# The runtime produced here is not guaranteed to run on all officially supported platforms. +# You have been warned. + +# TODO: Switch to https://github.com/AppImageCrafters/appimage-runtime + +set(CMAKE_VERBOSE_MAKEFILE ON) + +# C and C++ versions +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 98) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# sanitizer support +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH}) + +set(APPIMAGEKIT_RUNTIME_ENABLE_SETPROCTITLE OFF CACHE BOOL "Useful for $TARGET_APPIMAGE; see issue #763") + +# check type of current build +string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER) +if (BUILD_TYPE_UPPER STREQUAL DEBUG) + set(BUILD_DEBUG TRUE) +else() + set(BUILD_DEBUG FALSE) +endif() + +# must not include -flto in the following flags, otherwise the data sections will be stripped out +set(runtime_cflags + -std=c99 -ffunction-sections -fdata-sections + -I/feather/contrib/depends/${HOST}/include + -I/feather/contrib/depends/${HOST}/include/appimage + ) +# must not include -Wl,--gc-sections in the following flags, otherwise the data sections will be stripped out +set(runtime_ldflags -s -ffunction-sections -fdata-sections -flto) + +if(BUILD_DEBUG) + message(WARNING "Debug build, adding debug information") + set(runtime_cflags -g ${runtime_cflags}) +else() + message(STATUS "Release build, optimizing runtime") + set(runtime_cflags -Os ${runtime_cflags}) +endif() + +if(APPIMAGEKIT_RUNTIME_ENABLE_SETPROCTITLE) + set(runtime_cflags ${runtime_cflags} -DENABLE_SETPROCTITLE) +endif() + +# objcopy requires actual files for creating new sections to populate the new section +# therefore, we generate 3 suitable files containing blank bytes in the right sizes +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes + COMMAND dd if=/dev/zero bs=1 count=16 of=${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes + COMMAND dd if=/dev/zero bs=1 count=1024 of=${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/8192_blank_bytes + COMMAND dd if=/dev/zero bs=1 count=8192 of=${CMAKE_CURRENT_BINARY_DIR}/8192_blank_bytes +) + +# compile first raw object (not linked yet) into which the sections will be embedded +# TODO: find out how this .o object can be generated using a normal add_executable call +# that'd allow us to get rid of the -I parameters in runtime_cflags +add_custom_command( + MAIN_DEPENDENCY runtime.c + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.0.o + COMMAND ${CMAKE_C_COMPILER} ${runtime_cflags} -c ${CMAKE_CURRENT_SOURCE_DIR}/runtime.c -o runtime.0.o + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +# embed the sections, one by one +# TODO: find out whether all the sections can be embedded in a single objcopy call +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.1.o + COMMAND ${HOST}-objcopy --add-section .digest_md5=16_blank_bytes --set-section-flags .digest_md5=noload,readonly runtime.0.o runtime.1.o + MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/runtime.0.o + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/16_blank_bytes + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.2.o + COMMAND ${HOST}-objcopy --add-section .upd_info=1024_blank_bytes --set-section-flags .upd_info=noload,readonly runtime.1.o runtime.2.o + MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/runtime.1.o + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.3.o + COMMAND ${HOST}-objcopy --add-section .sha256_sig=1024_blank_bytes --set-section-flags .sha256_sig=noload,readonly runtime.2.o runtime.3.o + MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/runtime.2.o + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/1024_blank_bytes + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtime.4.o + COMMAND ${HOST}-objcopy --add-section .sig_key=8192_blank_bytes --set-section-flags .sig_key=noload,readonly runtime.3.o runtime.4.o + MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/runtime.3.o + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/8192_blank_bytes + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +# add the runtime as a normal executable +# CLion will recognize it as a normal executable, one can simply step into the code +add_executable(runtime ${CMAKE_CURRENT_BINARY_DIR}/runtime.4.o notify.c) +if(COMMAND target_link_options) + target_link_options(runtime PRIVATE ${runtime_ldflags}) +else() + message(WARNING "CMake version < 3.13, falling back to using target_link_libraries instead of target_link_options") + target_link_libraries(runtime PRIVATE ${runtime_ldflags}) +endif() +# CMake gets confused by the .o object, therefore we need to tell it that it shall link everything using the C compiler +set_property(TARGET runtime PROPERTY LINKER_LANGUAGE C) +target_link_libraries(runtime PRIVATE -Wl,--as-needed -Wl,--dynamic-linker=${GLIBC_DYNAMIC_LINKER} -static-libstdc++ -Wl,-no-pie -Wl,-O2 -zmuldefs -L/feather/contrib/depends/${HOST}/lib squashfuse squashfuse_ll fuseprivate lzma z dl pthread appimage_shared appimage_hashlib ) + +target_include_directories(runtime PRIVATE ${PROJECT_SOURCE_DIR}/include) + +add_custom_command( + TARGET runtime + POST_BUILD + COMMAND ${HOST}-strip ${CMAKE_CURRENT_BINARY_DIR}/runtime +) + +add_custom_command( + TARGET runtime + POST_BUILD + COMMAND echo -ne 'AI\\x02' | dd of="${CMAKE_CURRENT_BINARY_DIR}/runtime" bs=1 count=3 seek=8 conv=notrunc +) diff --git a/contrib/depends/patches/appimage_runtime/notify.c b/contrib/depends/patches/appimage_runtime/notify.c new file mode 100644 index 0000000..a05becd --- /dev/null +++ b/contrib/depends/patches/appimage_runtime/notify.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include + +/* Try to show a notification on the GUI, fall back to the command line + * timeout is the timeout in milliseconds. timeout = NULL seems to trigger a + * GUI error dialog rather than a notification */ +int notify(char *title, char *body, int timeout) +{ + /* http://stackoverflow.com/questions/13204177/how-to-find-out-if-running-from-terminal-or-gui */ + if (isatty(fileno(stdin))){ + /* We were launched from the command line. */ + printf("\n%s\n", title); + printf("%s\n", body); + } + else + { + /* We were launched from inside the desktop */ + printf("\n%s\n", title); + printf("%s\n", body); + /* https://debian-administration.org/article/407/Creating_desktop_notifications */ + void *handle, *n; + typedef void (*notify_init_t)(char *); + typedef void *(*notify_notification_new_t)( char *, char *, char *, char *); + typedef void (*notify_notification_set_timeout_t)( void *, int ); + typedef void (*notify_notification_show_t)(void *, char *); + handle = NULL; + if(handle == NULL) + handle= dlopen("libnotify.so.3", RTLD_LAZY); + if(handle == NULL) + handle= dlopen("libnotify.so.4", RTLD_LAZY); + if(handle == NULL) + handle= dlopen("libnotify.so.5", RTLD_LAZY); + if(handle == NULL) + handle= dlopen("libnotify.so.6", RTLD_LAZY); + if(handle == NULL) + handle= dlopen("libnotify.so.7", RTLD_LAZY); + if(handle == NULL) + handle= dlopen("libnotify.so.8", RTLD_LAZY); + + if(handle == NULL) + { + printf("Failed to open libnotify.\n\n" ); + } + notify_init_t init = (notify_init_t)dlsym(handle, "notify_init"); + if ( init == NULL ) + { + dlclose( handle ); + return 1; + } + init("AppImage"); + + notify_notification_new_t nnn = (notify_notification_new_t)dlsym(handle, "notify_notification_new"); + if ( nnn == NULL ) + { + dlclose( handle ); + return 1; + } + n = nnn(title, body, NULL, NULL); + notify_notification_set_timeout_t nnst = (notify_notification_set_timeout_t)dlsym(handle, "notify_notification_set_timeout"); + if ( nnst == NULL ) + { + dlclose( handle ); + return 1; + } + nnst(n, timeout); + notify_notification_show_t show = (notify_notification_show_t)dlsym(handle, "notify_notification_show"); + if ( init == NULL ) + { + dlclose( handle ); + return 1; + } + show(n, NULL ); + dlclose(handle ); + } + return 0; +} diff --git a/contrib/depends/patches/appimage_runtime/runtime.c b/contrib/depends/patches/appimage_runtime/runtime.c new file mode 100644 index 0000000..f8ff341 --- /dev/null +++ b/contrib/depends/patches/appimage_runtime/runtime.c @@ -0,0 +1,946 @@ +/************************************************************************** + * + * Copyright (c) 2004-18 Simon Peter + * Portions Copyright (c) 2007 Alexander Larsson + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + +#ident "AppImage by Simon Peter, http://appimage.org/" + +#define _GNU_SOURCE + +#include "squashfuse.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifndef ENABLE_DLOPEN +#define ENABLE_DLOPEN +#endif +#include "squashfuse_dlopen.h" + +/* Exit status to use when launching an AppImage fails. + * For applications that assign meanings to exit status codes (e.g. rsync), + * we avoid "cluttering" pre-defined exit status codes by using 127 which + * is known to alias an application exit status and also known as launcher + * error, see SYSTEM(3POSIX). + */ +#define EXIT_EXECERROR 127 /* Execution error exit status. */ + +//#include "notify.c" +extern int notify(char *title, char *body, int timeout); +struct stat st; + +static ssize_t fs_offset; // The offset at which a filesystem image is expected = end of this ELF + +static void die(const char *msg) { + fprintf(stderr, "%s\n", msg); + exit(EXIT_EXECERROR); +} + +/* Check whether directory is writable */ +bool is_writable_directory(char* str) { + if(access(str, W_OK) == 0) { + return true; + } else { + return false; + } +} + +bool startsWith(const char *pre, const char *str) +{ + size_t lenpre = strlen(pre), + lenstr = strlen(str); + return lenstr < lenpre ? false : strncmp(pre, str, lenpre) == 0; +} + +/* Fill in a stat structure. Does not set st_ino */ +sqfs_err private_sqfs_stat(sqfs *fs, sqfs_inode *inode, struct stat *st) { + sqfs_err err = SQFS_OK; + uid_t id; + + memset(st, 0, sizeof(*st)); + st->st_mode = inode->base.mode; + st->st_nlink = inode->nlink; + st->st_mtime = st->st_ctime = st->st_atime = inode->base.mtime; + + if (S_ISREG(st->st_mode)) { + /* FIXME: do symlinks, dirs, etc have a size? */ + st->st_size = inode->xtra.reg.file_size; + st->st_blocks = st->st_size / 512; + } else if (S_ISBLK(st->st_mode) || S_ISCHR(st->st_mode)) { + st->st_rdev = sqfs_makedev(inode->xtra.dev.major, + inode->xtra.dev.minor); + } else if (S_ISLNK(st->st_mode)) { + st->st_size = inode->xtra.symlink_size; + } + + st->st_blksize = fs->sb.block_size; /* seriously? */ + + err = sqfs_id_get(fs, inode->base.uid, &id); + if (err) + return err; + st->st_uid = id; + err = sqfs_id_get(fs, inode->base.guid, &id); + st->st_gid = id; + if (err) + return err; + + return SQFS_OK; +} + +/* ================= End ELF parsing */ + +extern int fusefs_main(int argc, char *argv[], void (*mounted) (void)); +// extern void ext2_quit(void); + +static pid_t fuse_pid; +static int keepalive_pipe[2]; + +static void * +write_pipe_thread (void *arg) +{ + char c[32]; + int res; + // sprintf(stderr, "Called write_pipe_thread"); + memset (c, 'x', sizeof (c)); + while (1) { + /* Write until we block, on broken pipe, exit */ + res = write (keepalive_pipe[1], c, sizeof (c)); + if (res == -1) { + kill (fuse_pid, SIGTERM); + break; + } + } + return NULL; +} + +void +fuse_mounted (void) +{ + pthread_t thread; + fuse_pid = getpid(); + pthread_create(&thread, NULL, write_pipe_thread, keepalive_pipe); +} + +char* getArg(int argc, char *argv[],char chr) +{ + int i; + for (i=1; i sizeof(_path)-1) { + errno = ENAMETOOLONG; + return -1; + } + strcpy(_path, path); + + /* Iterate the string */ + for (p = _path + 1; *p; p++) { + if (*p == '/') { + /* Temporarily truncate */ + *p = '\0'; + + if (mkdir(_path, 0755) != 0) { + if (errno != EEXIST) + return -1; + } + + *p = '/'; + } + } + + if (mkdir(_path, 0755) != 0) { + if (errno != EEXIST) + return -1; + } + + return 0; +} + +void +print_help(const char *appimage_path) +{ + // TODO: "--appimage-list List content from embedded filesystem image\n" + fprintf(stderr, + "AppImage options:\n\n" + " --appimage-extract [] Extract content from embedded filesystem image\n" + " If pattern is passed, only extract matching files\n" + " --appimage-help Print this help\n" + " --appimage-mount Mount embedded filesystem image and print\n" + " mount point and wait for kill with Ctrl-C\n" + " --appimage-offset Print byte offset to start of embedded\n" + " filesystem image\n" + " --appimage-portable-home Create a portable home folder to use as $HOME\n" + " --appimage-portable-config Create a portable config folder to use as\n" + " $XDG_CONFIG_HOME\n" + " --appimage-signature Print digital signature embedded in AppImage\n" + " --appimage-updateinfo[rmation] Print update info embedded in AppImage\n" + "\n" + "Portable home:\n" + "\n" + " If you would like the application contained inside this AppImage to store its\n" + " data alongside this AppImage rather than in your home directory, then you can\n" + " place a directory named\n" + "\n" + " %s.home\n" + "\n" + " Or you can invoke this AppImage with the --appimage-portable-home option,\n" + " which will create this directory for you. As long as the directory exists\n" + " and is neither moved nor renamed, the application contained inside this\n" + " AppImage to store its data in this directory rather than in your home\n" + " directory\n" + , appimage_path); +} + +void +portable_option(const char *arg, const char *appimage_path, const char *name) +{ + char option[32]; + sprintf(option, "appimage-portable-%s", name); + + if (arg && strcmp(arg, option)==0) { + char portable_dir[PATH_MAX]; + char fullpath[PATH_MAX]; + + ssize_t length = readlink(appimage_path, fullpath, sizeof(fullpath)); + if (length < 0) { + fprintf(stderr, "Error getting realpath for %s\n", appimage_path); + exit(EXIT_FAILURE); + } + fullpath[length] = '\0'; + + sprintf(portable_dir, "%s.%s", fullpath, name); + if (!mkdir(portable_dir, S_IRWXU)) + fprintf(stderr, "Portable %s directory created at %s\n", name, portable_dir); + else + fprintf(stderr, "Error creating portable %s directory at %s: %s\n", name, portable_dir, strerror(errno)); + + exit(0); + } +} + +bool extract_appimage(const char* const appimage_path, const char* const _prefix, const char* const _pattern, const bool overwrite, const bool verbose) { + sqfs_err err = SQFS_OK; + sqfs_traverse trv; + sqfs fs; + char prefixed_path_to_extract[1024]; + + // local copy we can modify safely + // allocate 1 more byte than we would need so we can add a trailing slash if there is none yet + char* prefix = malloc(strlen(_prefix) + 2); + strcpy(prefix, _prefix); + + // sanitize prefix + if (prefix[strlen(prefix) - 1] != '/') + strcat(prefix, "/"); + + if (access(prefix, F_OK) == -1) { + if (mkdir_p(prefix) == -1) { + perror("mkdir_p error"); + return false; + } + } + + if ((err = sqfs_open_image(&fs, appimage_path, (size_t) fs_offset))) { + fprintf(stderr, "Failed to open squashfs image\n"); + return false; + }; + + // track duplicate inodes for hardlinks + char** created_inode = calloc(fs.sb.inodes, sizeof(char*)); + if (created_inode == NULL) { + fprintf(stderr, "Failed allocating memory to track hardlinks\n"); + return false; + } + + if ((err = sqfs_traverse_open(&trv, &fs, sqfs_inode_root(&fs)))) { + fprintf(stderr, "sqfs_traverse_open error\n"); + free(created_inode); + return false; + } + + bool rv = true; + + while (sqfs_traverse_next(&trv, &err)) { + if (!trv.dir_end) { + if (_pattern == NULL || fnmatch(_pattern, trv.path, FNM_FILE_NAME | FNM_LEADING_DIR) == 0) { + // fprintf(stderr, "trv.path: %s\n", trv.path); + // fprintf(stderr, "sqfs_inode_id: %lu\n", trv.entry.inode); + sqfs_inode inode; + if (sqfs_inode_get(&fs, &inode, trv.entry.inode)) { + fprintf(stderr, "sqfs_inode_get error\n"); + rv = false; + break; + } + // fprintf(stderr, "inode.base.inode_type: %i\n", inode.base.inode_type); + // fprintf(stderr, "inode.xtra.reg.file_size: %lu\n", inode.xtra.reg.file_size); + strcpy(prefixed_path_to_extract, ""); + strcat(strcat(prefixed_path_to_extract, prefix), trv.path); + + if (verbose) + fprintf(stdout, "%s\n", prefixed_path_to_extract); + + if (inode.base.inode_type == SQUASHFS_DIR_TYPE || inode.base.inode_type == SQUASHFS_LDIR_TYPE) { + // fprintf(stderr, "inode.xtra.dir.parent_inode: %ui\n", inode.xtra.dir.parent_inode); + // fprintf(stderr, "mkdir_p: %s/\n", prefixed_path_to_extract); + if (access(prefixed_path_to_extract, F_OK) == -1) { + if (mkdir_p(prefixed_path_to_extract) == -1) { + perror("mkdir_p error"); + rv = false; + break; + } + } + } else if (inode.base.inode_type == SQUASHFS_REG_TYPE || inode.base.inode_type == SQUASHFS_LREG_TYPE) { + // if we've already created this inode, then this is a hardlink + char* existing_path_for_inode = created_inode[inode.base.inode_number - 1]; + if (existing_path_for_inode != NULL) { + unlink(prefixed_path_to_extract); + if (link(existing_path_for_inode, prefixed_path_to_extract) == -1) { + fprintf(stderr, "Couldn't create hardlink from \"%s\" to \"%s\": %s\n", + prefixed_path_to_extract, existing_path_for_inode, strerror(errno)); + rv = false; + break; + } else { + continue; + } + } else { + struct stat st; + if (!overwrite && stat(prefixed_path_to_extract, &st) == 0 && st.st_size == inode.xtra.reg.file_size) { + fprintf(stderr, "File exists and file size matches, skipping\n"); + continue; + } + + // track the path we extract to for this inode, so that we can `link` if this inode is found again + created_inode[inode.base.inode_number - 1] = strdup(prefixed_path_to_extract); + // fprintf(stderr, "Extract to: %s\n", prefixed_path_to_extract); + if (private_sqfs_stat(&fs, &inode, &st) != 0) + die("private_sqfs_stat error"); + + // create parent dir + char* p = strrchr(prefixed_path_to_extract, '/'); + if (p) { + // set an \0 to end the split the string + *p = '\0'; + mkdir_p(prefixed_path_to_extract); + + // restore dir seprator + *p = '/'; + } + + // Read the file in chunks + off_t bytes_already_read = 0; + sqfs_off_t bytes_at_a_time = 64 * 1024; + FILE* f; + f = fopen(prefixed_path_to_extract, "w+"); + if (f == NULL) { + perror("fopen error"); + rv = false; + break; + } + while (bytes_already_read < inode.xtra.reg.file_size) { + char buf[bytes_at_a_time]; + if (sqfs_read_range(&fs, &inode, (sqfs_off_t) bytes_already_read, &bytes_at_a_time, buf)) { + perror("sqfs_read_range error"); + rv = false; + break; + } + // fwrite(buf, 1, bytes_at_a_time, stdout); + fwrite(buf, 1, bytes_at_a_time, f); + bytes_already_read = bytes_already_read + bytes_at_a_time; + } + fclose(f); + chmod(prefixed_path_to_extract, st.st_mode); + if (!rv) + break; + } + } else if (inode.base.inode_type == SQUASHFS_SYMLINK_TYPE || inode.base.inode_type == SQUASHFS_LSYMLINK_TYPE) { + size_t size; + sqfs_readlink(&fs, &inode, NULL, &size); + char buf[size]; + int ret = sqfs_readlink(&fs, &inode, buf, &size); + if (ret != 0) { + perror("symlink error"); + rv = false; + break; + } + // fprintf(stderr, "Symlink: %s to %s \n", prefixed_path_to_extract, buf); + unlink(prefixed_path_to_extract); + ret = symlink(buf, prefixed_path_to_extract); + if (ret != 0) + fprintf(stderr, "WARNING: could not create symlink\n"); + } else { + fprintf(stderr, "TODO: Implement inode.base.inode_type %i\n", inode.base.inode_type); + } + // fprintf(stderr, "\n"); + + if (!rv) + break; + } + } + } + for (int i = 0; i < fs.sb.inodes; i++) { + free(created_inode[i]); + } + free(created_inode); + + if (err != SQFS_OK) { + fprintf(stderr, "sqfs_traverse_next error\n"); + rv = false; + } + sqfs_traverse_close(&trv); + sqfs_fd_close(fs.fd); + + return rv; +} + +int rm_recursive_callback(const char* path, const struct stat* stat, const int type, struct FTW* ftw) { + (void) stat; + (void) ftw; + + switch (type) { + case FTW_NS: + case FTW_DNR: + fprintf(stderr, "%s: ftw error: %s\n", + path, strerror(errno)); + return 1; + + case FTW_D: + // ignore directories at first, will be handled by FTW_DP + break; + + case FTW_F: + case FTW_SL: + case FTW_SLN: + if (remove(path) != 0) { + fprintf(stderr, "Failed to remove %s: %s\n", path, strerror(errno)); + return false; + } + break; + + + case FTW_DP: + if (rmdir(path) != 0) { + fprintf(stderr, "Failed to remove directory %s: %s\n", path, strerror(errno)); + return false; + } + break; + + default: + fprintf(stderr, "Unexpected fts_info\n"); + return 1; + } + + return 0; +}; + +bool rm_recursive(const char* const path) { + // FTW_DEPTH: perform depth-first search to make sure files are deleted before the containing directories + // FTW_MOUNT: prevent deletion of files on other mounted filesystems + // FTW_PHYS: do not follow symlinks, but report symlinks as such; this way, the symlink targets, which might point + // to locations outside path will not be deleted accidentally (attackers might abuse this) + int rv = nftw(path, &rm_recursive_callback, 0, FTW_DEPTH | FTW_MOUNT | FTW_PHYS); + + return rv == 0; +} + +bool build_mount_point(char* mount_dir, const char* const argv0, char const* const temp_base, const size_t templen) { + const size_t maxnamelen = 6; + + // when running for another AppImage, we should use that for building the mountpoint name instead + char* target_appimage = getenv("TARGET_APPIMAGE"); + + char* path_basename; + if (target_appimage != NULL) { + path_basename = basename(target_appimage); + } else { + path_basename = basename(argv0); + } + + size_t namelen = strlen(path_basename); + // limit length of tempdir name + if (namelen > maxnamelen) { + namelen = maxnamelen; + } + + strcpy(mount_dir, temp_base); + strncpy(mount_dir + templen, "/.mount_", 8); + strncpy(mount_dir + templen + 8, path_basename, namelen); + strncpy(mount_dir+templen+8+namelen, "XXXXXX", 6); + mount_dir[templen+8+namelen+6] = 0; // null terminate destination +} + +int main(int argc, char *argv[]) { + char appimage_path[PATH_MAX]; + char argv0_path[PATH_MAX]; + char * arg; + + /* We might want to operate on a target appimage rather than this file itself, + * e.g., for appimaged which must not run untrusted code from random AppImages. + * This variable is intended for use by e.g., appimaged and is subject to + * change any time. Do not rely on it being present. We might even limit this + * functionality specifically for builds used by appimaged. + */ + if (getenv("TARGET_APPIMAGE") == NULL) { + strcpy(appimage_path, "/proc/self/exe"); + strcpy(argv0_path, argv[0]); + } else { + strcpy(appimage_path, getenv("TARGET_APPIMAGE")); + strcpy(argv0_path, getenv("TARGET_APPIMAGE")); + +#ifdef ENABLE_SETPROCTITLE + // load libbsd dynamically to change proc title + // this is an optional feature, therefore we don't hard require it + void* libbsd = dlopen("libbsd.so", RTLD_NOW); + + if (libbsd != NULL) { + // clear error state + dlerror(); + + // try to load the two required symbols + void (*setproctitle_init)(int, char**, char**) = dlsym(libbsd, "setproctitle_init"); + + char* error; + + if ((error = dlerror()) == NULL) { + void (*setproctitle)(const char*, char*) = dlsym(libbsd, "setproctitle"); + + if (dlerror() == NULL) { + char buffer[1024]; + strcpy(buffer, getenv("TARGET_APPIMAGE")); + for (int i = 1; i < argc; i++) { + strcat(buffer, " "); + strcat(buffer, argv[i]); + } + + (*setproctitle_init)(argc, argv, environ); + (*setproctitle)("%s", buffer); + } + } + + dlclose(libbsd); + } +#endif + } + + // temporary directories are required in a few places + // therefore we implement the detection of the temp base dir at the top of the code to avoid redundancy + char temp_base[PATH_MAX] = P_tmpdir; + + { + const char* const TMPDIR = getenv("TMPDIR"); + if (TMPDIR != NULL) + strcpy(temp_base, getenv("TMPDIR")); + } + + fs_offset = appimage_get_elf_size(appimage_path); + + // error check + if (fs_offset < 0) { + fprintf(stderr, "Failed to get fs offset for %s\n", appimage_path); + exit(EXIT_EXECERROR); + } + + arg=getArg(argc,argv,'-'); + + /* Print the help and then exit */ + if(arg && strcmp(arg,"appimage-help")==0) { + char fullpath[PATH_MAX]; + + ssize_t length = readlink(appimage_path, fullpath, sizeof(fullpath)); + if (length < 0) { + fprintf(stderr, "Error getting realpath for %s\n", appimage_path); + exit(EXIT_EXECERROR); + } + fullpath[length] = '\0'; + + print_help(fullpath); + exit(0); + } + + /* Just print the offset and then exit */ + if(arg && strcmp(arg,"appimage-offset")==0) { + printf("%lu\n", fs_offset); + exit(0); + } + + arg=getArg(argc,argv,'-'); + + /* extract the AppImage */ + if(arg && strcmp(arg,"appimage-extract")==0) { + char* pattern; + + // default use case: use standard prefix + if (argc == 2) { + pattern = NULL; + } else if (argc == 3) { + pattern = argv[2]; + } else { + fprintf(stderr, "Unexpected argument count: %d\n", argc - 1); + fprintf(stderr, "Usage: %s --appimage-extract []\n", argv0_path); + exit(1); + } + + if (!extract_appimage(appimage_path, "squashfs-root/", pattern, true, true)) { + exit(1); + } + + exit(0); + } + + // calculate full path of AppImage + int length; + char fullpath[PATH_MAX]; + + if(getenv("TARGET_APPIMAGE") == NULL) { + // If we are operating on this file itself + ssize_t len = readlink(appimage_path, fullpath, sizeof(fullpath)); + if (len < 0) { + perror("Failed to obtain absolute path"); + exit(EXIT_EXECERROR); + } + fullpath[len] = '\0'; + } else { + char* abspath = realpath(appimage_path, NULL); + if (abspath == NULL) { + perror("Failed to obtain absolute path"); + exit(EXIT_EXECERROR); + } + strcpy(fullpath, abspath); + free(abspath); + } + + if (getenv("APPIMAGE_EXTRACT_AND_RUN") != NULL || (arg && strcmp(arg, "appimage-extract-and-run") == 0)) { + char* hexlified_digest = NULL; + + // calculate MD5 hash of file, and use it to make extracted directory name "content-aware" + // see https://github.com/AppImage/AppImageKit/issues/841 for more information + { + FILE* f = fopen(appimage_path, "rb"); + if (f == NULL) { + perror("Failed to open AppImage file"); + exit(EXIT_EXECERROR); + } + + Md5Context ctx; + Md5Initialise(&ctx); + + char buf[4096]; + for (size_t bytes_read; (bytes_read = fread(buf, sizeof(char), sizeof(buf), f)); bytes_read > 0) { + Md5Update(&ctx, buf, (uint32_t) bytes_read); + } + + MD5_HASH digest; + Md5Finalise(&ctx, &digest); + + hexlified_digest = appimage_hexlify(digest.bytes, sizeof(digest.bytes)); + } + + char* prefix = malloc(strlen(temp_base) + 20 + strlen(hexlified_digest) + 2); + strcpy(prefix, temp_base); + strcat(prefix, "/appimage_extracted_"); + strcat(prefix, hexlified_digest); + free(hexlified_digest); + + const bool verbose = (getenv("VERBOSE") != NULL); + + if (!extract_appimage(appimage_path, prefix, NULL, false, verbose)) { + fprintf(stderr, "Failed to extract AppImage\n"); + exit(EXIT_EXECERROR); + } + + int pid; + if ((pid = fork()) == -1) { + int error = errno; + fprintf(stderr, "fork() failed: %s\n", strerror(error)); + exit(EXIT_EXECERROR); + } else if (pid == 0) { + const char apprun_fname[] = "AppRun"; + char* apprun_path = malloc(strlen(prefix) + 1 + strlen(apprun_fname) + 1); + strcpy(apprun_path, prefix); + strcat(apprun_path, "/"); + strcat(apprun_path, apprun_fname); + + // create copy of argument list without the --appimage-extract-and-run parameter + char* new_argv[argc]; + int new_argc = 0; + new_argv[new_argc++] = strdup(apprun_path); + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "--appimage-extract-and-run") != 0) { + new_argv[new_argc++] = strdup(argv[i]); + } + } + new_argv[new_argc] = NULL; + + /* Setting some environment variables that the app "inside" might use */ + setenv("APPIMAGE", fullpath, 1); + setenv("ARGV0", argv0_path, 1); + setenv("APPDIR", prefix, 1); + + execv(apprun_path, new_argv); + + int error = errno; + fprintf(stderr, "Failed to run %s: %s\n", apprun_path, strerror(error)); + + free(apprun_path); + exit(EXIT_EXECERROR); + } + + int status = 0; + int rv = waitpid(pid, &status, 0); + status = rv > 0 && WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_EXECERROR; + + if (getenv("NO_CLEANUP") == NULL) { + if (!rm_recursive(prefix)) { + fprintf(stderr, "Failed to clean up cache directory\n"); + if (status == 0) /* avoid messing existing failure exit status */ + status = EXIT_EXECERROR; + } + } + + // template == prefix, must be freed only once + free(prefix); + + exit(status); + } + + if(arg && (strcmp(arg,"appimage-updateinformation")==0 || strcmp(arg,"appimage-updateinfo")==0)) { + unsigned long offset = 0; + unsigned long length = 0; + appimage_get_elf_section_offset_and_length(appimage_path, ".upd_info", &offset, &length); + // fprintf(stderr, "offset: %lu\n", offset); + // fprintf(stderr, "length: %lu\n", length); + // print_hex(appimage_path, offset, length); + appimage_print_binary(appimage_path, offset, length); + exit(0); + } + + if(arg && strcmp(arg,"appimage-signature")==0) { + unsigned long offset = 0; + unsigned long length = 0; + appimage_get_elf_section_offset_and_length(appimage_path, ".sha256_sig", &offset, &length); + // fprintf(stderr, "offset: %lu\n", offset); + // fprintf(stderr, "length: %lu\n", length); + // print_hex(appimage_path, offset, length); + appimage_print_binary(appimage_path, offset, length); + exit(0); + } + + portable_option(arg, appimage_path, "home"); + portable_option(arg, appimage_path, "config"); + + // If there is an argument starting with appimage- (but not appimage-mount which is handled further down) + // then stop here and print an error message + if((arg && strncmp(arg, "appimage-", 8) == 0) && (arg && strcmp(arg,"appimage-mount")!=0)) { + fprintf(stderr,"--%s is not yet implemented\n", arg); + exit(1); + } + + LOAD_LIBRARY; /* exit if libfuse is missing */ + + int dir_fd, res; + + size_t templen = strlen(temp_base); + + // allocate enough memory (size of name won't exceed 60 bytes) + char mount_dir[templen + 60]; + + build_mount_point(mount_dir, argv[0], temp_base, templen); + + size_t mount_dir_size = strlen(mount_dir); + pid_t pid; + char **real_argv; + int i; + + if (mkdtemp(mount_dir) == NULL) { + perror ("create mount dir error"); + exit (EXIT_EXECERROR); + } + + if (pipe (keepalive_pipe) == -1) { + perror ("pipe error"); + exit (EXIT_EXECERROR); + } + + pid = fork (); + if (pid == -1) { + perror ("fork error"); + exit (EXIT_EXECERROR); + } + + if (pid == 0) { + /* in child */ + + char *child_argv[5]; + + /* close read pipe */ + close (keepalive_pipe[0]); + + char *dir = realpath(appimage_path, NULL ); + + char options[100]; + sprintf(options, "ro,offset=%lu", fs_offset); + + child_argv[0] = dir; + child_argv[1] = "-o"; + child_argv[2] = options; + child_argv[3] = dir; + child_argv[4] = mount_dir; + + if(0 != fusefs_main (5, child_argv, fuse_mounted)){ + char *title; + char *body; + title = "Cannot mount AppImage, please check your FUSE setup."; + body = "You might still be able to extract the contents of this AppImage \n" + "if you run it with the --appimage-extract option. \n" + "See https://github.com/AppImage/AppImageKit/wiki/FUSE \n" + "for more information"; + notify(title, body, 0); // 3 seconds timeout + }; + } else { + /* in parent, child is $pid */ + int c; + + /* close write pipe */ + close (keepalive_pipe[1]); + + /* Pause until mounted */ + read (keepalive_pipe[0], &c, 1); + + /* Fuse process has now daemonized, reap our child */ + waitpid(pid, NULL, 0); + + dir_fd = open (mount_dir, O_RDONLY); + if (dir_fd == -1) { + perror ("open dir error"); + exit (EXIT_EXECERROR); + } + + res = dup2 (dir_fd, 1023); + if (res == -1) { + perror ("dup2 error"); + exit (EXIT_EXECERROR); + } + close (dir_fd); + + real_argv = malloc (sizeof (char *) * (argc + 1)); + for (i = 0; i < argc; i++) { + real_argv[i] = argv[i]; + } + real_argv[i] = NULL; + + if(arg && strcmp(arg, "appimage-mount") == 0) { + char real_mount_dir[PATH_MAX]; + + if (realpath(mount_dir, real_mount_dir) == real_mount_dir) { + printf("%s\n", real_mount_dir); + } else { + printf("%s\n", mount_dir); + } + + // stdout is, by default, buffered (unlike stderr), therefore in order to allow other processes to read + // the path from stdout, we need to flush the buffers now + // this is a less-invasive alternative to setbuf(stdout, NULL); + fflush(stdout); + + for (;;) pause(); + + exit(0); + } + + /* Setting some environment variables that the app "inside" might use */ + setenv( "APPIMAGE", fullpath, 1 ); + setenv( "ARGV0", argv0_path, 1 ); + setenv( "APPDIR", mount_dir, 1 ); + + char portable_home_dir[PATH_MAX]; + char portable_config_dir[PATH_MAX]; + + /* If there is a directory with the same name as the AppImage plus ".home", then export $HOME */ + strcpy (portable_home_dir, fullpath); + strcat (portable_home_dir, ".home"); + if(is_writable_directory(portable_home_dir)){ + fprintf(stderr, "Setting $HOME to %s\n", portable_home_dir); + setenv("HOME",portable_home_dir,1); + } + + /* If there is a directory with the same name as the AppImage plus ".config", then export $XDG_CONFIG_HOME */ + strcpy (portable_config_dir, fullpath); + strcat (portable_config_dir, ".config"); + if(is_writable_directory(portable_config_dir)){ + fprintf(stderr, "Setting $XDG_CONFIG_HOME to %s\n", portable_config_dir); + setenv("XDG_CONFIG_HOME",portable_config_dir,1); + } + + /* Original working directory */ + char cwd[1024]; + if (getcwd(cwd, sizeof(cwd)) != NULL) { + setenv( "OWD", cwd, 1 ); + } + + char filename[mount_dir_size + 8]; /* enough for mount_dir + "/AppRun" */ + strcpy (filename, mount_dir); + strcat (filename, "/AppRun"); + + /* TODO: Find a way to get the exit status and/or output of this */ + execv (filename, real_argv); + /* Error if we continue here */ + perror("execv error"); + exit(EXIT_EXECERROR); + } + + return 0; +} diff --git a/contrib/depends/patches/boost/fix_arm_arch.patch b/contrib/depends/patches/boost/fix_arm_arch.patch new file mode 100644 index 0000000..3cf6b6f --- /dev/null +++ b/contrib/depends/patches/boost/fix_arm_arch.patch @@ -0,0 +1,11 @@ +--- boost_1_64_0/tools/build/src/tools/darwin.jam.O 2017-04-17 03:22:26.000000000 +0100 ++++ boost_1_64_0/tools/build/src/tools/darwin.jam 2022-05-04 17:26:29.984464447 +0000 +@@ -505,7 +505,7 @@ + if $(instruction-set) { + options = -arch$(_)$(instruction-set) ; + } else { +- options = -arch arm ; ++# options = -arch arm ; + } + } + } diff --git a/contrib/depends/patches/boost/fix_aroptions.patch b/contrib/depends/patches/boost/fix_aroptions.patch new file mode 100644 index 0000000..5b2ec10 --- /dev/null +++ b/contrib/depends/patches/boost/fix_aroptions.patch @@ -0,0 +1,28 @@ +--- boost_1_64_0/tools/build/src/tools/gcc.jam.O 2017-04-17 03:22:26.000000000 +0100 ++++ boost_1_64_0/tools/build/src/tools/gcc.jam 2019-11-15 15:46:16.957937137 +0000 +@@ -243,6 +243,8 @@ + { + ECHO notice: using gcc archiver :: $(condition) :: $(archiver[1]) ; + } ++ local arflags = [ feature.get-values : $(options) ] ; ++ toolset.flags gcc.archive .ARFLAGS $(condition) : $(arflags) ; + + # - Ranlib. + local ranlib = [ common.get-invocation-command gcc +@@ -970,6 +972,7 @@ + # logic in intel-linux, but that is hardly worth the trouble as on Linux, 'ar' + # is always available. + .AR = ar ; ++.ARFLAGS = rc ; + .RANLIB = ranlib ; + + toolset.flags gcc.archive AROPTIONS ; +@@ -1011,7 +1014,7 @@ + # + actions piecemeal archive + { +- "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" ++ "$(.AR)" $(AROPTIONS) $(.ARFLAGS) "$(<)" "$(>)" + "$(.RANLIB)" "$(<)" + } + diff --git a/contrib/depends/patches/boost/fix_coalesce.patch b/contrib/depends/patches/boost/fix_coalesce.patch new file mode 100644 index 0000000..8ee2928 --- /dev/null +++ b/contrib/depends/patches/boost/fix_coalesce.patch @@ -0,0 +1,17 @@ +--- boost_1_64_0/tools/build/src/tools/darwin.jam ++++ boost_1_64_0/tools/build/src/tools/darwin.jam +@@ -138,10 +138,10 @@ rule init ( version ? : command * : options * : requirement * ) + common.handle-options darwin : $(condition) : $(command) : $(options) ; + + # - GCC 4.0 and higher in Darwin does not have -fcoalesce-templates. +- if $(real-version) < "4.0.0" +- { +- flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ; +- } ++ #if $(real-version) < "4.0.0" ++ #{ ++ # flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ; ++ #} + # - GCC 4.2 and higher in Darwin does not have -Wno-long-double. + if $(real-version) < "4.2.0" + { diff --git a/contrib/depends/patches/cmake/cmake-1-fixes.patch b/contrib/depends/patches/cmake/cmake-1-fixes.patch new file mode 100644 index 0000000..062c067 --- /dev/null +++ b/contrib/depends/patches/cmake/cmake-1-fixes.patch @@ -0,0 +1,67 @@ +This file is part of MXE. See LICENSE.md for licensing information. + +Contains ad hoc patches for cross building. + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Fri, 12 Aug 2016 02:01:20 +1000 +Subject: [PATCH 1/3] fix windres invocation options + +windres doesn't recognise various gcc flags like -mms-bitfields, +-fopenmp, -mthreads etc. (basically not `-D` or `-I`) + +diff --git a/Modules/Platform/Windows-windres.cmake b/Modules/Platform/Windows-windres.cmake +index 1111111..2222222 100644 +--- a/Modules/Platform/Windows-windres.cmake ++++ b/Modules/Platform/Windows-windres.cmake +@@ -1 +1 @@ +-set(CMAKE_RC_COMPILE_OBJECT " -O coff ") ++set(CMAKE_RC_COMPILE_OBJECT " -O coff ") + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Tue, 25 Jul 2017 20:34:56 +1000 +Subject: [PATCH 2/3] add option to disable -isystem + +taken from (not accepted): +https://gitlab.kitware.com/cmake/cmake/merge_requests/895 + +see also: +https://gitlab.kitware.com/cmake/cmake/issues/16291 +https://gitlab.kitware.com/cmake/cmake/issues/16919 + +diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake +index 1111111..2222222 100644 +--- a/Modules/Compiler/GNU.cmake ++++ b/Modules/Compiler/GNU.cmake +@@ -42,7 +42,7 @@ macro(__compiler_gnu lang) + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") +- if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462 ++ if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4 AND (NOT MXE_DISABLE_INCLUDE_SYSTEM_FLAG)) # work around #4462 + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + endif() + endmacro() + +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tony Theodore +Date: Tue, 15 Aug 2017 15:25:06 +1000 +Subject: [PATCH 3/3] add CPACK_NSIS_EXECUTABLE variable + + +diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx +index 1111111..2222222 100644 +--- a/Source/CPack/cmCPackNSISGenerator.cxx ++++ b/Source/CPack/cmCPackNSISGenerator.cxx +@@ -384,7 +384,9 @@ int cmCPackNSISGenerator::InitializeInternal() + } + #endif + +- nsisPath = cmSystemTools::FindProgram("makensis", path, false); ++ this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLE", "makensis"); ++ nsisPath = cmSystemTools::FindProgram( ++ this->GetOption("CPACK_NSIS_EXECUTABLE"), path, false); + + if (nsisPath.empty()) { + cmCPackLogger( diff --git a/contrib/depends/patches/fontconfig/gperf_header_regen.patch b/contrib/depends/patches/fontconfig/gperf_header_regen.patch new file mode 100644 index 0000000..b1a70d5 --- /dev/null +++ b/contrib/depends/patches/fontconfig/gperf_header_regen.patch @@ -0,0 +1,24 @@ +commit 7b6eb33ecd88768b28c67ce5d2d68a7eed5936b6 +Author: fanquake +Date: Tue Aug 25 14:34:53 2020 +0800 + + Remove rule that causes inadvertent header regeneration + + Otherwise the makefile will needlessly attempt to re-generate the + headers with gperf. This can be dropped once the upstream build is fixed. + + See #10851. + +diff --git a/src/Makefile.in b/src/Makefile.in +index f4626ad..4ae1b00 100644 +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -912,7 +912,7 @@ + ' - > $@.tmp && \ + mv -f $@.tmp fcobjshash.gperf && touch $@ || ( $(RM) $@.tmp && false ) + +-fcobjshash.h: Makefile fcobjshash.gperf ++fcobjshash.h: + $(AM_V_GEN) $(GPERF) --pic -m 100 fcobjshash.gperf > $@.tmp && \ + mv -f $@.tmp $@ || ( $(RM) $@.tmp && false ) + diff --git a/contrib/depends/patches/hidapi/missing_win_include.patch b/contrib/depends/patches/hidapi/missing_win_include.patch new file mode 100644 index 0000000..5bbe82d --- /dev/null +++ b/contrib/depends/patches/hidapi/missing_win_include.patch @@ -0,0 +1,21 @@ +From a77b066311da42ed7654e39c0356a3b951b2e296 Mon Sep 17 00:00:00 2001 +From: selsta +Date: Wed, 10 Nov 2021 02:28:54 +0100 +Subject: [PATCH] windows: add missing include for mingw32 + +--- + windows/hid.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/windows/hid.c b/windows/hid.c +index 24756a4..6d8394c 100644 +--- a/windows/hid.c ++++ b/windows/hid.c +@@ -33,6 +33,7 @@ typedef LONG NTSTATUS; + #endif + + #ifdef __MINGW32__ ++#include + #include + #include + #endif diff --git a/contrib/depends/patches/icu4c/icu-001-dont-build-static-dynamic-twice.patch b/contrib/depends/patches/icu4c/icu-001-dont-build-static-dynamic-twice.patch new file mode 100644 index 0000000..bbd4e99 --- /dev/null +++ b/contrib/depends/patches/icu4c/icu-001-dont-build-static-dynamic-twice.patch @@ -0,0 +1,37 @@ +Don't build object files twice + +When passed --enable-static and --enable-shared, icu will generate +both a shared and a static version of its libraries. + +However, in order to do so, it builds each and every object file +twice: once with -fPIC (for the shared library), and once without +-fPIC (for the static library). While admittedly building -fPIC for a +static library generates a slightly suboptimal code, this is what all +the autotools-based project are doing. They build each object file +once, and they use it for both the static and shared libraries. + +icu builds the object files for the shared library as .o files, and +the object files for static library as .ao files. By simply changing +the suffix of object files used for static libraries to ".o", we tell +icu to use the ones built for the shared library (i.e, with -fPIC), +and avoid the double build of icu. + +On a fast build server, this brings the target icu build from +3m41.302s down to 1m43.926s (approximate numbers: some other builds +are running on the system at the same time). + +Signed-off-by: Thomas Petazzoni + +Index: b/source/config/mh-linux +=================================================================== +--- a/source/config/mh-linux ++++ b/source/config/mh-linux +@@ -38,7 +38,7 @@ + ## Shared object suffix + SO = so + ## Non-shared intermediate object suffix +-STATIC_O = ao ++STATIC_O = o + + ## Compilation rules + %.$(STATIC_O): $(srcdir)/%.c diff --git a/contrib/depends/patches/icu4c/no-timestamp-in-makefile.patch b/contrib/depends/patches/icu4c/no-timestamp-in-makefile.patch new file mode 100644 index 0000000..c439632 --- /dev/null +++ b/contrib/depends/patches/icu4c/no-timestamp-in-makefile.patch @@ -0,0 +1,12 @@ +diff --git a/source/Makefile.in b/source/Makefile.in +index 9db6c52..b5a4ea3 100644 +--- a/source/Makefile.in ++++ b/source/Makefile.in +@@ -335,7 +335,6 @@ $(top_builddir)/config/icu-config: $(top_builddir)/Makefile $(top_srcdir)/config + LC_ALL=C sed -f $(top_srcdir)/config/make2sh.sed < $(top_builddir)/config/Makefile.inc | grep -v '#M#' | uniq >> $@ + LC_ALL=C sed -f $(top_srcdir)/config/make2sh.sed < @platform_make_fragment@ | grep -v '#M#' | uniq >> $@ + cat $(top_srcdir)/config/icu-config-bottom >> $@ +- echo "# Rebuilt on "`date` >> $@ + chmod u-w $@ + + config.status: $(srcdir)/configure $(srcdir)/common/unicode/uvernum.h diff --git a/contrib/depends/patches/libappimage/no-unneeded-deps.patch b/contrib/depends/patches/libappimage/no-unneeded-deps.patch new file mode 100644 index 0000000..e388b7f --- /dev/null +++ b/contrib/depends/patches/libappimage/no-unneeded-deps.patch @@ -0,0 +1,163 @@ +From b7875398d91821a49b7b0233950a3e687257c790 Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Mon, 7 Nov 2022 11:30:46 +0100 +Subject: [PATCH] no unneeded deps + +--- + cmake/dependencies.cmake | 78 +++++++++++++++---------------- + cmake/imported_dependencies.cmake | 10 ++-- + cmake/tools.cmake | 3 -- + src/CMakeLists.txt | 12 ++--- + 4 files changed, 50 insertions(+), 53 deletions(-) + +diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake +index 7c65e85..5bf5e51 100644 +--- a/cmake/dependencies.cmake ++++ b/cmake/dependencies.cmake +@@ -55,45 +55,45 @@ endif() + # for distro packaging, it can be linked to an existing package just fine + set(USE_SYSTEM_SQUASHFUSE OFF CACHE BOOL "Use system libsquashfuse instead of building our own") + +-if(NOT USE_SYSTEM_SQUASHFUSE) +- message(STATUS "Downloading and building squashfuse") +- +- # TODO: implement out-of-source builds for squashfuse, as for the other dependencies +- configure_file( +- ${CMAKE_CURRENT_SOURCE_DIR}/src/patches/patch-squashfuse.sh.in +- ${CMAKE_CURRENT_BINARY_DIR}/patch-squashfuse.sh +- @ONLY +- ) +- +- ExternalProject_Add(squashfuse-EXTERNAL +- GIT_REPOSITORY https://github.com/vasi/squashfuse/ +- GIT_TAG 1f98030 +- UPDATE_COMMAND "" # make sure CMake won't try to fetch updates unnecessarily and hence rebuild the dependency every time +- PATCH_COMMAND bash -xe ${CMAKE_CURRENT_BINARY_DIR}/patch-squashfuse.sh +- CONFIGURE_COMMAND ${LIBTOOLIZE} --force +- # for some reason, a first run may fail, but it seems just running it a second time fixes the issues +- COMMAND env PKG_CONFIG_PATH=${xz_LIBRARY_DIRS}/pkgconfig ./autogen.sh || true +- COMMAND env PKG_CONFIG_PATH=${xz_LIBRARY_DIRS}/pkgconfig ./autogen.sh +- COMMAND ${SED} -i "/PKG_CHECK_MODULES.*/,/,:./d" configure # https://github.com/vasi/squashfuse/issues/12 +- COMMAND ${SED} -i "s/typedef off_t sqfs_off_t/typedef int64_t sqfs_off_t/g" common.h # off_t's size might differ, see https://stackoverflow.com/a/9073762 +- COMMAND CC=${CC} CXX=${CXX} CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} /configure --disable-demo --disable-high-level --without-lzo --without-lz4 --prefix= --libdir=/lib --with-xz=${xz_PREFIX} ${EXTRA_CONFIGURE_FLAGS} +- COMMAND ${SED} -i "s|XZ_LIBS = -llzma |XZ_LIBS = -Bstatic ${xz_LIBRARIES}/|g" Makefile +- BUILD_COMMAND ${MAKE} +- BUILD_IN_SOURCE ON +- INSTALL_COMMAND ${MAKE} install +- ) +- +- import_external_project( +- TARGET_NAME libsquashfuse +- EXT_PROJECT_NAME squashfuse-EXTERNAL +- LIBRARIES "/.libs/libsquashfuse.a;/.libs/libsquashfuse_ll.a;/.libs/libfuseprivate.a" +- INCLUDE_DIRS "" +- ) +-else() +- message(STATUS "Using system squashfuse") +- +- import_pkgconfig_target(TARGET_NAME libsquashfuse PKGCONFIG_TARGET squashfuse) +-endif() ++#if(NOT USE_SYSTEM_SQUASHFUSE) ++# message(STATUS "Downloading and building squashfuse") ++# ++# # TODO: implement out-of-source builds for squashfuse, as for the other dependencies ++# configure_file( ++# ${CMAKE_CURRENT_SOURCE_DIR}/src/patches/patch-squashfuse.sh.in ++# ${CMAKE_CURRENT_BINARY_DIR}/patch-squashfuse.sh ++# @ONLY ++# ) ++# ++# ExternalProject_Add(squashfuse-EXTERNAL ++# GIT_REPOSITORY https://github.com/vasi/squashfuse/ ++# GIT_TAG 1f98030 ++# UPDATE_COMMAND "" # make sure CMake won't try to fetch updates unnecessarily and hence rebuild the dependency every time ++# PATCH_COMMAND bash -xe ${CMAKE_CURRENT_BINARY_DIR}/patch-squashfuse.sh ++# CONFIGURE_COMMAND ${LIBTOOLIZE} --force ++# # for some reason, a first run may fail, but it seems just running it a second time fixes the issues ++# COMMAND env PKG_CONFIG_PATH=${xz_LIBRARY_DIRS}/pkgconfig ./autogen.sh || true ++# COMMAND env PKG_CONFIG_PATH=${xz_LIBRARY_DIRS}/pkgconfig ./autogen.sh ++# COMMAND ${SED} -i "/PKG_CHECK_MODULES.*/,/,:./d" configure # https://github.com/vasi/squashfuse/issues/12 ++# COMMAND ${SED} -i "s/typedef off_t sqfs_off_t/typedef int64_t sqfs_off_t/g" common.h # off_t's size might differ, see https://stackoverflow.com/a/9073762 ++# COMMAND CC=${CC} CXX=${CXX} CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} /configure --disable-demo --disable-high-level --without-lzo --without-lz4 --prefix= --libdir=/lib --with-xz=${xz_PREFIX} ${EXTRA_CONFIGURE_FLAGS} ++# COMMAND ${SED} -i "s|XZ_LIBS = -llzma |XZ_LIBS = -Bstatic ${xz_LIBRARIES}/|g" Makefile ++# BUILD_COMMAND ${MAKE} ++# BUILD_IN_SOURCE ON ++# INSTALL_COMMAND ${MAKE} install ++# ) ++# ++# import_external_project( ++# TARGET_NAME libsquashfuse ++# EXT_PROJECT_NAME squashfuse-EXTERNAL ++# LIBRARIES "/.libs/libsquashfuse.a;/.libs/libsquashfuse_ll.a;/.libs/libfuseprivate.a" ++# INCLUDE_DIRS "" ++# ) ++#else() ++# message(STATUS "Using system squashfuse") ++# ++# import_pkgconfig_target(TARGET_NAME libsquashfuse PKGCONFIG_TARGET squashfuse) ++#endif() + + + set(USE_SYSTEM_LIBARCHIVE OFF CACHE BOOL "Use system libarchive instead of building our own") +diff --git a/cmake/imported_dependencies.cmake b/cmake/imported_dependencies.cmake +index 56d7fc0..2a709c9 100644 +--- a/cmake/imported_dependencies.cmake ++++ b/cmake/imported_dependencies.cmake +@@ -3,8 +3,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/scripts.cmake) + # the names of the targets need to differ from the library filenames + # this is especially an issue with libcairo, where the library is called libcairo + # therefore, all libs imported this way have been prefixed with lib +-import_pkgconfig_target(TARGET_NAME libglib PKGCONFIG_TARGET glib-2.0>=2.40) +-import_pkgconfig_target(TARGET_NAME libgobject PKGCONFIG_TARGET gobject-2.0>=2.40) +-import_pkgconfig_target(TARGET_NAME libgio PKGCONFIG_TARGET gio-2.0>=2.40) +-import_pkgconfig_target(TARGET_NAME libzlib PKGCONFIG_TARGET zlib) +-import_pkgconfig_target(TARGET_NAME libcairo PKGCONFIG_TARGET cairo) ++#import_pkgconfig_target(TARGET_NAME libglib PKGCONFIG_TARGET glib-2.0>=2.40) ++#import_pkgconfig_target(TARGET_NAME libgobject PKGCONFIG_TARGET gobject-2.0>=2.40) ++#import_pkgconfig_target(TARGET_NAME libgio PKGCONFIG_TARGET gio-2.0>=2.40) ++#import_pkgconfig_target(TARGET_NAME libzlib PKGCONFIG_TARGET zlib) ++#import_pkgconfig_target(TARGET_NAME libcairo PKGCONFIG_TARGET cairo) +diff --git a/cmake/tools.cmake b/cmake/tools.cmake +index d0941bb..c93b6b3 100644 +--- a/cmake/tools.cmake ++++ b/cmake/tools.cmake +@@ -50,9 +50,6 @@ check_program(NAME autoreconf) + check_program(NAME libtoolize) + check_program(NAME patch) + check_program(NAME sed) +-check_program(NAME wget) +-check_program(NAME xxd) +-check_program(NAME desktop-file-validate) + check_program(NAME objcopy FORCE_PREFIX) + check_program(NAME objdump FORCE_PREFIX) + check_program(NAME readelf FORCE_PREFIX) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 664bf2a..081523b 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -3,16 +3,16 @@ cmake_minimum_required(VERSION 3.6) + + find_package(PkgConfig) + +-pkg_check_modules(glib glib-2.0>=2.40 IMPORTED_TARGET) +-pkg_check_modules(gobject gobject-2.0>=2.40 IMPORTED_TARGET) +-pkg_check_modules(gio gio-2.0>=2.40 IMPORTED_TARGET) +-pkg_check_modules(zlib zlib IMPORTED_TARGET) +-pkg_check_modules(cairo cairo IMPORTED_TARGET) ++#pkg_check_modules(glib glib-2.0>=2.40 IMPORTED_TARGET) ++#pkg_check_modules(gobject gobject-2.0>=2.40 IMPORTED_TARGET) ++#pkg_check_modules(gio gio-2.0>=2.40 IMPORTED_TARGET) ++#pkg_check_modules(zlib zlib IMPORTED_TARGET) ++#pkg_check_modules(cairo cairo IMPORTED_TARGET) + + add_subdirectory(xdg-basedir) + add_subdirectory(libappimage_hashlib) + add_subdirectory(libappimage_shared) +-add_subdirectory(libappimage) ++#add_subdirectory(libappimage) + + # Export the package for use from the build-tree + # (this registers the build-tree with a global CMake-registry) +-- +2.38.1 + diff --git a/contrib/depends/patches/libfuse/arm64.patch b/contrib/depends/patches/libfuse/arm64.patch new file mode 100644 index 0000000..027f54a --- /dev/null +++ b/contrib/depends/patches/libfuse/arm64.patch @@ -0,0 +1,35 @@ +From 914871b20a901e3e1e981c92bc42b1c93b7ab81b Mon Sep 17 00:00:00 2001 +From: Riku Voipio +Date: Thu, 07 Feb 2013 11:04:21 +0000 +Subject: fuse_kernel.h: clean includes + +Use for linux and define types used for other operating systems +using types. +--- +(limited to 'include/fuse_kernel.h') + +diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h +index 501450c..df8e9b9 100644 +--- a/include/fuse_kernel.h ++++ b/include/fuse_kernel.h +@@ -91,12 +91,16 @@ + #ifndef _LINUX_FUSE_H + #define _LINUX_FUSE_H + +-#include ++#ifdef __linux__ ++#include ++#else ++#include + #define __u64 uint64_t + #define __s64 int64_t + #define __u32 uint32_t + #define __s32 int32_t + #define __u16 uint16_t ++#endif + + /* + * Version negotiation: +-- +cgit v0.9.0.3-67-gacbf + diff --git a/contrib/depends/patches/libgcrypt/gost-sb.h b/contrib/depends/patches/libgcrypt/gost-sb.h new file mode 100644 index 0000000..5a87fc9 --- /dev/null +++ b/contrib/depends/patches/libgcrypt/gost-sb.h @@ -0,0 +1,2127 @@ +static const u32 sbox_test_3411[4*256] = + { + /* 0 */ + 0x00072000, 0x00075000, 0x00074800, 0x00071000, + 0x00076800, 0x00074000, 0x00070000, 0x00077000, + 0x00073000, 0x00075800, 0x00070800, 0x00076000, + 0x00073800, 0x00077800, 0x00072800, 0x00071800, + 0x0005a000, 0x0005d000, 0x0005c800, 0x00059000, + 0x0005e800, 0x0005c000, 0x00058000, 0x0005f000, + 0x0005b000, 0x0005d800, 0x00058800, 0x0005e000, + 0x0005b800, 0x0005f800, 0x0005a800, 0x00059800, + 0x00022000, 0x00025000, 0x00024800, 0x00021000, + 0x00026800, 0x00024000, 0x00020000, 0x00027000, + 0x00023000, 0x00025800, 0x00020800, 0x00026000, + 0x00023800, 0x00027800, 0x00022800, 0x00021800, + 0x00062000, 0x00065000, 0x00064800, 0x00061000, + 0x00066800, 0x00064000, 0x00060000, 0x00067000, + 0x00063000, 0x00065800, 0x00060800, 0x00066000, + 0x00063800, 0x00067800, 0x00062800, 0x00061800, + 0x00032000, 0x00035000, 0x00034800, 0x00031000, + 0x00036800, 0x00034000, 0x00030000, 0x00037000, + 0x00033000, 0x00035800, 0x00030800, 0x00036000, + 0x00033800, 0x00037800, 0x00032800, 0x00031800, + 0x0006a000, 0x0006d000, 0x0006c800, 0x00069000, + 0x0006e800, 0x0006c000, 0x00068000, 0x0006f000, + 0x0006b000, 0x0006d800, 0x00068800, 0x0006e000, + 0x0006b800, 0x0006f800, 0x0006a800, 0x00069800, + 0x0007a000, 0x0007d000, 0x0007c800, 0x00079000, + 0x0007e800, 0x0007c000, 0x00078000, 0x0007f000, + 0x0007b000, 0x0007d800, 0x00078800, 0x0007e000, + 0x0007b800, 0x0007f800, 0x0007a800, 0x00079800, + 0x00052000, 0x00055000, 0x00054800, 0x00051000, + 0x00056800, 0x00054000, 0x00050000, 0x00057000, + 0x00053000, 0x00055800, 0x00050800, 0x00056000, + 0x00053800, 0x00057800, 0x00052800, 0x00051800, + 0x00012000, 0x00015000, 0x00014800, 0x00011000, + 0x00016800, 0x00014000, 0x00010000, 0x00017000, + 0x00013000, 0x00015800, 0x00010800, 0x00016000, + 0x00013800, 0x00017800, 0x00012800, 0x00011800, + 0x0001a000, 0x0001d000, 0x0001c800, 0x00019000, + 0x0001e800, 0x0001c000, 0x00018000, 0x0001f000, + 0x0001b000, 0x0001d800, 0x00018800, 0x0001e000, + 0x0001b800, 0x0001f800, 0x0001a800, 0x00019800, + 0x00042000, 0x00045000, 0x00044800, 0x00041000, + 0x00046800, 0x00044000, 0x00040000, 0x00047000, + 0x00043000, 0x00045800, 0x00040800, 0x00046000, + 0x00043800, 0x00047800, 0x00042800, 0x00041800, + 0x0000a000, 0x0000d000, 0x0000c800, 0x00009000, + 0x0000e800, 0x0000c000, 0x00008000, 0x0000f000, + 0x0000b000, 0x0000d800, 0x00008800, 0x0000e000, + 0x0000b800, 0x0000f800, 0x0000a800, 0x00009800, + 0x00002000, 0x00005000, 0x00004800, 0x00001000, + 0x00006800, 0x00004000, 0x00000000, 0x00007000, + 0x00003000, 0x00005800, 0x00000800, 0x00006000, + 0x00003800, 0x00007800, 0x00002800, 0x00001800, + 0x0003a000, 0x0003d000, 0x0003c800, 0x00039000, + 0x0003e800, 0x0003c000, 0x00038000, 0x0003f000, + 0x0003b000, 0x0003d800, 0x00038800, 0x0003e000, + 0x0003b800, 0x0003f800, 0x0003a800, 0x00039800, + 0x0002a000, 0x0002d000, 0x0002c800, 0x00029000, + 0x0002e800, 0x0002c000, 0x00028000, 0x0002f000, + 0x0002b000, 0x0002d800, 0x00028800, 0x0002e000, + 0x0002b800, 0x0002f800, 0x0002a800, 0x00029800, + 0x0004a000, 0x0004d000, 0x0004c800, 0x00049000, + 0x0004e800, 0x0004c000, 0x00048000, 0x0004f000, + 0x0004b000, 0x0004d800, 0x00048800, 0x0004e000, + 0x0004b800, 0x0004f800, 0x0004a800, 0x00049800, + /* 1 */ + 0x03a80000, 0x03c00000, 0x03880000, 0x03e80000, + 0x03d00000, 0x03980000, 0x03a00000, 0x03900000, + 0x03f00000, 0x03f80000, 0x03e00000, 0x03b80000, + 0x03b00000, 0x03800000, 0x03c80000, 0x03d80000, + 0x06a80000, 0x06c00000, 0x06880000, 0x06e80000, + 0x06d00000, 0x06980000, 0x06a00000, 0x06900000, + 0x06f00000, 0x06f80000, 0x06e00000, 0x06b80000, + 0x06b00000, 0x06800000, 0x06c80000, 0x06d80000, + 0x05280000, 0x05400000, 0x05080000, 0x05680000, + 0x05500000, 0x05180000, 0x05200000, 0x05100000, + 0x05700000, 0x05780000, 0x05600000, 0x05380000, + 0x05300000, 0x05000000, 0x05480000, 0x05580000, + 0x00a80000, 0x00c00000, 0x00880000, 0x00e80000, + 0x00d00000, 0x00980000, 0x00a00000, 0x00900000, + 0x00f00000, 0x00f80000, 0x00e00000, 0x00b80000, + 0x00b00000, 0x00800000, 0x00c80000, 0x00d80000, + 0x00280000, 0x00400000, 0x00080000, 0x00680000, + 0x00500000, 0x00180000, 0x00200000, 0x00100000, + 0x00700000, 0x00780000, 0x00600000, 0x00380000, + 0x00300000, 0x00000000, 0x00480000, 0x00580000, + 0x04280000, 0x04400000, 0x04080000, 0x04680000, + 0x04500000, 0x04180000, 0x04200000, 0x04100000, + 0x04700000, 0x04780000, 0x04600000, 0x04380000, + 0x04300000, 0x04000000, 0x04480000, 0x04580000, + 0x04a80000, 0x04c00000, 0x04880000, 0x04e80000, + 0x04d00000, 0x04980000, 0x04a00000, 0x04900000, + 0x04f00000, 0x04f80000, 0x04e00000, 0x04b80000, + 0x04b00000, 0x04800000, 0x04c80000, 0x04d80000, + 0x07a80000, 0x07c00000, 0x07880000, 0x07e80000, + 0x07d00000, 0x07980000, 0x07a00000, 0x07900000, + 0x07f00000, 0x07f80000, 0x07e00000, 0x07b80000, + 0x07b00000, 0x07800000, 0x07c80000, 0x07d80000, + 0x07280000, 0x07400000, 0x07080000, 0x07680000, + 0x07500000, 0x07180000, 0x07200000, 0x07100000, + 0x07700000, 0x07780000, 0x07600000, 0x07380000, + 0x07300000, 0x07000000, 0x07480000, 0x07580000, + 0x02280000, 0x02400000, 0x02080000, 0x02680000, + 0x02500000, 0x02180000, 0x02200000, 0x02100000, + 0x02700000, 0x02780000, 0x02600000, 0x02380000, + 0x02300000, 0x02000000, 0x02480000, 0x02580000, + 0x03280000, 0x03400000, 0x03080000, 0x03680000, + 0x03500000, 0x03180000, 0x03200000, 0x03100000, + 0x03700000, 0x03780000, 0x03600000, 0x03380000, + 0x03300000, 0x03000000, 0x03480000, 0x03580000, + 0x06280000, 0x06400000, 0x06080000, 0x06680000, + 0x06500000, 0x06180000, 0x06200000, 0x06100000, + 0x06700000, 0x06780000, 0x06600000, 0x06380000, + 0x06300000, 0x06000000, 0x06480000, 0x06580000, + 0x05a80000, 0x05c00000, 0x05880000, 0x05e80000, + 0x05d00000, 0x05980000, 0x05a00000, 0x05900000, + 0x05f00000, 0x05f80000, 0x05e00000, 0x05b80000, + 0x05b00000, 0x05800000, 0x05c80000, 0x05d80000, + 0x01280000, 0x01400000, 0x01080000, 0x01680000, + 0x01500000, 0x01180000, 0x01200000, 0x01100000, + 0x01700000, 0x01780000, 0x01600000, 0x01380000, + 0x01300000, 0x01000000, 0x01480000, 0x01580000, + 0x02a80000, 0x02c00000, 0x02880000, 0x02e80000, + 0x02d00000, 0x02980000, 0x02a00000, 0x02900000, + 0x02f00000, 0x02f80000, 0x02e00000, 0x02b80000, + 0x02b00000, 0x02800000, 0x02c80000, 0x02d80000, + 0x01a80000, 0x01c00000, 0x01880000, 0x01e80000, + 0x01d00000, 0x01980000, 0x01a00000, 0x01900000, + 0x01f00000, 0x01f80000, 0x01e00000, 0x01b80000, + 0x01b00000, 0x01800000, 0x01c80000, 0x01d80000, + /* 2 */ + 0x30000002, 0x60000002, 0x38000002, 0x08000002, + 0x28000002, 0x78000002, 0x68000002, 0x40000002, + 0x20000002, 0x50000002, 0x48000002, 0x70000002, + 0x00000002, 0x18000002, 0x58000002, 0x10000002, + 0xb0000005, 0xe0000005, 0xb8000005, 0x88000005, + 0xa8000005, 0xf8000005, 0xe8000005, 0xc0000005, + 0xa0000005, 0xd0000005, 0xc8000005, 0xf0000005, + 0x80000005, 0x98000005, 0xd8000005, 0x90000005, + 0x30000005, 0x60000005, 0x38000005, 0x08000005, + 0x28000005, 0x78000005, 0x68000005, 0x40000005, + 0x20000005, 0x50000005, 0x48000005, 0x70000005, + 0x00000005, 0x18000005, 0x58000005, 0x10000005, + 0x30000000, 0x60000000, 0x38000000, 0x08000000, + 0x28000000, 0x78000000, 0x68000000, 0x40000000, + 0x20000000, 0x50000000, 0x48000000, 0x70000000, + 0x00000000, 0x18000000, 0x58000000, 0x10000000, + 0xb0000003, 0xe0000003, 0xb8000003, 0x88000003, + 0xa8000003, 0xf8000003, 0xe8000003, 0xc0000003, + 0xa0000003, 0xd0000003, 0xc8000003, 0xf0000003, + 0x80000003, 0x98000003, 0xd8000003, 0x90000003, + 0x30000001, 0x60000001, 0x38000001, 0x08000001, + 0x28000001, 0x78000001, 0x68000001, 0x40000001, + 0x20000001, 0x50000001, 0x48000001, 0x70000001, + 0x00000001, 0x18000001, 0x58000001, 0x10000001, + 0xb0000000, 0xe0000000, 0xb8000000, 0x88000000, + 0xa8000000, 0xf8000000, 0xe8000000, 0xc0000000, + 0xa0000000, 0xd0000000, 0xc8000000, 0xf0000000, + 0x80000000, 0x98000000, 0xd8000000, 0x90000000, + 0xb0000006, 0xe0000006, 0xb8000006, 0x88000006, + 0xa8000006, 0xf8000006, 0xe8000006, 0xc0000006, + 0xa0000006, 0xd0000006, 0xc8000006, 0xf0000006, + 0x80000006, 0x98000006, 0xd8000006, 0x90000006, + 0xb0000001, 0xe0000001, 0xb8000001, 0x88000001, + 0xa8000001, 0xf8000001, 0xe8000001, 0xc0000001, + 0xa0000001, 0xd0000001, 0xc8000001, 0xf0000001, + 0x80000001, 0x98000001, 0xd8000001, 0x90000001, + 0x30000003, 0x60000003, 0x38000003, 0x08000003, + 0x28000003, 0x78000003, 0x68000003, 0x40000003, + 0x20000003, 0x50000003, 0x48000003, 0x70000003, + 0x00000003, 0x18000003, 0x58000003, 0x10000003, + 0x30000004, 0x60000004, 0x38000004, 0x08000004, + 0x28000004, 0x78000004, 0x68000004, 0x40000004, + 0x20000004, 0x50000004, 0x48000004, 0x70000004, + 0x00000004, 0x18000004, 0x58000004, 0x10000004, + 0xb0000002, 0xe0000002, 0xb8000002, 0x88000002, + 0xa8000002, 0xf8000002, 0xe8000002, 0xc0000002, + 0xa0000002, 0xd0000002, 0xc8000002, 0xf0000002, + 0x80000002, 0x98000002, 0xd8000002, 0x90000002, + 0xb0000004, 0xe0000004, 0xb8000004, 0x88000004, + 0xa8000004, 0xf8000004, 0xe8000004, 0xc0000004, + 0xa0000004, 0xd0000004, 0xc8000004, 0xf0000004, + 0x80000004, 0x98000004, 0xd8000004, 0x90000004, + 0x30000006, 0x60000006, 0x38000006, 0x08000006, + 0x28000006, 0x78000006, 0x68000006, 0x40000006, + 0x20000006, 0x50000006, 0x48000006, 0x70000006, + 0x00000006, 0x18000006, 0x58000006, 0x10000006, + 0xb0000007, 0xe0000007, 0xb8000007, 0x88000007, + 0xa8000007, 0xf8000007, 0xe8000007, 0xc0000007, + 0xa0000007, 0xd0000007, 0xc8000007, 0xf0000007, + 0x80000007, 0x98000007, 0xd8000007, 0x90000007, + 0x30000007, 0x60000007, 0x38000007, 0x08000007, + 0x28000007, 0x78000007, 0x68000007, 0x40000007, + 0x20000007, 0x50000007, 0x48000007, 0x70000007, + 0x00000007, 0x18000007, 0x58000007, 0x10000007, + /* 3 */ + 0x000000e8, 0x000000d8, 0x000000a0, 0x00000088, + 0x00000098, 0x000000f8, 0x000000a8, 0x000000c8, + 0x00000080, 0x000000d0, 0x000000f0, 0x000000b8, + 0x000000b0, 0x000000c0, 0x00000090, 0x000000e0, + 0x000007e8, 0x000007d8, 0x000007a0, 0x00000788, + 0x00000798, 0x000007f8, 0x000007a8, 0x000007c8, + 0x00000780, 0x000007d0, 0x000007f0, 0x000007b8, + 0x000007b0, 0x000007c0, 0x00000790, 0x000007e0, + 0x000006e8, 0x000006d8, 0x000006a0, 0x00000688, + 0x00000698, 0x000006f8, 0x000006a8, 0x000006c8, + 0x00000680, 0x000006d0, 0x000006f0, 0x000006b8, + 0x000006b0, 0x000006c0, 0x00000690, 0x000006e0, + 0x00000068, 0x00000058, 0x00000020, 0x00000008, + 0x00000018, 0x00000078, 0x00000028, 0x00000048, + 0x00000000, 0x00000050, 0x00000070, 0x00000038, + 0x00000030, 0x00000040, 0x00000010, 0x00000060, + 0x000002e8, 0x000002d8, 0x000002a0, 0x00000288, + 0x00000298, 0x000002f8, 0x000002a8, 0x000002c8, + 0x00000280, 0x000002d0, 0x000002f0, 0x000002b8, + 0x000002b0, 0x000002c0, 0x00000290, 0x000002e0, + 0x000003e8, 0x000003d8, 0x000003a0, 0x00000388, + 0x00000398, 0x000003f8, 0x000003a8, 0x000003c8, + 0x00000380, 0x000003d0, 0x000003f0, 0x000003b8, + 0x000003b0, 0x000003c0, 0x00000390, 0x000003e0, + 0x00000568, 0x00000558, 0x00000520, 0x00000508, + 0x00000518, 0x00000578, 0x00000528, 0x00000548, + 0x00000500, 0x00000550, 0x00000570, 0x00000538, + 0x00000530, 0x00000540, 0x00000510, 0x00000560, + 0x00000268, 0x00000258, 0x00000220, 0x00000208, + 0x00000218, 0x00000278, 0x00000228, 0x00000248, + 0x00000200, 0x00000250, 0x00000270, 0x00000238, + 0x00000230, 0x00000240, 0x00000210, 0x00000260, + 0x000004e8, 0x000004d8, 0x000004a0, 0x00000488, + 0x00000498, 0x000004f8, 0x000004a8, 0x000004c8, + 0x00000480, 0x000004d0, 0x000004f0, 0x000004b8, + 0x000004b0, 0x000004c0, 0x00000490, 0x000004e0, + 0x00000168, 0x00000158, 0x00000120, 0x00000108, + 0x00000118, 0x00000178, 0x00000128, 0x00000148, + 0x00000100, 0x00000150, 0x00000170, 0x00000138, + 0x00000130, 0x00000140, 0x00000110, 0x00000160, + 0x000001e8, 0x000001d8, 0x000001a0, 0x00000188, + 0x00000198, 0x000001f8, 0x000001a8, 0x000001c8, + 0x00000180, 0x000001d0, 0x000001f0, 0x000001b8, + 0x000001b0, 0x000001c0, 0x00000190, 0x000001e0, + 0x00000768, 0x00000758, 0x00000720, 0x00000708, + 0x00000718, 0x00000778, 0x00000728, 0x00000748, + 0x00000700, 0x00000750, 0x00000770, 0x00000738, + 0x00000730, 0x00000740, 0x00000710, 0x00000760, + 0x00000368, 0x00000358, 0x00000320, 0x00000308, + 0x00000318, 0x00000378, 0x00000328, 0x00000348, + 0x00000300, 0x00000350, 0x00000370, 0x00000338, + 0x00000330, 0x00000340, 0x00000310, 0x00000360, + 0x000005e8, 0x000005d8, 0x000005a0, 0x00000588, + 0x00000598, 0x000005f8, 0x000005a8, 0x000005c8, + 0x00000580, 0x000005d0, 0x000005f0, 0x000005b8, + 0x000005b0, 0x000005c0, 0x00000590, 0x000005e0, + 0x00000468, 0x00000458, 0x00000420, 0x00000408, + 0x00000418, 0x00000478, 0x00000428, 0x00000448, + 0x00000400, 0x00000450, 0x00000470, 0x00000438, + 0x00000430, 0x00000440, 0x00000410, 0x00000460, + 0x00000668, 0x00000658, 0x00000620, 0x00000608, + 0x00000618, 0x00000678, 0x00000628, 0x00000648, + 0x00000600, 0x00000650, 0x00000670, 0x00000638, + 0x00000630, 0x00000640, 0x00000610, 0x00000660, + }; + +static const u32 sbox_CryptoPro_3411[4*256] = + { + /* 0 */ + 0x0002d000, 0x0002a000, 0x0002a800, 0x0002b000, + 0x0002c000, 0x00028800, 0x00029800, 0x0002b800, + 0x0002e800, 0x0002e000, 0x0002f000, 0x00028000, + 0x0002c800, 0x00029000, 0x0002d800, 0x0002f800, + 0x0007d000, 0x0007a000, 0x0007a800, 0x0007b000, + 0x0007c000, 0x00078800, 0x00079800, 0x0007b800, + 0x0007e800, 0x0007e000, 0x0007f000, 0x00078000, + 0x0007c800, 0x00079000, 0x0007d800, 0x0007f800, + 0x00025000, 0x00022000, 0x00022800, 0x00023000, + 0x00024000, 0x00020800, 0x00021800, 0x00023800, + 0x00026800, 0x00026000, 0x00027000, 0x00020000, + 0x00024800, 0x00021000, 0x00025800, 0x00027800, + 0x00005000, 0x00002000, 0x00002800, 0x00003000, + 0x00004000, 0x00000800, 0x00001800, 0x00003800, + 0x00006800, 0x00006000, 0x00007000, 0x00000000, + 0x00004800, 0x00001000, 0x00005800, 0x00007800, + 0x00015000, 0x00012000, 0x00012800, 0x00013000, + 0x00014000, 0x00010800, 0x00011800, 0x00013800, + 0x00016800, 0x00016000, 0x00017000, 0x00010000, + 0x00014800, 0x00011000, 0x00015800, 0x00017800, + 0x0006d000, 0x0006a000, 0x0006a800, 0x0006b000, + 0x0006c000, 0x00068800, 0x00069800, 0x0006b800, + 0x0006e800, 0x0006e000, 0x0006f000, 0x00068000, + 0x0006c800, 0x00069000, 0x0006d800, 0x0006f800, + 0x0005d000, 0x0005a000, 0x0005a800, 0x0005b000, + 0x0005c000, 0x00058800, 0x00059800, 0x0005b800, + 0x0005e800, 0x0005e000, 0x0005f000, 0x00058000, + 0x0005c800, 0x00059000, 0x0005d800, 0x0005f800, + 0x0004d000, 0x0004a000, 0x0004a800, 0x0004b000, + 0x0004c000, 0x00048800, 0x00049800, 0x0004b800, + 0x0004e800, 0x0004e000, 0x0004f000, 0x00048000, + 0x0004c800, 0x00049000, 0x0004d800, 0x0004f800, + 0x0000d000, 0x0000a000, 0x0000a800, 0x0000b000, + 0x0000c000, 0x00008800, 0x00009800, 0x0000b800, + 0x0000e800, 0x0000e000, 0x0000f000, 0x00008000, + 0x0000c800, 0x00009000, 0x0000d800, 0x0000f800, + 0x0003d000, 0x0003a000, 0x0003a800, 0x0003b000, + 0x0003c000, 0x00038800, 0x00039800, 0x0003b800, + 0x0003e800, 0x0003e000, 0x0003f000, 0x00038000, + 0x0003c800, 0x00039000, 0x0003d800, 0x0003f800, + 0x00035000, 0x00032000, 0x00032800, 0x00033000, + 0x00034000, 0x00030800, 0x00031800, 0x00033800, + 0x00036800, 0x00036000, 0x00037000, 0x00030000, + 0x00034800, 0x00031000, 0x00035800, 0x00037800, + 0x0001d000, 0x0001a000, 0x0001a800, 0x0001b000, + 0x0001c000, 0x00018800, 0x00019800, 0x0001b800, + 0x0001e800, 0x0001e000, 0x0001f000, 0x00018000, + 0x0001c800, 0x00019000, 0x0001d800, 0x0001f800, + 0x00065000, 0x00062000, 0x00062800, 0x00063000, + 0x00064000, 0x00060800, 0x00061800, 0x00063800, + 0x00066800, 0x00066000, 0x00067000, 0x00060000, + 0x00064800, 0x00061000, 0x00065800, 0x00067800, + 0x00075000, 0x00072000, 0x00072800, 0x00073000, + 0x00074000, 0x00070800, 0x00071800, 0x00073800, + 0x00076800, 0x00076000, 0x00077000, 0x00070000, + 0x00074800, 0x00071000, 0x00075800, 0x00077800, + 0x00055000, 0x00052000, 0x00052800, 0x00053000, + 0x00054000, 0x00050800, 0x00051800, 0x00053800, + 0x00056800, 0x00056000, 0x00057000, 0x00050000, + 0x00054800, 0x00051000, 0x00055800, 0x00057800, + 0x00045000, 0x00042000, 0x00042800, 0x00043000, + 0x00044000, 0x00040800, 0x00041800, 0x00043800, + 0x00046800, 0x00046000, 0x00047000, 0x00040000, + 0x00044800, 0x00041000, 0x00045800, 0x00047800, + /* 1 */ + 0x02380000, 0x02780000, 0x02600000, 0x02700000, + 0x02480000, 0x02200000, 0x02080000, 0x02000000, + 0x02180000, 0x02580000, 0x02280000, 0x02100000, + 0x02300000, 0x02500000, 0x02400000, 0x02680000, + 0x05380000, 0x05780000, 0x05600000, 0x05700000, + 0x05480000, 0x05200000, 0x05080000, 0x05000000, + 0x05180000, 0x05580000, 0x05280000, 0x05100000, + 0x05300000, 0x05500000, 0x05400000, 0x05680000, + 0x03b80000, 0x03f80000, 0x03e00000, 0x03f00000, + 0x03c80000, 0x03a00000, 0x03880000, 0x03800000, + 0x03980000, 0x03d80000, 0x03a80000, 0x03900000, + 0x03b00000, 0x03d00000, 0x03c00000, 0x03e80000, + 0x06380000, 0x06780000, 0x06600000, 0x06700000, + 0x06480000, 0x06200000, 0x06080000, 0x06000000, + 0x06180000, 0x06580000, 0x06280000, 0x06100000, + 0x06300000, 0x06500000, 0x06400000, 0x06680000, + 0x00380000, 0x00780000, 0x00600000, 0x00700000, + 0x00480000, 0x00200000, 0x00080000, 0x00000000, + 0x00180000, 0x00580000, 0x00280000, 0x00100000, + 0x00300000, 0x00500000, 0x00400000, 0x00680000, + 0x07b80000, 0x07f80000, 0x07e00000, 0x07f00000, + 0x07c80000, 0x07a00000, 0x07880000, 0x07800000, + 0x07980000, 0x07d80000, 0x07a80000, 0x07900000, + 0x07b00000, 0x07d00000, 0x07c00000, 0x07e80000, + 0x01380000, 0x01780000, 0x01600000, 0x01700000, + 0x01480000, 0x01200000, 0x01080000, 0x01000000, + 0x01180000, 0x01580000, 0x01280000, 0x01100000, + 0x01300000, 0x01500000, 0x01400000, 0x01680000, + 0x04380000, 0x04780000, 0x04600000, 0x04700000, + 0x04480000, 0x04200000, 0x04080000, 0x04000000, + 0x04180000, 0x04580000, 0x04280000, 0x04100000, + 0x04300000, 0x04500000, 0x04400000, 0x04680000, + 0x07380000, 0x07780000, 0x07600000, 0x07700000, + 0x07480000, 0x07200000, 0x07080000, 0x07000000, + 0x07180000, 0x07580000, 0x07280000, 0x07100000, + 0x07300000, 0x07500000, 0x07400000, 0x07680000, + 0x00b80000, 0x00f80000, 0x00e00000, 0x00f00000, + 0x00c80000, 0x00a00000, 0x00880000, 0x00800000, + 0x00980000, 0x00d80000, 0x00a80000, 0x00900000, + 0x00b00000, 0x00d00000, 0x00c00000, 0x00e80000, + 0x03380000, 0x03780000, 0x03600000, 0x03700000, + 0x03480000, 0x03200000, 0x03080000, 0x03000000, + 0x03180000, 0x03580000, 0x03280000, 0x03100000, + 0x03300000, 0x03500000, 0x03400000, 0x03680000, + 0x02b80000, 0x02f80000, 0x02e00000, 0x02f00000, + 0x02c80000, 0x02a00000, 0x02880000, 0x02800000, + 0x02980000, 0x02d80000, 0x02a80000, 0x02900000, + 0x02b00000, 0x02d00000, 0x02c00000, 0x02e80000, + 0x06b80000, 0x06f80000, 0x06e00000, 0x06f00000, + 0x06c80000, 0x06a00000, 0x06880000, 0x06800000, + 0x06980000, 0x06d80000, 0x06a80000, 0x06900000, + 0x06b00000, 0x06d00000, 0x06c00000, 0x06e80000, + 0x05b80000, 0x05f80000, 0x05e00000, 0x05f00000, + 0x05c80000, 0x05a00000, 0x05880000, 0x05800000, + 0x05980000, 0x05d80000, 0x05a80000, 0x05900000, + 0x05b00000, 0x05d00000, 0x05c00000, 0x05e80000, + 0x04b80000, 0x04f80000, 0x04e00000, 0x04f00000, + 0x04c80000, 0x04a00000, 0x04880000, 0x04800000, + 0x04980000, 0x04d80000, 0x04a80000, 0x04900000, + 0x04b00000, 0x04d00000, 0x04c00000, 0x04e80000, + 0x01b80000, 0x01f80000, 0x01e00000, 0x01f00000, + 0x01c80000, 0x01a00000, 0x01880000, 0x01800000, + 0x01980000, 0x01d80000, 0x01a80000, 0x01900000, + 0x01b00000, 0x01d00000, 0x01c00000, 0x01e80000, + /* 2 */ + 0xb8000003, 0xb0000003, 0xa0000003, 0xd8000003, + 0xc8000003, 0xe0000003, 0x90000003, 0xd0000003, + 0x88000003, 0xc0000003, 0x80000003, 0xf0000003, + 0xf8000003, 0xe8000003, 0x98000003, 0xa8000003, + 0x38000003, 0x30000003, 0x20000003, 0x58000003, + 0x48000003, 0x60000003, 0x10000003, 0x50000003, + 0x08000003, 0x40000003, 0x00000003, 0x70000003, + 0x78000003, 0x68000003, 0x18000003, 0x28000003, + 0x38000001, 0x30000001, 0x20000001, 0x58000001, + 0x48000001, 0x60000001, 0x10000001, 0x50000001, + 0x08000001, 0x40000001, 0x00000001, 0x70000001, + 0x78000001, 0x68000001, 0x18000001, 0x28000001, + 0x38000002, 0x30000002, 0x20000002, 0x58000002, + 0x48000002, 0x60000002, 0x10000002, 0x50000002, + 0x08000002, 0x40000002, 0x00000002, 0x70000002, + 0x78000002, 0x68000002, 0x18000002, 0x28000002, + 0xb8000006, 0xb0000006, 0xa0000006, 0xd8000006, + 0xc8000006, 0xe0000006, 0x90000006, 0xd0000006, + 0x88000006, 0xc0000006, 0x80000006, 0xf0000006, + 0xf8000006, 0xe8000006, 0x98000006, 0xa8000006, + 0xb8000004, 0xb0000004, 0xa0000004, 0xd8000004, + 0xc8000004, 0xe0000004, 0x90000004, 0xd0000004, + 0x88000004, 0xc0000004, 0x80000004, 0xf0000004, + 0xf8000004, 0xe8000004, 0x98000004, 0xa8000004, + 0xb8000007, 0xb0000007, 0xa0000007, 0xd8000007, + 0xc8000007, 0xe0000007, 0x90000007, 0xd0000007, + 0x88000007, 0xc0000007, 0x80000007, 0xf0000007, + 0xf8000007, 0xe8000007, 0x98000007, 0xa8000007, + 0x38000000, 0x30000000, 0x20000000, 0x58000000, + 0x48000000, 0x60000000, 0x10000000, 0x50000000, + 0x08000000, 0x40000000, 0x00000000, 0x70000000, + 0x78000000, 0x68000000, 0x18000000, 0x28000000, + 0x38000005, 0x30000005, 0x20000005, 0x58000005, + 0x48000005, 0x60000005, 0x10000005, 0x50000005, + 0x08000005, 0x40000005, 0x00000005, 0x70000005, + 0x78000005, 0x68000005, 0x18000005, 0x28000005, + 0xb8000000, 0xb0000000, 0xa0000000, 0xd8000000, + 0xc8000000, 0xe0000000, 0x90000000, 0xd0000000, + 0x88000000, 0xc0000000, 0x80000000, 0xf0000000, + 0xf8000000, 0xe8000000, 0x98000000, 0xa8000000, + 0xb8000002, 0xb0000002, 0xa0000002, 0xd8000002, + 0xc8000002, 0xe0000002, 0x90000002, 0xd0000002, + 0x88000002, 0xc0000002, 0x80000002, 0xf0000002, + 0xf8000002, 0xe8000002, 0x98000002, 0xa8000002, + 0xb8000005, 0xb0000005, 0xa0000005, 0xd8000005, + 0xc8000005, 0xe0000005, 0x90000005, 0xd0000005, + 0x88000005, 0xc0000005, 0x80000005, 0xf0000005, + 0xf8000005, 0xe8000005, 0x98000005, 0xa8000005, + 0x38000004, 0x30000004, 0x20000004, 0x58000004, + 0x48000004, 0x60000004, 0x10000004, 0x50000004, + 0x08000004, 0x40000004, 0x00000004, 0x70000004, + 0x78000004, 0x68000004, 0x18000004, 0x28000004, + 0x38000007, 0x30000007, 0x20000007, 0x58000007, + 0x48000007, 0x60000007, 0x10000007, 0x50000007, + 0x08000007, 0x40000007, 0x00000007, 0x70000007, + 0x78000007, 0x68000007, 0x18000007, 0x28000007, + 0x38000006, 0x30000006, 0x20000006, 0x58000006, + 0x48000006, 0x60000006, 0x10000006, 0x50000006, + 0x08000006, 0x40000006, 0x00000006, 0x70000006, + 0x78000006, 0x68000006, 0x18000006, 0x28000006, + 0xb8000001, 0xb0000001, 0xa0000001, 0xd8000001, + 0xc8000001, 0xe0000001, 0x90000001, 0xd0000001, + 0x88000001, 0xc0000001, 0x80000001, 0xf0000001, + 0xf8000001, 0xe8000001, 0x98000001, 0xa8000001, + /* 3 */ + 0x000000e8, 0x000000f0, 0x000000a0, 0x00000088, + 0x000000b8, 0x00000080, 0x000000a8, 0x000000d0, + 0x00000098, 0x000000e0, 0x000000c0, 0x000000f8, + 0x000000b0, 0x00000090, 0x000000c8, 0x000000d8, + 0x000001e8, 0x000001f0, 0x000001a0, 0x00000188, + 0x000001b8, 0x00000180, 0x000001a8, 0x000001d0, + 0x00000198, 0x000001e0, 0x000001c0, 0x000001f8, + 0x000001b0, 0x00000190, 0x000001c8, 0x000001d8, + 0x00000568, 0x00000570, 0x00000520, 0x00000508, + 0x00000538, 0x00000500, 0x00000528, 0x00000550, + 0x00000518, 0x00000560, 0x00000540, 0x00000578, + 0x00000530, 0x00000510, 0x00000548, 0x00000558, + 0x000004e8, 0x000004f0, 0x000004a0, 0x00000488, + 0x000004b8, 0x00000480, 0x000004a8, 0x000004d0, + 0x00000498, 0x000004e0, 0x000004c0, 0x000004f8, + 0x000004b0, 0x00000490, 0x000004c8, 0x000004d8, + 0x000002e8, 0x000002f0, 0x000002a0, 0x00000288, + 0x000002b8, 0x00000280, 0x000002a8, 0x000002d0, + 0x00000298, 0x000002e0, 0x000002c0, 0x000002f8, + 0x000002b0, 0x00000290, 0x000002c8, 0x000002d8, + 0x000005e8, 0x000005f0, 0x000005a0, 0x00000588, + 0x000005b8, 0x00000580, 0x000005a8, 0x000005d0, + 0x00000598, 0x000005e0, 0x000005c0, 0x000005f8, + 0x000005b0, 0x00000590, 0x000005c8, 0x000005d8, + 0x00000268, 0x00000270, 0x00000220, 0x00000208, + 0x00000238, 0x00000200, 0x00000228, 0x00000250, + 0x00000218, 0x00000260, 0x00000240, 0x00000278, + 0x00000230, 0x00000210, 0x00000248, 0x00000258, + 0x000007e8, 0x000007f0, 0x000007a0, 0x00000788, + 0x000007b8, 0x00000780, 0x000007a8, 0x000007d0, + 0x00000798, 0x000007e0, 0x000007c0, 0x000007f8, + 0x000007b0, 0x00000790, 0x000007c8, 0x000007d8, + 0x00000468, 0x00000470, 0x00000420, 0x00000408, + 0x00000438, 0x00000400, 0x00000428, 0x00000450, + 0x00000418, 0x00000460, 0x00000440, 0x00000478, + 0x00000430, 0x00000410, 0x00000448, 0x00000458, + 0x00000368, 0x00000370, 0x00000320, 0x00000308, + 0x00000338, 0x00000300, 0x00000328, 0x00000350, + 0x00000318, 0x00000360, 0x00000340, 0x00000378, + 0x00000330, 0x00000310, 0x00000348, 0x00000358, + 0x000003e8, 0x000003f0, 0x000003a0, 0x00000388, + 0x000003b8, 0x00000380, 0x000003a8, 0x000003d0, + 0x00000398, 0x000003e0, 0x000003c0, 0x000003f8, + 0x000003b0, 0x00000390, 0x000003c8, 0x000003d8, + 0x00000768, 0x00000770, 0x00000720, 0x00000708, + 0x00000738, 0x00000700, 0x00000728, 0x00000750, + 0x00000718, 0x00000760, 0x00000740, 0x00000778, + 0x00000730, 0x00000710, 0x00000748, 0x00000758, + 0x000006e8, 0x000006f0, 0x000006a0, 0x00000688, + 0x000006b8, 0x00000680, 0x000006a8, 0x000006d0, + 0x00000698, 0x000006e0, 0x000006c0, 0x000006f8, + 0x000006b0, 0x00000690, 0x000006c8, 0x000006d8, + 0x00000068, 0x00000070, 0x00000020, 0x00000008, + 0x00000038, 0x00000000, 0x00000028, 0x00000050, + 0x00000018, 0x00000060, 0x00000040, 0x00000078, + 0x00000030, 0x00000010, 0x00000048, 0x00000058, + 0x00000168, 0x00000170, 0x00000120, 0x00000108, + 0x00000138, 0x00000100, 0x00000128, 0x00000150, + 0x00000118, 0x00000160, 0x00000140, 0x00000178, + 0x00000130, 0x00000110, 0x00000148, 0x00000158, + 0x00000668, 0x00000670, 0x00000620, 0x00000608, + 0x00000638, 0x00000600, 0x00000628, 0x00000650, + 0x00000618, 0x00000660, 0x00000640, 0x00000678, + 0x00000630, 0x00000610, 0x00000648, 0x00000658, + }; + +static const u32 sbox_Test_89[4*256] = + { + /* 0 */ + 0x00062000, 0x00061000, 0x00067800, 0x00062800, + 0x00064800, 0x00060800, 0x00060000, 0x00064000, + 0x00067000, 0x00061800, 0x00065800, 0x00066000, + 0x00066800, 0x00063800, 0x00065000, 0x00063000, + 0x0004a000, 0x00049000, 0x0004f800, 0x0004a800, + 0x0004c800, 0x00048800, 0x00048000, 0x0004c000, + 0x0004f000, 0x00049800, 0x0004d800, 0x0004e000, + 0x0004e800, 0x0004b800, 0x0004d000, 0x0004b000, + 0x0007a000, 0x00079000, 0x0007f800, 0x0007a800, + 0x0007c800, 0x00078800, 0x00078000, 0x0007c000, + 0x0007f000, 0x00079800, 0x0007d800, 0x0007e000, + 0x0007e800, 0x0007b800, 0x0007d000, 0x0007b000, + 0x00072000, 0x00071000, 0x00077800, 0x00072800, + 0x00074800, 0x00070800, 0x00070000, 0x00074000, + 0x00077000, 0x00071800, 0x00075800, 0x00076000, + 0x00076800, 0x00073800, 0x00075000, 0x00073000, + 0x00042000, 0x00041000, 0x00047800, 0x00042800, + 0x00044800, 0x00040800, 0x00040000, 0x00044000, + 0x00047000, 0x00041800, 0x00045800, 0x00046000, + 0x00046800, 0x00043800, 0x00045000, 0x00043000, + 0x0000a000, 0x00009000, 0x0000f800, 0x0000a800, + 0x0000c800, 0x00008800, 0x00008000, 0x0000c000, + 0x0000f000, 0x00009800, 0x0000d800, 0x0000e000, + 0x0000e800, 0x0000b800, 0x0000d000, 0x0000b000, + 0x0001a000, 0x00019000, 0x0001f800, 0x0001a800, + 0x0001c800, 0x00018800, 0x00018000, 0x0001c000, + 0x0001f000, 0x00019800, 0x0001d800, 0x0001e000, + 0x0001e800, 0x0001b800, 0x0001d000, 0x0001b000, + 0x00052000, 0x00051000, 0x00057800, 0x00052800, + 0x00054800, 0x00050800, 0x00050000, 0x00054000, + 0x00057000, 0x00051800, 0x00055800, 0x00056000, + 0x00056800, 0x00053800, 0x00055000, 0x00053000, + 0x00012000, 0x00011000, 0x00017800, 0x00012800, + 0x00014800, 0x00010800, 0x00010000, 0x00014000, + 0x00017000, 0x00011800, 0x00015800, 0x00016000, + 0x00016800, 0x00013800, 0x00015000, 0x00013000, + 0x0003a000, 0x00039000, 0x0003f800, 0x0003a800, + 0x0003c800, 0x00038800, 0x00038000, 0x0003c000, + 0x0003f000, 0x00039800, 0x0003d800, 0x0003e000, + 0x0003e800, 0x0003b800, 0x0003d000, 0x0003b000, + 0x00022000, 0x00021000, 0x00027800, 0x00022800, + 0x00024800, 0x00020800, 0x00020000, 0x00024000, + 0x00027000, 0x00021800, 0x00025800, 0x00026000, + 0x00026800, 0x00023800, 0x00025000, 0x00023000, + 0x0006a000, 0x00069000, 0x0006f800, 0x0006a800, + 0x0006c800, 0x00068800, 0x00068000, 0x0006c000, + 0x0006f000, 0x00069800, 0x0006d800, 0x0006e000, + 0x0006e800, 0x0006b800, 0x0006d000, 0x0006b000, + 0x00032000, 0x00031000, 0x00037800, 0x00032800, + 0x00034800, 0x00030800, 0x00030000, 0x00034000, + 0x00037000, 0x00031800, 0x00035800, 0x00036000, + 0x00036800, 0x00033800, 0x00035000, 0x00033000, + 0x00002000, 0x00001000, 0x00007800, 0x00002800, + 0x00004800, 0x00000800, 0x00000000, 0x00004000, + 0x00007000, 0x00001800, 0x00005800, 0x00006000, + 0x00006800, 0x00003800, 0x00005000, 0x00003000, + 0x0005a000, 0x00059000, 0x0005f800, 0x0005a800, + 0x0005c800, 0x00058800, 0x00058000, 0x0005c000, + 0x0005f000, 0x00059800, 0x0005d800, 0x0005e000, + 0x0005e800, 0x0005b800, 0x0005d000, 0x0005b000, + 0x0002a000, 0x00029000, 0x0002f800, 0x0002a800, + 0x0002c800, 0x00028800, 0x00028000, 0x0002c000, + 0x0002f000, 0x00029800, 0x0002d800, 0x0002e000, + 0x0002e800, 0x0002b800, 0x0002d000, 0x0002b000, + /* 1 */ + 0x07680000, 0x07400000, 0x07700000, 0x07600000, + 0x07380000, 0x07180000, 0x07480000, 0x07500000, + 0x07080000, 0x07280000, 0x07100000, 0x07200000, + 0x07300000, 0x07780000, 0x07000000, 0x07580000, + 0x04e80000, 0x04c00000, 0x04f00000, 0x04e00000, + 0x04b80000, 0x04980000, 0x04c80000, 0x04d00000, + 0x04880000, 0x04a80000, 0x04900000, 0x04a00000, + 0x04b00000, 0x04f80000, 0x04800000, 0x04d80000, + 0x05e80000, 0x05c00000, 0x05f00000, 0x05e00000, + 0x05b80000, 0x05980000, 0x05c80000, 0x05d00000, + 0x05880000, 0x05a80000, 0x05900000, 0x05a00000, + 0x05b00000, 0x05f80000, 0x05800000, 0x05d80000, + 0x01680000, 0x01400000, 0x01700000, 0x01600000, + 0x01380000, 0x01180000, 0x01480000, 0x01500000, + 0x01080000, 0x01280000, 0x01100000, 0x01200000, + 0x01300000, 0x01780000, 0x01000000, 0x01580000, + 0x02e80000, 0x02c00000, 0x02f00000, 0x02e00000, + 0x02b80000, 0x02980000, 0x02c80000, 0x02d00000, + 0x02880000, 0x02a80000, 0x02900000, 0x02a00000, + 0x02b00000, 0x02f80000, 0x02800000, 0x02d80000, + 0x07e80000, 0x07c00000, 0x07f00000, 0x07e00000, + 0x07b80000, 0x07980000, 0x07c80000, 0x07d00000, + 0x07880000, 0x07a80000, 0x07900000, 0x07a00000, + 0x07b00000, 0x07f80000, 0x07800000, 0x07d80000, + 0x03e80000, 0x03c00000, 0x03f00000, 0x03e00000, + 0x03b80000, 0x03980000, 0x03c80000, 0x03d00000, + 0x03880000, 0x03a80000, 0x03900000, 0x03a00000, + 0x03b00000, 0x03f80000, 0x03800000, 0x03d80000, + 0x00e80000, 0x00c00000, 0x00f00000, 0x00e00000, + 0x00b80000, 0x00980000, 0x00c80000, 0x00d00000, + 0x00880000, 0x00a80000, 0x00900000, 0x00a00000, + 0x00b00000, 0x00f80000, 0x00800000, 0x00d80000, + 0x00680000, 0x00400000, 0x00700000, 0x00600000, + 0x00380000, 0x00180000, 0x00480000, 0x00500000, + 0x00080000, 0x00280000, 0x00100000, 0x00200000, + 0x00300000, 0x00780000, 0x00000000, 0x00580000, + 0x06e80000, 0x06c00000, 0x06f00000, 0x06e00000, + 0x06b80000, 0x06980000, 0x06c80000, 0x06d00000, + 0x06880000, 0x06a80000, 0x06900000, 0x06a00000, + 0x06b00000, 0x06f80000, 0x06800000, 0x06d80000, + 0x06680000, 0x06400000, 0x06700000, 0x06600000, + 0x06380000, 0x06180000, 0x06480000, 0x06500000, + 0x06080000, 0x06280000, 0x06100000, 0x06200000, + 0x06300000, 0x06780000, 0x06000000, 0x06580000, + 0x03680000, 0x03400000, 0x03700000, 0x03600000, + 0x03380000, 0x03180000, 0x03480000, 0x03500000, + 0x03080000, 0x03280000, 0x03100000, 0x03200000, + 0x03300000, 0x03780000, 0x03000000, 0x03580000, + 0x05680000, 0x05400000, 0x05700000, 0x05600000, + 0x05380000, 0x05180000, 0x05480000, 0x05500000, + 0x05080000, 0x05280000, 0x05100000, 0x05200000, + 0x05300000, 0x05780000, 0x05000000, 0x05580000, + 0x02680000, 0x02400000, 0x02700000, 0x02600000, + 0x02380000, 0x02180000, 0x02480000, 0x02500000, + 0x02080000, 0x02280000, 0x02100000, 0x02200000, + 0x02300000, 0x02780000, 0x02000000, 0x02580000, + 0x01e80000, 0x01c00000, 0x01f00000, 0x01e00000, + 0x01b80000, 0x01980000, 0x01c80000, 0x01d00000, + 0x01880000, 0x01a80000, 0x01900000, 0x01a00000, + 0x01b00000, 0x01f80000, 0x01800000, 0x01d80000, + 0x04680000, 0x04400000, 0x04700000, 0x04600000, + 0x04380000, 0x04180000, 0x04480000, 0x04500000, + 0x04080000, 0x04280000, 0x04100000, 0x04200000, + 0x04300000, 0x04780000, 0x04000000, 0x04580000, + /* 2 */ + 0x18000004, 0x70000004, 0x28000004, 0x48000004, + 0x30000004, 0x40000004, 0x00000004, 0x68000004, + 0x50000004, 0x58000004, 0x38000004, 0x60000004, + 0x10000004, 0x08000004, 0x78000004, 0x20000004, + 0x98000007, 0xf0000007, 0xa8000007, 0xc8000007, + 0xb0000007, 0xc0000007, 0x80000007, 0xe8000007, + 0xd0000007, 0xd8000007, 0xb8000007, 0xe0000007, + 0x90000007, 0x88000007, 0xf8000007, 0xa0000007, + 0x18000003, 0x70000003, 0x28000003, 0x48000003, + 0x30000003, 0x40000003, 0x00000003, 0x68000003, + 0x50000003, 0x58000003, 0x38000003, 0x60000003, + 0x10000003, 0x08000003, 0x78000003, 0x20000003, + 0x98000005, 0xf0000005, 0xa8000005, 0xc8000005, + 0xb0000005, 0xc0000005, 0x80000005, 0xe8000005, + 0xd0000005, 0xd8000005, 0xb8000005, 0xe0000005, + 0x90000005, 0x88000005, 0xf8000005, 0xa0000005, + 0x98000000, 0xf0000000, 0xa8000000, 0xc8000000, + 0xb0000000, 0xc0000000, 0x80000000, 0xe8000000, + 0xd0000000, 0xd8000000, 0xb8000000, 0xe0000000, + 0x90000000, 0x88000000, 0xf8000000, 0xa0000000, + 0x98000004, 0xf0000004, 0xa8000004, 0xc8000004, + 0xb0000004, 0xc0000004, 0x80000004, 0xe8000004, + 0xd0000004, 0xd8000004, 0xb8000004, 0xe0000004, + 0x90000004, 0x88000004, 0xf8000004, 0xa0000004, + 0x18000006, 0x70000006, 0x28000006, 0x48000006, + 0x30000006, 0x40000006, 0x00000006, 0x68000006, + 0x50000006, 0x58000006, 0x38000006, 0x60000006, + 0x10000006, 0x08000006, 0x78000006, 0x20000006, + 0x98000002, 0xf0000002, 0xa8000002, 0xc8000002, + 0xb0000002, 0xc0000002, 0x80000002, 0xe8000002, + 0xd0000002, 0xd8000002, 0xb8000002, 0xe0000002, + 0x90000002, 0x88000002, 0xf8000002, 0xa0000002, + 0x98000006, 0xf0000006, 0xa8000006, 0xc8000006, + 0xb0000006, 0xc0000006, 0x80000006, 0xe8000006, + 0xd0000006, 0xd8000006, 0xb8000006, 0xe0000006, + 0x90000006, 0x88000006, 0xf8000006, 0xa0000006, + 0x98000001, 0xf0000001, 0xa8000001, 0xc8000001, + 0xb0000001, 0xc0000001, 0x80000001, 0xe8000001, + 0xd0000001, 0xd8000001, 0xb8000001, 0xe0000001, + 0x90000001, 0x88000001, 0xf8000001, 0xa0000001, + 0x98000003, 0xf0000003, 0xa8000003, 0xc8000003, + 0xb0000003, 0xc0000003, 0x80000003, 0xe8000003, + 0xd0000003, 0xd8000003, 0xb8000003, 0xe0000003, + 0x90000003, 0x88000003, 0xf8000003, 0xa0000003, + 0x18000005, 0x70000005, 0x28000005, 0x48000005, + 0x30000005, 0x40000005, 0x00000005, 0x68000005, + 0x50000005, 0x58000005, 0x38000005, 0x60000005, + 0x10000005, 0x08000005, 0x78000005, 0x20000005, + 0x18000000, 0x70000000, 0x28000000, 0x48000000, + 0x30000000, 0x40000000, 0x00000000, 0x68000000, + 0x50000000, 0x58000000, 0x38000000, 0x60000000, + 0x10000000, 0x08000000, 0x78000000, 0x20000000, + 0x18000007, 0x70000007, 0x28000007, 0x48000007, + 0x30000007, 0x40000007, 0x00000007, 0x68000007, + 0x50000007, 0x58000007, 0x38000007, 0x60000007, + 0x10000007, 0x08000007, 0x78000007, 0x20000007, + 0x18000001, 0x70000001, 0x28000001, 0x48000001, + 0x30000001, 0x40000001, 0x00000001, 0x68000001, + 0x50000001, 0x58000001, 0x38000001, 0x60000001, + 0x10000001, 0x08000001, 0x78000001, 0x20000001, + 0x18000002, 0x70000002, 0x28000002, 0x48000002, + 0x30000002, 0x40000002, 0x00000002, 0x68000002, + 0x50000002, 0x58000002, 0x38000002, 0x60000002, + 0x10000002, 0x08000002, 0x78000002, 0x20000002, + /* 3 */ + 0x00000648, 0x00000658, 0x00000660, 0x00000600, + 0x00000618, 0x00000630, 0x00000638, 0x00000628, + 0x00000620, 0x00000640, 0x00000670, 0x00000678, + 0x00000608, 0x00000650, 0x00000610, 0x00000668, + 0x00000348, 0x00000358, 0x00000360, 0x00000300, + 0x00000318, 0x00000330, 0x00000338, 0x00000328, + 0x00000320, 0x00000340, 0x00000370, 0x00000378, + 0x00000308, 0x00000350, 0x00000310, 0x00000368, + 0x000002c8, 0x000002d8, 0x000002e0, 0x00000280, + 0x00000298, 0x000002b0, 0x000002b8, 0x000002a8, + 0x000002a0, 0x000002c0, 0x000002f0, 0x000002f8, + 0x00000288, 0x000002d0, 0x00000290, 0x000002e8, + 0x00000148, 0x00000158, 0x00000160, 0x00000100, + 0x00000118, 0x00000130, 0x00000138, 0x00000128, + 0x00000120, 0x00000140, 0x00000170, 0x00000178, + 0x00000108, 0x00000150, 0x00000110, 0x00000168, + 0x000005c8, 0x000005d8, 0x000005e0, 0x00000580, + 0x00000598, 0x000005b0, 0x000005b8, 0x000005a8, + 0x000005a0, 0x000005c0, 0x000005f0, 0x000005f8, + 0x00000588, 0x000005d0, 0x00000590, 0x000005e8, + 0x00000048, 0x00000058, 0x00000060, 0x00000000, + 0x00000018, 0x00000030, 0x00000038, 0x00000028, + 0x00000020, 0x00000040, 0x00000070, 0x00000078, + 0x00000008, 0x00000050, 0x00000010, 0x00000068, + 0x000004c8, 0x000004d8, 0x000004e0, 0x00000480, + 0x00000498, 0x000004b0, 0x000004b8, 0x000004a8, + 0x000004a0, 0x000004c0, 0x000004f0, 0x000004f8, + 0x00000488, 0x000004d0, 0x00000490, 0x000004e8, + 0x000006c8, 0x000006d8, 0x000006e0, 0x00000680, + 0x00000698, 0x000006b0, 0x000006b8, 0x000006a8, + 0x000006a0, 0x000006c0, 0x000006f0, 0x000006f8, + 0x00000688, 0x000006d0, 0x00000690, 0x000006e8, + 0x000001c8, 0x000001d8, 0x000001e0, 0x00000180, + 0x00000198, 0x000001b0, 0x000001b8, 0x000001a8, + 0x000001a0, 0x000001c0, 0x000001f0, 0x000001f8, + 0x00000188, 0x000001d0, 0x00000190, 0x000001e8, + 0x00000748, 0x00000758, 0x00000760, 0x00000700, + 0x00000718, 0x00000730, 0x00000738, 0x00000728, + 0x00000720, 0x00000740, 0x00000770, 0x00000778, + 0x00000708, 0x00000750, 0x00000710, 0x00000768, + 0x000003c8, 0x000003d8, 0x000003e0, 0x00000380, + 0x00000398, 0x000003b0, 0x000003b8, 0x000003a8, + 0x000003a0, 0x000003c0, 0x000003f0, 0x000003f8, + 0x00000388, 0x000003d0, 0x00000390, 0x000003e8, + 0x00000548, 0x00000558, 0x00000560, 0x00000500, + 0x00000518, 0x00000530, 0x00000538, 0x00000528, + 0x00000520, 0x00000540, 0x00000570, 0x00000578, + 0x00000508, 0x00000550, 0x00000510, 0x00000568, + 0x000007c8, 0x000007d8, 0x000007e0, 0x00000780, + 0x00000798, 0x000007b0, 0x000007b8, 0x000007a8, + 0x000007a0, 0x000007c0, 0x000007f0, 0x000007f8, + 0x00000788, 0x000007d0, 0x00000790, 0x000007e8, + 0x00000248, 0x00000258, 0x00000260, 0x00000200, + 0x00000218, 0x00000230, 0x00000238, 0x00000228, + 0x00000220, 0x00000240, 0x00000270, 0x00000278, + 0x00000208, 0x00000250, 0x00000210, 0x00000268, + 0x000000c8, 0x000000d8, 0x000000e0, 0x00000080, + 0x00000098, 0x000000b0, 0x000000b8, 0x000000a8, + 0x000000a0, 0x000000c0, 0x000000f0, 0x000000f8, + 0x00000088, 0x000000d0, 0x00000090, 0x000000e8, + 0x00000448, 0x00000458, 0x00000460, 0x00000400, + 0x00000418, 0x00000430, 0x00000438, 0x00000428, + 0x00000420, 0x00000440, 0x00000470, 0x00000478, + 0x00000408, 0x00000450, 0x00000410, 0x00000468, + }; + +static const u32 sbox_CryptoPro_A[4*256] = + { + /* 0 */ + 0x0001c800, 0x0001b000, 0x00019800, 0x00019000, + 0x0001c000, 0x0001d800, 0x00018800, 0x0001b800, + 0x0001d000, 0x0001a000, 0x0001f000, 0x0001f800, + 0x0001e000, 0x00018000, 0x0001e800, 0x0001a800, + 0x0003c800, 0x0003b000, 0x00039800, 0x00039000, + 0x0003c000, 0x0003d800, 0x00038800, 0x0003b800, + 0x0003d000, 0x0003a000, 0x0003f000, 0x0003f800, + 0x0003e000, 0x00038000, 0x0003e800, 0x0003a800, + 0x00074800, 0x00073000, 0x00071800, 0x00071000, + 0x00074000, 0x00075800, 0x00070800, 0x00073800, + 0x00075000, 0x00072000, 0x00077000, 0x00077800, + 0x00076000, 0x00070000, 0x00076800, 0x00072800, + 0x0004c800, 0x0004b000, 0x00049800, 0x00049000, + 0x0004c000, 0x0004d800, 0x00048800, 0x0004b800, + 0x0004d000, 0x0004a000, 0x0004f000, 0x0004f800, + 0x0004e000, 0x00048000, 0x0004e800, 0x0004a800, + 0x00044800, 0x00043000, 0x00041800, 0x00041000, + 0x00044000, 0x00045800, 0x00040800, 0x00043800, + 0x00045000, 0x00042000, 0x00047000, 0x00047800, + 0x00046000, 0x00040000, 0x00046800, 0x00042800, + 0x00054800, 0x00053000, 0x00051800, 0x00051000, + 0x00054000, 0x00055800, 0x00050800, 0x00053800, + 0x00055000, 0x00052000, 0x00057000, 0x00057800, + 0x00056000, 0x00050000, 0x00056800, 0x00052800, + 0x0007c800, 0x0007b000, 0x00079800, 0x00079000, + 0x0007c000, 0x0007d800, 0x00078800, 0x0007b800, + 0x0007d000, 0x0007a000, 0x0007f000, 0x0007f800, + 0x0007e000, 0x00078000, 0x0007e800, 0x0007a800, + 0x00004800, 0x00003000, 0x00001800, 0x00001000, + 0x00004000, 0x00005800, 0x00000800, 0x00003800, + 0x00005000, 0x00002000, 0x00007000, 0x00007800, + 0x00006000, 0x00000000, 0x00006800, 0x00002800, + 0x0002c800, 0x0002b000, 0x00029800, 0x00029000, + 0x0002c000, 0x0002d800, 0x00028800, 0x0002b800, + 0x0002d000, 0x0002a000, 0x0002f000, 0x0002f800, + 0x0002e000, 0x00028000, 0x0002e800, 0x0002a800, + 0x00014800, 0x00013000, 0x00011800, 0x00011000, + 0x00014000, 0x00015800, 0x00010800, 0x00013800, + 0x00015000, 0x00012000, 0x00017000, 0x00017800, + 0x00016000, 0x00010000, 0x00016800, 0x00012800, + 0x00034800, 0x00033000, 0x00031800, 0x00031000, + 0x00034000, 0x00035800, 0x00030800, 0x00033800, + 0x00035000, 0x00032000, 0x00037000, 0x00037800, + 0x00036000, 0x00030000, 0x00036800, 0x00032800, + 0x00064800, 0x00063000, 0x00061800, 0x00061000, + 0x00064000, 0x00065800, 0x00060800, 0x00063800, + 0x00065000, 0x00062000, 0x00067000, 0x00067800, + 0x00066000, 0x00060000, 0x00066800, 0x00062800, + 0x0005c800, 0x0005b000, 0x00059800, 0x00059000, + 0x0005c000, 0x0005d800, 0x00058800, 0x0005b800, + 0x0005d000, 0x0005a000, 0x0005f000, 0x0005f800, + 0x0005e000, 0x00058000, 0x0005e800, 0x0005a800, + 0x00024800, 0x00023000, 0x00021800, 0x00021000, + 0x00024000, 0x00025800, 0x00020800, 0x00023800, + 0x00025000, 0x00022000, 0x00027000, 0x00027800, + 0x00026000, 0x00020000, 0x00026800, 0x00022800, + 0x0006c800, 0x0006b000, 0x00069800, 0x00069000, + 0x0006c000, 0x0006d800, 0x00068800, 0x0006b800, + 0x0006d000, 0x0006a000, 0x0006f000, 0x0006f800, + 0x0006e000, 0x00068000, 0x0006e800, 0x0006a800, + 0x0000c800, 0x0000b000, 0x00009800, 0x00009000, + 0x0000c000, 0x0000d800, 0x00008800, 0x0000b800, + 0x0000d000, 0x0000a000, 0x0000f000, 0x0000f800, + 0x0000e000, 0x00008000, 0x0000e800, 0x0000a800, + /* 1 */ + 0x07700000, 0x07200000, 0x07300000, 0x07100000, + 0x07580000, 0x07180000, 0x07680000, 0x07400000, + 0x07600000, 0x07780000, 0x07280000, 0x07500000, + 0x07000000, 0x07380000, 0x07080000, 0x07480000, + 0x03f00000, 0x03a00000, 0x03b00000, 0x03900000, + 0x03d80000, 0x03980000, 0x03e80000, 0x03c00000, + 0x03e00000, 0x03f80000, 0x03a80000, 0x03d00000, + 0x03800000, 0x03b80000, 0x03880000, 0x03c80000, + 0x05700000, 0x05200000, 0x05300000, 0x05100000, + 0x05580000, 0x05180000, 0x05680000, 0x05400000, + 0x05600000, 0x05780000, 0x05280000, 0x05500000, + 0x05000000, 0x05380000, 0x05080000, 0x05480000, + 0x06700000, 0x06200000, 0x06300000, 0x06100000, + 0x06580000, 0x06180000, 0x06680000, 0x06400000, + 0x06600000, 0x06780000, 0x06280000, 0x06500000, + 0x06000000, 0x06380000, 0x06080000, 0x06480000, + 0x06f00000, 0x06a00000, 0x06b00000, 0x06900000, + 0x06d80000, 0x06980000, 0x06e80000, 0x06c00000, + 0x06e00000, 0x06f80000, 0x06a80000, 0x06d00000, + 0x06800000, 0x06b80000, 0x06880000, 0x06c80000, + 0x00f00000, 0x00a00000, 0x00b00000, 0x00900000, + 0x00d80000, 0x00980000, 0x00e80000, 0x00c00000, + 0x00e00000, 0x00f80000, 0x00a80000, 0x00d00000, + 0x00800000, 0x00b80000, 0x00880000, 0x00c80000, + 0x01f00000, 0x01a00000, 0x01b00000, 0x01900000, + 0x01d80000, 0x01980000, 0x01e80000, 0x01c00000, + 0x01e00000, 0x01f80000, 0x01a80000, 0x01d00000, + 0x01800000, 0x01b80000, 0x01880000, 0x01c80000, + 0x04f00000, 0x04a00000, 0x04b00000, 0x04900000, + 0x04d80000, 0x04980000, 0x04e80000, 0x04c00000, + 0x04e00000, 0x04f80000, 0x04a80000, 0x04d00000, + 0x04800000, 0x04b80000, 0x04880000, 0x04c80000, + 0x00700000, 0x00200000, 0x00300000, 0x00100000, + 0x00580000, 0x00180000, 0x00680000, 0x00400000, + 0x00600000, 0x00780000, 0x00280000, 0x00500000, + 0x00000000, 0x00380000, 0x00080000, 0x00480000, + 0x01700000, 0x01200000, 0x01300000, 0x01100000, + 0x01580000, 0x01180000, 0x01680000, 0x01400000, + 0x01600000, 0x01780000, 0x01280000, 0x01500000, + 0x01000000, 0x01380000, 0x01080000, 0x01480000, + 0x05f00000, 0x05a00000, 0x05b00000, 0x05900000, + 0x05d80000, 0x05980000, 0x05e80000, 0x05c00000, + 0x05e00000, 0x05f80000, 0x05a80000, 0x05d00000, + 0x05800000, 0x05b80000, 0x05880000, 0x05c80000, + 0x02700000, 0x02200000, 0x02300000, 0x02100000, + 0x02580000, 0x02180000, 0x02680000, 0x02400000, + 0x02600000, 0x02780000, 0x02280000, 0x02500000, + 0x02000000, 0x02380000, 0x02080000, 0x02480000, + 0x07f00000, 0x07a00000, 0x07b00000, 0x07900000, + 0x07d80000, 0x07980000, 0x07e80000, 0x07c00000, + 0x07e00000, 0x07f80000, 0x07a80000, 0x07d00000, + 0x07800000, 0x07b80000, 0x07880000, 0x07c80000, + 0x04700000, 0x04200000, 0x04300000, 0x04100000, + 0x04580000, 0x04180000, 0x04680000, 0x04400000, + 0x04600000, 0x04780000, 0x04280000, 0x04500000, + 0x04000000, 0x04380000, 0x04080000, 0x04480000, + 0x02f00000, 0x02a00000, 0x02b00000, 0x02900000, + 0x02d80000, 0x02980000, 0x02e80000, 0x02c00000, + 0x02e00000, 0x02f80000, 0x02a80000, 0x02d00000, + 0x02800000, 0x02b80000, 0x02880000, 0x02c80000, + 0x03700000, 0x03200000, 0x03300000, 0x03100000, + 0x03580000, 0x03180000, 0x03680000, 0x03400000, + 0x03600000, 0x03780000, 0x03280000, 0x03500000, + 0x03000000, 0x03380000, 0x03080000, 0x03480000, + /* 2 */ + 0xd8000001, 0xa8000001, 0x88000001, 0xc8000001, + 0xc0000001, 0xe8000001, 0xf8000001, 0x80000001, + 0xf0000001, 0xa0000001, 0x90000001, 0x98000001, + 0xe0000001, 0xb8000001, 0xd0000001, 0xb0000001, + 0x58000005, 0x28000005, 0x08000005, 0x48000005, + 0x40000005, 0x68000005, 0x78000005, 0x00000005, + 0x70000005, 0x20000005, 0x10000005, 0x18000005, + 0x60000005, 0x38000005, 0x50000005, 0x30000005, + 0xd8000006, 0xa8000006, 0x88000006, 0xc8000006, + 0xc0000006, 0xe8000006, 0xf8000006, 0x80000006, + 0xf0000006, 0xa0000006, 0x90000006, 0x98000006, + 0xe0000006, 0xb8000006, 0xd0000006, 0xb0000006, + 0x58000006, 0x28000006, 0x08000006, 0x48000006, + 0x40000006, 0x68000006, 0x78000006, 0x00000006, + 0x70000006, 0x20000006, 0x10000006, 0x18000006, + 0x60000006, 0x38000006, 0x50000006, 0x30000006, + 0xd8000000, 0xa8000000, 0x88000000, 0xc8000000, + 0xc0000000, 0xe8000000, 0xf8000000, 0x80000000, + 0xf0000000, 0xa0000000, 0x90000000, 0x98000000, + 0xe0000000, 0xb8000000, 0xd0000000, 0xb0000000, + 0x58000001, 0x28000001, 0x08000001, 0x48000001, + 0x40000001, 0x68000001, 0x78000001, 0x00000001, + 0x70000001, 0x20000001, 0x10000001, 0x18000001, + 0x60000001, 0x38000001, 0x50000001, 0x30000001, + 0x58000000, 0x28000000, 0x08000000, 0x48000000, + 0x40000000, 0x68000000, 0x78000000, 0x00000000, + 0x70000000, 0x20000000, 0x10000000, 0x18000000, + 0x60000000, 0x38000000, 0x50000000, 0x30000000, + 0xd8000005, 0xa8000005, 0x88000005, 0xc8000005, + 0xc0000005, 0xe8000005, 0xf8000005, 0x80000005, + 0xf0000005, 0xa0000005, 0x90000005, 0x98000005, + 0xe0000005, 0xb8000005, 0xd0000005, 0xb0000005, + 0xd8000003, 0xa8000003, 0x88000003, 0xc8000003, + 0xc0000003, 0xe8000003, 0xf8000003, 0x80000003, + 0xf0000003, 0xa0000003, 0x90000003, 0x98000003, + 0xe0000003, 0xb8000003, 0xd0000003, 0xb0000003, + 0xd8000002, 0xa8000002, 0x88000002, 0xc8000002, + 0xc0000002, 0xe8000002, 0xf8000002, 0x80000002, + 0xf0000002, 0xa0000002, 0x90000002, 0x98000002, + 0xe0000002, 0xb8000002, 0xd0000002, 0xb0000002, + 0xd8000004, 0xa8000004, 0x88000004, 0xc8000004, + 0xc0000004, 0xe8000004, 0xf8000004, 0x80000004, + 0xf0000004, 0xa0000004, 0x90000004, 0x98000004, + 0xe0000004, 0xb8000004, 0xd0000004, 0xb0000004, + 0x58000002, 0x28000002, 0x08000002, 0x48000002, + 0x40000002, 0x68000002, 0x78000002, 0x00000002, + 0x70000002, 0x20000002, 0x10000002, 0x18000002, + 0x60000002, 0x38000002, 0x50000002, 0x30000002, + 0x58000004, 0x28000004, 0x08000004, 0x48000004, + 0x40000004, 0x68000004, 0x78000004, 0x00000004, + 0x70000004, 0x20000004, 0x10000004, 0x18000004, + 0x60000004, 0x38000004, 0x50000004, 0x30000004, + 0xd8000007, 0xa8000007, 0x88000007, 0xc8000007, + 0xc0000007, 0xe8000007, 0xf8000007, 0x80000007, + 0xf0000007, 0xa0000007, 0x90000007, 0x98000007, + 0xe0000007, 0xb8000007, 0xd0000007, 0xb0000007, + 0x58000007, 0x28000007, 0x08000007, 0x48000007, + 0x40000007, 0x68000007, 0x78000007, 0x00000007, + 0x70000007, 0x20000007, 0x10000007, 0x18000007, + 0x60000007, 0x38000007, 0x50000007, 0x30000007, + 0x58000003, 0x28000003, 0x08000003, 0x48000003, + 0x40000003, 0x68000003, 0x78000003, 0x00000003, + 0x70000003, 0x20000003, 0x10000003, 0x18000003, + 0x60000003, 0x38000003, 0x50000003, 0x30000003, + /* 3 */ + 0x00000588, 0x000005e8, 0x00000590, 0x000005c8, + 0x000005b8, 0x000005d0, 0x000005b0, 0x00000580, + 0x000005c0, 0x000005e0, 0x000005a0, 0x000005a8, + 0x000005f8, 0x00000598, 0x000005d8, 0x000005f0, + 0x00000508, 0x00000568, 0x00000510, 0x00000548, + 0x00000538, 0x00000550, 0x00000530, 0x00000500, + 0x00000540, 0x00000560, 0x00000520, 0x00000528, + 0x00000578, 0x00000518, 0x00000558, 0x00000570, + 0x00000788, 0x000007e8, 0x00000790, 0x000007c8, + 0x000007b8, 0x000007d0, 0x000007b0, 0x00000780, + 0x000007c0, 0x000007e0, 0x000007a0, 0x000007a8, + 0x000007f8, 0x00000798, 0x000007d8, 0x000007f0, + 0x00000288, 0x000002e8, 0x00000290, 0x000002c8, + 0x000002b8, 0x000002d0, 0x000002b0, 0x00000280, + 0x000002c0, 0x000002e0, 0x000002a0, 0x000002a8, + 0x000002f8, 0x00000298, 0x000002d8, 0x000002f0, + 0x00000008, 0x00000068, 0x00000010, 0x00000048, + 0x00000038, 0x00000050, 0x00000030, 0x00000000, + 0x00000040, 0x00000060, 0x00000020, 0x00000028, + 0x00000078, 0x00000018, 0x00000058, 0x00000070, + 0x00000608, 0x00000668, 0x00000610, 0x00000648, + 0x00000638, 0x00000650, 0x00000630, 0x00000600, + 0x00000640, 0x00000660, 0x00000620, 0x00000628, + 0x00000678, 0x00000618, 0x00000658, 0x00000670, + 0x00000708, 0x00000768, 0x00000710, 0x00000748, + 0x00000738, 0x00000750, 0x00000730, 0x00000700, + 0x00000740, 0x00000760, 0x00000720, 0x00000728, + 0x00000778, 0x00000718, 0x00000758, 0x00000770, + 0x00000408, 0x00000468, 0x00000410, 0x00000448, + 0x00000438, 0x00000450, 0x00000430, 0x00000400, + 0x00000440, 0x00000460, 0x00000420, 0x00000428, + 0x00000478, 0x00000418, 0x00000458, 0x00000470, + 0x00000308, 0x00000368, 0x00000310, 0x00000348, + 0x00000338, 0x00000350, 0x00000330, 0x00000300, + 0x00000340, 0x00000360, 0x00000320, 0x00000328, + 0x00000378, 0x00000318, 0x00000358, 0x00000370, + 0x00000108, 0x00000168, 0x00000110, 0x00000148, + 0x00000138, 0x00000150, 0x00000130, 0x00000100, + 0x00000140, 0x00000160, 0x00000120, 0x00000128, + 0x00000178, 0x00000118, 0x00000158, 0x00000170, + 0x00000188, 0x000001e8, 0x00000190, 0x000001c8, + 0x000001b8, 0x000001d0, 0x000001b0, 0x00000180, + 0x000001c0, 0x000001e0, 0x000001a0, 0x000001a8, + 0x000001f8, 0x00000198, 0x000001d8, 0x000001f0, + 0x00000488, 0x000004e8, 0x00000490, 0x000004c8, + 0x000004b8, 0x000004d0, 0x000004b0, 0x00000480, + 0x000004c0, 0x000004e0, 0x000004a0, 0x000004a8, + 0x000004f8, 0x00000498, 0x000004d8, 0x000004f0, + 0x00000088, 0x000000e8, 0x00000090, 0x000000c8, + 0x000000b8, 0x000000d0, 0x000000b0, 0x00000080, + 0x000000c0, 0x000000e0, 0x000000a0, 0x000000a8, + 0x000000f8, 0x00000098, 0x000000d8, 0x000000f0, + 0x00000388, 0x000003e8, 0x00000390, 0x000003c8, + 0x000003b8, 0x000003d0, 0x000003b0, 0x00000380, + 0x000003c0, 0x000003e0, 0x000003a0, 0x000003a8, + 0x000003f8, 0x00000398, 0x000003d8, 0x000003f0, + 0x00000688, 0x000006e8, 0x00000690, 0x000006c8, + 0x000006b8, 0x000006d0, 0x000006b0, 0x00000680, + 0x000006c0, 0x000006e0, 0x000006a0, 0x000006a8, + 0x000006f8, 0x00000698, 0x000006d8, 0x000006f0, + 0x00000208, 0x00000268, 0x00000210, 0x00000248, + 0x00000238, 0x00000250, 0x00000230, 0x00000200, + 0x00000240, 0x00000260, 0x00000220, 0x00000228, + 0x00000278, 0x00000218, 0x00000258, 0x00000270, + }; + +static const u32 sbox_CryptoPro_B[4*256] = + { + /* 0 */ + 0x00004000, 0x00002000, 0x00005800, 0x00000800, + 0x00001800, 0x00002800, 0x00000000, 0x00004800, + 0x00001000, 0x00007000, 0x00005000, 0x00006000, + 0x00006800, 0x00003000, 0x00003800, 0x00007800, + 0x0000c000, 0x0000a000, 0x0000d800, 0x00008800, + 0x00009800, 0x0000a800, 0x00008000, 0x0000c800, + 0x00009000, 0x0000f000, 0x0000d000, 0x0000e000, + 0x0000e800, 0x0000b000, 0x0000b800, 0x0000f800, + 0x00014000, 0x00012000, 0x00015800, 0x00010800, + 0x00011800, 0x00012800, 0x00010000, 0x00014800, + 0x00011000, 0x00017000, 0x00015000, 0x00016000, + 0x00016800, 0x00013000, 0x00013800, 0x00017800, + 0x00054000, 0x00052000, 0x00055800, 0x00050800, + 0x00051800, 0x00052800, 0x00050000, 0x00054800, + 0x00051000, 0x00057000, 0x00055000, 0x00056000, + 0x00056800, 0x00053000, 0x00053800, 0x00057800, + 0x00024000, 0x00022000, 0x00025800, 0x00020800, + 0x00021800, 0x00022800, 0x00020000, 0x00024800, + 0x00021000, 0x00027000, 0x00025000, 0x00026000, + 0x00026800, 0x00023000, 0x00023800, 0x00027800, + 0x0006c000, 0x0006a000, 0x0006d800, 0x00068800, + 0x00069800, 0x0006a800, 0x00068000, 0x0006c800, + 0x00069000, 0x0006f000, 0x0006d000, 0x0006e000, + 0x0006e800, 0x0006b000, 0x0006b800, 0x0006f800, + 0x0002c000, 0x0002a000, 0x0002d800, 0x00028800, + 0x00029800, 0x0002a800, 0x00028000, 0x0002c800, + 0x00029000, 0x0002f000, 0x0002d000, 0x0002e000, + 0x0002e800, 0x0002b000, 0x0002b800, 0x0002f800, + 0x00064000, 0x00062000, 0x00065800, 0x00060800, + 0x00061800, 0x00062800, 0x00060000, 0x00064800, + 0x00061000, 0x00067000, 0x00065000, 0x00066000, + 0x00066800, 0x00063000, 0x00063800, 0x00067800, + 0x0004c000, 0x0004a000, 0x0004d800, 0x00048800, + 0x00049800, 0x0004a800, 0x00048000, 0x0004c800, + 0x00049000, 0x0004f000, 0x0004d000, 0x0004e000, + 0x0004e800, 0x0004b000, 0x0004b800, 0x0004f800, + 0x0003c000, 0x0003a000, 0x0003d800, 0x00038800, + 0x00039800, 0x0003a800, 0x00038000, 0x0003c800, + 0x00039000, 0x0003f000, 0x0003d000, 0x0003e000, + 0x0003e800, 0x0003b000, 0x0003b800, 0x0003f800, + 0x0001c000, 0x0001a000, 0x0001d800, 0x00018800, + 0x00019800, 0x0001a800, 0x00018000, 0x0001c800, + 0x00019000, 0x0001f000, 0x0001d000, 0x0001e000, + 0x0001e800, 0x0001b000, 0x0001b800, 0x0001f800, + 0x0007c000, 0x0007a000, 0x0007d800, 0x00078800, + 0x00079800, 0x0007a800, 0x00078000, 0x0007c800, + 0x00079000, 0x0007f000, 0x0007d000, 0x0007e000, + 0x0007e800, 0x0007b000, 0x0007b800, 0x0007f800, + 0x0005c000, 0x0005a000, 0x0005d800, 0x00058800, + 0x00059800, 0x0005a800, 0x00058000, 0x0005c800, + 0x00059000, 0x0005f000, 0x0005d000, 0x0005e000, + 0x0005e800, 0x0005b000, 0x0005b800, 0x0005f800, + 0x00044000, 0x00042000, 0x00045800, 0x00040800, + 0x00041800, 0x00042800, 0x00040000, 0x00044800, + 0x00041000, 0x00047000, 0x00045000, 0x00046000, + 0x00046800, 0x00043000, 0x00043800, 0x00047800, + 0x00034000, 0x00032000, 0x00035800, 0x00030800, + 0x00031800, 0x00032800, 0x00030000, 0x00034800, + 0x00031000, 0x00037000, 0x00035000, 0x00036000, + 0x00036800, 0x00033000, 0x00033800, 0x00037800, + 0x00074000, 0x00072000, 0x00075800, 0x00070800, + 0x00071800, 0x00072800, 0x00070000, 0x00074800, + 0x00071000, 0x00077000, 0x00075000, 0x00076000, + 0x00076800, 0x00073000, 0x00073800, 0x00077800, + /* 1 */ + 0x03f00000, 0x03e00000, 0x03800000, 0x03d00000, + 0x03c80000, 0x03900000, 0x03e80000, 0x03d80000, + 0x03b80000, 0x03a80000, 0x03c00000, 0x03f80000, + 0x03980000, 0x03b00000, 0x03880000, 0x03a00000, + 0x02f00000, 0x02e00000, 0x02800000, 0x02d00000, + 0x02c80000, 0x02900000, 0x02e80000, 0x02d80000, + 0x02b80000, 0x02a80000, 0x02c00000, 0x02f80000, + 0x02980000, 0x02b00000, 0x02880000, 0x02a00000, + 0x00700000, 0x00600000, 0x00000000, 0x00500000, + 0x00480000, 0x00100000, 0x00680000, 0x00580000, + 0x00380000, 0x00280000, 0x00400000, 0x00780000, + 0x00180000, 0x00300000, 0x00080000, 0x00200000, + 0x06f00000, 0x06e00000, 0x06800000, 0x06d00000, + 0x06c80000, 0x06900000, 0x06e80000, 0x06d80000, + 0x06b80000, 0x06a80000, 0x06c00000, 0x06f80000, + 0x06980000, 0x06b00000, 0x06880000, 0x06a00000, + 0x05f00000, 0x05e00000, 0x05800000, 0x05d00000, + 0x05c80000, 0x05900000, 0x05e80000, 0x05d80000, + 0x05b80000, 0x05a80000, 0x05c00000, 0x05f80000, + 0x05980000, 0x05b00000, 0x05880000, 0x05a00000, + 0x03700000, 0x03600000, 0x03000000, 0x03500000, + 0x03480000, 0x03100000, 0x03680000, 0x03580000, + 0x03380000, 0x03280000, 0x03400000, 0x03780000, + 0x03180000, 0x03300000, 0x03080000, 0x03200000, + 0x00f00000, 0x00e00000, 0x00800000, 0x00d00000, + 0x00c80000, 0x00900000, 0x00e80000, 0x00d80000, + 0x00b80000, 0x00a80000, 0x00c00000, 0x00f80000, + 0x00980000, 0x00b00000, 0x00880000, 0x00a00000, + 0x01700000, 0x01600000, 0x01000000, 0x01500000, + 0x01480000, 0x01100000, 0x01680000, 0x01580000, + 0x01380000, 0x01280000, 0x01400000, 0x01780000, + 0x01180000, 0x01300000, 0x01080000, 0x01200000, + 0x01f00000, 0x01e00000, 0x01800000, 0x01d00000, + 0x01c80000, 0x01900000, 0x01e80000, 0x01d80000, + 0x01b80000, 0x01a80000, 0x01c00000, 0x01f80000, + 0x01980000, 0x01b00000, 0x01880000, 0x01a00000, + 0x05700000, 0x05600000, 0x05000000, 0x05500000, + 0x05480000, 0x05100000, 0x05680000, 0x05580000, + 0x05380000, 0x05280000, 0x05400000, 0x05780000, + 0x05180000, 0x05300000, 0x05080000, 0x05200000, + 0x06700000, 0x06600000, 0x06000000, 0x06500000, + 0x06480000, 0x06100000, 0x06680000, 0x06580000, + 0x06380000, 0x06280000, 0x06400000, 0x06780000, + 0x06180000, 0x06300000, 0x06080000, 0x06200000, + 0x07f00000, 0x07e00000, 0x07800000, 0x07d00000, + 0x07c80000, 0x07900000, 0x07e80000, 0x07d80000, + 0x07b80000, 0x07a80000, 0x07c00000, 0x07f80000, + 0x07980000, 0x07b00000, 0x07880000, 0x07a00000, + 0x02700000, 0x02600000, 0x02000000, 0x02500000, + 0x02480000, 0x02100000, 0x02680000, 0x02580000, + 0x02380000, 0x02280000, 0x02400000, 0x02780000, + 0x02180000, 0x02300000, 0x02080000, 0x02200000, + 0x07700000, 0x07600000, 0x07000000, 0x07500000, + 0x07480000, 0x07100000, 0x07680000, 0x07580000, + 0x07380000, 0x07280000, 0x07400000, 0x07780000, + 0x07180000, 0x07300000, 0x07080000, 0x07200000, + 0x04f00000, 0x04e00000, 0x04800000, 0x04d00000, + 0x04c80000, 0x04900000, 0x04e80000, 0x04d80000, + 0x04b80000, 0x04a80000, 0x04c00000, 0x04f80000, + 0x04980000, 0x04b00000, 0x04880000, 0x04a00000, + 0x04700000, 0x04600000, 0x04000000, 0x04500000, + 0x04480000, 0x04100000, 0x04680000, 0x04580000, + 0x04380000, 0x04280000, 0x04400000, 0x04780000, + 0x04180000, 0x04300000, 0x04080000, 0x04200000, + /* 2 */ + 0x10000004, 0x38000004, 0x60000004, 0x78000004, + 0x48000004, 0x28000004, 0x50000004, 0x58000004, + 0x08000004, 0x20000004, 0x00000004, 0x68000004, + 0x30000004, 0x40000004, 0x70000004, 0x18000004, + 0x90000001, 0xb8000001, 0xe0000001, 0xf8000001, + 0xc8000001, 0xa8000001, 0xd0000001, 0xd8000001, + 0x88000001, 0xa0000001, 0x80000001, 0xe8000001, + 0xb0000001, 0xc0000001, 0xf0000001, 0x98000001, + 0x10000001, 0x38000001, 0x60000001, 0x78000001, + 0x48000001, 0x28000001, 0x50000001, 0x58000001, + 0x08000001, 0x20000001, 0x00000001, 0x68000001, + 0x30000001, 0x40000001, 0x70000001, 0x18000001, + 0x10000003, 0x38000003, 0x60000003, 0x78000003, + 0x48000003, 0x28000003, 0x50000003, 0x58000003, + 0x08000003, 0x20000003, 0x00000003, 0x68000003, + 0x30000003, 0x40000003, 0x70000003, 0x18000003, + 0x10000002, 0x38000002, 0x60000002, 0x78000002, + 0x48000002, 0x28000002, 0x50000002, 0x58000002, + 0x08000002, 0x20000002, 0x00000002, 0x68000002, + 0x30000002, 0x40000002, 0x70000002, 0x18000002, + 0x90000006, 0xb8000006, 0xe0000006, 0xf8000006, + 0xc8000006, 0xa8000006, 0xd0000006, 0xd8000006, + 0x88000006, 0xa0000006, 0x80000006, 0xe8000006, + 0xb0000006, 0xc0000006, 0xf0000006, 0x98000006, + 0x10000007, 0x38000007, 0x60000007, 0x78000007, + 0x48000007, 0x28000007, 0x50000007, 0x58000007, + 0x08000007, 0x20000007, 0x00000007, 0x68000007, + 0x30000007, 0x40000007, 0x70000007, 0x18000007, + 0x90000005, 0xb8000005, 0xe0000005, 0xf8000005, + 0xc8000005, 0xa8000005, 0xd0000005, 0xd8000005, + 0x88000005, 0xa0000005, 0x80000005, 0xe8000005, + 0xb0000005, 0xc0000005, 0xf0000005, 0x98000005, + 0x10000006, 0x38000006, 0x60000006, 0x78000006, + 0x48000006, 0x28000006, 0x50000006, 0x58000006, + 0x08000006, 0x20000006, 0x00000006, 0x68000006, + 0x30000006, 0x40000006, 0x70000006, 0x18000006, + 0x90000000, 0xb8000000, 0xe0000000, 0xf8000000, + 0xc8000000, 0xa8000000, 0xd0000000, 0xd8000000, + 0x88000000, 0xa0000000, 0x80000000, 0xe8000000, + 0xb0000000, 0xc0000000, 0xf0000000, 0x98000000, + 0x90000003, 0xb8000003, 0xe0000003, 0xf8000003, + 0xc8000003, 0xa8000003, 0xd0000003, 0xd8000003, + 0x88000003, 0xa0000003, 0x80000003, 0xe8000003, + 0xb0000003, 0xc0000003, 0xf0000003, 0x98000003, + 0x90000007, 0xb8000007, 0xe0000007, 0xf8000007, + 0xc8000007, 0xa8000007, 0xd0000007, 0xd8000007, + 0x88000007, 0xa0000007, 0x80000007, 0xe8000007, + 0xb0000007, 0xc0000007, 0xf0000007, 0x98000007, + 0x10000005, 0x38000005, 0x60000005, 0x78000005, + 0x48000005, 0x28000005, 0x50000005, 0x58000005, + 0x08000005, 0x20000005, 0x00000005, 0x68000005, + 0x30000005, 0x40000005, 0x70000005, 0x18000005, + 0x10000000, 0x38000000, 0x60000000, 0x78000000, + 0x48000000, 0x28000000, 0x50000000, 0x58000000, + 0x08000000, 0x20000000, 0x00000000, 0x68000000, + 0x30000000, 0x40000000, 0x70000000, 0x18000000, + 0x90000004, 0xb8000004, 0xe0000004, 0xf8000004, + 0xc8000004, 0xa8000004, 0xd0000004, 0xd8000004, + 0x88000004, 0xa0000004, 0x80000004, 0xe8000004, + 0xb0000004, 0xc0000004, 0xf0000004, 0x98000004, + 0x90000002, 0xb8000002, 0xe0000002, 0xf8000002, + 0xc8000002, 0xa8000002, 0xd0000002, 0xd8000002, + 0x88000002, 0xa0000002, 0x80000002, 0xe8000002, + 0xb0000002, 0xc0000002, 0xf0000002, 0x98000002, + /* 3 */ + 0x00000028, 0x00000010, 0x00000050, 0x00000058, + 0x00000048, 0x00000008, 0x00000060, 0x00000018, + 0x00000038, 0x00000020, 0x00000068, 0x00000000, + 0x00000030, 0x00000078, 0x00000040, 0x00000070, + 0x00000228, 0x00000210, 0x00000250, 0x00000258, + 0x00000248, 0x00000208, 0x00000260, 0x00000218, + 0x00000238, 0x00000220, 0x00000268, 0x00000200, + 0x00000230, 0x00000278, 0x00000240, 0x00000270, + 0x000005a8, 0x00000590, 0x000005d0, 0x000005d8, + 0x000005c8, 0x00000588, 0x000005e0, 0x00000598, + 0x000005b8, 0x000005a0, 0x000005e8, 0x00000580, + 0x000005b0, 0x000005f8, 0x000005c0, 0x000005f0, + 0x00000728, 0x00000710, 0x00000750, 0x00000758, + 0x00000748, 0x00000708, 0x00000760, 0x00000718, + 0x00000738, 0x00000720, 0x00000768, 0x00000700, + 0x00000730, 0x00000778, 0x00000740, 0x00000770, + 0x00000428, 0x00000410, 0x00000450, 0x00000458, + 0x00000448, 0x00000408, 0x00000460, 0x00000418, + 0x00000438, 0x00000420, 0x00000468, 0x00000400, + 0x00000430, 0x00000478, 0x00000440, 0x00000470, + 0x000001a8, 0x00000190, 0x000001d0, 0x000001d8, + 0x000001c8, 0x00000188, 0x000001e0, 0x00000198, + 0x000001b8, 0x000001a0, 0x000001e8, 0x00000180, + 0x000001b0, 0x000001f8, 0x000001c0, 0x000001f0, + 0x000003a8, 0x00000390, 0x000003d0, 0x000003d8, + 0x000003c8, 0x00000388, 0x000003e0, 0x00000398, + 0x000003b8, 0x000003a0, 0x000003e8, 0x00000380, + 0x000003b0, 0x000003f8, 0x000003c0, 0x000003f0, + 0x000000a8, 0x00000090, 0x000000d0, 0x000000d8, + 0x000000c8, 0x00000088, 0x000000e0, 0x00000098, + 0x000000b8, 0x000000a0, 0x000000e8, 0x00000080, + 0x000000b0, 0x000000f8, 0x000000c0, 0x000000f0, + 0x00000528, 0x00000510, 0x00000550, 0x00000558, + 0x00000548, 0x00000508, 0x00000560, 0x00000518, + 0x00000538, 0x00000520, 0x00000568, 0x00000500, + 0x00000530, 0x00000578, 0x00000540, 0x00000570, + 0x00000128, 0x00000110, 0x00000150, 0x00000158, + 0x00000148, 0x00000108, 0x00000160, 0x00000118, + 0x00000138, 0x00000120, 0x00000168, 0x00000100, + 0x00000130, 0x00000178, 0x00000140, 0x00000170, + 0x000004a8, 0x00000490, 0x000004d0, 0x000004d8, + 0x000004c8, 0x00000488, 0x000004e0, 0x00000498, + 0x000004b8, 0x000004a0, 0x000004e8, 0x00000480, + 0x000004b0, 0x000004f8, 0x000004c0, 0x000004f0, + 0x00000328, 0x00000310, 0x00000350, 0x00000358, + 0x00000348, 0x00000308, 0x00000360, 0x00000318, + 0x00000338, 0x00000320, 0x00000368, 0x00000300, + 0x00000330, 0x00000378, 0x00000340, 0x00000370, + 0x000007a8, 0x00000790, 0x000007d0, 0x000007d8, + 0x000007c8, 0x00000788, 0x000007e0, 0x00000798, + 0x000007b8, 0x000007a0, 0x000007e8, 0x00000780, + 0x000007b0, 0x000007f8, 0x000007c0, 0x000007f0, + 0x000006a8, 0x00000690, 0x000006d0, 0x000006d8, + 0x000006c8, 0x00000688, 0x000006e0, 0x00000698, + 0x000006b8, 0x000006a0, 0x000006e8, 0x00000680, + 0x000006b0, 0x000006f8, 0x000006c0, 0x000006f0, + 0x000002a8, 0x00000290, 0x000002d0, 0x000002d8, + 0x000002c8, 0x00000288, 0x000002e0, 0x00000298, + 0x000002b8, 0x000002a0, 0x000002e8, 0x00000280, + 0x000002b0, 0x000002f8, 0x000002c0, 0x000002f0, + 0x00000628, 0x00000610, 0x00000650, 0x00000658, + 0x00000648, 0x00000608, 0x00000660, 0x00000618, + 0x00000638, 0x00000620, 0x00000668, 0x00000600, + 0x00000630, 0x00000678, 0x00000640, 0x00000670, + }; + +static const u32 sbox_CryptoPro_C[4*256] = + { + /* 0 */ + 0x00000800, 0x00005800, 0x00006000, 0x00001000, + 0x00004800, 0x00006800, 0x00000000, 0x00007800, + 0x00002000, 0x00002800, 0x00004000, 0x00007000, + 0x00005000, 0x00003800, 0x00003000, 0x00001800, + 0x00008800, 0x0000d800, 0x0000e000, 0x00009000, + 0x0000c800, 0x0000e800, 0x00008000, 0x0000f800, + 0x0000a000, 0x0000a800, 0x0000c000, 0x0000f000, + 0x0000d000, 0x0000b800, 0x0000b000, 0x00009800, + 0x00038800, 0x0003d800, 0x0003e000, 0x00039000, + 0x0003c800, 0x0003e800, 0x00038000, 0x0003f800, + 0x0003a000, 0x0003a800, 0x0003c000, 0x0003f000, + 0x0003d000, 0x0003b800, 0x0003b000, 0x00039800, + 0x00068800, 0x0006d800, 0x0006e000, 0x00069000, + 0x0006c800, 0x0006e800, 0x00068000, 0x0006f800, + 0x0006a000, 0x0006a800, 0x0006c000, 0x0006f000, + 0x0006d000, 0x0006b800, 0x0006b000, 0x00069800, + 0x00058800, 0x0005d800, 0x0005e000, 0x00059000, + 0x0005c800, 0x0005e800, 0x00058000, 0x0005f800, + 0x0005a000, 0x0005a800, 0x0005c000, 0x0005f000, + 0x0005d000, 0x0005b800, 0x0005b000, 0x00059800, + 0x00020800, 0x00025800, 0x00026000, 0x00021000, + 0x00024800, 0x00026800, 0x00020000, 0x00027800, + 0x00022000, 0x00022800, 0x00024000, 0x00027000, + 0x00025000, 0x00023800, 0x00023000, 0x00021800, + 0x00028800, 0x0002d800, 0x0002e000, 0x00029000, + 0x0002c800, 0x0002e800, 0x00028000, 0x0002f800, + 0x0002a000, 0x0002a800, 0x0002c000, 0x0002f000, + 0x0002d000, 0x0002b800, 0x0002b000, 0x00029800, + 0x00010800, 0x00015800, 0x00016000, 0x00011000, + 0x00014800, 0x00016800, 0x00010000, 0x00017800, + 0x00012000, 0x00012800, 0x00014000, 0x00017000, + 0x00015000, 0x00013800, 0x00013000, 0x00011800, + 0x00040800, 0x00045800, 0x00046000, 0x00041000, + 0x00044800, 0x00046800, 0x00040000, 0x00047800, + 0x00042000, 0x00042800, 0x00044000, 0x00047000, + 0x00045000, 0x00043800, 0x00043000, 0x00041800, + 0x00070800, 0x00075800, 0x00076000, 0x00071000, + 0x00074800, 0x00076800, 0x00070000, 0x00077800, + 0x00072000, 0x00072800, 0x00074000, 0x00077000, + 0x00075000, 0x00073800, 0x00073000, 0x00071800, + 0x00078800, 0x0007d800, 0x0007e000, 0x00079000, + 0x0007c800, 0x0007e800, 0x00078000, 0x0007f800, + 0x0007a000, 0x0007a800, 0x0007c000, 0x0007f000, + 0x0007d000, 0x0007b800, 0x0007b000, 0x00079800, + 0x00060800, 0x00065800, 0x00066000, 0x00061000, + 0x00064800, 0x00066800, 0x00060000, 0x00067800, + 0x00062000, 0x00062800, 0x00064000, 0x00067000, + 0x00065000, 0x00063800, 0x00063000, 0x00061800, + 0x00048800, 0x0004d800, 0x0004e000, 0x00049000, + 0x0004c800, 0x0004e800, 0x00048000, 0x0004f800, + 0x0004a000, 0x0004a800, 0x0004c000, 0x0004f000, + 0x0004d000, 0x0004b800, 0x0004b000, 0x00049800, + 0x00050800, 0x00055800, 0x00056000, 0x00051000, + 0x00054800, 0x00056800, 0x00050000, 0x00057800, + 0x00052000, 0x00052800, 0x00054000, 0x00057000, + 0x00055000, 0x00053800, 0x00053000, 0x00051800, + 0x00030800, 0x00035800, 0x00036000, 0x00031000, + 0x00034800, 0x00036800, 0x00030000, 0x00037800, + 0x00032000, 0x00032800, 0x00034000, 0x00037000, + 0x00035000, 0x00033800, 0x00033000, 0x00031800, + 0x00018800, 0x0001d800, 0x0001e000, 0x00019000, + 0x0001c800, 0x0001e800, 0x00018000, 0x0001f800, + 0x0001a000, 0x0001a800, 0x0001c000, 0x0001f000, + 0x0001d000, 0x0001b800, 0x0001b000, 0x00019800, + /* 1 */ + 0x01c00000, 0x01900000, 0x01a80000, 0x01800000, + 0x01a00000, 0x01c80000, 0x01f80000, 0x01d00000, + 0x01980000, 0x01b80000, 0x01e00000, 0x01e80000, + 0x01b00000, 0x01f00000, 0x01880000, 0x01d80000, + 0x03400000, 0x03100000, 0x03280000, 0x03000000, + 0x03200000, 0x03480000, 0x03780000, 0x03500000, + 0x03180000, 0x03380000, 0x03600000, 0x03680000, + 0x03300000, 0x03700000, 0x03080000, 0x03580000, + 0x00400000, 0x00100000, 0x00280000, 0x00000000, + 0x00200000, 0x00480000, 0x00780000, 0x00500000, + 0x00180000, 0x00380000, 0x00600000, 0x00680000, + 0x00300000, 0x00700000, 0x00080000, 0x00580000, + 0x00c00000, 0x00900000, 0x00a80000, 0x00800000, + 0x00a00000, 0x00c80000, 0x00f80000, 0x00d00000, + 0x00980000, 0x00b80000, 0x00e00000, 0x00e80000, + 0x00b00000, 0x00f00000, 0x00880000, 0x00d80000, + 0x02c00000, 0x02900000, 0x02a80000, 0x02800000, + 0x02a00000, 0x02c80000, 0x02f80000, 0x02d00000, + 0x02980000, 0x02b80000, 0x02e00000, 0x02e80000, + 0x02b00000, 0x02f00000, 0x02880000, 0x02d80000, + 0x06c00000, 0x06900000, 0x06a80000, 0x06800000, + 0x06a00000, 0x06c80000, 0x06f80000, 0x06d00000, + 0x06980000, 0x06b80000, 0x06e00000, 0x06e80000, + 0x06b00000, 0x06f00000, 0x06880000, 0x06d80000, + 0x05400000, 0x05100000, 0x05280000, 0x05000000, + 0x05200000, 0x05480000, 0x05780000, 0x05500000, + 0x05180000, 0x05380000, 0x05600000, 0x05680000, + 0x05300000, 0x05700000, 0x05080000, 0x05580000, + 0x04400000, 0x04100000, 0x04280000, 0x04000000, + 0x04200000, 0x04480000, 0x04780000, 0x04500000, + 0x04180000, 0x04380000, 0x04600000, 0x04680000, + 0x04300000, 0x04700000, 0x04080000, 0x04580000, + 0x05c00000, 0x05900000, 0x05a80000, 0x05800000, + 0x05a00000, 0x05c80000, 0x05f80000, 0x05d00000, + 0x05980000, 0x05b80000, 0x05e00000, 0x05e80000, + 0x05b00000, 0x05f00000, 0x05880000, 0x05d80000, + 0x01400000, 0x01100000, 0x01280000, 0x01000000, + 0x01200000, 0x01480000, 0x01780000, 0x01500000, + 0x01180000, 0x01380000, 0x01600000, 0x01680000, + 0x01300000, 0x01700000, 0x01080000, 0x01580000, + 0x04c00000, 0x04900000, 0x04a80000, 0x04800000, + 0x04a00000, 0x04c80000, 0x04f80000, 0x04d00000, + 0x04980000, 0x04b80000, 0x04e00000, 0x04e80000, + 0x04b00000, 0x04f00000, 0x04880000, 0x04d80000, + 0x03c00000, 0x03900000, 0x03a80000, 0x03800000, + 0x03a00000, 0x03c80000, 0x03f80000, 0x03d00000, + 0x03980000, 0x03b80000, 0x03e00000, 0x03e80000, + 0x03b00000, 0x03f00000, 0x03880000, 0x03d80000, + 0x07400000, 0x07100000, 0x07280000, 0x07000000, + 0x07200000, 0x07480000, 0x07780000, 0x07500000, + 0x07180000, 0x07380000, 0x07600000, 0x07680000, + 0x07300000, 0x07700000, 0x07080000, 0x07580000, + 0x07c00000, 0x07900000, 0x07a80000, 0x07800000, + 0x07a00000, 0x07c80000, 0x07f80000, 0x07d00000, + 0x07980000, 0x07b80000, 0x07e00000, 0x07e80000, + 0x07b00000, 0x07f00000, 0x07880000, 0x07d80000, + 0x06400000, 0x06100000, 0x06280000, 0x06000000, + 0x06200000, 0x06480000, 0x06780000, 0x06500000, + 0x06180000, 0x06380000, 0x06600000, 0x06680000, + 0x06300000, 0x06700000, 0x06080000, 0x06580000, + 0x02400000, 0x02100000, 0x02280000, 0x02000000, + 0x02200000, 0x02480000, 0x02780000, 0x02500000, + 0x02180000, 0x02380000, 0x02600000, 0x02680000, + 0x02300000, 0x02700000, 0x02080000, 0x02580000, + /* 2 */ + 0x40000006, 0x68000006, 0x58000006, 0x00000006, + 0x20000006, 0x28000006, 0x08000006, 0x10000006, + 0x48000006, 0x18000006, 0x60000006, 0x70000006, + 0x30000006, 0x78000006, 0x50000006, 0x38000006, + 0xc0000004, 0xe8000004, 0xd8000004, 0x80000004, + 0xa0000004, 0xa8000004, 0x88000004, 0x90000004, + 0xc8000004, 0x98000004, 0xe0000004, 0xf0000004, + 0xb0000004, 0xf8000004, 0xd0000004, 0xb8000004, + 0xc0000005, 0xe8000005, 0xd8000005, 0x80000005, + 0xa0000005, 0xa8000005, 0x88000005, 0x90000005, + 0xc8000005, 0x98000005, 0xe0000005, 0xf0000005, + 0xb0000005, 0xf8000005, 0xd0000005, 0xb8000005, + 0xc0000000, 0xe8000000, 0xd8000000, 0x80000000, + 0xa0000000, 0xa8000000, 0x88000000, 0x90000000, + 0xc8000000, 0x98000000, 0xe0000000, 0xf0000000, + 0xb0000000, 0xf8000000, 0xd0000000, 0xb8000000, + 0x40000004, 0x68000004, 0x58000004, 0x00000004, + 0x20000004, 0x28000004, 0x08000004, 0x10000004, + 0x48000004, 0x18000004, 0x60000004, 0x70000004, + 0x30000004, 0x78000004, 0x50000004, 0x38000004, + 0x40000007, 0x68000007, 0x58000007, 0x00000007, + 0x20000007, 0x28000007, 0x08000007, 0x10000007, + 0x48000007, 0x18000007, 0x60000007, 0x70000007, + 0x30000007, 0x78000007, 0x50000007, 0x38000007, + 0x40000001, 0x68000001, 0x58000001, 0x00000001, + 0x20000001, 0x28000001, 0x08000001, 0x10000001, + 0x48000001, 0x18000001, 0x60000001, 0x70000001, + 0x30000001, 0x78000001, 0x50000001, 0x38000001, + 0x40000002, 0x68000002, 0x58000002, 0x00000002, + 0x20000002, 0x28000002, 0x08000002, 0x10000002, + 0x48000002, 0x18000002, 0x60000002, 0x70000002, + 0x30000002, 0x78000002, 0x50000002, 0x38000002, + 0xc0000003, 0xe8000003, 0xd8000003, 0x80000003, + 0xa0000003, 0xa8000003, 0x88000003, 0x90000003, + 0xc8000003, 0x98000003, 0xe0000003, 0xf0000003, + 0xb0000003, 0xf8000003, 0xd0000003, 0xb8000003, + 0xc0000001, 0xe8000001, 0xd8000001, 0x80000001, + 0xa0000001, 0xa8000001, 0x88000001, 0x90000001, + 0xc8000001, 0x98000001, 0xe0000001, 0xf0000001, + 0xb0000001, 0xf8000001, 0xd0000001, 0xb8000001, + 0x40000003, 0x68000003, 0x58000003, 0x00000003, + 0x20000003, 0x28000003, 0x08000003, 0x10000003, + 0x48000003, 0x18000003, 0x60000003, 0x70000003, + 0x30000003, 0x78000003, 0x50000003, 0x38000003, + 0xc0000002, 0xe8000002, 0xd8000002, 0x80000002, + 0xa0000002, 0xa8000002, 0x88000002, 0x90000002, + 0xc8000002, 0x98000002, 0xe0000002, 0xf0000002, + 0xb0000002, 0xf8000002, 0xd0000002, 0xb8000002, + 0x40000005, 0x68000005, 0x58000005, 0x00000005, + 0x20000005, 0x28000005, 0x08000005, 0x10000005, + 0x48000005, 0x18000005, 0x60000005, 0x70000005, + 0x30000005, 0x78000005, 0x50000005, 0x38000005, + 0x40000000, 0x68000000, 0x58000000, 0x00000000, + 0x20000000, 0x28000000, 0x08000000, 0x10000000, + 0x48000000, 0x18000000, 0x60000000, 0x70000000, + 0x30000000, 0x78000000, 0x50000000, 0x38000000, + 0xc0000007, 0xe8000007, 0xd8000007, 0x80000007, + 0xa0000007, 0xa8000007, 0x88000007, 0x90000007, + 0xc8000007, 0x98000007, 0xe0000007, 0xf0000007, + 0xb0000007, 0xf8000007, 0xd0000007, 0xb8000007, + 0xc0000006, 0xe8000006, 0xd8000006, 0x80000006, + 0xa0000006, 0xa8000006, 0x88000006, 0x90000006, + 0xc8000006, 0x98000006, 0xe0000006, 0xf0000006, + 0xb0000006, 0xf8000006, 0xd0000006, 0xb8000006, + /* 3 */ + 0x000003d0, 0x000003c8, 0x000003b0, 0x000003c0, + 0x000003e8, 0x000003f0, 0x00000390, 0x00000380, + 0x000003f8, 0x00000398, 0x000003a8, 0x000003d8, + 0x000003a0, 0x00000388, 0x000003e0, 0x000003b8, + 0x00000250, 0x00000248, 0x00000230, 0x00000240, + 0x00000268, 0x00000270, 0x00000210, 0x00000200, + 0x00000278, 0x00000218, 0x00000228, 0x00000258, + 0x00000220, 0x00000208, 0x00000260, 0x00000238, + 0x00000050, 0x00000048, 0x00000030, 0x00000040, + 0x00000068, 0x00000070, 0x00000010, 0x00000000, + 0x00000078, 0x00000018, 0x00000028, 0x00000058, + 0x00000020, 0x00000008, 0x00000060, 0x00000038, + 0x000002d0, 0x000002c8, 0x000002b0, 0x000002c0, + 0x000002e8, 0x000002f0, 0x00000290, 0x00000280, + 0x000002f8, 0x00000298, 0x000002a8, 0x000002d8, + 0x000002a0, 0x00000288, 0x000002e0, 0x000002b8, + 0x00000550, 0x00000548, 0x00000530, 0x00000540, + 0x00000568, 0x00000570, 0x00000510, 0x00000500, + 0x00000578, 0x00000518, 0x00000528, 0x00000558, + 0x00000520, 0x00000508, 0x00000560, 0x00000538, + 0x00000150, 0x00000148, 0x00000130, 0x00000140, + 0x00000168, 0x00000170, 0x00000110, 0x00000100, + 0x00000178, 0x00000118, 0x00000128, 0x00000158, + 0x00000120, 0x00000108, 0x00000160, 0x00000138, + 0x000007d0, 0x000007c8, 0x000007b0, 0x000007c0, + 0x000007e8, 0x000007f0, 0x00000790, 0x00000780, + 0x000007f8, 0x00000798, 0x000007a8, 0x000007d8, + 0x000007a0, 0x00000788, 0x000007e0, 0x000007b8, + 0x00000750, 0x00000748, 0x00000730, 0x00000740, + 0x00000768, 0x00000770, 0x00000710, 0x00000700, + 0x00000778, 0x00000718, 0x00000728, 0x00000758, + 0x00000720, 0x00000708, 0x00000760, 0x00000738, + 0x00000650, 0x00000648, 0x00000630, 0x00000640, + 0x00000668, 0x00000670, 0x00000610, 0x00000600, + 0x00000678, 0x00000618, 0x00000628, 0x00000658, + 0x00000620, 0x00000608, 0x00000660, 0x00000638, + 0x00000350, 0x00000348, 0x00000330, 0x00000340, + 0x00000368, 0x00000370, 0x00000310, 0x00000300, + 0x00000378, 0x00000318, 0x00000328, 0x00000358, + 0x00000320, 0x00000308, 0x00000360, 0x00000338, + 0x000000d0, 0x000000c8, 0x000000b0, 0x000000c0, + 0x000000e8, 0x000000f0, 0x00000090, 0x00000080, + 0x000000f8, 0x00000098, 0x000000a8, 0x000000d8, + 0x000000a0, 0x00000088, 0x000000e0, 0x000000b8, + 0x000005d0, 0x000005c8, 0x000005b0, 0x000005c0, + 0x000005e8, 0x000005f0, 0x00000590, 0x00000580, + 0x000005f8, 0x00000598, 0x000005a8, 0x000005d8, + 0x000005a0, 0x00000588, 0x000005e0, 0x000005b8, + 0x000006d0, 0x000006c8, 0x000006b0, 0x000006c0, + 0x000006e8, 0x000006f0, 0x00000690, 0x00000680, + 0x000006f8, 0x00000698, 0x000006a8, 0x000006d8, + 0x000006a0, 0x00000688, 0x000006e0, 0x000006b8, + 0x000004d0, 0x000004c8, 0x000004b0, 0x000004c0, + 0x000004e8, 0x000004f0, 0x00000490, 0x00000480, + 0x000004f8, 0x00000498, 0x000004a8, 0x000004d8, + 0x000004a0, 0x00000488, 0x000004e0, 0x000004b8, + 0x000001d0, 0x000001c8, 0x000001b0, 0x000001c0, + 0x000001e8, 0x000001f0, 0x00000190, 0x00000180, + 0x000001f8, 0x00000198, 0x000001a8, 0x000001d8, + 0x000001a0, 0x00000188, 0x000001e0, 0x000001b8, + 0x00000450, 0x00000448, 0x00000430, 0x00000440, + 0x00000468, 0x00000470, 0x00000410, 0x00000400, + 0x00000478, 0x00000418, 0x00000428, 0x00000458, + 0x00000420, 0x00000408, 0x00000460, 0x00000438, + }; + +static const u32 sbox_CryptoPro_D[4*256] = + { + /* 0 */ + 0x0005f800, 0x0005e000, 0x00059000, 0x0005d000, + 0x0005b000, 0x0005a000, 0x0005a800, 0x00058000, + 0x0005b800, 0x0005c800, 0x0005f000, 0x0005e800, + 0x00058800, 0x0005d800, 0x0005c000, 0x00059800, + 0x00037800, 0x00036000, 0x00031000, 0x00035000, + 0x00033000, 0x00032000, 0x00032800, 0x00030000, + 0x00033800, 0x00034800, 0x00037000, 0x00036800, + 0x00030800, 0x00035800, 0x00034000, 0x00031800, + 0x0001f800, 0x0001e000, 0x00019000, 0x0001d000, + 0x0001b000, 0x0001a000, 0x0001a800, 0x00018000, + 0x0001b800, 0x0001c800, 0x0001f000, 0x0001e800, + 0x00018800, 0x0001d800, 0x0001c000, 0x00019800, + 0x00027800, 0x00026000, 0x00021000, 0x00025000, + 0x00023000, 0x00022000, 0x00022800, 0x00020000, + 0x00023800, 0x00024800, 0x00027000, 0x00026800, + 0x00020800, 0x00025800, 0x00024000, 0x00021800, + 0x00067800, 0x00066000, 0x00061000, 0x00065000, + 0x00063000, 0x00062000, 0x00062800, 0x00060000, + 0x00063800, 0x00064800, 0x00067000, 0x00066800, + 0x00060800, 0x00065800, 0x00064000, 0x00061800, + 0x0007f800, 0x0007e000, 0x00079000, 0x0007d000, + 0x0007b000, 0x0007a000, 0x0007a800, 0x00078000, + 0x0007b800, 0x0007c800, 0x0007f000, 0x0007e800, + 0x00078800, 0x0007d800, 0x0007c000, 0x00079800, + 0x00077800, 0x00076000, 0x00071000, 0x00075000, + 0x00073000, 0x00072000, 0x00072800, 0x00070000, + 0x00073800, 0x00074800, 0x00077000, 0x00076800, + 0x00070800, 0x00075800, 0x00074000, 0x00071800, + 0x00017800, 0x00016000, 0x00011000, 0x00015000, + 0x00013000, 0x00012000, 0x00012800, 0x00010000, + 0x00013800, 0x00014800, 0x00017000, 0x00016800, + 0x00010800, 0x00015800, 0x00014000, 0x00011800, + 0x0003f800, 0x0003e000, 0x00039000, 0x0003d000, + 0x0003b000, 0x0003a000, 0x0003a800, 0x00038000, + 0x0003b800, 0x0003c800, 0x0003f000, 0x0003e800, + 0x00038800, 0x0003d800, 0x0003c000, 0x00039800, + 0x0006f800, 0x0006e000, 0x00069000, 0x0006d000, + 0x0006b000, 0x0006a000, 0x0006a800, 0x00068000, + 0x0006b800, 0x0006c800, 0x0006f000, 0x0006e800, + 0x00068800, 0x0006d800, 0x0006c000, 0x00069800, + 0x00047800, 0x00046000, 0x00041000, 0x00045000, + 0x00043000, 0x00042000, 0x00042800, 0x00040000, + 0x00043800, 0x00044800, 0x00047000, 0x00046800, + 0x00040800, 0x00045800, 0x00044000, 0x00041800, + 0x00007800, 0x00006000, 0x00001000, 0x00005000, + 0x00003000, 0x00002000, 0x00002800, 0x00000000, + 0x00003800, 0x00004800, 0x00007000, 0x00006800, + 0x00000800, 0x00005800, 0x00004000, 0x00001800, + 0x0002f800, 0x0002e000, 0x00029000, 0x0002d000, + 0x0002b000, 0x0002a000, 0x0002a800, 0x00028000, + 0x0002b800, 0x0002c800, 0x0002f000, 0x0002e800, + 0x00028800, 0x0002d800, 0x0002c000, 0x00029800, + 0x00057800, 0x00056000, 0x00051000, 0x00055000, + 0x00053000, 0x00052000, 0x00052800, 0x00050000, + 0x00053800, 0x00054800, 0x00057000, 0x00056800, + 0x00050800, 0x00055800, 0x00054000, 0x00051800, + 0x0004f800, 0x0004e000, 0x00049000, 0x0004d000, + 0x0004b000, 0x0004a000, 0x0004a800, 0x00048000, + 0x0004b800, 0x0004c800, 0x0004f000, 0x0004e800, + 0x00048800, 0x0004d800, 0x0004c000, 0x00049800, + 0x0000f800, 0x0000e000, 0x00009000, 0x0000d000, + 0x0000b000, 0x0000a000, 0x0000a800, 0x00008000, + 0x0000b800, 0x0000c800, 0x0000f000, 0x0000e800, + 0x00008800, 0x0000d800, 0x0000c000, 0x00009800, + /* 1 */ + 0x00880000, 0x00e00000, 0x00d80000, 0x00800000, + 0x00f80000, 0x00f00000, 0x00b00000, 0x00a80000, + 0x00d00000, 0x00e80000, 0x00a00000, 0x00c00000, + 0x00c80000, 0x00980000, 0x00b80000, 0x00900000, + 0x02880000, 0x02e00000, 0x02d80000, 0x02800000, + 0x02f80000, 0x02f00000, 0x02b00000, 0x02a80000, + 0x02d00000, 0x02e80000, 0x02a00000, 0x02c00000, + 0x02c80000, 0x02980000, 0x02b80000, 0x02900000, + 0x07080000, 0x07600000, 0x07580000, 0x07000000, + 0x07780000, 0x07700000, 0x07300000, 0x07280000, + 0x07500000, 0x07680000, 0x07200000, 0x07400000, + 0x07480000, 0x07180000, 0x07380000, 0x07100000, + 0x06080000, 0x06600000, 0x06580000, 0x06000000, + 0x06780000, 0x06700000, 0x06300000, 0x06280000, + 0x06500000, 0x06680000, 0x06200000, 0x06400000, + 0x06480000, 0x06180000, 0x06380000, 0x06100000, + 0x05080000, 0x05600000, 0x05580000, 0x05000000, + 0x05780000, 0x05700000, 0x05300000, 0x05280000, + 0x05500000, 0x05680000, 0x05200000, 0x05400000, + 0x05480000, 0x05180000, 0x05380000, 0x05100000, + 0x03880000, 0x03e00000, 0x03d80000, 0x03800000, + 0x03f80000, 0x03f00000, 0x03b00000, 0x03a80000, + 0x03d00000, 0x03e80000, 0x03a00000, 0x03c00000, + 0x03c80000, 0x03980000, 0x03b80000, 0x03900000, + 0x00080000, 0x00600000, 0x00580000, 0x00000000, + 0x00780000, 0x00700000, 0x00300000, 0x00280000, + 0x00500000, 0x00680000, 0x00200000, 0x00400000, + 0x00480000, 0x00180000, 0x00380000, 0x00100000, + 0x06880000, 0x06e00000, 0x06d80000, 0x06800000, + 0x06f80000, 0x06f00000, 0x06b00000, 0x06a80000, + 0x06d00000, 0x06e80000, 0x06a00000, 0x06c00000, + 0x06c80000, 0x06980000, 0x06b80000, 0x06900000, + 0x03080000, 0x03600000, 0x03580000, 0x03000000, + 0x03780000, 0x03700000, 0x03300000, 0x03280000, + 0x03500000, 0x03680000, 0x03200000, 0x03400000, + 0x03480000, 0x03180000, 0x03380000, 0x03100000, + 0x01080000, 0x01600000, 0x01580000, 0x01000000, + 0x01780000, 0x01700000, 0x01300000, 0x01280000, + 0x01500000, 0x01680000, 0x01200000, 0x01400000, + 0x01480000, 0x01180000, 0x01380000, 0x01100000, + 0x05880000, 0x05e00000, 0x05d80000, 0x05800000, + 0x05f80000, 0x05f00000, 0x05b00000, 0x05a80000, + 0x05d00000, 0x05e80000, 0x05a00000, 0x05c00000, + 0x05c80000, 0x05980000, 0x05b80000, 0x05900000, + 0x02080000, 0x02600000, 0x02580000, 0x02000000, + 0x02780000, 0x02700000, 0x02300000, 0x02280000, + 0x02500000, 0x02680000, 0x02200000, 0x02400000, + 0x02480000, 0x02180000, 0x02380000, 0x02100000, + 0x04880000, 0x04e00000, 0x04d80000, 0x04800000, + 0x04f80000, 0x04f00000, 0x04b00000, 0x04a80000, + 0x04d00000, 0x04e80000, 0x04a00000, 0x04c00000, + 0x04c80000, 0x04980000, 0x04b80000, 0x04900000, + 0x01880000, 0x01e00000, 0x01d80000, 0x01800000, + 0x01f80000, 0x01f00000, 0x01b00000, 0x01a80000, + 0x01d00000, 0x01e80000, 0x01a00000, 0x01c00000, + 0x01c80000, 0x01980000, 0x01b80000, 0x01900000, + 0x07880000, 0x07e00000, 0x07d80000, 0x07800000, + 0x07f80000, 0x07f00000, 0x07b00000, 0x07a80000, + 0x07d00000, 0x07e80000, 0x07a00000, 0x07c00000, + 0x07c80000, 0x07980000, 0x07b80000, 0x07900000, + 0x04080000, 0x04600000, 0x04580000, 0x04000000, + 0x04780000, 0x04700000, 0x04300000, 0x04280000, + 0x04500000, 0x04680000, 0x04200000, 0x04400000, + 0x04480000, 0x04180000, 0x04380000, 0x04100000, + /* 2 */ + 0x00000004, 0x60000004, 0x40000004, 0x48000004, + 0x68000004, 0x10000004, 0x50000004, 0x58000004, + 0x38000004, 0x18000004, 0x30000004, 0x28000004, + 0x20000004, 0x70000004, 0x78000004, 0x08000004, + 0x00000000, 0x60000000, 0x40000000, 0x48000000, + 0x68000000, 0x10000000, 0x50000000, 0x58000000, + 0x38000000, 0x18000000, 0x30000000, 0x28000000, + 0x20000000, 0x70000000, 0x78000000, 0x08000000, + 0x80000007, 0xe0000007, 0xc0000007, 0xc8000007, + 0xe8000007, 0x90000007, 0xd0000007, 0xd8000007, + 0xb8000007, 0x98000007, 0xb0000007, 0xa8000007, + 0xa0000007, 0xf0000007, 0xf8000007, 0x88000007, + 0x80000001, 0xe0000001, 0xc0000001, 0xc8000001, + 0xe8000001, 0x90000001, 0xd0000001, 0xd8000001, + 0xb8000001, 0x98000001, 0xb0000001, 0xa8000001, + 0xa0000001, 0xf0000001, 0xf8000001, 0x88000001, + 0x00000001, 0x60000001, 0x40000001, 0x48000001, + 0x68000001, 0x10000001, 0x50000001, 0x58000001, + 0x38000001, 0x18000001, 0x30000001, 0x28000001, + 0x20000001, 0x70000001, 0x78000001, 0x08000001, + 0x80000002, 0xe0000002, 0xc0000002, 0xc8000002, + 0xe8000002, 0x90000002, 0xd0000002, 0xd8000002, + 0xb8000002, 0x98000002, 0xb0000002, 0xa8000002, + 0xa0000002, 0xf0000002, 0xf8000002, 0x88000002, + 0x00000007, 0x60000007, 0x40000007, 0x48000007, + 0x68000007, 0x10000007, 0x50000007, 0x58000007, + 0x38000007, 0x18000007, 0x30000007, 0x28000007, + 0x20000007, 0x70000007, 0x78000007, 0x08000007, + 0x80000005, 0xe0000005, 0xc0000005, 0xc8000005, + 0xe8000005, 0x90000005, 0xd0000005, 0xd8000005, + 0xb8000005, 0x98000005, 0xb0000005, 0xa8000005, + 0xa0000005, 0xf0000005, 0xf8000005, 0x88000005, + 0x80000000, 0xe0000000, 0xc0000000, 0xc8000000, + 0xe8000000, 0x90000000, 0xd0000000, 0xd8000000, + 0xb8000000, 0x98000000, 0xb0000000, 0xa8000000, + 0xa0000000, 0xf0000000, 0xf8000000, 0x88000000, + 0x00000005, 0x60000005, 0x40000005, 0x48000005, + 0x68000005, 0x10000005, 0x50000005, 0x58000005, + 0x38000005, 0x18000005, 0x30000005, 0x28000005, + 0x20000005, 0x70000005, 0x78000005, 0x08000005, + 0x00000002, 0x60000002, 0x40000002, 0x48000002, + 0x68000002, 0x10000002, 0x50000002, 0x58000002, + 0x38000002, 0x18000002, 0x30000002, 0x28000002, + 0x20000002, 0x70000002, 0x78000002, 0x08000002, + 0x80000003, 0xe0000003, 0xc0000003, 0xc8000003, + 0xe8000003, 0x90000003, 0xd0000003, 0xd8000003, + 0xb8000003, 0x98000003, 0xb0000003, 0xa8000003, + 0xa0000003, 0xf0000003, 0xf8000003, 0x88000003, + 0x00000006, 0x60000006, 0x40000006, 0x48000006, + 0x68000006, 0x10000006, 0x50000006, 0x58000006, + 0x38000006, 0x18000006, 0x30000006, 0x28000006, + 0x20000006, 0x70000006, 0x78000006, 0x08000006, + 0x80000004, 0xe0000004, 0xc0000004, 0xc8000004, + 0xe8000004, 0x90000004, 0xd0000004, 0xd8000004, + 0xb8000004, 0x98000004, 0xb0000004, 0xa8000004, + 0xa0000004, 0xf0000004, 0xf8000004, 0x88000004, + 0x80000006, 0xe0000006, 0xc0000006, 0xc8000006, + 0xe8000006, 0x90000006, 0xd0000006, 0xd8000006, + 0xb8000006, 0x98000006, 0xb0000006, 0xa8000006, + 0xa0000006, 0xf0000006, 0xf8000006, 0x88000006, + 0x00000003, 0x60000003, 0x40000003, 0x48000003, + 0x68000003, 0x10000003, 0x50000003, 0x58000003, + 0x38000003, 0x18000003, 0x30000003, 0x28000003, + 0x20000003, 0x70000003, 0x78000003, 0x08000003, + /* 3 */ + 0x00000098, 0x00000080, 0x000000b0, 0x000000f8, + 0x00000088, 0x000000f0, 0x000000c8, 0x00000090, + 0x000000e8, 0x000000c0, 0x000000e0, 0x000000a0, + 0x000000d8, 0x000000d0, 0x000000a8, 0x000000b8, + 0x00000518, 0x00000500, 0x00000530, 0x00000578, + 0x00000508, 0x00000570, 0x00000548, 0x00000510, + 0x00000568, 0x00000540, 0x00000560, 0x00000520, + 0x00000558, 0x00000550, 0x00000528, 0x00000538, + 0x00000318, 0x00000300, 0x00000330, 0x00000378, + 0x00000308, 0x00000370, 0x00000348, 0x00000310, + 0x00000368, 0x00000340, 0x00000360, 0x00000320, + 0x00000358, 0x00000350, 0x00000328, 0x00000338, + 0x00000418, 0x00000400, 0x00000430, 0x00000478, + 0x00000408, 0x00000470, 0x00000448, 0x00000410, + 0x00000468, 0x00000440, 0x00000460, 0x00000420, + 0x00000458, 0x00000450, 0x00000428, 0x00000438, + 0x00000798, 0x00000780, 0x000007b0, 0x000007f8, + 0x00000788, 0x000007f0, 0x000007c8, 0x00000790, + 0x000007e8, 0x000007c0, 0x000007e0, 0x000007a0, + 0x000007d8, 0x000007d0, 0x000007a8, 0x000007b8, + 0x00000598, 0x00000580, 0x000005b0, 0x000005f8, + 0x00000588, 0x000005f0, 0x000005c8, 0x00000590, + 0x000005e8, 0x000005c0, 0x000005e0, 0x000005a0, + 0x000005d8, 0x000005d0, 0x000005a8, 0x000005b8, + 0x00000018, 0x00000000, 0x00000030, 0x00000078, + 0x00000008, 0x00000070, 0x00000048, 0x00000010, + 0x00000068, 0x00000040, 0x00000060, 0x00000020, + 0x00000058, 0x00000050, 0x00000028, 0x00000038, + 0x00000218, 0x00000200, 0x00000230, 0x00000278, + 0x00000208, 0x00000270, 0x00000248, 0x00000210, + 0x00000268, 0x00000240, 0x00000260, 0x00000220, + 0x00000258, 0x00000250, 0x00000228, 0x00000238, + 0x00000618, 0x00000600, 0x00000630, 0x00000678, + 0x00000608, 0x00000670, 0x00000648, 0x00000610, + 0x00000668, 0x00000640, 0x00000660, 0x00000620, + 0x00000658, 0x00000650, 0x00000628, 0x00000638, + 0x00000198, 0x00000180, 0x000001b0, 0x000001f8, + 0x00000188, 0x000001f0, 0x000001c8, 0x00000190, + 0x000001e8, 0x000001c0, 0x000001e0, 0x000001a0, + 0x000001d8, 0x000001d0, 0x000001a8, 0x000001b8, + 0x00000298, 0x00000280, 0x000002b0, 0x000002f8, + 0x00000288, 0x000002f0, 0x000002c8, 0x00000290, + 0x000002e8, 0x000002c0, 0x000002e0, 0x000002a0, + 0x000002d8, 0x000002d0, 0x000002a8, 0x000002b8, + 0x00000498, 0x00000480, 0x000004b0, 0x000004f8, + 0x00000488, 0x000004f0, 0x000004c8, 0x00000490, + 0x000004e8, 0x000004c0, 0x000004e0, 0x000004a0, + 0x000004d8, 0x000004d0, 0x000004a8, 0x000004b8, + 0x00000398, 0x00000380, 0x000003b0, 0x000003f8, + 0x00000388, 0x000003f0, 0x000003c8, 0x00000390, + 0x000003e8, 0x000003c0, 0x000003e0, 0x000003a0, + 0x000003d8, 0x000003d0, 0x000003a8, 0x000003b8, + 0x00000698, 0x00000680, 0x000006b0, 0x000006f8, + 0x00000688, 0x000006f0, 0x000006c8, 0x00000690, + 0x000006e8, 0x000006c0, 0x000006e0, 0x000006a0, + 0x000006d8, 0x000006d0, 0x000006a8, 0x000006b8, + 0x00000118, 0x00000100, 0x00000130, 0x00000178, + 0x00000108, 0x00000170, 0x00000148, 0x00000110, + 0x00000168, 0x00000140, 0x00000160, 0x00000120, + 0x00000158, 0x00000150, 0x00000128, 0x00000138, + 0x00000718, 0x00000700, 0x00000730, 0x00000778, + 0x00000708, 0x00000770, 0x00000748, 0x00000710, + 0x00000768, 0x00000740, 0x00000760, 0x00000720, + 0x00000758, 0x00000750, 0x00000728, 0x00000738, + }; + +static const u32 sbox_TC26_Z[4*256] = + { + /* 0 */ + 0x00036000, 0x00032000, 0x00033000, 0x00031000, + 0x00035000, 0x00032800, 0x00035800, 0x00034800, + 0x00037000, 0x00034000, 0x00036800, 0x00033800, + 0x00030000, 0x00031800, 0x00037800, 0x00030800, + 0x00046000, 0x00042000, 0x00043000, 0x00041000, + 0x00045000, 0x00042800, 0x00045800, 0x00044800, + 0x00047000, 0x00044000, 0x00046800, 0x00043800, + 0x00040000, 0x00041800, 0x00047800, 0x00040800, + 0x00016000, 0x00012000, 0x00013000, 0x00011000, + 0x00015000, 0x00012800, 0x00015800, 0x00014800, + 0x00017000, 0x00014000, 0x00016800, 0x00013800, + 0x00010000, 0x00011800, 0x00017800, 0x00010800, + 0x0001e000, 0x0001a000, 0x0001b000, 0x00019000, + 0x0001d000, 0x0001a800, 0x0001d800, 0x0001c800, + 0x0001f000, 0x0001c000, 0x0001e800, 0x0001b800, + 0x00018000, 0x00019800, 0x0001f800, 0x00018800, + 0x0004e000, 0x0004a000, 0x0004b000, 0x00049000, + 0x0004d000, 0x0004a800, 0x0004d800, 0x0004c800, + 0x0004f000, 0x0004c000, 0x0004e800, 0x0004b800, + 0x00048000, 0x00049800, 0x0004f800, 0x00048800, + 0x00056000, 0x00052000, 0x00053000, 0x00051000, + 0x00055000, 0x00052800, 0x00055800, 0x00054800, + 0x00057000, 0x00054000, 0x00056800, 0x00053800, + 0x00050000, 0x00051800, 0x00057800, 0x00050800, + 0x0002e000, 0x0002a000, 0x0002b000, 0x00029000, + 0x0002d000, 0x0002a800, 0x0002d800, 0x0002c800, + 0x0002f000, 0x0002c000, 0x0002e800, 0x0002b800, + 0x00028000, 0x00029800, 0x0002f800, 0x00028800, + 0x00066000, 0x00062000, 0x00063000, 0x00061000, + 0x00065000, 0x00062800, 0x00065800, 0x00064800, + 0x00067000, 0x00064000, 0x00066800, 0x00063800, + 0x00060000, 0x00061800, 0x00067800, 0x00060800, + 0x0000e000, 0x0000a000, 0x0000b000, 0x00009000, + 0x0000d000, 0x0000a800, 0x0000d800, 0x0000c800, + 0x0000f000, 0x0000c000, 0x0000e800, 0x0000b800, + 0x00008000, 0x00009800, 0x0000f800, 0x00008800, + 0x00076000, 0x00072000, 0x00073000, 0x00071000, + 0x00075000, 0x00072800, 0x00075800, 0x00074800, + 0x00077000, 0x00074000, 0x00076800, 0x00073800, + 0x00070000, 0x00071800, 0x00077800, 0x00070800, + 0x00026000, 0x00022000, 0x00023000, 0x00021000, + 0x00025000, 0x00022800, 0x00025800, 0x00024800, + 0x00027000, 0x00024000, 0x00026800, 0x00023800, + 0x00020000, 0x00021800, 0x00027800, 0x00020800, + 0x0003e000, 0x0003a000, 0x0003b000, 0x00039000, + 0x0003d000, 0x0003a800, 0x0003d800, 0x0003c800, + 0x0003f000, 0x0003c000, 0x0003e800, 0x0003b800, + 0x00038000, 0x00039800, 0x0003f800, 0x00038800, + 0x0005e000, 0x0005a000, 0x0005b000, 0x00059000, + 0x0005d000, 0x0005a800, 0x0005d800, 0x0005c800, + 0x0005f000, 0x0005c000, 0x0005e800, 0x0005b800, + 0x00058000, 0x00059800, 0x0005f800, 0x00058800, + 0x0006e000, 0x0006a000, 0x0006b000, 0x00069000, + 0x0006d000, 0x0006a800, 0x0006d800, 0x0006c800, + 0x0006f000, 0x0006c000, 0x0006e800, 0x0006b800, + 0x00068000, 0x00069800, 0x0006f800, 0x00068800, + 0x00006000, 0x00002000, 0x00003000, 0x00001000, + 0x00005000, 0x00002800, 0x00005800, 0x00004800, + 0x00007000, 0x00004000, 0x00006800, 0x00003800, + 0x00000000, 0x00001800, 0x00007800, 0x00000800, + 0x0007e000, 0x0007a000, 0x0007b000, 0x00079000, + 0x0007d000, 0x0007a800, 0x0007d800, 0x0007c800, + 0x0007f000, 0x0007c000, 0x0007e800, 0x0007b800, + 0x00078000, 0x00079800, 0x0007f800, 0x00078800, + /* 1 */ + 0x06580000, 0x06180000, 0x06280000, 0x06400000, + 0x06100000, 0x06780000, 0x06500000, 0x06680000, + 0x06700000, 0x06080000, 0x06380000, 0x06200000, + 0x06600000, 0x06480000, 0x06300000, 0x06000000, + 0x04580000, 0x04180000, 0x04280000, 0x04400000, + 0x04100000, 0x04780000, 0x04500000, 0x04680000, + 0x04700000, 0x04080000, 0x04380000, 0x04200000, + 0x04600000, 0x04480000, 0x04300000, 0x04000000, + 0x01580000, 0x01180000, 0x01280000, 0x01400000, + 0x01100000, 0x01780000, 0x01500000, 0x01680000, + 0x01700000, 0x01080000, 0x01380000, 0x01200000, + 0x01600000, 0x01480000, 0x01300000, 0x01000000, + 0x00d80000, 0x00980000, 0x00a80000, 0x00c00000, + 0x00900000, 0x00f80000, 0x00d00000, 0x00e80000, + 0x00f00000, 0x00880000, 0x00b80000, 0x00a00000, + 0x00e00000, 0x00c80000, 0x00b00000, 0x00800000, + 0x06d80000, 0x06980000, 0x06a80000, 0x06c00000, + 0x06900000, 0x06f80000, 0x06d00000, 0x06e80000, + 0x06f00000, 0x06880000, 0x06b80000, 0x06a00000, + 0x06e00000, 0x06c80000, 0x06b00000, 0x06800000, + 0x02580000, 0x02180000, 0x02280000, 0x02400000, + 0x02100000, 0x02780000, 0x02500000, 0x02680000, + 0x02700000, 0x02080000, 0x02380000, 0x02200000, + 0x02600000, 0x02480000, 0x02300000, 0x02000000, + 0x07d80000, 0x07980000, 0x07a80000, 0x07c00000, + 0x07900000, 0x07f80000, 0x07d00000, 0x07e80000, + 0x07f00000, 0x07880000, 0x07b80000, 0x07a00000, + 0x07e00000, 0x07c80000, 0x07b00000, 0x07800000, + 0x03580000, 0x03180000, 0x03280000, 0x03400000, + 0x03100000, 0x03780000, 0x03500000, 0x03680000, + 0x03700000, 0x03080000, 0x03380000, 0x03200000, + 0x03600000, 0x03480000, 0x03300000, 0x03000000, + 0x03d80000, 0x03980000, 0x03a80000, 0x03c00000, + 0x03900000, 0x03f80000, 0x03d00000, 0x03e80000, + 0x03f00000, 0x03880000, 0x03b80000, 0x03a00000, + 0x03e00000, 0x03c80000, 0x03b00000, 0x03800000, + 0x00580000, 0x00180000, 0x00280000, 0x00400000, + 0x00100000, 0x00780000, 0x00500000, 0x00680000, + 0x00700000, 0x00080000, 0x00380000, 0x00200000, + 0x00600000, 0x00480000, 0x00300000, 0x00000000, + 0x05580000, 0x05180000, 0x05280000, 0x05400000, + 0x05100000, 0x05780000, 0x05500000, 0x05680000, + 0x05700000, 0x05080000, 0x05380000, 0x05200000, + 0x05600000, 0x05480000, 0x05300000, 0x05000000, + 0x02d80000, 0x02980000, 0x02a80000, 0x02c00000, + 0x02900000, 0x02f80000, 0x02d00000, 0x02e80000, + 0x02f00000, 0x02880000, 0x02b80000, 0x02a00000, + 0x02e00000, 0x02c80000, 0x02b00000, 0x02800000, + 0x01d80000, 0x01980000, 0x01a80000, 0x01c00000, + 0x01900000, 0x01f80000, 0x01d00000, 0x01e80000, + 0x01f00000, 0x01880000, 0x01b80000, 0x01a00000, + 0x01e00000, 0x01c80000, 0x01b00000, 0x01800000, + 0x07580000, 0x07180000, 0x07280000, 0x07400000, + 0x07100000, 0x07780000, 0x07500000, 0x07680000, + 0x07700000, 0x07080000, 0x07380000, 0x07200000, + 0x07600000, 0x07480000, 0x07300000, 0x07000000, + 0x04d80000, 0x04980000, 0x04a80000, 0x04c00000, + 0x04900000, 0x04f80000, 0x04d00000, 0x04e80000, + 0x04f00000, 0x04880000, 0x04b80000, 0x04a00000, + 0x04e00000, 0x04c80000, 0x04b00000, 0x04800000, + 0x05d80000, 0x05980000, 0x05a80000, 0x05c00000, + 0x05900000, 0x05f80000, 0x05d00000, 0x05e80000, + 0x05f00000, 0x05880000, 0x05b80000, 0x05a00000, + 0x05e00000, 0x05c80000, 0x05b00000, 0x05800000, + /* 2 */ + 0xb8000002, 0xf8000002, 0xa8000002, 0xd0000002, + 0xc0000002, 0x88000002, 0xb0000002, 0xe8000002, + 0x80000002, 0xc8000002, 0x98000002, 0xf0000002, + 0xd8000002, 0xa0000002, 0x90000002, 0xe0000002, + 0xb8000006, 0xf8000006, 0xa8000006, 0xd0000006, + 0xc0000006, 0x88000006, 0xb0000006, 0xe8000006, + 0x80000006, 0xc8000006, 0x98000006, 0xf0000006, + 0xd8000006, 0xa0000006, 0x90000006, 0xe0000006, + 0xb8000007, 0xf8000007, 0xa8000007, 0xd0000007, + 0xc0000007, 0x88000007, 0xb0000007, 0xe8000007, + 0x80000007, 0xc8000007, 0x98000007, 0xf0000007, + 0xd8000007, 0xa0000007, 0x90000007, 0xe0000007, + 0x38000003, 0x78000003, 0x28000003, 0x50000003, + 0x40000003, 0x08000003, 0x30000003, 0x68000003, + 0x00000003, 0x48000003, 0x18000003, 0x70000003, + 0x58000003, 0x20000003, 0x10000003, 0x60000003, + 0xb8000004, 0xf8000004, 0xa8000004, 0xd0000004, + 0xc0000004, 0x88000004, 0xb0000004, 0xe8000004, + 0x80000004, 0xc8000004, 0x98000004, 0xf0000004, + 0xd8000004, 0xa0000004, 0x90000004, 0xe0000004, + 0x38000001, 0x78000001, 0x28000001, 0x50000001, + 0x40000001, 0x08000001, 0x30000001, 0x68000001, + 0x00000001, 0x48000001, 0x18000001, 0x70000001, + 0x58000001, 0x20000001, 0x10000001, 0x60000001, + 0x38000006, 0x78000006, 0x28000006, 0x50000006, + 0x40000006, 0x08000006, 0x30000006, 0x68000006, + 0x00000006, 0x48000006, 0x18000006, 0x70000006, + 0x58000006, 0x20000006, 0x10000006, 0x60000006, + 0x38000005, 0x78000005, 0x28000005, 0x50000005, + 0x40000005, 0x08000005, 0x30000005, 0x68000005, + 0x00000005, 0x48000005, 0x18000005, 0x70000005, + 0x58000005, 0x20000005, 0x10000005, 0x60000005, + 0xb8000005, 0xf8000005, 0xa8000005, 0xd0000005, + 0xc0000005, 0x88000005, 0xb0000005, 0xe8000005, + 0x80000005, 0xc8000005, 0x98000005, 0xf0000005, + 0xd8000005, 0xa0000005, 0x90000005, 0xe0000005, + 0xb8000003, 0xf8000003, 0xa8000003, 0xd0000003, + 0xc0000003, 0x88000003, 0xb0000003, 0xe8000003, + 0x80000003, 0xc8000003, 0x98000003, 0xf0000003, + 0xd8000003, 0xa0000003, 0x90000003, 0xe0000003, + 0x38000004, 0x78000004, 0x28000004, 0x50000004, + 0x40000004, 0x08000004, 0x30000004, 0x68000004, + 0x00000004, 0x48000004, 0x18000004, 0x70000004, + 0x58000004, 0x20000004, 0x10000004, 0x60000004, + 0xb8000000, 0xf8000000, 0xa8000000, 0xd0000000, + 0xc0000000, 0x88000000, 0xb0000000, 0xe8000000, + 0x80000000, 0xc8000000, 0x98000000, 0xf0000000, + 0xd8000000, 0xa0000000, 0x90000000, 0xe0000000, + 0x38000002, 0x78000002, 0x28000002, 0x50000002, + 0x40000002, 0x08000002, 0x30000002, 0x68000002, + 0x00000002, 0x48000002, 0x18000002, 0x70000002, + 0x58000002, 0x20000002, 0x10000002, 0x60000002, + 0xb8000001, 0xf8000001, 0xa8000001, 0xd0000001, + 0xc0000001, 0x88000001, 0xb0000001, 0xe8000001, + 0x80000001, 0xc8000001, 0x98000001, 0xf0000001, + 0xd8000001, 0xa0000001, 0x90000001, 0xe0000001, + 0x38000007, 0x78000007, 0x28000007, 0x50000007, + 0x40000007, 0x08000007, 0x30000007, 0x68000007, + 0x00000007, 0x48000007, 0x18000007, 0x70000007, + 0x58000007, 0x20000007, 0x10000007, 0x60000007, + 0x38000000, 0x78000000, 0x28000000, 0x50000000, + 0x40000000, 0x08000000, 0x30000000, 0x68000000, + 0x00000000, 0x48000000, 0x18000000, 0x70000000, + 0x58000000, 0x20000000, 0x10000000, 0x60000000, + /* 3 */ + 0x000000c0, 0x000000f0, 0x00000090, 0x000000a8, + 0x000000b0, 0x000000c8, 0x00000088, 0x000000e0, + 0x000000f8, 0x000000a0, 0x000000d8, 0x00000080, + 0x000000e8, 0x000000d0, 0x00000098, 0x000000b8, + 0x000003c0, 0x000003f0, 0x00000390, 0x000003a8, + 0x000003b0, 0x000003c8, 0x00000388, 0x000003e0, + 0x000003f8, 0x000003a0, 0x000003d8, 0x00000380, + 0x000003e8, 0x000003d0, 0x00000398, 0x000003b8, + 0x00000740, 0x00000770, 0x00000710, 0x00000728, + 0x00000730, 0x00000748, 0x00000708, 0x00000760, + 0x00000778, 0x00000720, 0x00000758, 0x00000700, + 0x00000768, 0x00000750, 0x00000718, 0x00000738, + 0x000006c0, 0x000006f0, 0x00000690, 0x000006a8, + 0x000006b0, 0x000006c8, 0x00000688, 0x000006e0, + 0x000006f8, 0x000006a0, 0x000006d8, 0x00000680, + 0x000006e8, 0x000006d0, 0x00000698, 0x000006b8, + 0x00000040, 0x00000070, 0x00000010, 0x00000028, + 0x00000030, 0x00000048, 0x00000008, 0x00000060, + 0x00000078, 0x00000020, 0x00000058, 0x00000000, + 0x00000068, 0x00000050, 0x00000018, 0x00000038, + 0x000002c0, 0x000002f0, 0x00000290, 0x000002a8, + 0x000002b0, 0x000002c8, 0x00000288, 0x000002e0, + 0x000002f8, 0x000002a0, 0x000002d8, 0x00000280, + 0x000002e8, 0x000002d0, 0x00000298, 0x000002b8, + 0x00000440, 0x00000470, 0x00000410, 0x00000428, + 0x00000430, 0x00000448, 0x00000408, 0x00000460, + 0x00000478, 0x00000420, 0x00000458, 0x00000400, + 0x00000468, 0x00000450, 0x00000418, 0x00000438, + 0x000001c0, 0x000001f0, 0x00000190, 0x000001a8, + 0x000001b0, 0x000001c8, 0x00000188, 0x000001e0, + 0x000001f8, 0x000001a0, 0x000001d8, 0x00000180, + 0x000001e8, 0x000001d0, 0x00000198, 0x000001b8, + 0x00000240, 0x00000270, 0x00000210, 0x00000228, + 0x00000230, 0x00000248, 0x00000208, 0x00000260, + 0x00000278, 0x00000220, 0x00000258, 0x00000200, + 0x00000268, 0x00000250, 0x00000218, 0x00000238, + 0x000007c0, 0x000007f0, 0x00000790, 0x000007a8, + 0x000007b0, 0x000007c8, 0x00000788, 0x000007e0, + 0x000007f8, 0x000007a0, 0x000007d8, 0x00000780, + 0x000007e8, 0x000007d0, 0x00000798, 0x000007b8, + 0x00000540, 0x00000570, 0x00000510, 0x00000528, + 0x00000530, 0x00000548, 0x00000508, 0x00000560, + 0x00000578, 0x00000520, 0x00000558, 0x00000500, + 0x00000568, 0x00000550, 0x00000518, 0x00000538, + 0x00000340, 0x00000370, 0x00000310, 0x00000328, + 0x00000330, 0x00000348, 0x00000308, 0x00000360, + 0x00000378, 0x00000320, 0x00000358, 0x00000300, + 0x00000368, 0x00000350, 0x00000318, 0x00000338, + 0x000004c0, 0x000004f0, 0x00000490, 0x000004a8, + 0x000004b0, 0x000004c8, 0x00000488, 0x000004e0, + 0x000004f8, 0x000004a0, 0x000004d8, 0x00000480, + 0x000004e8, 0x000004d0, 0x00000498, 0x000004b8, + 0x00000640, 0x00000670, 0x00000610, 0x00000628, + 0x00000630, 0x00000648, 0x00000608, 0x00000660, + 0x00000678, 0x00000620, 0x00000658, 0x00000600, + 0x00000668, 0x00000650, 0x00000618, 0x00000638, + 0x000005c0, 0x000005f0, 0x00000590, 0x000005a8, + 0x000005b0, 0x000005c8, 0x00000588, 0x000005e0, + 0x000005f8, 0x000005a0, 0x000005d8, 0x00000580, + 0x000005e8, 0x000005d0, 0x00000598, 0x000005b8, + 0x00000140, 0x00000170, 0x00000110, 0x00000128, + 0x00000130, 0x00000148, 0x00000108, 0x00000160, + 0x00000178, 0x00000120, 0x00000158, 0x00000100, + 0x00000168, 0x00000150, 0x00000118, 0x00000138, + }; + +static struct +{ + const char *oid; + const u32 *sbox; +} gost_oid_map[] = { + { "1.2.643.2.2.30.0", sbox_test_3411 }, + { "1.2.643.2.2.30.1", sbox_CryptoPro_3411 }, + { "1.2.643.2.2.31.0", sbox_Test_89 }, + { "1.2.643.2.2.31.1", sbox_CryptoPro_A }, + { "1.2.643.2.2.31.2", sbox_CryptoPro_B }, + { "1.2.643.2.2.31.3", sbox_CryptoPro_C }, + { "1.2.643.2.2.31.4", sbox_CryptoPro_D }, + { "1.2.643.7.1.2.5.1.1", sbox_TC26_Z }, + { NULL, NULL } +}; diff --git a/contrib/depends/patches/libgcrypt/no_gen_gost-sb.patch b/contrib/depends/patches/libgcrypt/no_gen_gost-sb.patch new file mode 100644 index 0000000..335d710 --- /dev/null +++ b/contrib/depends/patches/libgcrypt/no_gen_gost-sb.patch @@ -0,0 +1,13 @@ +--- a/cipher/Makefile.in ++++ b/cipher/Makefile.in +@@ -1228,9 +1228,7 @@ uninstall-am: + .PRECIOUS: Makefile + + +-gost28147.lo: gost-sb.h +-gost-sb.h: gost-s-box +- ./gost-s-box $@ ++gost28147.lo: + + gost-s-box: gost-s-box.c + $(CC_FOR_BUILD) -o $@ $(srcdir)/gost-s-box.c diff --git a/contrib/depends/patches/libiconv/fix-whitespace.patch b/contrib/depends/patches/libiconv/fix-whitespace.patch new file mode 100644 index 0000000..531364b --- /dev/null +++ b/contrib/depends/patches/libiconv/fix-whitespace.patch @@ -0,0 +1,13 @@ +diff --git a/preload/configure b/preload/configure +index aab5c77..e20b8f0 100755 +--- a/preload/configure ++++ b/preload/configure +@@ -588,7 +588,7 @@ MAKEFLAGS= + PACKAGE_NAME='libiconv' + PACKAGE_TARNAME='libiconv' + PACKAGE_VERSION='0' +-PACKAGE_STRING='libiconv 0' ++PACKAGE_STRING='libiconv0' + PACKAGE_BUGREPORT='' + PACKAGE_URL='' + diff --git a/contrib/depends/patches/libsquashfuse/squashfuse.patch b/contrib/depends/patches/libsquashfuse/squashfuse.patch new file mode 100644 index 0000000..db94d2f --- /dev/null +++ b/contrib/depends/patches/libsquashfuse/squashfuse.patch @@ -0,0 +1,57 @@ +diff --git a/Makefile.am b/Makefile.am +index f0d7cde..70c4aa0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -14,6 +14,7 @@ bin_PROGRAMS = + noinst_PROGRAMS = + + noinst_LTLIBRARIES = libsquashfuse.la ++noinst_LTLIBRARIES += libsquashfuse_ll.la + + # Main library: libsquashfuse + libsquashfuse_la_SOURCES = swap.c cache.c table.c dir.c file.c fs.c \ +@@ -46,10 +47,9 @@ endif + + # Low-level squashfuse_ll, if supported + if SQ_WANT_LOWLEVEL +-bin_PROGRAMS += squashfuse_ll +-squashfuse_ll_SOURCES = ll.c ll_inode.c nonstd-daemon.c ll.h +-squashfuse_ll_CPPFLAGS = $(FUSE_CPPFLAGS) +-squashfuse_ll_LDADD = libsquashfuse.la libfuseprivate.la $(COMPRESSION_LIBS) \ ++libsquashfuse_ll_la_SOURCES = ll.c ll_inode.c nonstd-daemon.c ll.h ++libsquashfuse_ll_la_CPPFLAGS = $(FUSE_CPPFLAGS) ++libsquashfuse_ll_la_LIBADD = libsquashfuse.la libfuseprivate.la $(COMPRESSION_LIBS) \ + $(FUSE_LIBS) + + noinst_LTLIBRARIES += libfuseprivate.la +diff --git a/ll.c b/ll.c +index a2c7902..8fcb3f4 100644 +--- a/ll.c ++++ b/ll.c +@@ -390,7 +390,7 @@ static sqfs_ll *sqfs_ll_open(const char *path, size_t offset) { + return NULL; + } + +-int main(int argc, char *argv[]) { ++int fusefs_main(int argc, char *argv[], void (*mounted) (void)) { + struct fuse_args args; + sqfs_opts opts; + +@@ -451,6 +451,8 @@ int main(int argc, char *argv[]) { + if (sqfs_ll_daemonize(fg) != -1) { + if (fuse_set_signal_handlers(se) != -1) { + fuse_session_add_chan(se, ch.ch); ++ if (mounted) ++ mounted (); + /* FIXME: multithreading */ + err = fuse_session_loop(se); + fuse_remove_signal_handlers(se); +@@ -466,6 +468,8 @@ int main(int argc, char *argv[]) { + } + } + fuse_opt_free_args(&args); ++ if (mounted) ++ rmdir (mountpoint); + free(ll); + free(mountpoint); + diff --git a/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.c b/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.c new file mode 100644 index 0000000..e4a9d6a --- /dev/null +++ b/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.c @@ -0,0 +1,11 @@ +#include "squashfuse_dlopen.h" + +int have_libloaded = 0; + +const char *load_library_errmsg = + "AppImages require FUSE to run. \n" + "You might still be able to extract the contents of this AppImage \n" + "if you run it with the --appimage-extract option. \n" + "See https://github.com/AppImage/AppImageKit/wiki/FUSE \n" + "for more information\n"; + diff --git a/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.h b/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.h new file mode 100644 index 0000000..da3c34f --- /dev/null +++ b/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.h @@ -0,0 +1,262 @@ +#ifndef SQFS_DLOPEN_H +#define SQFS_DLOPEN_H + +//#define ENABLE_DLOPEN + +#ifdef ENABLE_DLOPEN + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/*** dlopen() stuff ***/ + +#define LIBNAME "libfuse.so.2" + +void *libhandle; +int have_libloaded; +const char *load_library_errmsg; + +#define LOAD_LIBRARY \ +if (have_libloaded != 1) { \ + if (!(libhandle = dlopen(LIBNAME, RTLD_LAZY))) { \ + fprintf(stderr, "dlopen(): error loading " LIBNAME "\n\n%s", load_library_errmsg ); \ + exit(1); \ + } else { \ + have_libloaded = 1; \ + } \ +} + +#define STRINGIFY(x) #x + +#define LOAD_SYMBOL(type,x,param) \ +type (*dl_##x) param; \ +*(void **) (&dl_##x) = dlsym(libhandle, STRINGIFY(x)); \ +if (dlerror()) { \ + fprintf(stderr, "dlsym(): error loading symbol from " LIBNAME "\n\n%s", load_library_errmsg ); \ + CLOSE_LIBRARY; \ + exit(1); \ +} + +#define DL(x) dl_##x +#define CLOSE_LIBRARY dlclose(libhandle); + + +/*** libfuse stuff ***/ + +#define FUSE_ROOT_ID 1 +#define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 } +#define FUSE_OPT_KEY(templ, key) { templ, -1U, key } +#define FUSE_OPT_KEY_OPT -1 +#define FUSE_OPT_KEY_NONOPT -2 +#define FUSE_OPT_END { NULL, 0, 0 } + +enum fuse_buf_flags { + FUSE_BUF_IS_FD = (1 << 1), + FUSE_BUF_FD_SEEK = (1 << 2), + FUSE_BUF_FD_RETRY = (1 << 3), +}; + +typedef unsigned long fuse_ino_t; +typedef struct fuse_req *fuse_req_t; + +struct fuse_chan; +struct fuse_pollhandle; + +struct fuse_args { + int argc; + char **argv; + int allocated; +}; + +typedef int (*fuse_fill_dir_t) (void *buf, const char *name, const struct stat *stbuf, off_t off); +typedef int (*fuse_opt_proc_t)(void *data, const char *arg, int key, struct fuse_args *outargs); +typedef struct fuse_dirhandle *fuse_dirh_t; +typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type, ino_t ino); + +struct fuse_file_info { + int flags; + unsigned long fh_old; + int writepage; + unsigned int direct_io : 1; + unsigned int keep_cache : 1; + unsigned int flush : 1; + unsigned int nonseekable : 1; + unsigned int flock_release : 1; + unsigned int padding : 27; + uint64_t fh; + uint64_t lock_owner; +}; + +struct fuse_entry_param { + fuse_ino_t ino; + unsigned long generation; + struct stat attr; + double attr_timeout; + double entry_timeout; +}; + +struct fuse_opt { + const char *templ; + unsigned long offset; + int value; +}; + +struct fuse_forget_data { + uint64_t ino; + uint64_t nlookup; +}; + +struct fuse_conn_info { + unsigned proto_major; + unsigned proto_minor; + unsigned async_read; + unsigned max_write; + unsigned max_readahead; + unsigned capable; + unsigned want; + unsigned max_background; + unsigned congestion_threshold; + unsigned reserved[23]; +}; + +struct fuse_buf { + size_t size; + enum fuse_buf_flags flags; + void *mem; + int fd; + off_t pos; +}; + +struct fuse_bufvec { + size_t count; + size_t idx; + size_t off; + struct fuse_buf buf[1]; +}; + +struct fuse_context { + struct fuse *fuse; + uid_t uid; + gid_t gid; + pid_t pid; + void *private_data; + mode_t umask; +}; + +struct fuse_operations { + int (*getattr) (const char *, struct stat *); + int (*readlink) (const char *, char *, size_t); + int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t); + int (*mknod) (const char *, mode_t, dev_t); + int (*mkdir) (const char *, mode_t); + int (*unlink) (const char *); + int (*rmdir) (const char *); + int (*symlink) (const char *, const char *); + int (*rename) (const char *, const char *); + int (*link) (const char *, const char *); + int (*chmod) (const char *, mode_t); + int (*chown) (const char *, uid_t, gid_t); + int (*truncate) (const char *, off_t); + int (*utime) (const char *, struct utimbuf *); + int (*open) (const char *, struct fuse_file_info *); + int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *); + int (*write) (const char *, const char *, size_t, off_t, struct fuse_file_info *); + int (*statfs) (const char *, struct statvfs *); + int (*flush) (const char *, struct fuse_file_info *); + int (*release) (const char *, struct fuse_file_info *); + int (*fsync) (const char *, int, struct fuse_file_info *); + int (*setxattr) (const char *, const char *, const char *, size_t, int); + int (*getxattr) (const char *, const char *, char *, size_t); + int (*listxattr) (const char *, char *, size_t); + int (*removexattr) (const char *, const char *); + int (*opendir) (const char *, struct fuse_file_info *); + int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *); + int (*releasedir) (const char *, struct fuse_file_info *); + int (*fsyncdir) (const char *, int, struct fuse_file_info *); + void *(*init) (struct fuse_conn_info *conn); + void (*destroy) (void *); + int (*access) (const char *, int); + int (*create) (const char *, mode_t, struct fuse_file_info *); + int (*ftruncate) (const char *, off_t, struct fuse_file_info *); + int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); + int (*lock) (const char *, struct fuse_file_info *, int cmd, struct flock *); + int (*utimens) (const char *, const struct timespec tv[2]); + int (*bmap) (const char *, size_t blocksize, uint64_t *idx); + unsigned int flag_nullpath_ok:1; + unsigned int flag_nopath:1; + unsigned int flag_utime_omit_ok:1; + unsigned int flag_reserved:29; + int (*ioctl) (const char *, int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void *data); + int (*poll) (const char *, struct fuse_file_info *, struct fuse_pollhandle *ph, unsigned *reventsp); + int (*write_buf) (const char *, struct fuse_bufvec *buf, off_t off, struct fuse_file_info *); + int (*read_buf) (const char *, struct fuse_bufvec **bufp, size_t size, off_t off, struct fuse_file_info *); + int (*flock) (const char *, struct fuse_file_info *, int op); + int (*fallocate) (const char *, int, off_t, off_t, struct fuse_file_info *); +}; + +struct fuse_lowlevel_ops { + void (*init) (void *userdata, struct fuse_conn_info *conn); + void (*destroy) (void *userdata); + void (*lookup) (fuse_req_t req, fuse_ino_t parent, const char *name); + void (*forget) (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup); + void (*getattr) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); + void (*setattr) (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, struct fuse_file_info *fi); + void (*readlink) (fuse_req_t req, fuse_ino_t ino); + void (*mknod) (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, dev_t rdev); + void (*mkdir) (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode); + void (*unlink) (fuse_req_t req, fuse_ino_t parent, const char *name); + void (*rmdir) (fuse_req_t req, fuse_ino_t parent, const char *name); + void (*symlink) (fuse_req_t req, const char *link, fuse_ino_t parent, const char *name); + void (*rename) (fuse_req_t req, fuse_ino_t parent, const char *name, fuse_ino_t newparent, const char *newname); + void (*link) (fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent, const char *newname); + void (*open) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); + void (*read) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi); + void (*write) (fuse_req_t req, fuse_ino_t ino, const char *buf, size_t size, off_t off, struct fuse_file_info *fi); + void (*flush) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); + void (*release) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); + void (*fsync) (fuse_req_t req, fuse_ino_t ino, int datasync, struct fuse_file_info *fi); + void (*opendir) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); + void (*readdir) (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi); + void (*releasedir) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi); + void (*fsyncdir) (fuse_req_t req, fuse_ino_t ino, int datasync, struct fuse_file_info *fi); + void (*statfs) (fuse_req_t req, fuse_ino_t ino); + void (*setxattr) (fuse_req_t req, fuse_ino_t ino, const char *name, const char *value, size_t size, int flags); + void (*getxattr) (fuse_req_t req, fuse_ino_t ino, const char *name, size_t size); + void (*listxattr) (fuse_req_t req, fuse_ino_t ino, size_t size); + void (*removexattr) (fuse_req_t req, fuse_ino_t ino, const char *name); + void (*access) (fuse_req_t req, fuse_ino_t ino, int mask); + void (*create) (fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, struct fuse_file_info *fi); + void (*getlk) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi, struct flock *lock); + void (*setlk) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi, struct flock *lock, int sleep); + void (*bmap) (fuse_req_t req, fuse_ino_t ino, size_t blocksize, uint64_t idx); + void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, struct fuse_file_info *fi, unsigned flags, const void *in_buf, size_t in_bufsz, size_t out_bufsz); + void (*poll) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi, struct fuse_pollhandle *ph); + void (*write_buf) (fuse_req_t req, fuse_ino_t ino, struct fuse_bufvec *bufv, off_t off, struct fuse_file_info *fi); + void (*retrieve_reply) (fuse_req_t req, void *cookie, fuse_ino_t ino, off_t offset, struct fuse_bufvec *bufv); + void (*forget_multi) (fuse_req_t req, size_t count, struct fuse_forget_data *forgets); + void (*flock) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi, int op); + void (*fallocate) (fuse_req_t req, fuse_ino_t ino, int mode, off_t offset, off_t length, struct fuse_file_info *fi); +}; + +#else /* !ENABLE_DLOPEN */ + +#define LOAD_LIBRARY +#define LOAD_SYMBOL(x) +#define DL(x) +#define CLOSE_LIBRARY + +#endif /* !ENABLE_DLOPEN */ + +#endif /* SQFS_DLOPEN_H */ + diff --git a/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.patch b/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.patch new file mode 100644 index 0000000..59e1e6e --- /dev/null +++ b/contrib/depends/patches/libsquashfuse/squashfuse_dlopen.patch @@ -0,0 +1,640 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,7 @@ + COMPRESSION_LIBS = $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(LZ4_LIBS) + + ACLOCAL_AMFLAGS = -I m4 --install ++AM_CFLAGS = -fno-strict-aliasing -DENABLE_DLOPEN + + # Suppress AppleDouble + if MAKE_EXPORT +@@ -19,13 +20,13 @@ + # Main library: libsquashfuse + libsquashfuse_la_SOURCES = swap.c cache.c table.c dir.c file.c fs.c \ + decompress.c xattr.c hash.c stack.c traverse.c util.c \ +- nonstd-pread.c nonstd-stat.c \ ++ nonstd-pread.c nonstd-stat.c squashfuse_dlopen.c \ + squashfs_fs.h common.h nonstd-internal.h nonstd.h swap.h cache.h table.h \ + dir.h file.h decompress.h xattr.h squashfuse.h hash.h stack.h traverse.h \ +- util.h fs.h ++ util.h fs.h squashfuse_dlopen.h + libsquashfuse_la_CPPFLAGS = $(ZLIB_CPPFLAGS) $(XZ_CPPFLAGS) $(LZO_CPPFLAGS) \ + $(LZ4_CPPFLAGS) +-libsquashfuse_la_LIBADD = ++libsquashfuse_la_LIBADD = -ldl + + # Helper for FUSE clients: libfuseprivate + libfuseprivate_la_SOURCES = fuseprivate.c nonstd-makedev.c nonstd-enoattr.c \ +--- a/fuseprivate.c ++++ b/fuseprivate.c +@@ -94,15 +94,17 @@ + } + + void sqfs_usage(char *progname, bool fuse_usage) { ++ LOAD_SYMBOL(int,fuse_opt_add_arg,(struct fuse_args *args, const char *arg)); ++ LOAD_SYMBOL(int,fuse_parse_cmdline,(struct fuse_args *args, char **mountpoint, int *multithreaded, int *foreground)); + fprintf(stderr, "%s (c) 2012 Dave Vasilevsky\n\n", PACKAGE_STRING); + fprintf(stderr, "Usage: %s [options] ARCHIVE MOUNTPOINT\n", + progname ? progname : PACKAGE_NAME); + if (fuse_usage) { + struct fuse_args args = FUSE_ARGS_INIT(0, NULL); +- fuse_opt_add_arg(&args, ""); /* progname */ +- fuse_opt_add_arg(&args, "-ho"); ++ DL(fuse_opt_add_arg)(&args, ""); /* progname */ ++ DL(fuse_opt_add_arg)(&args, "-ho"); + fprintf(stderr, "\n"); +- fuse_parse_cmdline(&args, NULL, NULL, NULL); ++ DL(fuse_parse_cmdline)(&args, NULL, NULL, NULL); + } + exit(-2); + } +--- a/fuseprivate.h ++++ b/fuseprivate.h +@@ -27,7 +27,10 @@ + + #include "squashfuse.h" + +-#include ++#include "squashfuse_dlopen.h" ++#ifndef ENABLE_DLOPEN ++# include ++#endif + + #include + +--- a/hl.c ++++ b/hl.c +@@ -33,6 +33,7 @@ + #include + #include + ++int have_libloaded = 0; + + typedef struct sqfs_hl sqfs_hl; + struct sqfs_hl { +@@ -42,9 +43,10 @@ + + static sqfs_err sqfs_hl_lookup(sqfs **fs, sqfs_inode *inode, + const char *path) { ++ LOAD_SYMBOL(struct fuse_context *,fuse_get_context,(void)); + bool found; + +- sqfs_hl *hl = fuse_get_context()->private_data; ++ sqfs_hl *hl = DL(fuse_get_context)()->private_data; + *fs = &hl->fs; + if (inode) + *inode = hl->root; /* copy */ +@@ -67,7 +69,8 @@ + } + + static void *sqfs_hl_op_init(struct fuse_conn_info *conn) { +- return fuse_get_context()->private_data; ++ LOAD_SYMBOL(struct fuse_context *,fuse_get_context,(void)); ++ return DL(fuse_get_context)()->private_data; + } + + static int sqfs_hl_op_getattr(const char *path, struct stat *st) { +@@ -264,7 +267,16 @@ + return NULL; + } + ++#ifdef ENABLE_DLOPEN ++#define fuse_main(argc, argv, op, user_data) \ ++ DL(fuse_main_real)(argc, argv, op, sizeof(*(op)), user_data) ++#endif ++ + int main(int argc, char *argv[]) { ++ LOAD_SYMBOL(int,fuse_opt_parse,(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc)); ++ LOAD_SYMBOL(int,fuse_opt_add_arg,(struct fuse_args *args, const char *arg)); ++ LOAD_SYMBOL(int,fuse_main_real,(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, void *user_data)); /* fuse_main */ ++ LOAD_SYMBOL(void,fuse_opt_free_args,(struct fuse_args *args)); + struct fuse_args args; + sqfs_opts opts; + sqfs_hl *hl; +@@ -299,7 +311,7 @@ + opts.image = NULL; + opts.mountpoint = 0; + opts.offset = 0; +- if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1) ++ if (DL(fuse_opt_parse)(&args, &opts, fuse_opts, sqfs_opt_proc) == -1) + sqfs_usage(argv[0], true); + if (!opts.image) + sqfs_usage(argv[0], true); +@@ -308,8 +320,9 @@ + if (!hl) + return -1; + +- fuse_opt_add_arg(&args, "-s"); /* single threaded */ ++ DL(fuse_opt_add_arg)(&args, "-s"); /* single threaded */ + ret = fuse_main(args.argc, args.argv, &sqfs_hl_ops, hl); +- fuse_opt_free_args(&args); ++ DL(fuse_opt_free_args)(&args); ++ CLOSE_LIBRARY; + return ret; + } +--- a/ll.h ++++ b/ll.h +@@ -27,7 +27,10 @@ + + #include "squashfuse.h" + +-#include ++#include "squashfuse_dlopen.h" ++#ifndef ENABLE_DLOPEN ++# include ++#endif + + typedef struct sqfs_ll sqfs_ll; + struct sqfs_ll { +--- a/ll_inode.c ++++ b/ll_inode.c +@@ -348,12 +348,14 @@ + + + sqfs_err sqfs_ll_iget(fuse_req_t req, sqfs_ll_i *lli, fuse_ino_t i) { ++ LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req)); ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); + sqfs_err err = SQFS_OK; +- lli->ll = fuse_req_userdata(req); ++ lli->ll = DL(fuse_req_userdata)(req); + if (i != SQFS_FUSE_INODE_NONE) { + err = sqfs_ll_inode(lli->ll, &lli->inode, i); + if (err) +- fuse_reply_err(req, ENOENT); ++ DL(fuse_reply_err)(req, ENOENT); + } + return err; + } +--- a/nonstd-daemon.c ++++ b/nonstd-daemon.c +@@ -28,11 +28,16 @@ + #include "nonstd-internal.h" + + #include +-#include ++ ++#include "squashfuse_dlopen.h" ++#ifndef ENABLE_DLOPEN ++# include ++#endif + + int sqfs_ll_daemonize(int fg) { + #if HAVE_DECL_FUSE_DAEMONIZE +- return fuse_daemonize(fg); ++ LOAD_SYMBOL(int,fuse_daemonize,(int foreground)); ++ return DL(fuse_daemonize)(fg); + #else + return daemon(0,0); + #endif +--- a/ll.c ++++ b/ll.c +@@ -38,37 +38,41 @@ + + static void sqfs_ll_op_getattr(fuse_req_t req, fuse_ino_t ino, + struct fuse_file_info *fi) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_attr,(fuse_req_t req, const struct stat *attr, double attr_timeout)); + sqfs_ll_i lli; + struct stat st; + if (sqfs_ll_iget(req, &lli, ino)) + return; + + if (sqfs_stat(&lli.ll->fs, &lli.inode, &st)) { +- fuse_reply_err(req, ENOENT); ++ DL(fuse_reply_err)(req, ENOENT); + } else { + st.st_ino = ino; +- fuse_reply_attr(req, &st, SQFS_TIMEOUT); ++ DL(fuse_reply_attr)(req, &st, SQFS_TIMEOUT); + } + } + + static void sqfs_ll_op_opendir(fuse_req_t req, fuse_ino_t ino, + struct fuse_file_info *fi) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_open,(fuse_req_t req, const struct fuse_file_info *fi)); + sqfs_ll_i *lli; + + fi->fh = (intptr_t)NULL; + + lli = malloc(sizeof(*lli)); + if (!lli) { +- fuse_reply_err(req, ENOMEM); ++ DL(fuse_reply_err)(req, ENOMEM); + return; + } + + if (sqfs_ll_iget(req, lli, ino) == SQFS_OK) { + if (!S_ISDIR(lli->inode.base.mode)) { +- fuse_reply_err(req, ENOTDIR); ++ DL(fuse_reply_err)(req, ENOTDIR); + } else { + fi->fh = (intptr_t)lli; +- fuse_reply_open(req, fi); ++ DL(fuse_reply_open)(req, fi); + return; + } + } +@@ -77,28 +81,35 @@ + + static void sqfs_ll_op_create(fuse_req_t req, fuse_ino_t parent, const char *name, + mode_t mode, struct fuse_file_info *fi) { +- fuse_reply_err(req, EROFS); ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ DL(fuse_reply_err)(req, EROFS); + } + + static void sqfs_ll_op_releasedir(fuse_req_t req, fuse_ino_t ino, + struct fuse_file_info *fi) { + free((sqfs_ll_i*)(intptr_t)fi->fh); +- fuse_reply_err(req, 0); /* yes, this is necessary */ ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ DL(fuse_reply_err)(req, 0); /* yes, this is necessary */ + } + + static size_t sqfs_ll_add_direntry(fuse_req_t req, char *buf, size_t bufsize, + const char *name, const struct stat *st, off_t off) { + #if HAVE_DECL_FUSE_ADD_DIRENTRY +- return fuse_add_direntry(req, buf, bufsize, name, st, off); ++ LOAD_SYMBOL(size_t,fuse_add_direntry,(fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct stat *stbuf, off_t off)); ++ return DL(fuse_add_direntry)(req, buf, bufsize, name, st, off); + #else +- size_t esize = fuse_dirent_size(strlen(name)); ++ LOAD_SYMBOL(size_t,fuse_dirent_size(size_t namelen)); ++ LOAD_SYMBOL(char *,fuse_add_dirent,(char *buf, const char *name, const struct stat *stbuf, off_t off)); ++ size_t esize = DL(fuse_dirent_size)(strlen(name)); + if (bufsize >= esize) +- fuse_add_dirent(buf, name, st, off); ++ DL(fuse_add_dirent)(buf, name, st, off); + return esize; + #endif + } + static void sqfs_ll_op_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, + off_t off, struct fuse_file_info *fi) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size)); + sqfs_err sqerr; + sqfs_dir dir; + sqfs_name namebuf; +@@ -135,14 +146,16 @@ + } + + if (err) +- fuse_reply_err(req, err); ++ DL(fuse_reply_err)(req, err); + else +- fuse_reply_buf(req, buf, bufpos - buf); ++ DL(fuse_reply_buf)(req, buf, bufpos - buf); + free(buf); + } + + static void sqfs_ll_op_lookup(fuse_req_t req, fuse_ino_t parent, + const char *name) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_entry,(fuse_req_t req, const struct fuse_entry_param *e)); + sqfs_ll_i lli; + sqfs_err sqerr; + sqfs_name namebuf; +@@ -154,7 +167,7 @@ + return; + + if (!S_ISDIR(lli.inode.base.mode)) { +- fuse_reply_err(req, ENOTDIR); ++ DL(fuse_reply_err)(req, ENOTDIR); + return; + } + +@@ -162,55 +175,58 @@ + sqerr = sqfs_dir_lookup(&lli.ll->fs, &lli.inode, name, strlen(name), &entry, + &found); + if (sqerr) { +- fuse_reply_err(req, EIO); ++ DL(fuse_reply_err)(req, EIO); + return; + } + if (!found) { +- fuse_reply_err(req, ENOENT); ++ DL(fuse_reply_err)(req, ENOENT); + return; + } + + if (sqfs_inode_get(&lli.ll->fs, &inode, sqfs_dentry_inode(&entry))) { +- fuse_reply_err(req, ENOENT); ++ DL(fuse_reply_err)(req, ENOENT); + } else { + struct fuse_entry_param fentry; + memset(&fentry, 0, sizeof(fentry)); + if (sqfs_stat(&lli.ll->fs, &inode, &fentry.attr)) { +- fuse_reply_err(req, EIO); ++ DL(fuse_reply_err)(req, EIO); + } else { + fentry.attr_timeout = fentry.entry_timeout = SQFS_TIMEOUT; + fentry.ino = lli.ll->ino_register(lli.ll, &entry); + fentry.attr.st_ino = fentry.ino; +- fuse_reply_entry(req, &fentry); ++ DL(fuse_reply_entry)(req, &fentry); + } + } + } + + static void sqfs_ll_op_open(fuse_req_t req, fuse_ino_t ino, + struct fuse_file_info *fi) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_open,(fuse_req_t req, const struct fuse_file_info *fi)); ++ LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req)); + sqfs_inode *inode; + sqfs_ll *ll; + + if (fi->flags & (O_WRONLY | O_RDWR)) { +- fuse_reply_err(req, EROFS); ++ DL(fuse_reply_err)(req, EROFS); + return; + } + + inode = malloc(sizeof(sqfs_inode)); + if (!inode) { +- fuse_reply_err(req, ENOMEM); ++ DL(fuse_reply_err)(req, ENOMEM); + return; + } + +- ll = fuse_req_userdata(req); ++ ll = DL(fuse_req_userdata)(req); + if (sqfs_ll_inode(ll, inode, ino)) { +- fuse_reply_err(req, ENOENT); ++ DL(fuse_reply_err)(req, ENOENT); + } else if (!S_ISREG(inode->base.mode)) { +- fuse_reply_err(req, EISDIR); ++ DL(fuse_reply_err)(req, EISDIR); + } else { + fi->fh = (intptr_t)inode; + fi->keep_cache = 1; +- fuse_reply_open(req, fi); ++ DL(fuse_reply_open)(req, fi); + return; + } + free(inode); +@@ -218,37 +234,43 @@ + + static void sqfs_ll_op_release(fuse_req_t req, fuse_ino_t ino, + struct fuse_file_info *fi) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); + free((sqfs_inode*)(intptr_t)fi->fh); + fi->fh = 0; +- fuse_reply_err(req, 0); ++ DL(fuse_reply_err)(req, 0); + } + + static void sqfs_ll_op_read(fuse_req_t req, fuse_ino_t ino, + size_t size, off_t off, struct fuse_file_info *fi) { +- sqfs_ll *ll = fuse_req_userdata(req); ++ LOAD_SYMBOL(void *,fuse_req_userdata,(fuse_req_t req)); ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size)); ++ sqfs_ll *ll = DL(fuse_req_userdata)(req); + sqfs_inode *inode = (sqfs_inode*)(intptr_t)fi->fh; + sqfs_err err = SQFS_OK; + + off_t osize; + char *buf = malloc(size); + if (!buf) { +- fuse_reply_err(req, ENOMEM); ++ DL(fuse_reply_err)(req, ENOMEM); + return; + } + + osize = size; + err = sqfs_read_range(&ll->fs, inode, off, &osize, buf); + if (err) { +- fuse_reply_err(req, EIO); ++ DL(fuse_reply_err)(req, EIO); + } else if (osize == 0) { /* EOF */ +- fuse_reply_buf(req, NULL, 0); ++ DL(fuse_reply_buf)(req, NULL, 0); + } else { +- fuse_reply_buf(req, buf, osize); ++ DL(fuse_reply_buf)(req, buf, osize); + } + free(buf); + } + + static void sqfs_ll_op_readlink(fuse_req_t req, fuse_ino_t ino) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_readlink,(fuse_req_t req, const char *link)); + char *dst; + size_t size; + sqfs_ll_i lli; +@@ -256,21 +278,24 @@ + return; + + if (!S_ISLNK(lli.inode.base.mode)) { +- fuse_reply_err(req, EINVAL); ++ DL(fuse_reply_err)(req, EINVAL); + } else if (sqfs_readlink(&lli.ll->fs, &lli.inode, NULL, &size)) { +- fuse_reply_err(req, EIO); ++ DL(fuse_reply_err)(req, EIO); + } else if (!(dst = malloc(size + 1))) { +- fuse_reply_err(req, ENOMEM); ++ DL(fuse_reply_err)(req, ENOMEM); + } else if (sqfs_readlink(&lli.ll->fs, &lli.inode, dst, &size)) { +- fuse_reply_err(req, EIO); ++ DL(fuse_reply_err)(req, EIO); + free(dst); + } else { +- fuse_reply_readlink(req, dst); ++ DL(fuse_reply_readlink)(req, dst); + free(dst); + } + } + + static void sqfs_ll_op_listxattr(fuse_req_t req, fuse_ino_t ino, size_t size) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_xattr,(fuse_req_t req, size_t count)); ++ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size)); + sqfs_ll_i lli; + char *buf; + int ferr; +@@ -280,17 +305,17 @@ + + buf = NULL; + if (size && !(buf = malloc(size))) { +- fuse_reply_err(req, ENOMEM); ++ DL(fuse_reply_err)(req, ENOMEM); + return; + } + + ferr = sqfs_listxattr(&lli.ll->fs, &lli.inode, buf, &size); + if (ferr) { +- fuse_reply_err(req, ferr); ++ DL(fuse_reply_err)(req, ferr); + } else if (buf) { +- fuse_reply_buf(req, buf, size); ++ DL(fuse_reply_buf)(req, buf, size); + } else { +- fuse_reply_xattr(req, size); ++ DL(fuse_reply_xattr)(req, size); + } + free(buf); + } +@@ -301,13 +326,16 @@ + , uint32_t position + #endif + ) { ++ LOAD_SYMBOL(int,fuse_reply_err,(fuse_req_t req, int err)); ++ LOAD_SYMBOL(int,fuse_reply_xattr,(fuse_req_t req, size_t count)); ++ LOAD_SYMBOL(int,fuse_reply_buf,(fuse_req_t req, const char *buf, size_t size)); + sqfs_ll_i lli; + char *buf = NULL; + size_t real = size; + + #ifdef FUSE_XATTR_POSITION + if (position != 0) { /* We don't support resource forks */ +- fuse_reply_err(req, EINVAL); ++ DL(fuse_reply_err)(req, EINVAL); + return; + } + #endif +@@ -316,26 +344,27 @@ + return; + + if (!(buf = malloc(size))) +- fuse_reply_err(req, ENOMEM); ++ DL(fuse_reply_err)(req, ENOMEM); + else if (sqfs_xattr_lookup(&lli.ll->fs, &lli.inode, name, buf, &real)) +- fuse_reply_err(req, EIO); ++ DL(fuse_reply_err)(req, EIO); + else if (real == 0) +- fuse_reply_err(req, sqfs_enoattr()); ++ DL(fuse_reply_err)(req, sqfs_enoattr()); + else if (size == 0) +- fuse_reply_xattr(req, real); ++ DL(fuse_reply_xattr)(req, real); + else if (size < real) +- fuse_reply_err(req, ERANGE); ++ DL(fuse_reply_err)(req, ERANGE); + else +- fuse_reply_buf(req, buf, real); ++ DL(fuse_reply_buf)(req, buf, real); + free(buf); + } + + static void sqfs_ll_op_forget(fuse_req_t req, fuse_ino_t ino, + unsigned long nlookup) { ++ LOAD_SYMBOL(void,fuse_reply_none,(fuse_req_t req)); + sqfs_ll_i lli; + sqfs_ll_iget(req, &lli, SQFS_FUSE_INODE_NONE); + lli.ll->ino_forget(lli.ll, ino, nlookup); +- fuse_reply_none(req); ++ DL(fuse_reply_none)(req); + } + + +@@ -348,23 +377,27 @@ + + static sqfs_err sqfs_ll_mount(sqfs_ll_chan *ch, const char *mountpoint, + struct fuse_args *args) { ++ LOAD_SYMBOL(struct fuse_chan *,fuse_mount,(const char *mountpoint, struct fuse_args *args)); + #ifdef HAVE_NEW_FUSE_UNMOUNT +- ch->ch = fuse_mount(mountpoint, args); ++ ch->ch = DL(fuse_mount)(mountpoint, args); + #else +- ch->fd = fuse_mount(mountpoint, args); ++ LOAD_SYMBOL(struct fuse_chan *,fuse_kern_chan_new,(int fd)); ++ ch->fd = DL(fuse_mount)(mountpoint, args); + if (ch->fd == -1) + return SQFS_ERR; +- ch->ch = fuse_kern_chan_new(ch->fd); ++ ch->ch = DL(fuse_kern_chan_new)(ch->fd); + #endif + return ch->ch ? SQFS_OK : SQFS_ERR; + } + + static void sqfs_ll_unmount(sqfs_ll_chan *ch, const char *mountpoint) { + #ifdef HAVE_NEW_FUSE_UNMOUNT +- fuse_unmount(mountpoint, ch->ch); ++ LOAD_SYMBOL(void,fuse_unmount,(const char *mountpoint, struct fuse_chan *ch)); ++ DL(fuse_unmount)(mountpoint, ch->ch); + #else ++ LOAD_SYMBOL(void,fuse_unmount,(const char *mountpoint)); + close(ch->fd); +- fuse_unmount(mountpoint); ++ DL(fuse_unmount)(mountpoint); + #endif + } + +@@ -391,6 +424,19 @@ + } + + int fusefs_main(int argc, char *argv[], void (*mounted) (void)) { ++ LOAD_SYMBOL(int,fuse_opt_parse,(struct fuse_args *args, void *data, const struct fuse_opt opts[], fuse_opt_proc_t proc)); ++ LOAD_SYMBOL(int,fuse_parse_cmdline,(struct fuse_args *args, char **mountpoint, int *multithreaded, int *foreground)); ++ LOAD_SYMBOL(struct fuse_session *,fuse_lowlevel_new,(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)); ++ LOAD_SYMBOL(int,fuse_set_signal_handlers,(struct fuse_session *se)); ++ LOAD_SYMBOL(void,fuse_session_add_chan,(struct fuse_session *se, struct fuse_chan *ch)); ++ LOAD_SYMBOL(int,fuse_session_loop,(struct fuse_session *se)); ++ LOAD_SYMBOL(void,fuse_remove_signal_handlers,(struct fuse_session *se)); ++#if HAVE_DECL_FUSE_SESSION_REMOVE_CHAN ++ LOAD_SYMBOL(void,fuse_session_remove_chan,(struct fuse_chan *ch)); ++#endif ++ LOAD_SYMBOL(void,fuse_session_destroy,(struct fuse_session *se)); ++ LOAD_SYMBOL(void,fuse_opt_free_args,(struct fuse_args *args)); ++ + struct fuse_args args; + sqfs_opts opts; + +@@ -429,10 +475,10 @@ + opts.image = NULL; + opts.mountpoint = 0; + opts.offset = 0; +- if (fuse_opt_parse(&args, &opts, fuse_opts, sqfs_opt_proc) == -1) ++ if (DL(fuse_opt_parse)(&args, &opts, fuse_opts, sqfs_opt_proc) == -1) + sqfs_usage(argv[0], true); + +- if (fuse_parse_cmdline(&args, &mountpoint, &mt, &fg) == -1) ++ if (DL(fuse_parse_cmdline)(&args, &mountpoint, &mt, &fg) == -1) + sqfs_usage(argv[0], true); + if (mountpoint == NULL) + sqfs_usage(argv[0], true); +@@ -445,33 +491,34 @@ + sqfs_ll_chan ch; + err = -1; + if (sqfs_ll_mount(&ch, mountpoint, &args) == SQFS_OK) { +- struct fuse_session *se = fuse_lowlevel_new(&args, ++ struct fuse_session *se = DL(fuse_lowlevel_new)(&args, + &sqfs_ll_ops, sizeof(sqfs_ll_ops), ll); + if (se != NULL) { + if (sqfs_ll_daemonize(fg) != -1) { +- if (fuse_set_signal_handlers(se) != -1) { +- fuse_session_add_chan(se, ch.ch); ++ if (DL(fuse_set_signal_handlers)(se) != -1) { ++ DL(fuse_session_add_chan)(se, ch.ch); + if (mounted) + mounted (); + /* FIXME: multithreading */ +- err = fuse_session_loop(se); +- fuse_remove_signal_handlers(se); ++ err = DL(fuse_session_loop)(se); ++ DL(fuse_remove_signal_handlers)(se); + #if HAVE_DECL_FUSE_SESSION_REMOVE_CHAN +- fuse_session_remove_chan(ch.ch); ++ DL(fuse_session_remove_chan)(ch.ch); + #endif + } + } +- fuse_session_destroy(se); ++ DL(fuse_session_destroy)(se); + } + sqfs_ll_destroy(ll); + sqfs_ll_unmount(&ch, mountpoint); + } + } +- fuse_opt_free_args(&args); ++ DL(fuse_opt_free_args)(&args); + if (mounted) + rmdir (mountpoint); + free(ll); + free(mountpoint); ++ CLOSE_LIBRARY; + + return -err; + } diff --git a/contrib/depends/patches/libxcb/remove_pthread_stubs.patch b/contrib/depends/patches/libxcb/remove_pthread_stubs.patch new file mode 100644 index 0000000..d6eb83b --- /dev/null +++ b/contrib/depends/patches/libxcb/remove_pthread_stubs.patch @@ -0,0 +1,12 @@ +Remove uneeded pthread-stubs dependency +--- a/configure ++++ b/configure +@@ -19695,7 +19695,7 @@ fi + NEEDED="xau >= 0.99.2" + case $host_os in + linux*) ;; +- *) NEEDED="$NEEDED pthread-stubs" ;; ++ *) NEEDED="$NEEDED" ;; + esac + + pkg_failed=no \ No newline at end of file diff --git a/contrib/depends/patches/libzip/no-clonefile.patch b/contrib/depends/patches/libzip/no-clonefile.patch new file mode 100644 index 0000000..9848680 --- /dev/null +++ b/contrib/depends/patches/libzip/no-clonefile.patch @@ -0,0 +1,10 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -99,7 +99,6 @@ check_function_exists(_strtoi64 HAVE__STRTOI64) + check_function_exists(_strtoui64 HAVE__STRTOUI64) + check_function_exists(_unlink HAVE__UNLINK) + check_function_exists(arc4random HAVE_ARC4RANDOM) +-check_function_exists(clonefile HAVE_CLONEFILE) + check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO) + check_function_exists(explicit_memset HAVE_EXPLICIT_MEMSET) + check_function_exists(fchmod HAVE_FCHMOD) diff --git a/contrib/depends/patches/native_biplist/sorted_list.patch b/contrib/depends/patches/native_biplist/sorted_list.patch new file mode 100644 index 0000000..89abdb1 --- /dev/null +++ b/contrib/depends/patches/native_biplist/sorted_list.patch @@ -0,0 +1,29 @@ +--- a/biplist/__init__.py 2014-10-26 19:03:11.000000000 +0000 ++++ b/biplist/__init__.py 2016-07-19 19:30:17.663521999 +0000 +@@ -541,7 +541,7 @@ + return HashableWrapper(n) + elif isinstance(root, dict): + n = {} +- for key, value in iteritems(root): ++ for key, value in sorted(iteritems(root)): + n[self.wrapRoot(key)] = self.wrapRoot(value) + return HashableWrapper(n) + elif isinstance(root, list): +@@ -616,7 +616,7 @@ + elif isinstance(obj, dict): + size = proc_size(len(obj)) + self.incrementByteCount('dictBytes', incr=1+size) +- for key, value in iteritems(obj): ++ for key, value in sorted(iteritems(obj)): + check_key(key) + self.computeOffsets(key, asReference=True) + self.computeOffsets(value, asReference=True) +@@ -714,7 +714,7 @@ + keys = [] + values = [] + objectsToWrite = [] +- for key, value in iteritems(obj): ++ for key, value in sorted(iteritems(obj)): + keys.append(key) + values.append(value) + for key in keys: diff --git a/contrib/depends/patches/native_cctools/no-build-date.patch b/contrib/depends/patches/native_cctools/no-build-date.patch new file mode 100644 index 0000000..8b7d1e1 --- /dev/null +++ b/contrib/depends/patches/native_cctools/no-build-date.patch @@ -0,0 +1,12 @@ +diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp +index 3bb8324..033760d 100644 +--- a/cctools/ld64/src/ld/Options.cpp ++++ b/cctools/ld64/src/ld/Options.cpp +@@ -4279,7 +4279,6 @@ void Options::buildSearchPaths(int argc, const char* argv[]) + fVerbose = true; + extern const char ldVersionString[]; + fprintf(stderr, "%s", ldVersionString); +- fprintf(stderr, "BUILD " __TIME__ " " __DATE__"\n"); + fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS); + // if only -v specified, exit cleanly + if ( argc == 2 ) { diff --git a/contrib/depends/patches/native_cctools/skip_otool.patch b/contrib/depends/patches/native_cctools/skip_otool.patch new file mode 100644 index 0000000..30c4ee5 --- /dev/null +++ b/contrib/depends/patches/native_cctools/skip_otool.patch @@ -0,0 +1,12 @@ +--- cctools/Makefile.am.O 2016-06-09 15:06:16.000000000 +0100 ++++ cctools/Makefile.am 2019-11-18 08:59:20.078663220 +0000 +@@ -1,7 +1,7 @@ + if ISDARWIN +-SUBDIRS=libstuff ar as misc otool ld64 $(LD_CLASSIC) ++SUBDIRS=libstuff ar as misc ld64 $(LD_CLASSIC) + else +-SUBDIRS=libstuff ar as misc libobjc2 otool ld64 $(LD_CLASSIC) ++SUBDIRS=libstuff ar as misc ld64 $(LD_CLASSIC) + endif + + ACLOCAL_AMFLAGS = -I m4 diff --git a/contrib/depends/patches/native_cdrkit/cdrkit-deterministic.patch b/contrib/depends/patches/native_cdrkit/cdrkit-deterministic.patch new file mode 100644 index 0000000..8ab0993 --- /dev/null +++ b/contrib/depends/patches/native_cdrkit/cdrkit-deterministic.patch @@ -0,0 +1,86 @@ +--- cdrkit-1.1.11.old/genisoimage/tree.c 2008-10-21 19:57:47.000000000 -0400 ++++ cdrkit-1.1.11/genisoimage/tree.c 2013-12-06 00:23:18.489622668 -0500 +@@ -1139,8 +1139,9 @@ + scan_directory_tree(struct directory *this_dir, char *path, + struct directory_entry *de) + { +- DIR *current_dir; ++ int current_file; + char whole_path[PATH_MAX]; ++ struct dirent **d_list; + struct dirent *d_entry; + struct directory *parent; + int dflag; +@@ -1164,7 +1165,8 @@ + this_dir->dir_flags |= DIR_WAS_SCANNED; + + errno = 0; /* Paranoia */ +- current_dir = opendir(path); ++ //current_dir = opendir(path); ++ current_file = scandir(path, &d_list, NULL, alphasort); + d_entry = NULL; + + /* +@@ -1173,12 +1175,12 @@ + */ + old_path = path; + +- if (current_dir) { ++ if (current_file >= 0) { + errno = 0; +- d_entry = readdir(current_dir); ++ d_entry = d_list[0]; + } + +- if (!current_dir || !d_entry) { ++ if (current_file < 0 || !d_entry) { + int ret = 1; + + #ifdef USE_LIBSCHILY +@@ -1191,8 +1193,8 @@ + de->isorec.flags[0] &= ~ISO_DIRECTORY; + ret = 0; + } +- if (current_dir) +- closedir(current_dir); ++ if(d_list) ++ free(d_list); + return (ret); + } + #ifdef ABORT_DEEP_ISO_ONLY +@@ -1208,7 +1210,7 @@ + errmsgno(EX_BAD, "use Rock Ridge extensions via -R or -r,\n"); + errmsgno(EX_BAD, "or allow deep ISO9660 directory nesting via -D.\n"); + } +- closedir(current_dir); ++ free(d_list); + return (1); + } + #endif +@@ -1250,13 +1252,13 @@ + * The first time through, skip this, since we already asked + * for the first entry when we opened the directory. + */ +- if (dflag) +- d_entry = readdir(current_dir); ++ if (dflag && current_file >= 0) ++ d_entry = d_list[current_file]; + dflag++; + +- if (!d_entry) ++ if (current_file < 0) + break; +- ++ current_file--; + /* OK, got a valid entry */ + + /* If we do not want all files, then pitch the backups. */ +@@ -1348,7 +1350,7 @@ + insert_file_entry(this_dir, whole_path, d_entry->d_name); + #endif /* APPLE_HYB */ + } +- closedir(current_dir); ++ free(d_list); + + #ifdef APPLE_HYB + /* diff --git a/contrib/depends/patches/native_fontconfig/gperf_header_regen.patch b/contrib/depends/patches/native_fontconfig/gperf_header_regen.patch new file mode 100644 index 0000000..b1a70d5 --- /dev/null +++ b/contrib/depends/patches/native_fontconfig/gperf_header_regen.patch @@ -0,0 +1,24 @@ +commit 7b6eb33ecd88768b28c67ce5d2d68a7eed5936b6 +Author: fanquake +Date: Tue Aug 25 14:34:53 2020 +0800 + + Remove rule that causes inadvertent header regeneration + + Otherwise the makefile will needlessly attempt to re-generate the + headers with gperf. This can be dropped once the upstream build is fixed. + + See #10851. + +diff --git a/src/Makefile.in b/src/Makefile.in +index f4626ad..4ae1b00 100644 +--- a/src/Makefile.in ++++ b/src/Makefile.in +@@ -912,7 +912,7 @@ + ' - > $@.tmp && \ + mv -f $@.tmp fcobjshash.gperf && touch $@ || ( $(RM) $@.tmp && false ) + +-fcobjshash.h: Makefile fcobjshash.gperf ++fcobjshash.h: + $(AM_V_GEN) $(GPERF) --pic -m 100 fcobjshash.gperf > $@.tmp && \ + mv -f $@.tmp $@ || ( $(RM) $@.tmp && false ) + diff --git a/contrib/depends/patches/native_libxcb/remove_pthread_stubs.patch b/contrib/depends/patches/native_libxcb/remove_pthread_stubs.patch new file mode 100644 index 0000000..d6eb83b --- /dev/null +++ b/contrib/depends/patches/native_libxcb/remove_pthread_stubs.patch @@ -0,0 +1,12 @@ +Remove uneeded pthread-stubs dependency +--- a/configure ++++ b/configure +@@ -19695,7 +19695,7 @@ fi + NEEDED="xau >= 0.99.2" + case $host_os in + linux*) ;; +- *) NEEDED="$NEEDED pthread-stubs" ;; ++ *) NEEDED="$NEEDED" ;; + esac + + pkg_failed=no \ No newline at end of file diff --git a/contrib/depends/patches/native_mac_alias/python3.patch b/contrib/depends/patches/native_mac_alias/python3.patch new file mode 100644 index 0000000..1a32340 --- /dev/null +++ b/contrib/depends/patches/native_mac_alias/python3.patch @@ -0,0 +1,72 @@ +diff -dur a/mac_alias/alias.py b/mac_alias/alias.py +--- a/mac_alias/alias.py 2015-10-19 12:12:48.000000000 +0200 ++++ b/mac_alias/alias.py 2016-04-03 12:13:12.037159417 +0200 +@@ -243,10 +243,10 @@ + alias = Alias() + alias.appinfo = appinfo + +- alias.volume = VolumeInfo (volname.replace('/',':'), ++ alias.volume = VolumeInfo (volname.decode().replace('/',':'), + voldate, fstype, disktype, + volattrs, volfsid) +- alias.target = TargetInfo (kind, filename.replace('/',':'), ++ alias.target = TargetInfo (kind, filename.decode().replace('/',':'), + folder_cnid, cnid, + crdate, creator_code, type_code) + alias.target.levels_from = levels_from +@@ -261,9 +261,9 @@ + b.read(1) + + if tag == TAG_CARBON_FOLDER_NAME: +- alias.target.folder_name = value.replace('/',':') ++ alias.target.folder_name = value.decode().replace('/',':') + elif tag == TAG_CNID_PATH: +- alias.target.cnid_path = struct.unpack(b'>%uI' % (length // 4), ++ alias.target.cnid_path = struct.unpack('>%uI' % (length // 4), + value) + elif tag == TAG_CARBON_PATH: + alias.target.carbon_path = value +@@ -298,9 +298,9 @@ + alias.target.creation_date \ + = mac_epoch + datetime.timedelta(seconds=seconds) + elif tag == TAG_POSIX_PATH: +- alias.target.posix_path = value ++ alias.target.posix_path = value.decode() + elif tag == TAG_POSIX_PATH_TO_MOUNTPOINT: +- alias.volume.posix_path = value ++ alias.volume.posix_path = value.decode() + elif tag == TAG_RECURSIVE_ALIAS_OF_DISK_IMAGE: + alias.volume.disk_image_alias = Alias.from_bytes(value) + elif tag == TAG_USER_HOME_LENGTH_PREFIX: +@@ -422,13 +422,13 @@ + # (so doing so is ridiculous, and nothing could rely on it). + b.write(struct.pack(b'>h28pI2shI64pII4s4shhI2s10s', + self.target.kind, +- carbon_volname, voldate, ++ carbon_volname, int(voldate), + self.volume.fs_type, + self.volume.disk_type, + self.target.folder_cnid, + carbon_filename, + self.target.cnid, +- crdate, ++ int(crdate), + self.target.creator_code, + self.target.type_code, + self.target.levels_from, +@@ -449,12 +449,12 @@ + + b.write(struct.pack(b'>hhQhhQ', + TAG_HIGH_RES_VOLUME_CREATION_DATE, +- 8, long(voldate * 65536), ++ 8, int(voldate * 65536), + TAG_HIGH_RES_CREATION_DATE, +- 8, long(crdate * 65536))) ++ 8, int(crdate * 65536))) + + if self.target.cnid_path: +- cnid_path = struct.pack(b'>%uI' % len(self.target.cnid_path), ++ cnid_path = struct.pack('>%uI' % len(self.target.cnid_path), + *self.target.cnid_path) + b.write(struct.pack(b'>hh', TAG_CNID_PATH, + len(cnid_path))) diff --git a/contrib/depends/patches/native_qt/QShader_map.patch b/contrib/depends/patches/native_qt/QShader_map.patch new file mode 100644 index 0000000..fa2ccbe --- /dev/null +++ b/contrib/depends/patches/native_qt/QShader_map.patch @@ -0,0 +1,21 @@ +diff --git a/src/gui/rhi/qshader_p.h b/src/gui/rhi/qshader_p.h +index 690a7f44cd..8e5894c97f 100644 +--- a/src/gui/rhi/qshader_p.h ++++ b/src/gui/rhi/qshader_p.h +@@ -17,6 +17,7 @@ + + #include + #include ++#include + #include + + QT_BEGIN_NAMESPACE +@@ -127,7 +128,7 @@ public: + QByteArray serialized() const; + static QShader fromSerialized(const QByteArray &data); + +- using NativeResourceBindingMap = QHash >; // binding -> native_binding[, native_binding] ++ using NativeResourceBindingMap = QMap >; // binding -> native_binding[, native_binding] + NativeResourceBindingMap nativeResourceBindingMap(const QShaderKey &key) const; + void setResourceBindingMap(const QShaderKey &key, const NativeResourceBindingMap &map); + void removeResourceBindingMap(const QShaderKey &key); diff --git a/contrib/depends/patches/native_qt/Use-consistent-ordering-in-QShader.patch b/contrib/depends/patches/native_qt/Use-consistent-ordering-in-QShader.patch new file mode 100644 index 0000000..af6b60c --- /dev/null +++ b/contrib/depends/patches/native_qt/Use-consistent-ordering-in-QShader.patch @@ -0,0 +1,145 @@ +From 9dced35b41882c42f4239a6380bd86dfda4cd7f5 Mon Sep 17 00:00:00 2001 +From: Laszlo Agocs +Date: Fri, 10 Jun 2022 12:09:11 +0200 +Subject: [PATCH] Use consistent ordering in QShader + +Fixes: QTBUG-101923 +Change-Id: I62df3eba773350e47ed650acb00bc42b3ce6a899 +Reviewed-by: Qt CI Bot +Reviewed-by: Andy Nichols +--- + src/gui/rhi/qshader.cpp | 38 ++++++++++++++++++++++ + src/gui/rhi/qshader_p.h | 2 ++ + src/gui/rhi/qshader_p_p.h | 9 ++--- + tests/auto/gui/rhi/qshader/tst_qshader.cpp | 11 +++++++ + 4 files changed, 56 insertions(+), 4 deletions(-) + +diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp +index 1992708ba4..cd4a9f3854 100644 +--- a/src/gui/rhi/qshader.cpp ++++ b/src/gui/rhi/qshader.cpp +@@ -563,6 +563,22 @@ size_t qHash(const QShaderVersion &s, size_t seed) noexcept + } + #endif + ++/*! ++ Establishes a sorting order between the two QShaderVersion \a lhs and \a rhs. ++ ++ \relates QShaderVersion ++ */ ++bool operator<(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept ++{ ++ if (lhs.version() < rhs.version()) ++ return true; ++ ++ if (lhs.version() == rhs.version()) ++ return int(lhs.flags()) < int(rhs.flags()); ++ ++ return false; ++} ++ + /*! + \internal + \fn bool operator!=(const QShaderVersion &lhs, const QShaderVersion &rhs) +@@ -584,6 +600,28 @@ bool operator==(const QShaderKey &lhs, const QShaderKey &rhs) noexcept + && lhs.sourceVariant() == rhs.sourceVariant(); + } + ++/*! ++ Establishes a sorting order between the two keys \a lhs and \a rhs. ++ ++ \relates QShaderKey ++ */ ++bool operator<(const QShaderKey &lhs, const QShaderKey &rhs) noexcept ++{ ++ if (int(lhs.source()) < int(rhs.source())) ++ return true; ++ ++ if (int(lhs.source()) == int(rhs.source())) { ++ if (lhs.sourceVersion() < rhs.sourceVersion()) ++ return true; ++ if (lhs.sourceVersion() == rhs.sourceVersion()) { ++ if (int(lhs.sourceVariant()) < int(rhs.sourceVariant())) ++ return true; ++ } ++ } ++ ++ return false; ++} ++ + /*! + \internal + \fn bool operator!=(const QShaderKey &lhs, const QShaderKey &rhs) +diff --git a/src/gui/rhi/qshader_p.h b/src/gui/rhi/qshader_p.h +index 690a7f44cd..c6ef338bfa 100644 +--- a/src/gui/rhi/qshader_p.h ++++ b/src/gui/rhi/qshader_p.h +@@ -187,7 +187,9 @@ inline bool operator!=(const QShader &lhs, const QShader &rhs) noexcept + } + + Q_GUI_EXPORT bool operator==(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept; ++Q_GUI_EXPORT bool operator<(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept; + Q_GUI_EXPORT bool operator==(const QShaderKey &lhs, const QShaderKey &rhs) noexcept; ++Q_GUI_EXPORT bool operator<(const QShaderKey &lhs, const QShaderKey &rhs) noexcept; + Q_GUI_EXPORT bool operator==(const QShaderCode &lhs, const QShaderCode &rhs) noexcept; + + inline bool operator!=(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept +diff --git a/src/gui/rhi/qshader_p_p.h b/src/gui/rhi/qshader_p_p.h +index c87f882bc5..e9d1e31aaf 100644 +--- a/src/gui/rhi/qshader_p_p.h ++++ b/src/gui/rhi/qshader_p_p.h +@@ -17,7 +17,7 @@ + + #include "qshader_p.h" + #include +-#include ++#include + #include + + QT_BEGIN_NAMESPACE +@@ -54,9 +54,10 @@ struct Q_GUI_EXPORT QShaderPrivate + int qsbVersion = QSB_VERSION; + QShader::Stage stage = QShader::VertexStage; + QShaderDescription desc; +- QHash shaders; +- QHash bindings; +- QHash combinedImageMap; ++ // QMap not QHash because we need to be able to iterate based on sorted keys ++ QMap shaders; ++ QMap bindings; ++ QMap combinedImageMap; + }; + + QT_END_NAMESPACE +diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp +index cd883b34d9..40aa9d9a87 100644 +--- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp ++++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp +@@ -18,6 +18,7 @@ private slots: + void genVariants(); + void shaderDescImplicitSharing(); + void bakedShaderImplicitSharing(); ++ void sortedKeys(); + void mslResourceMapping(); + void serializeShaderDesc(); + void comparison(); +@@ -238,6 +239,16 @@ void tst_QShader::bakedShaderImplicitSharing() + } + } + ++void tst_QShader::sortedKeys() ++{ ++ QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb")); ++ QVERIFY(s.isValid()); ++ QList availableShaders = s.availableShaders(); ++ QCOMPARE(availableShaders.count(), 7); ++ std::sort(availableShaders.begin(), availableShaders.end()); ++ QCOMPARE(availableShaders, s.availableShaders()); ++} ++ + void tst_QShader::mslResourceMapping() + { + QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb")); +-- +2.39.0 + diff --git a/contrib/depends/patches/native_qt/dont_hardcode_pwd.patch b/contrib/depends/patches/native_qt/dont_hardcode_pwd.patch new file mode 100644 index 0000000..cf2c4d3 --- /dev/null +++ b/contrib/depends/patches/native_qt/dont_hardcode_pwd.patch @@ -0,0 +1,25 @@ +commit 0e953866fc4672486e29e1ba6d83b4207e7b2f0b +Author: fanquake +Date: Tue Aug 18 15:09:06 2020 +0800 + + Don't hardcode pwd path + + Let a man use his builtins if he wants to! Also, removes the unnecessary + assumption that pwd lives under /bin/pwd. + + See #15581. + +--- a/qtbase/configure ++++ b/qtbase/configure +@@ -34,9 +34,9 @@ + + # the directory of this script is the "source tree" + relpath=`dirname $0` +-relpath=`(cd "$relpath"; /bin/pwd)` ++relpath=`(cd "$relpath"; pwd)` + # the current directory is the "build tree" or "object tree" +-outpath=`/bin/pwd` ++outpath=`pwd` + + # do this early so we don't store it in config.status + CFG_TOPLEVEL= diff --git a/contrib/depends/patches/native_qt/fast_fixed_dtoa_no_optimize.patch b/contrib/depends/patches/native_qt/fast_fixed_dtoa_no_optimize.patch new file mode 100644 index 0000000..6bf4a43 --- /dev/null +++ b/contrib/depends/patches/native_qt/fast_fixed_dtoa_no_optimize.patch @@ -0,0 +1,20 @@ +Modify the optimisation flags for FastFixedDtoa. +This fixes a non-determinism issue in the asm produced for +this function when cross-compiling on x86_64 and aarch64 for +the arm-linux-gnueabihf HOST. + +--- a/qtbase/src/3rdparty/double-conversion/double-conversion/fixed-dtoa.h ++++ b/qtbase/src/3rdparty/double-conversion/double-conversion/fixed-dtoa.h +@@ -48,9 +48,12 @@ namespace double_conversion { + // + // This method only works for some parameters. If it can't handle the input it + // returns false. The output is null-terminated when the function succeeds. ++#pragma GCC push_options ++#pragma GCC optimize ("-O1") + bool FastFixedDtoa(double v, int fractional_count, + Vector buffer, int* length, int* decimal_point); + ++#pragma GCC pop_options + } // namespace double_conversion + + #endif // DOUBLE_CONVERSION_FIXED_DTOA_H_ diff --git a/contrib/depends/patches/native_qt/guix_cross_lib_path.patch b/contrib/depends/patches/native_qt/guix_cross_lib_path.patch new file mode 100644 index 0000000..7911dc2 --- /dev/null +++ b/contrib/depends/patches/native_qt/guix_cross_lib_path.patch @@ -0,0 +1,17 @@ +Facilitate guix building with CROSS_LIBRARY_PATH + +See discussion in https://github.com/bitcoin/bitcoin/pull/15277. + +--- a/qtbase/mkspecs/features/toolchain.prf ++++ b/qtbase/mkspecs/features/toolchain.prf +@@ -236,8 +236,8 @@ isEmpty($${target_prefix}.INCDIRS) { + add_libraries = false + for (line, output) { + line ~= s/^[ \\t]*// # remove leading spaces +- contains(line, "LIBRARY_PATH=.*") { +- line ~= s/^LIBRARY_PATH=// # remove leading LIBRARY_PATH= ++ contains(line, "(CROSS_)?LIBRARY_PATH=.*") { ++ line ~= s/^(CROSS_)?LIBRARY_PATH=// # remove leading (CROSS_)?LIBRARY_PATH= + equals(QMAKE_HOST.os, Windows): \ + paths = $$split(line, ;) + else: \ diff --git a/contrib/depends/patches/native_qt/mac-qmake.conf b/contrib/depends/patches/native_qt/mac-qmake.conf new file mode 100644 index 0000000..cb94bf0 --- /dev/null +++ b/contrib/depends/patches/native_qt/mac-qmake.conf @@ -0,0 +1,22 @@ +MAKEFILE_GENERATOR = UNIX +CONFIG += app_bundle incremental lib_version_first absolute_library_soname +QMAKE_INCREMENTAL_STYLE = sublib +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) +include(../common/clang.conf) +include(../common/clang-mac.conf) +QMAKE_MAC_SDK_PATH=$${MAC_SDK_PATH} +QMAKE_XCODE_VERSION = $${XCODE_VERSION} +QMAKE_XCODE_DEVELOPER_PATH=/Developer +QMAKE_MAC_SDK=macosx +QMAKE_MAC_SDK.macosx.Path = $${MAC_SDK_PATH} +QMAKE_MAC_SDK.macosx.platform_name = macosx +QMAKE_MAC_SDK.macosx.SDKVersion = $${MAC_SDK_VERSION} +QMAKE_MAC_SDK.macosx.PlatformPath = /phony +!host_build: QMAKE_CFLAGS += -target $${MAC_TARGET} +!host_build: QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CFLAGS +!host_build: QMAKE_CXXFLAGS += -target $${MAC_TARGET} +!host_build: QMAKE_LFLAGS += -target $${MAC_TARGET} +QMAKE_AR = $${CROSS_COMPILE}ar cq +QMAKE_RANLIB=$${CROSS_COMPILE}ranlib +load(qt_config) diff --git a/contrib/depends/patches/native_qt/no-renameat2.patch b/contrib/depends/patches/native_qt/no-renameat2.patch new file mode 100644 index 0000000..d93dd0e --- /dev/null +++ b/contrib/depends/patches/native_qt/no-renameat2.patch @@ -0,0 +1,42 @@ +From 92ba295ee64a55c73c8a32b77c352a6181289fe8 Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sun, 30 Oct 2022 23:15:34 +0100 +Subject: [PATCH] no renameat2 + +--- + qtbase/src/corelib/configure.cmake | 2 -- + qtbase/src/corelib/global/qconfig-bootstrapped.h | 4 ---- + 2 files changed, 6 deletions(-) + +diff --git a/qtbase/src/corelib/configure.cmake b/qtbase/src/corelib/configure.cmake +index 183decb530..f8e9ad0e87 100644 +--- a/qtbase/src/corelib/configure.cmake ++++ b/qtbase/src/corelib/configure.cmake +@@ -434,8 +434,6 @@ qt_config_compile_test(renameat2 + LABEL "renameat2()" + CODE + "#define _ATFILE_SOURCE 1 +-#include +-#include + + int main(int, char **argv) + { +diff --git a/qtbase/src/corelib/global/qconfig-bootstrapped.h b/qtbase/src/corelib/global/qconfig-bootstrapped.h +index 61fd6479b1..06d06235d5 100644 +--- a/qtbase/src/corelib/global/qconfig-bootstrapped.h ++++ b/qtbase/src/corelib/global/qconfig-bootstrapped.h +@@ -74,11 +74,7 @@ + #define QT_NO_QOBJECT + #define QT_FEATURE_process -1 + #define QT_FEATURE_regularexpression 1 +-#ifdef __GLIBC_PREREQ +-# define QT_FEATURE_renameat2 (__GLIBC_PREREQ(2, 28) ? 1 : -1) +-#else + # define QT_FEATURE_renameat2 -1 +-#endif + #define QT_FEATURE_shortcut -1 + #define QT_FEATURE_signaling_nan -1 + #define QT_FEATURE_slog2 -1 +-- +2.38.1 + diff --git a/contrib/depends/patches/native_qt/no-statx.patch b/contrib/depends/patches/native_qt/no-statx.patch new file mode 100644 index 0000000..d4c88ae --- /dev/null +++ b/contrib/depends/patches/native_qt/no-statx.patch @@ -0,0 +1,56 @@ +From ceb48fa2f01b9c421d880f6220778d830e5c5f7b Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sun, 30 Oct 2022 16:52:17 +0100 +Subject: [PATCH] Never use statx + +--- + src/corelib/configure.cmake | 1 - + src/corelib/global/qconfig-bootstrapped.h | 6 +----- + src/corelib/io/qfilesystemengine_unix.cpp | 2 +- + 3 files changed, 2 insertions(+), 7 deletions(-) + +diff --git a/qtbase/src/corelib/configure.cmake b/qtbase/src/corelib/configure.cmake +index 4ab122afd0..7b89fa3dd7 100644 +--- a/qtbase/src/corelib/configure.cmake ++++ b/qtbase/src/corelib/configure.cmake +@@ -428,7 +428,6 @@ qt_config_compile_test(statx + CODE + "#define _ATFILE_SOURCE 1 + #include +-#include + #include + #include + +diff --git a/qtbase/src/corelib/global/qconfig-bootstrapped.h b/qtbase/src/corelib/global/qconfig-bootstrapped.h +index 42d38d0d04..25b551210c 100644 +--- a/qtbase/src/corelib/global/qconfig-bootstrapped.h ++++ b/qtbase/src/corelib/global/qconfig-bootstrapped.h +@@ -119,11 +119,7 @@ + #define QT_FEATURE_shortcut -1 + #define QT_FEATURE_signaling_nan -1 + #define QT_FEATURE_slog2 -1 +-#ifdef __GLIBC_PREREQ +-# define QT_FEATURE_statx (__GLIBC_PREREQ(2, 28) ? 1 : -1) +-#else +-# define QT_FEATURE_statx -1 +-#endif ++#define QT_FEATURE_statx -1 + #define QT_FEATURE_syslog -1 + #define QT_NO_SYSTEMLOCALE + #define QT_FEATURE_systemsemaphore -1 +diff --git a/qtbase/src/corelib/io/qfilesystemengine_unix.cpp b/qtbase/src/corelib/io/qfilesystemengine_unix.cpp +index 5ba9309426..c968d1c61f 100644 +--- a/qtbase/src/corelib/io/qfilesystemengine_unix.cpp ++++ b/qtbase/src/corelib/io/qfilesystemengine_unix.cpp +@@ -99,7 +99,7 @@ extern "C" NSString *NSTemporaryDirectory(); + #endif + #endif + +-#if defined(Q_OS_ANDROID) ++#if defined(Q_OS_LINUX) + // statx() is disabled on Android because quite a few systems + // come with sandboxes that kill applications that make system calls outside a + // whitelist and several Android vendors can't be bothered to update the list. +-- +2.38.1 + diff --git a/contrib/depends/patches/native_qt/no-xlib.patch b/contrib/depends/patches/native_qt/no-xlib.patch new file mode 100644 index 0000000..f767a4a --- /dev/null +++ b/contrib/depends/patches/native_qt/no-xlib.patch @@ -0,0 +1,68 @@ +From 0171c86423f6c5aa8becf1259d42a3e67b8da59c Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sun, 30 Oct 2022 17:43:43 +0100 +Subject: [PATCH] no xlib + +--- + src/plugins/platforms/xcb/qxcbcursor.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp b/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp +index 2cc39f1e85..90efc1f1fb 100644 +--- a/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp ++++ b/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp +@@ -13,7 +13,9 @@ + #include + #include + #include ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + #include ++#endif + #include + #include + +@@ -357,6 +359,7 @@ void QXcbCursor::changeCursor(QCursor *cursor, QWindow *window) + xcb_flush(xcb_connection()); + } + ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + static int cursorIdForShape(int cshape) + { + int cursorId = 0; +@@ -410,6 +413,7 @@ static int cursorIdForShape(int cshape) + } + return cursorId; + } ++#endif + + xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) + { +@@ -524,7 +528,9 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape) + xcb_cursor_t QXcbCursor::createFontCursor(int cshape) + { + xcb_connection_t *conn = xcb_connection(); ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + int cursorId = cursorIdForShape(cshape); ++#endif + xcb_cursor_t cursor = XCB_NONE; + + #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) +@@ -556,6 +562,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) + // Non-standard X11 cursors are created from bitmaps + cursor = createNonStandardCursor(cshape); + ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + // Create a glyph cursor if everything else failed + if (!cursor && cursorId) { + cursor = xcb_generate_id(conn); +@@ -563,6 +570,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) + cursorId, cursorId + 1, + 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0); + } ++#endif + + if (cursor && cshape >= 0 && cshape < Qt::LastCursor && connection()->hasXFixes()) { + const char *name = cursorNames[cshape].front(); +-- +2.38.1 + diff --git a/contrib/depends/patches/native_qt/no_pthread_cond_clockwait.patch b/contrib/depends/patches/native_qt/no_pthread_cond_clockwait.patch new file mode 100644 index 0000000..336434a --- /dev/null +++ b/contrib/depends/patches/native_qt/no_pthread_cond_clockwait.patch @@ -0,0 +1,174 @@ +From e062494e888e4dfbb42cb0b2f2c9d41dd76b9bfb Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Mon, 31 Oct 2022 00:38:39 +0100 +Subject: [PATCH] Revert "Re-apply "QReadWriteLock: replace (QWaitCondition, + QMutex) with std::(condition_variable, mutex)"" + +This reverts commit fd8f81f3859fe92082caec925223e08cf61c69d4. +--- + src/corelib/thread/qreadwritelock.cpp | 35 ++++++++++++--------------- + src/corelib/thread/qreadwritelock_p.h | 12 ++++----- + 2 files changed, 22 insertions(+), 25 deletions(-) + +diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp +index c31782d684..a46b70180c 100644 +--- a/qtbase/src/corelib/thread/qreadwritelock.cpp ++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp +@@ -31,9 +31,6 @@ QT_BEGIN_NAMESPACE + */ + + namespace { +- +-using ms = std::chrono::milliseconds; +- + enum { + StateMask = 0x3, + StateLockedForRead = 0x1, +@@ -243,7 +240,7 @@ bool QReadWriteLock::tryLockForRead(int timeout) + d = d_ptr.loadAcquire(); + continue; + } +- return d->lockForRead(lock, timeout); ++ return d->lockForRead(timeout); + } + } + +@@ -347,7 +344,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout) + d = d_ptr.loadAcquire(); + continue; + } +- return d->lockForWrite(lock, timeout); ++ return d->lockForWrite(timeout); + } + } + +@@ -431,9 +428,9 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co + + } + +-bool QReadWriteLockPrivate::lockForRead(std::unique_lock &lock, int timeout) ++bool QReadWriteLockPrivate::lockForRead(int timeout) + { +- Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function ++ Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function + + QElapsedTimer t; + if (timeout > 0) +@@ -447,10 +444,10 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock &lock + if (elapsed > timeout) + return false; + waitingReaders++; +- readerCond.wait_for(lock, ms{timeout - elapsed}); ++ readerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed)); + } else { + waitingReaders++; +- readerCond.wait(lock); ++ readerCond.wait(&mutex); + } + waitingReaders--; + } +@@ -459,9 +456,9 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock &lock + return true; + } + +-bool QReadWriteLockPrivate::lockForWrite(std::unique_lock &lock, int timeout) ++bool QReadWriteLockPrivate::lockForWrite(int timeout) + { +- Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function ++ Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function + + QElapsedTimer t; + if (timeout > 0) +@@ -476,15 +473,15 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock &loc + if (waitingReaders && !waitingWriters && !writerCount) { + // We timed out and now there is no more writers or waiting writers, but some + // readers were queued (probably because of us). Wake the waiting readers. +- readerCond.notify_all(); ++ readerCond.wakeAll(); + } + return false; + } + waitingWriters++; +- writerCond.wait_for(lock, ms{timeout - elapsed}); ++ writerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed)); + } else { + waitingWriters++; +- writerCond.wait(lock); ++ writerCond.wait(&mutex); + } + waitingWriters--; + } +@@ -497,11 +494,11 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock &loc + + void QReadWriteLockPrivate::unlock() + { +- Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function ++ Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function + if (waitingWriters) +- writerCond.notify_one(); ++ writerCond.wakeOne(); + else if (waitingReaders) +- readerCond.notify_all(); ++ readerCond.wakeAll(); + } + + static auto handleEquals(Qt::HANDLE handle) +@@ -523,7 +520,7 @@ bool QReadWriteLockPrivate::recursiveLockForRead(int timeout) + return true; + } + +- if (!lockForRead(lock, timeout)) ++ if (!lockForRead(timeout)) + return false; + + Reader r = {self, 1}; +@@ -542,7 +539,7 @@ bool QReadWriteLockPrivate::recursiveLockForWrite(int timeout) + return true; + } + +- if (!lockForWrite(lock, timeout)) ++ if (!lockForWrite(timeout)) + return false; + + currentWriter = self; +diff --git a/qtbase/src/corelib/thread/qreadwritelock_p.h b/qtbase/src/corelib/thread/qreadwritelock_p.h +index e1d42fbbf3..c88eb15e1b 100644 +--- a/qtbase/src/corelib/thread/qreadwritelock_p.h ++++ b/qtbase/src/corelib/thread/qreadwritelock_p.h +@@ -17,8 +17,8 @@ + // + + #include +-#include + #include ++#include + + QT_REQUIRE_CONFIG(thread); + +@@ -30,9 +30,9 @@ public: + explicit QReadWriteLockPrivate(bool isRecursive = false) + : recursive(isRecursive) {} + +- QtPrivate::mutex mutex; +- QtPrivate::condition_variable writerCond; +- QtPrivate::condition_variable readerCond; ++ QMutex mutex; ++ QWaitCondition writerCond; ++ QWaitCondition readerCond; + int readerCount = 0; + int writerCount = 0; + int waitingReaders = 0; +@@ -40,8 +40,8 @@ public: + const bool recursive; + + //Called with the mutex locked +- bool lockForWrite(std::unique_lock &lock, int timeout); +- bool lockForRead(std::unique_lock &lock, int timeout); ++ bool lockForWrite(int timeout); ++ bool lockForRead(int timeout); + void unlock(); + + //memory management +-- +2.38.1 + diff --git a/contrib/depends/patches/native_qt/qtbase-moc-ignore-gcc-macro.patch b/contrib/depends/patches/native_qt/qtbase-moc-ignore-gcc-macro.patch new file mode 100644 index 0000000..9b848cc --- /dev/null +++ b/contrib/depends/patches/native_qt/qtbase-moc-ignore-gcc-macro.patch @@ -0,0 +1,17 @@ +The moc executable loops through headers on CPLUS_INCLUDE_PATH and stumbles +on the GCC internal _GLIBCXX_VISIBILITY macro. Tell it to ignore it as it is +not supposed to be looking there to begin with. + +Upstream report: https://bugreports.qt.io/browse/QTBUG-83160 + +diff --git a/qtbase/src/tools/moc/main.cpp b/qtbase/src/tools/moc/main.cpp +--- a/qtbase/src/tools/moc/main.cpp ++++ b/qtbase/src/tools/moc/main.cpp +@@ -197,6 +197,7 @@ int runMoc(int argc, char **argv) + dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__"); + pp.macros["__attribute__"] = dummyVariadicFunctionMacro; + pp.macros["__declspec"] = dummyVariadicFunctionMacro; ++ pp.macros["_GLIBCXX_VISIBILITY"] = dummyVariadicFunctionMacro; + + QString filename; + QString output; diff --git a/contrib/depends/patches/native_qt/rcc_hardcode_timestamp.patch b/contrib/depends/patches/native_qt/rcc_hardcode_timestamp.patch new file mode 100644 index 0000000..6379112 --- /dev/null +++ b/contrib/depends/patches/native_qt/rcc_hardcode_timestamp.patch @@ -0,0 +1,24 @@ +Hardcode last modified timestamp in Qt RCC + +This change allows the already built qt package to be reused even with +the SOURCE_DATE_EPOCH variable set, e.g., for Guix builds. + + +--- old/qtbase/src/tools/rcc/rcc.cpp ++++ new/qtbase/src/tools/rcc/rcc.cpp +@@ -229,14 +229,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) + + if (lib.formatVersion() >= 2) { + // last modified time stamp +- const QDateTime lastModified = m_fileInfo.lastModified(); +- quint64 lastmod = quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0); +- static const quint64 sourceDate = 1000 * qgetenv("QT_RCC_SOURCE_DATE_OVERRIDE").toULongLong(); +- if (sourceDate != 0) +- lastmod = sourceDate; +- static const quint64 sourceDate2 = 1000 * qgetenv("SOURCE_DATE_EPOCH").toULongLong(); +- if (sourceDate2 != 0) +- lastmod = sourceDate2; ++ quint64 lastmod = quint64(1); + lib.writeNumber8(lastmod); + if (text || pass1) + lib.writeChar('\n'); diff --git a/contrib/depends/patches/native_qt/root_CMakeLists.txt b/contrib/depends/patches/native_qt/root_CMakeLists.txt new file mode 100644 index 0000000..2a7d35c --- /dev/null +++ b/contrib/depends/patches/native_qt/root_CMakeLists.txt @@ -0,0 +1,51 @@ +# The real minimum version will be checked by the qtbase project. +# 3.16 is the absolute minimum though. +cmake_minimum_required(VERSION 3.16...3.20) + +# Include qtbase's .cmake.conf for access to QT_REPO_MODULE_VERSION +set(__qt6_qtbase_src_path "${CMAKE_CURRENT_SOURCE_DIR}/qtbase") +include("${__qt6_qtbase_src_path}/.cmake.conf") + +# Run platform auto-detection /before/ the first project() call and thus +# before the toolchain file is loaded. +include("${__qt6_qtbase_src_path}/cmake/QtAutoDetect.cmake") + +project(Qt + VERSION "${QT_REPO_MODULE_VERSION}" + DESCRIPTION "Qt Libraries" + HOMEPAGE_URL "https://qt.io/" + LANGUAGES CXX C ASM +) + +# Required so we can call ctest from the root build directory +enable_testing() + +set(qt_module_prop_prefix "__qt_prop_") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${__qt6_qtbase_src_path}/cmake") +list(APPEND CMAKE_MODULE_PATH + "${__qt6_qtbase_src_path}/cmake/3rdparty/extra-cmake-modules/find-modules") +list(APPEND CMAKE_MODULE_PATH "${__qt6_qtbase_src_path}/cmake/3rdparty/kwin") + +# Also make sure the CMake config files do not recreate the already-existing targets +set(QT_NO_CREATE_TARGETS TRUE) +set(QT_SUPERBUILD TRUE) + +set(QT_BUILD_SUBMODULES "qtbase;qttranslations;qtsvg;qtshadertools;qtmultimedia" CACHE STRING "Submodules to build") + +foreach(module IN LISTS QT_BUILD_SUBMODULES) + message(NOTICE "Configuring '${module}'") + add_subdirectory("${module}") + + if(module STREQUAL "qtbase") + list(APPEND CMAKE_PREFIX_PATH "${QtBase_BINARY_DIR}/lib/cmake") + list(APPEND CMAKE_FIND_ROOT_PATH "${QtBase_BINARY_DIR}") + endif() +endforeach() + +# Display a summary of everything +include(QtBuildInformation) +include(QtPlatformSupport) +qt_print_feature_summary() +qt_print_build_instructions() diff --git a/contrib/depends/patches/openssl/fix_darwin.patch b/contrib/depends/patches/openssl/fix_darwin.patch new file mode 100644 index 0000000..a917daa --- /dev/null +++ b/contrib/depends/patches/openssl/fix_darwin.patch @@ -0,0 +1,60 @@ +From 96ac8f13f4d0ee96baf5724d9f96c44c34b8606c Mon Sep 17 00:00:00 2001 +From: David Carlier +Date: Tue, 24 Aug 2021 22:40:14 +0100 +Subject: [PATCH] Darwin platform allows to build on releases before + Yosemite/ios 8. + +issue #16407 #16408 + +Reviewed-by: Paul Dale +Reviewed-by: Tomas Mraz +(Merged from https://github.com/openssl/openssl/pull/16409) +--- + crypto/rand/rand_unix.c | 5 +---- + include/crypto/rand.h | 10 ++++++++++ + 2 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c +index 43f1069d151d..0f4525106af7 100644 +--- a/crypto/rand/rand_unix.c ++++ b/crypto/rand/rand_unix.c +@@ -34,9 +34,6 @@ + #if defined(__OpenBSD__) + # include + #endif +-#if defined(__APPLE__) +-# include +-#endif + + #if defined(OPENSSL_SYS_UNIX) || defined(__DJGPP__) + # include +@@ -381,7 +378,7 @@ static ssize_t syscall_random(void *buf, size_t buflen) + if (errno != ENOSYS) + return -1; + } +-# elif defined(__APPLE__) ++# elif defined(OPENSSL_APPLE_CRYPTO_RANDOM) + if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess) + return (ssize_t)buflen; + +diff --git a/include/crypto/rand.h b/include/crypto/rand.h +index 5350d3a93119..674f840fd13c 100644 +--- a/include/crypto/rand.h ++++ b/include/crypto/rand.h +@@ -20,6 +20,16 @@ + + # include + ++# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM) ++# include ++# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || \ ++ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) ++# define OPENSSL_APPLE_CRYPTO_RANDOM 1 ++# include ++# include ++# endif ++# endif ++ + /* forward declaration */ + typedef struct rand_pool_st RAND_POOL; + diff --git a/contrib/depends/patches/polyseed/32-bit.patch b/contrib/depends/patches/polyseed/32-bit.patch new file mode 100644 index 0000000..07da254 --- /dev/null +++ b/contrib/depends/patches/polyseed/32-bit.patch @@ -0,0 +1,25 @@ +From 8c51b00cb98381a791ef3dcda39f76bebaf9d68f Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Fri, 23 Dec 2022 13:51:36 +0100 +Subject: [PATCH] allow compiling on 32-bit machines + +--- + src/birthday.h | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/src/birthday.h b/src/birthday.h +index 822883a..5af79aa 100644 +--- a/src/birthday.h ++++ b/src/birthday.h +@@ -7,8 +7,6 @@ + #include + #include + +-static_assert(sizeof(time_t) == 8, "time_t must be a 64-bit type."); +- + #define EPOCH ((uint64_t)1635768000) /* 1st November 2021 12:00 UTC */ + #define TIME_STEP ((uint64_t)2629746) /* 30.436875 days = 1/12 of the Gregorian year */ + +-- +2.39.0 + diff --git a/contrib/patches/polyseed/force-static-mingw.patch b/contrib/depends/patches/polyseed/force-static-mingw.patch similarity index 100% rename from contrib/patches/polyseed/force-static-mingw.patch rename to contrib/depends/patches/polyseed/force-static-mingw.patch diff --git a/contrib/patches/polyseed/no_shared.patch b/contrib/depends/patches/polyseed/no_shared.patch similarity index 100% rename from contrib/patches/polyseed/no_shared.patch rename to contrib/depends/patches/polyseed/no_shared.patch diff --git a/contrib/depends/patches/qt/MacToolchain.cmake b/contrib/depends/patches/qt/MacToolchain.cmake new file mode 100644 index 0000000..ffb3a03 --- /dev/null +++ b/contrib/depends/patches/qt/MacToolchain.cmake @@ -0,0 +1,25 @@ +# Targeted operating system. +set(CMAKE_SYSTEM_NAME Darwin) + +# TODO: don't hardcode this +set(TARGET_SYSROOT /feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers) +set(CMAKE_SYSROOT ${TARGET_SYSROOT}) +set(CMAKE_OSX_SYSROOT ${TARGET_SYSROOT}) + +set(CMAKE_C_COMPILER clang) +set(CMAKE_CXX_COMPILER clang++) + +# TODO: don't hardcode this +set(CMAKE_C_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.15 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include") +set(CMAKE_CXX_FLAGS "--target=x86_64-apple-darwin -mmacosx-version-min=10.15 -B/feather/contrib/depends/x86_64-apple-darwin/native/bin -mlinker-version=609 -isysroot/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers -stdlib=libc++ -stdlib++-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include/c++/v1 -isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include/c++/v1 -isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include -Xclang -internal-externc-isystem/gnu/store/rwsysyzpxzwi7g1jv4hxwi3m8i36iwcc-clang-10.0.1/lib/clang/10.0.1/include -Xclang -internal-externc-isystem/feather/contrib/depends/SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/usr/include") + +set(CMAKE_INSTALL_NAME_TOOL x86_64-apple-darwin-install_name_tool) +set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/x86_64-apple-darwin/) + +# Adjust the default behavior of the find commands: +# search headers and libraries in the target environment +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +# Search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/contrib/depends/patches/qt/QShader_map.patch b/contrib/depends/patches/qt/QShader_map.patch new file mode 100644 index 0000000..fa2ccbe --- /dev/null +++ b/contrib/depends/patches/qt/QShader_map.patch @@ -0,0 +1,21 @@ +diff --git a/src/gui/rhi/qshader_p.h b/src/gui/rhi/qshader_p.h +index 690a7f44cd..8e5894c97f 100644 +--- a/src/gui/rhi/qshader_p.h ++++ b/src/gui/rhi/qshader_p.h +@@ -17,6 +17,7 @@ + + #include + #include ++#include + #include + + QT_BEGIN_NAMESPACE +@@ -127,7 +128,7 @@ public: + QByteArray serialized() const; + static QShader fromSerialized(const QByteArray &data); + +- using NativeResourceBindingMap = QHash >; // binding -> native_binding[, native_binding] ++ using NativeResourceBindingMap = QMap >; // binding -> native_binding[, native_binding] + NativeResourceBindingMap nativeResourceBindingMap(const QShaderKey &key) const; + void setResourceBindingMap(const QShaderKey &key, const NativeResourceBindingMap &map); + void removeResourceBindingMap(const QShaderKey &key); diff --git a/contrib/depends/patches/qt/Use-consistent-ordering-in-QShader.patch b/contrib/depends/patches/qt/Use-consistent-ordering-in-QShader.patch new file mode 100644 index 0000000..af6b60c --- /dev/null +++ b/contrib/depends/patches/qt/Use-consistent-ordering-in-QShader.patch @@ -0,0 +1,145 @@ +From 9dced35b41882c42f4239a6380bd86dfda4cd7f5 Mon Sep 17 00:00:00 2001 +From: Laszlo Agocs +Date: Fri, 10 Jun 2022 12:09:11 +0200 +Subject: [PATCH] Use consistent ordering in QShader + +Fixes: QTBUG-101923 +Change-Id: I62df3eba773350e47ed650acb00bc42b3ce6a899 +Reviewed-by: Qt CI Bot +Reviewed-by: Andy Nichols +--- + src/gui/rhi/qshader.cpp | 38 ++++++++++++++++++++++ + src/gui/rhi/qshader_p.h | 2 ++ + src/gui/rhi/qshader_p_p.h | 9 ++--- + tests/auto/gui/rhi/qshader/tst_qshader.cpp | 11 +++++++ + 4 files changed, 56 insertions(+), 4 deletions(-) + +diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp +index 1992708ba4..cd4a9f3854 100644 +--- a/src/gui/rhi/qshader.cpp ++++ b/src/gui/rhi/qshader.cpp +@@ -563,6 +563,22 @@ size_t qHash(const QShaderVersion &s, size_t seed) noexcept + } + #endif + ++/*! ++ Establishes a sorting order between the two QShaderVersion \a lhs and \a rhs. ++ ++ \relates QShaderVersion ++ */ ++bool operator<(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept ++{ ++ if (lhs.version() < rhs.version()) ++ return true; ++ ++ if (lhs.version() == rhs.version()) ++ return int(lhs.flags()) < int(rhs.flags()); ++ ++ return false; ++} ++ + /*! + \internal + \fn bool operator!=(const QShaderVersion &lhs, const QShaderVersion &rhs) +@@ -584,6 +600,28 @@ bool operator==(const QShaderKey &lhs, const QShaderKey &rhs) noexcept + && lhs.sourceVariant() == rhs.sourceVariant(); + } + ++/*! ++ Establishes a sorting order between the two keys \a lhs and \a rhs. ++ ++ \relates QShaderKey ++ */ ++bool operator<(const QShaderKey &lhs, const QShaderKey &rhs) noexcept ++{ ++ if (int(lhs.source()) < int(rhs.source())) ++ return true; ++ ++ if (int(lhs.source()) == int(rhs.source())) { ++ if (lhs.sourceVersion() < rhs.sourceVersion()) ++ return true; ++ if (lhs.sourceVersion() == rhs.sourceVersion()) { ++ if (int(lhs.sourceVariant()) < int(rhs.sourceVariant())) ++ return true; ++ } ++ } ++ ++ return false; ++} ++ + /*! + \internal + \fn bool operator!=(const QShaderKey &lhs, const QShaderKey &rhs) +diff --git a/src/gui/rhi/qshader_p.h b/src/gui/rhi/qshader_p.h +index 690a7f44cd..c6ef338bfa 100644 +--- a/src/gui/rhi/qshader_p.h ++++ b/src/gui/rhi/qshader_p.h +@@ -187,7 +187,9 @@ inline bool operator!=(const QShader &lhs, const QShader &rhs) noexcept + } + + Q_GUI_EXPORT bool operator==(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept; ++Q_GUI_EXPORT bool operator<(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept; + Q_GUI_EXPORT bool operator==(const QShaderKey &lhs, const QShaderKey &rhs) noexcept; ++Q_GUI_EXPORT bool operator<(const QShaderKey &lhs, const QShaderKey &rhs) noexcept; + Q_GUI_EXPORT bool operator==(const QShaderCode &lhs, const QShaderCode &rhs) noexcept; + + inline bool operator!=(const QShaderVersion &lhs, const QShaderVersion &rhs) noexcept +diff --git a/src/gui/rhi/qshader_p_p.h b/src/gui/rhi/qshader_p_p.h +index c87f882bc5..e9d1e31aaf 100644 +--- a/src/gui/rhi/qshader_p_p.h ++++ b/src/gui/rhi/qshader_p_p.h +@@ -17,7 +17,7 @@ + + #include "qshader_p.h" + #include +-#include ++#include + #include + + QT_BEGIN_NAMESPACE +@@ -54,9 +54,10 @@ struct Q_GUI_EXPORT QShaderPrivate + int qsbVersion = QSB_VERSION; + QShader::Stage stage = QShader::VertexStage; + QShaderDescription desc; +- QHash shaders; +- QHash bindings; +- QHash combinedImageMap; ++ // QMap not QHash because we need to be able to iterate based on sorted keys ++ QMap shaders; ++ QMap bindings; ++ QMap combinedImageMap; + }; + + QT_END_NAMESPACE +diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp +index cd883b34d9..40aa9d9a87 100644 +--- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp ++++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp +@@ -18,6 +18,7 @@ private slots: + void genVariants(); + void shaderDescImplicitSharing(); + void bakedShaderImplicitSharing(); ++ void sortedKeys(); + void mslResourceMapping(); + void serializeShaderDesc(); + void comparison(); +@@ -238,6 +239,16 @@ void tst_QShader::bakedShaderImplicitSharing() + } + } + ++void tst_QShader::sortedKeys() ++{ ++ QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb")); ++ QVERIFY(s.isValid()); ++ QList availableShaders = s.availableShaders(); ++ QCOMPARE(availableShaders.count(), 7); ++ std::sort(availableShaders.begin(), availableShaders.end()); ++ QCOMPARE(availableShaders, s.availableShaders()); ++} ++ + void tst_QShader::mslResourceMapping() + { + QShader s = getShader(QLatin1String(":/data/texture_all_v4.frag.qsb")); +-- +2.39.0 + diff --git a/contrib/depends/patches/qt/WindowsToolchain.cmake b/contrib/depends/patches/qt/WindowsToolchain.cmake new file mode 100644 index 0000000..7674061 --- /dev/null +++ b/contrib/depends/patches/qt/WindowsToolchain.cmake @@ -0,0 +1,15 @@ +# Targeted operating system. +set(CMAKE_SYSTEM_NAME Windows) + +# Use mingw 64-bit compilers. +set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/x86_64-w64-mingw32/) + +# Adjust the default behavior of the find commands: +# search headers and libraries in the target environment +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +# Search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/contrib/depends/patches/qt/___isOSVersionAtLeast_hack.patch b/contrib/depends/patches/qt/___isOSVersionAtLeast_hack.patch new file mode 100644 index 0000000..02059dc --- /dev/null +++ b/contrib/depends/patches/qt/___isOSVersionAtLeast_hack.patch @@ -0,0 +1,151 @@ +From 3a7a87074b8c1efd93b587e25a0790708f43dc17 Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sat, 26 Nov 2022 19:50:04 +0100 +Subject: [PATCH] don't use @available + +--- + src/gui/rhi/qrhimetal.mm | 25 ++----------------------- + 1 file changed, 2 insertions(+), 23 deletions(-) + +diff --git a/qtbase/src/gui/rhi/qrhimetal.mm b/qtbase/src/gui/rhi/qrhimetal.mm +index bd761b4e15..deb584125c 100644 +--- a/qtbase/src/gui/rhi/qrhimetal.mm ++++ b/qtbase/src/gui/rhi/qrhimetal.mm +@@ -2545,119 +2545,102 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR + #else + case QRhiTexture::ETC2_RGB8: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatETC2_RGB8_sRGB : MTLPixelFormatETC2_RGB8; + } + qWarning("QRhiMetal: ETC2 compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ETC2_RGB8A1: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatETC2_RGB8A1_sRGB : MTLPixelFormatETC2_RGB8A1; + } + qWarning("QRhiMetal: ETC2 compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ETC2_RGBA8: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatEAC_RGBA8_sRGB : MTLPixelFormatEAC_RGBA8; + } + qWarning("QRhiMetal: ETC2 compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_4x4: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_4x4_sRGB : MTLPixelFormatASTC_4x4_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_5x4: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_5x4_sRGB : MTLPixelFormatASTC_5x4_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_5x5: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_5x5_sRGB : MTLPixelFormatASTC_5x5_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_6x5: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_6x5_sRGB : MTLPixelFormatASTC_6x5_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_6x6: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_6x6_sRGB : MTLPixelFormatASTC_6x6_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_8x5: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_8x5_sRGB : MTLPixelFormatASTC_8x5_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_8x6: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_8x6_sRGB : MTLPixelFormatASTC_8x6_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_8x8: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_8x8_sRGB : MTLPixelFormatASTC_8x8_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_10x5: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_10x5_sRGB : MTLPixelFormatASTC_10x5_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_10x6: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_10x6_sRGB : MTLPixelFormatASTC_10x6_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_10x8: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_10x8_sRGB : MTLPixelFormatASTC_10x8_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_10x10: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_10x10_sRGB : MTLPixelFormatASTC_10x10_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_12x10: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_12x10_sRGB : MTLPixelFormatASTC_12x10_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); + return MTLPixelFormatInvalid; + case QRhiTexture::ASTC_12x12: + if (d->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) + return srgb ? MTLPixelFormatASTC_12x12_sRGB : MTLPixelFormatASTC_12x12_LDR; + } + qWarning("QRhiMetal: ASTC compression not supported on this platform"); +@@ -2727,12 +2710,8 @@ bool QMetalRenderBuffer::create() + case DepthStencil: + #ifdef Q_OS_MACOS + if (rhiD->caps.isAppleGPU) { +- if (@available(macOS 11.0, *)) { +- desc.storageMode = MTLStorageModeMemoryless; +- d->format = MTLPixelFormatDepth32Float_Stencil8; +- } else { +- Q_UNREACHABLE(); +- } ++ desc.storageMode = MTLStorageModeMemoryless; ++ d->format = MTLPixelFormatDepth32Float_Stencil8; + } else { + desc.storageMode = MTLStorageModePrivate; + d->format = rhiD->d->dev.depth24Stencil8PixelFormatSupported +-- +2.38.1 + diff --git a/contrib/depends/patches/qt/aarch64Toolchain.cmake b/contrib/depends/patches/qt/aarch64Toolchain.cmake new file mode 100644 index 0000000..1acf4a5 --- /dev/null +++ b/contrib/depends/patches/qt/aarch64Toolchain.cmake @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++) +set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/aarch64-linux-gnu/) + +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/contrib/depends/patches/qt/dont_hardcode_pwd.patch b/contrib/depends/patches/qt/dont_hardcode_pwd.patch new file mode 100644 index 0000000..cf2c4d3 --- /dev/null +++ b/contrib/depends/patches/qt/dont_hardcode_pwd.patch @@ -0,0 +1,25 @@ +commit 0e953866fc4672486e29e1ba6d83b4207e7b2f0b +Author: fanquake +Date: Tue Aug 18 15:09:06 2020 +0800 + + Don't hardcode pwd path + + Let a man use his builtins if he wants to! Also, removes the unnecessary + assumption that pwd lives under /bin/pwd. + + See #15581. + +--- a/qtbase/configure ++++ b/qtbase/configure +@@ -34,9 +34,9 @@ + + # the directory of this script is the "source tree" + relpath=`dirname $0` +-relpath=`(cd "$relpath"; /bin/pwd)` ++relpath=`(cd "$relpath"; pwd)` + # the current directory is the "build tree" or "object tree" +-outpath=`/bin/pwd` ++outpath=`pwd` + + # do this early so we don't store it in config.status + CFG_TOPLEVEL= diff --git a/contrib/depends/patches/qt/fast_fixed_dtoa_no_optimize.patch b/contrib/depends/patches/qt/fast_fixed_dtoa_no_optimize.patch new file mode 100644 index 0000000..6bf4a43 --- /dev/null +++ b/contrib/depends/patches/qt/fast_fixed_dtoa_no_optimize.patch @@ -0,0 +1,20 @@ +Modify the optimisation flags for FastFixedDtoa. +This fixes a non-determinism issue in the asm produced for +this function when cross-compiling on x86_64 and aarch64 for +the arm-linux-gnueabihf HOST. + +--- a/qtbase/src/3rdparty/double-conversion/double-conversion/fixed-dtoa.h ++++ b/qtbase/src/3rdparty/double-conversion/double-conversion/fixed-dtoa.h +@@ -48,9 +48,12 @@ namespace double_conversion { + // + // This method only works for some parameters. If it can't handle the input it + // returns false. The output is null-terminated when the function succeeds. ++#pragma GCC push_options ++#pragma GCC optimize ("-O1") + bool FastFixedDtoa(double v, int fractional_count, + Vector buffer, int* length, int* decimal_point); + ++#pragma GCC pop_options + } // namespace double_conversion + + #endif // DOUBLE_CONVERSION_FIXED_DTOA_H_ diff --git a/contrib/depends/patches/qt/gnueabihfToolchain.cmake b/contrib/depends/patches/qt/gnueabihfToolchain.cmake new file mode 100644 index 0000000..d8ceb75 --- /dev/null +++ b/contrib/depends/patches/qt/gnueabihfToolchain.cmake @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) +set(CMAKE_FIND_ROOT_PATH /feather/contrib/depends/arm-linux-gnueabihf/) + +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/contrib/depends/patches/qt/guix_cross_lib_path.patch b/contrib/depends/patches/qt/guix_cross_lib_path.patch new file mode 100644 index 0000000..7911dc2 --- /dev/null +++ b/contrib/depends/patches/qt/guix_cross_lib_path.patch @@ -0,0 +1,17 @@ +Facilitate guix building with CROSS_LIBRARY_PATH + +See discussion in https://github.com/bitcoin/bitcoin/pull/15277. + +--- a/qtbase/mkspecs/features/toolchain.prf ++++ b/qtbase/mkspecs/features/toolchain.prf +@@ -236,8 +236,8 @@ isEmpty($${target_prefix}.INCDIRS) { + add_libraries = false + for (line, output) { + line ~= s/^[ \\t]*// # remove leading spaces +- contains(line, "LIBRARY_PATH=.*") { +- line ~= s/^LIBRARY_PATH=// # remove leading LIBRARY_PATH= ++ contains(line, "(CROSS_)?LIBRARY_PATH=.*") { ++ line ~= s/^(CROSS_)?LIBRARY_PATH=// # remove leading (CROSS_)?LIBRARY_PATH= + equals(QMAKE_HOST.os, Windows): \ + paths = $$split(line, ;) + else: \ diff --git a/contrib/depends/patches/qt/mac-qmake.conf b/contrib/depends/patches/qt/mac-qmake.conf new file mode 100644 index 0000000..cb94bf0 --- /dev/null +++ b/contrib/depends/patches/qt/mac-qmake.conf @@ -0,0 +1,22 @@ +MAKEFILE_GENERATOR = UNIX +CONFIG += app_bundle incremental lib_version_first absolute_library_soname +QMAKE_INCREMENTAL_STYLE = sublib +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) +include(../common/clang.conf) +include(../common/clang-mac.conf) +QMAKE_MAC_SDK_PATH=$${MAC_SDK_PATH} +QMAKE_XCODE_VERSION = $${XCODE_VERSION} +QMAKE_XCODE_DEVELOPER_PATH=/Developer +QMAKE_MAC_SDK=macosx +QMAKE_MAC_SDK.macosx.Path = $${MAC_SDK_PATH} +QMAKE_MAC_SDK.macosx.platform_name = macosx +QMAKE_MAC_SDK.macosx.SDKVersion = $${MAC_SDK_VERSION} +QMAKE_MAC_SDK.macosx.PlatformPath = /phony +!host_build: QMAKE_CFLAGS += -target $${MAC_TARGET} +!host_build: QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CFLAGS +!host_build: QMAKE_CXXFLAGS += -target $${MAC_TARGET} +!host_build: QMAKE_LFLAGS += -target $${MAC_TARGET} +QMAKE_AR = $${CROSS_COMPILE}ar cq +QMAKE_RANLIB=$${CROSS_COMPILE}ranlib +load(qt_config) diff --git a/contrib/depends/patches/qt/no-renameat2.patch b/contrib/depends/patches/qt/no-renameat2.patch new file mode 100644 index 0000000..d93dd0e --- /dev/null +++ b/contrib/depends/patches/qt/no-renameat2.patch @@ -0,0 +1,42 @@ +From 92ba295ee64a55c73c8a32b77c352a6181289fe8 Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sun, 30 Oct 2022 23:15:34 +0100 +Subject: [PATCH] no renameat2 + +--- + qtbase/src/corelib/configure.cmake | 2 -- + qtbase/src/corelib/global/qconfig-bootstrapped.h | 4 ---- + 2 files changed, 6 deletions(-) + +diff --git a/qtbase/src/corelib/configure.cmake b/qtbase/src/corelib/configure.cmake +index 183decb530..f8e9ad0e87 100644 +--- a/qtbase/src/corelib/configure.cmake ++++ b/qtbase/src/corelib/configure.cmake +@@ -434,8 +434,6 @@ qt_config_compile_test(renameat2 + LABEL "renameat2()" + CODE + "#define _ATFILE_SOURCE 1 +-#include +-#include + + int main(int, char **argv) + { +diff --git a/qtbase/src/corelib/global/qconfig-bootstrapped.h b/qtbase/src/corelib/global/qconfig-bootstrapped.h +index 61fd6479b1..06d06235d5 100644 +--- a/qtbase/src/corelib/global/qconfig-bootstrapped.h ++++ b/qtbase/src/corelib/global/qconfig-bootstrapped.h +@@ -74,11 +74,7 @@ + #define QT_NO_QOBJECT + #define QT_FEATURE_process -1 + #define QT_FEATURE_regularexpression 1 +-#ifdef __GLIBC_PREREQ +-# define QT_FEATURE_renameat2 (__GLIBC_PREREQ(2, 28) ? 1 : -1) +-#else + # define QT_FEATURE_renameat2 -1 +-#endif + #define QT_FEATURE_shortcut -1 + #define QT_FEATURE_signaling_nan -1 + #define QT_FEATURE_slog2 -1 +-- +2.38.1 + diff --git a/contrib/depends/patches/qt/no-statx.patch b/contrib/depends/patches/qt/no-statx.patch new file mode 100644 index 0000000..d4c88ae --- /dev/null +++ b/contrib/depends/patches/qt/no-statx.patch @@ -0,0 +1,56 @@ +From ceb48fa2f01b9c421d880f6220778d830e5c5f7b Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sun, 30 Oct 2022 16:52:17 +0100 +Subject: [PATCH] Never use statx + +--- + src/corelib/configure.cmake | 1 - + src/corelib/global/qconfig-bootstrapped.h | 6 +----- + src/corelib/io/qfilesystemengine_unix.cpp | 2 +- + 3 files changed, 2 insertions(+), 7 deletions(-) + +diff --git a/qtbase/src/corelib/configure.cmake b/qtbase/src/corelib/configure.cmake +index 4ab122afd0..7b89fa3dd7 100644 +--- a/qtbase/src/corelib/configure.cmake ++++ b/qtbase/src/corelib/configure.cmake +@@ -428,7 +428,6 @@ qt_config_compile_test(statx + CODE + "#define _ATFILE_SOURCE 1 + #include +-#include + #include + #include + +diff --git a/qtbase/src/corelib/global/qconfig-bootstrapped.h b/qtbase/src/corelib/global/qconfig-bootstrapped.h +index 42d38d0d04..25b551210c 100644 +--- a/qtbase/src/corelib/global/qconfig-bootstrapped.h ++++ b/qtbase/src/corelib/global/qconfig-bootstrapped.h +@@ -119,11 +119,7 @@ + #define QT_FEATURE_shortcut -1 + #define QT_FEATURE_signaling_nan -1 + #define QT_FEATURE_slog2 -1 +-#ifdef __GLIBC_PREREQ +-# define QT_FEATURE_statx (__GLIBC_PREREQ(2, 28) ? 1 : -1) +-#else +-# define QT_FEATURE_statx -1 +-#endif ++#define QT_FEATURE_statx -1 + #define QT_FEATURE_syslog -1 + #define QT_NO_SYSTEMLOCALE + #define QT_FEATURE_systemsemaphore -1 +diff --git a/qtbase/src/corelib/io/qfilesystemengine_unix.cpp b/qtbase/src/corelib/io/qfilesystemengine_unix.cpp +index 5ba9309426..c968d1c61f 100644 +--- a/qtbase/src/corelib/io/qfilesystemengine_unix.cpp ++++ b/qtbase/src/corelib/io/qfilesystemengine_unix.cpp +@@ -99,7 +99,7 @@ extern "C" NSString *NSTemporaryDirectory(); + #endif + #endif + +-#if defined(Q_OS_ANDROID) ++#if defined(Q_OS_LINUX) + // statx() is disabled on Android because quite a few systems + // come with sandboxes that kill applications that make system calls outside a + // whitelist and several Android vendors can't be bothered to update the list. +-- +2.38.1 + diff --git a/contrib/depends/patches/qt/no-xlib.patch b/contrib/depends/patches/qt/no-xlib.patch new file mode 100644 index 0000000..f767a4a --- /dev/null +++ b/contrib/depends/patches/qt/no-xlib.patch @@ -0,0 +1,68 @@ +From 0171c86423f6c5aa8becf1259d42a3e67b8da59c Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sun, 30 Oct 2022 17:43:43 +0100 +Subject: [PATCH] no xlib + +--- + src/plugins/platforms/xcb/qxcbcursor.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp b/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp +index 2cc39f1e85..90efc1f1fb 100644 +--- a/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp ++++ b/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp +@@ -13,7 +13,9 @@ + #include + #include + #include ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + #include ++#endif + #include + #include + +@@ -357,6 +359,7 @@ void QXcbCursor::changeCursor(QCursor *cursor, QWindow *window) + xcb_flush(xcb_connection()); + } + ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + static int cursorIdForShape(int cshape) + { + int cursorId = 0; +@@ -410,6 +413,7 @@ static int cursorIdForShape(int cshape) + } + return cursorId; + } ++#endif + + xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) + { +@@ -524,7 +528,9 @@ static xcb_cursor_t loadCursor(void *dpy, int cshape) + xcb_cursor_t QXcbCursor::createFontCursor(int cshape) + { + xcb_connection_t *conn = xcb_connection(); ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + int cursorId = cursorIdForShape(cshape); ++#endif + xcb_cursor_t cursor = XCB_NONE; + + #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) +@@ -556,6 +562,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) + // Non-standard X11 cursors are created from bitmaps + cursor = createNonStandardCursor(cshape); + ++#if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) + // Create a glyph cursor if everything else failed + if (!cursor && cursorId) { + cursor = xcb_generate_id(conn); +@@ -563,6 +570,7 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) + cursorId, cursorId + 1, + 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0); + } ++#endif + + if (cursor && cshape >= 0 && cshape < Qt::LastCursor && connection()->hasXFixes()) { + const char *name = cursorNames[cshape].front(); +-- +2.38.1 + diff --git a/contrib/depends/patches/qt/no_pthread_cond_clockwait.patch b/contrib/depends/patches/qt/no_pthread_cond_clockwait.patch new file mode 100644 index 0000000..336434a --- /dev/null +++ b/contrib/depends/patches/qt/no_pthread_cond_clockwait.patch @@ -0,0 +1,174 @@ +From e062494e888e4dfbb42cb0b2f2c9d41dd76b9bfb Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Mon, 31 Oct 2022 00:38:39 +0100 +Subject: [PATCH] Revert "Re-apply "QReadWriteLock: replace (QWaitCondition, + QMutex) with std::(condition_variable, mutex)"" + +This reverts commit fd8f81f3859fe92082caec925223e08cf61c69d4. +--- + src/corelib/thread/qreadwritelock.cpp | 35 ++++++++++++--------------- + src/corelib/thread/qreadwritelock_p.h | 12 ++++----- + 2 files changed, 22 insertions(+), 25 deletions(-) + +diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp +index c31782d684..a46b70180c 100644 +--- a/qtbase/src/corelib/thread/qreadwritelock.cpp ++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp +@@ -31,9 +31,6 @@ QT_BEGIN_NAMESPACE + */ + + namespace { +- +-using ms = std::chrono::milliseconds; +- + enum { + StateMask = 0x3, + StateLockedForRead = 0x1, +@@ -243,7 +240,7 @@ bool QReadWriteLock::tryLockForRead(int timeout) + d = d_ptr.loadAcquire(); + continue; + } +- return d->lockForRead(lock, timeout); ++ return d->lockForRead(timeout); + } + } + +@@ -347,7 +344,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout) + d = d_ptr.loadAcquire(); + continue; + } +- return d->lockForWrite(lock, timeout); ++ return d->lockForWrite(timeout); + } + } + +@@ -431,9 +428,9 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co + + } + +-bool QReadWriteLockPrivate::lockForRead(std::unique_lock &lock, int timeout) ++bool QReadWriteLockPrivate::lockForRead(int timeout) + { +- Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function ++ Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function + + QElapsedTimer t; + if (timeout > 0) +@@ -447,10 +444,10 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock &lock + if (elapsed > timeout) + return false; + waitingReaders++; +- readerCond.wait_for(lock, ms{timeout - elapsed}); ++ readerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed)); + } else { + waitingReaders++; +- readerCond.wait(lock); ++ readerCond.wait(&mutex); + } + waitingReaders--; + } +@@ -459,9 +456,9 @@ bool QReadWriteLockPrivate::lockForRead(std::unique_lock &lock + return true; + } + +-bool QReadWriteLockPrivate::lockForWrite(std::unique_lock &lock, int timeout) ++bool QReadWriteLockPrivate::lockForWrite(int timeout) + { +- Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function ++ Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function + + QElapsedTimer t; + if (timeout > 0) +@@ -476,15 +473,15 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock &loc + if (waitingReaders && !waitingWriters && !writerCount) { + // We timed out and now there is no more writers or waiting writers, but some + // readers were queued (probably because of us). Wake the waiting readers. +- readerCond.notify_all(); ++ readerCond.wakeAll(); + } + return false; + } + waitingWriters++; +- writerCond.wait_for(lock, ms{timeout - elapsed}); ++ writerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed)); + } else { + waitingWriters++; +- writerCond.wait(lock); ++ writerCond.wait(&mutex); + } + waitingWriters--; + } +@@ -497,11 +494,11 @@ bool QReadWriteLockPrivate::lockForWrite(std::unique_lock &loc + + void QReadWriteLockPrivate::unlock() + { +- Q_ASSERT(!mutex.try_lock()); // mutex must be locked when entering this function ++ Q_ASSERT(!mutex.tryLock()); // mutex must be locked when entering this function + if (waitingWriters) +- writerCond.notify_one(); ++ writerCond.wakeOne(); + else if (waitingReaders) +- readerCond.notify_all(); ++ readerCond.wakeAll(); + } + + static auto handleEquals(Qt::HANDLE handle) +@@ -523,7 +520,7 @@ bool QReadWriteLockPrivate::recursiveLockForRead(int timeout) + return true; + } + +- if (!lockForRead(lock, timeout)) ++ if (!lockForRead(timeout)) + return false; + + Reader r = {self, 1}; +@@ -542,7 +539,7 @@ bool QReadWriteLockPrivate::recursiveLockForWrite(int timeout) + return true; + } + +- if (!lockForWrite(lock, timeout)) ++ if (!lockForWrite(timeout)) + return false; + + currentWriter = self; +diff --git a/qtbase/src/corelib/thread/qreadwritelock_p.h b/qtbase/src/corelib/thread/qreadwritelock_p.h +index e1d42fbbf3..c88eb15e1b 100644 +--- a/qtbase/src/corelib/thread/qreadwritelock_p.h ++++ b/qtbase/src/corelib/thread/qreadwritelock_p.h +@@ -17,8 +17,8 @@ + // + + #include +-#include + #include ++#include + + QT_REQUIRE_CONFIG(thread); + +@@ -30,9 +30,9 @@ public: + explicit QReadWriteLockPrivate(bool isRecursive = false) + : recursive(isRecursive) {} + +- QtPrivate::mutex mutex; +- QtPrivate::condition_variable writerCond; +- QtPrivate::condition_variable readerCond; ++ QMutex mutex; ++ QWaitCondition writerCond; ++ QWaitCondition readerCond; + int readerCount = 0; + int writerCount = 0; + int waitingReaders = 0; +@@ -40,8 +40,8 @@ public: + const bool recursive; + + //Called with the mutex locked +- bool lockForWrite(std::unique_lock &lock, int timeout); +- bool lockForRead(std::unique_lock &lock, int timeout); ++ bool lockForWrite(int timeout); ++ bool lockForRead(int timeout); + void unlock(); + + //memory management +-- +2.38.1 + diff --git a/contrib/depends/patches/qt/no_wraprt_on_apple.patch b/contrib/depends/patches/qt/no_wraprt_on_apple.patch new file mode 100644 index 0000000..bde4b1f --- /dev/null +++ b/contrib/depends/patches/qt/no_wraprt_on_apple.patch @@ -0,0 +1,27 @@ +From da01a1fcdfffeef62024546abf03a28fc1673c9e Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Sat, 26 Nov 2022 14:07:42 +0100 +Subject: [PATCH] No WrapRT on APPLE + +--- + src/corelib/CMakeLists.txt | 2 +- + src/corelib/meta_types/qt6core_release_metatypes.json | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + create mode 100644 src/corelib/meta_types/qt6core_release_metatypes.json + +diff --git a/qtbase/src/corelib/CMakeLists.txt b/qtbase/src/corelib/CMakeLists.txt +index c683bb46dd..c018b81cf2 100644 +--- a/qtbase/src/corelib/CMakeLists.txt ++++ b/qtbase/src/corelib/CMakeLists.txt +@@ -1071,7 +1071,7 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_glib AND UNIX + GLIB2::GLIB2 + ) + +-qt_internal_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX ++qt_internal_extend_target(Core CONDITION QT_FEATURE_clock_gettime AND UNIX AND NOT APPLE + LIBRARIES + WrapRt::WrapRt + ) +-- +2.38.1 + diff --git a/contrib/depends/patches/qt/qtbase-moc-ignore-gcc-macro.patch b/contrib/depends/patches/qt/qtbase-moc-ignore-gcc-macro.patch new file mode 100644 index 0000000..9b848cc --- /dev/null +++ b/contrib/depends/patches/qt/qtbase-moc-ignore-gcc-macro.patch @@ -0,0 +1,17 @@ +The moc executable loops through headers on CPLUS_INCLUDE_PATH and stumbles +on the GCC internal _GLIBCXX_VISIBILITY macro. Tell it to ignore it as it is +not supposed to be looking there to begin with. + +Upstream report: https://bugreports.qt.io/browse/QTBUG-83160 + +diff --git a/qtbase/src/tools/moc/main.cpp b/qtbase/src/tools/moc/main.cpp +--- a/qtbase/src/tools/moc/main.cpp ++++ b/qtbase/src/tools/moc/main.cpp +@@ -197,6 +197,7 @@ int runMoc(int argc, char **argv) + dummyVariadicFunctionMacro.arguments += Symbol(0, PP_IDENTIFIER, "__VA_ARGS__"); + pp.macros["__attribute__"] = dummyVariadicFunctionMacro; + pp.macros["__declspec"] = dummyVariadicFunctionMacro; ++ pp.macros["_GLIBCXX_VISIBILITY"] = dummyVariadicFunctionMacro; + + QString filename; + QString output; diff --git a/contrib/depends/patches/qt/qtmultimedia-fixes.patch b/contrib/depends/patches/qt/qtmultimedia-fixes.patch new file mode 100644 index 0000000..79f8d2d --- /dev/null +++ b/contrib/depends/patches/qt/qtmultimedia-fixes.patch @@ -0,0 +1,9109 @@ +From 070ac586846f4ae2bbe88946afcc0f5ef109c4a5 Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Mon, 2 Jan 2023 20:03:18 +0100 +Subject: [PATCH] qtmultimedia fixes + +--- + cmake/FindWMF.cmake | 10 +- + src/multimedia/configure.cmake | 3 +- + .../windows/qwindowsmediadevices.cpp | 2 +- + src/multimedia/windows/qwindowsresampler.cpp | 2 +- + .../darwin/camera/qavfcamerabase.mm | 1 + + .../multimedia/darwin/qdarwinintegration.mm | 3 +- + src/plugins/multimedia/ffmpeg/CMakeLists.txt | 87 +- + src/plugins/multimedia/ffmpeg/qavfcamera.mm | 422 ------ + src/plugins/multimedia/ffmpeg/qavfcamera_p.h | 87 -- + src/plugins/multimedia/ffmpeg/qffmpeg_p.h | 60 - + .../multimedia/ffmpeg/qffmpegaudiodecoder.cpp | 265 ---- + .../multimedia/ffmpeg/qffmpegaudiodecoder_p.h | 69 - + .../multimedia/ffmpeg/qffmpegaudioinput.cpp | 189 --- + .../multimedia/ffmpeg/qffmpegaudioinput_p.h | 54 - + .../multimedia/ffmpeg/qffmpegclock.cpp | 193 --- + .../multimedia/ffmpeg/qffmpegclock_p.h | 113 -- + .../multimedia/ffmpeg/qffmpegdecoder.cpp | 1272 ----------------- + .../multimedia/ffmpeg/qffmpegdecoder_p.h | 501 ------- + .../multimedia/ffmpeg/qffmpegencoder.cpp | 557 -------- + .../multimedia/ffmpeg/qffmpegencoder_p.h | 197 --- + .../ffmpeg/qffmpegencoderoptions.cpp | 272 ---- + .../ffmpeg/qffmpegencoderoptions_p.h | 32 - + .../multimedia/ffmpeg/qffmpeghwaccel.cpp | 372 ----- + .../ffmpeg/qffmpeghwaccel_d3d11.cpp | 158 -- + .../ffmpeg/qffmpeghwaccel_d3d11_p.h | 43 - + .../ffmpeg/qffmpeghwaccel_mediacodec.cpp | 70 - + .../ffmpeg/qffmpeghwaccel_mediacodec_p.h | 35 - + .../multimedia/ffmpeg/qffmpeghwaccel_p.h | 121 -- + .../ffmpeg/qffmpeghwaccel_vaapi.cpp | 346 ----- + .../ffmpeg/qffmpeghwaccel_vaapi_p.h | 48 - + .../ffmpeg/qffmpeghwaccel_videotoolbox.mm | 281 ---- + .../ffmpeg/qffmpeghwaccel_videotoolbox_p.h | 63 - + .../ffmpeg/qffmpegmediacapturesession.cpp | 15 +- + .../ffmpeg/qffmpegmediacapturesession_p.h | 1 - + .../ffmpeg/qffmpegmediaformatinfo.cpp | 474 ------ + .../ffmpeg/qffmpegmediaformatinfo_p.h | 18 - + .../ffmpeg/qffmpegmediaintegration.cpp | 31 - + .../ffmpeg/qffmpegmediaintegration_p.h | 8 - + .../ffmpeg/qffmpegmediametadata.cpp | 105 -- + .../ffmpeg/qffmpegmediametadata_p.h | 5 - + .../multimedia/ffmpeg/qffmpegmediaplayer.cpp | 236 --- + .../multimedia/ffmpeg/qffmpegmediaplayer_p.h | 98 -- + .../ffmpeg/qffmpegmediarecorder.cpp | 157 -- + .../ffmpeg/qffmpegmediarecorder_p.h | 68 - + .../multimedia/ffmpeg/qffmpegresampler.cpp | 95 -- + .../multimedia/ffmpeg/qffmpegresampler_p.h | 46 - + .../multimedia/ffmpeg/qffmpegthread.cpp | 57 - + .../multimedia/ffmpeg/qffmpegthread_p.h | 68 - + .../multimedia/ffmpeg/qffmpegvideobuffer.cpp | 356 ----- + .../multimedia/ffmpeg/qffmpegvideobuffer_p.h | 72 - + .../ffmpeg/qffmpegvideoframeencoder.cpp | 374 ----- + .../ffmpeg/qffmpegvideoframeencoder_p.h | 76 - + .../multimedia/ffmpeg/qffmpegvideosink.cpp | 14 - + .../multimedia/ffmpeg/qffmpegvideosink_p.h | 10 +- + src/plugins/multimedia/ffmpeg/qv4l2camera.cpp | 4 +- + .../multimedia/ffmpeg/qwindowscamera.cpp | 4 +- + .../multimedia/windows/common/mfmetadata_p.h | 2 +- + .../windows/decoder/mfaudiodecodercontrol.cpp | 2 +- + .../qwindowsmediadevicereader_p.h | 4 +- + .../mediacapture/qwindowsmediaencoder.cpp | 2 +- + .../windows/player/mfplayercontrol_p.h | 2 +- + .../windows/player/mfplayersession.cpp | 2 +- + .../multimedia/windows/player/mftvideo.cpp | 2 +- + .../windows/qwindowsvideodevices.cpp | 4 +- + 64 files changed, 33 insertions(+), 8307 deletions(-) + delete mode 100644 src/plugins/multimedia/ffmpeg/qavfcamera.mm + delete mode 100644 src/plugins/multimedia/ffmpeg/qavfcamera_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeg_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegaudioinput.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegaudioinput_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegclock.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegclock_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegdecoder_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegencoder.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegencoder_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegencoderoptions.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegencoderoptions_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegmediaplayer.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegmediaplayer_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegmediarecorder.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegmediarecorder_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegresampler.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegresampler_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegthread.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegthread_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegvideobuffer_p.h + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp + delete mode 100644 src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder_p.h + +diff --git a/cmake/FindWMF.cmake b/cmake/FindWMF.cmake +index 7c6923c1e..b69274be5 100644 +--- a/cmake/FindWMF.cmake ++++ b/cmake/FindWMF.cmake +@@ -22,11 +22,11 @@ find_library(WMF_UUID_LIBRARY uuid HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + find_library(WMF_MSDMO_LIBRARY msdmo HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + find_library(WMF_OLE32_LIBRARY ole32 HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + find_library(WMF_OLEAUT32_LIBRARY oleaut32 HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) +-find_library(WMF_MF_LIBRARY Mf HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) +-find_library(WMF_MFUUID_LIBRARY Mfuuid HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) +-find_library(WMF_MFPLAT_LIBRARY Mfplat HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) +-find_library(WMF_MFCORE_LIBRARY Mfcore HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) +-find_library(WMF_PROPSYS_LIBRARY Propsys HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) ++find_library(WMF_MF_LIBRARY mf HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) ++find_library(WMF_MFUUID_LIBRARY mfuuid HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) ++find_library(WMF_MFPLAT_LIBRARY mfplat HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) ++find_library(WMF_MFCORE_LIBRARY mfcore HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) ++find_library(WMF_PROPSYS_LIBRARY propsys HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) + + + set(WMF_LIBRARIES ${WMF_STRMIIDS_LIBRARY} ${WMF_AMSTRMID_LIBRARY} ${WMF_DMOGUIDS_LIBRARY} ${WMF_UUID_LIBRARY} +diff --git a/src/multimedia/configure.cmake b/src/multimedia/configure.cmake +index efcadfc5c..29b056003 100644 +--- a/src/multimedia/configure.cmake ++++ b/src/multimedia/configure.cmake +@@ -21,7 +21,6 @@ qt_find_package(WrapPulseAudio PROVIDED_TARGETS WrapPulseAudio::WrapPulseAudio M + qt_find_package(WMF PROVIDED_TARGETS WMF::WMF MODULE_NAME multimedia QMAKE_LIB wmf) + qt_find_package(EGL) + +-qt_find_package(FFmpeg OPTIONAL_COMPONENTS AVCODEC AVFORMAT AVUTIL AVDEVICE SWRESAMPLE SWSCALE PROVIDED_TARGETS FFmpeg::avcodec FFmpeg::avformat FFmpeg::avutil FFmpeg::avdevice FFmpeg::swresample FFmpeg::swscale MODULE_NAME multimedia QMAKE_LIB ffmpeg) + qt_find_package(VAAPI COMPONENTS VA DRM PROVIDED_TARGETS VAAPI::VA VAAPI::DRM MODULE_NAME multimedia QMAKE_LIB vaapi) + + #### Tests +@@ -73,7 +72,7 @@ qt_feature("ffmpeg" PRIVATE + LABEL "FFmpeg" + ENABLE INPUT_ffmpeg STREQUAL 'yes' + DISABLE INPUT_ffmpeg STREQUAL 'no' +- CONDITION FFmpeg_FOUND AND (APPLE OR WIN32 OR ANDROID OR QNX OR QT_FEATURE_pulseaudio) ++ CONDITION UNIX OR WIN32 + ) + qt_feature("alsa" PUBLIC PRIVATE + LABEL "ALSA (experimental)" +diff --git a/src/multimedia/windows/qwindowsmediadevices.cpp b/src/multimedia/windows/qwindowsmediadevices.cpp +index c91597102..8c2df5816 100644 +--- a/src/multimedia/windows/qwindowsmediadevices.cpp ++++ b/src/multimedia/windows/qwindowsmediadevices.cpp +@@ -13,7 +13,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +diff --git a/src/multimedia/windows/qwindowsresampler.cpp b/src/multimedia/windows/qwindowsresampler.cpp +index 9e76c9159..f78628c91 100644 +--- a/src/multimedia/windows/qwindowsresampler.cpp ++++ b/src/multimedia/windows/qwindowsresampler.cpp +@@ -7,7 +7,7 @@ + #include + #include + +-#include ++#include + #include + #include + +diff --git a/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm b/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm +index a11290a8d..b40c1133e 100644 +--- a/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm ++++ b/src/plugins/multimedia/darwin/camera/qavfcamerabase.mm +@@ -7,6 +7,7 @@ + #include + #include "qavfhelpers_p.h" + #include ++#include + + QT_USE_NAMESPACE + +diff --git a/src/plugins/multimedia/darwin/qdarwinintegration.mm b/src/plugins/multimedia/darwin/qdarwinintegration.mm +index 5e26fe5c4..3e82655b0 100644 +--- a/src/plugins/multimedia/darwin/qdarwinintegration.mm ++++ b/src/plugins/multimedia/darwin/qdarwinintegration.mm +@@ -39,8 +39,7 @@ public: + QDarwinIntegration::QDarwinIntegration() + { + #if defined(Q_OS_MACOS) && QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_11_0) +- if (__builtin_available(macOS 11.0, *)) +- VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9); ++ VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9); + #endif + m_videoDevices = new QAVFVideoDevices(this); + } +diff --git a/src/plugins/multimedia/ffmpeg/CMakeLists.txt b/src/plugins/multimedia/ffmpeg/CMakeLists.txt +index 5d6c0a8c3..6c83b9cb2 100644 +--- a/src/plugins/multimedia/ffmpeg/CMakeLists.txt ++++ b/src/plugins/multimedia/ffmpeg/CMakeLists.txt +@@ -1,107 +1,32 @@ +-qt_find_package(EGL) +-qt_find_package(VAAPI COMPONENTS VA DRM PROVIDED_TARGETS VAAPI::VA VAAPI::DRM MODULE_NAME multimedia QMAKE_LIB vaapi) +- +-qt_internal_find_apple_system_framework(FWCoreMedia CoreMedia) # special case +-qt_internal_find_apple_system_framework(FWCoreAudio CoreAudio) # special case +-qt_internal_find_apple_system_framework(FWAudioUnit AudioUnit) # special case +-qt_internal_find_apple_system_framework(FWVideoToolbox VideoToolbox) # special case +-qt_internal_find_apple_system_framework(FWAVFoundation AVFoundation) # special case +- + qt_internal_add_plugin(QFFmpegMediaPlugin + OUTPUT_NAME ffmpegmediaplugin + PLUGIN_TYPE multimedia + SOURCES +- qffmpeg_p.h +- qffmpegaudiodecoder.cpp qffmpegaudiodecoder_p.h +- qffmpegaudioinput.cpp qffmpegaudioinput_p.h +- qffmpegclock.cpp qffmpegclock_p.h +- qffmpegdecoder.cpp qffmpegdecoder_p.h +- qffmpeghwaccel.cpp qffmpeghwaccel_p.h +- qffmpegencoderoptions.cpp qffmpegencoderoptions_p.h + qffmpegmediametadata.cpp qffmpegmediametadata_p.h +- qffmpegmediaplayer.cpp qffmpegmediaplayer_p.h + qffmpegvideosink.cpp qffmpegvideosink_p.h + qffmpegmediaformatinfo.cpp qffmpegmediaformatinfo_p.h + qffmpegmediaintegration.cpp qffmpegmediaintegration_p.h +- qffmpegvideobuffer.cpp qffmpegvideobuffer_p.h + qffmpegimagecapture.cpp qffmpegimagecapture_p.h + qffmpegmediacapturesession.cpp qffmpegmediacapturesession_p.h +- qffmpegmediarecorder.cpp qffmpegmediarecorder_p.h +- qffmpegencoder.cpp qffmpegencoder_p.h +- qffmpegthread.cpp qffmpegthread_p.h +- qffmpegresampler.cpp qffmpegresampler_p.h +- qffmpegvideoframeencoder.cpp qffmpegvideoframeencoder_p.h + DEFINES + QT_COMPILING_FFMPEG + LIBRARIES + Qt::MultimediaPrivate + Qt::CorePrivate +- FFmpeg::avformat FFmpeg::avcodec FFmpeg::swresample FFmpeg::swscale FFmpeg::avutil +-) +- +-qt_internal_extend_target(QFFmpegMediaPlugin CONDITION QT_FEATURE_ffmpeg AND QT_FEATURE_vaapi +- SOURCES +- qffmpeghwaccel_vaapi.cpp qffmpeghwaccel_vaapi_p.h +- LIBRARIES +- VAAPI::VAAPI +- EGL::EGL + ) + +-qt_internal_extend_target(QFFmpegMediaPlugin CONDITION APPLE ++qt_internal_extend_target(QFFmpegMediaPlugin CONDITION QT_FEATURE_linux_v4l + SOURCES +- ../darwin/qavfhelpers.mm ../darwin/qavfhelpers_p.h +- ../darwin/camera/qavfcamerabase_p.h ../darwin/camera/qavfcamerabase.mm +- ../darwin/camera/avfcamerautility_p.h ../darwin/camera/avfcamerautility.mm +- qffmpeghwaccel_videotoolbox.mm qffmpeghwaccel_videotoolbox_p.h +- qavfcamera.mm qavfcamera_p.h +- INCLUDE_DIRECTORIES +- ../darwin +- ../darwin/camera +- LIBRARIES +- ${FWAudioToolbox} +- ${FWCoreAudio} +- ${FWCoreFoundation} +- ${FWCoreMedia} +- ${FWCoreVideo} +- ${FWVideoToolbox} +- AVFoundation::AVFoundation ++ qv4l2camera.cpp qv4l2camera_p.h + ) + + qt_internal_extend_target(QFFmpegMediaPlugin CONDITION WIN32 +- SOURCES ++ SOURCES + ../windows/qwindowsvideodevices.cpp ../windows/qwindowsvideodevices_p.h + qwindowscamera.cpp qwindowscamera_p.h +- qffmpeghwaccel_d3d11.cpp qffmpeghwaccel_d3d11_p.h +- INCLUDE_DIRECTORIES ++ INCLUDE_DIRECTORIES + ../windows +- LIBRARIES ++ LIBRARIES + WMF::WMF + mfreadwrite +-) +- +-qt_internal_extend_target(QFFmpegMediaPlugin CONDITION QT_FEATURE_linux_v4l +- SOURCES +- qv4l2camera.cpp qv4l2camera_p.h +-) +- +-if (ANDROID) +- qt_internal_extend_target(QFFmpegMediaPlugin +- SOURCES +- qffmpeghwaccel_mediacodec.cpp qffmpeghwaccel_mediacodec_p.h +- ../android/wrappers/jni/androidsurfacetexture_p.h +- ../android/wrappers/jni/androidsurfacetexture.cpp +- INCLUDE_DIRECTORIES +- ${FFMPEG_DIR}/include +- ../android/wrappers/jni/ +- ) +- +- set_property(TARGET QFFmpegMediaPlugin APPEND PROPERTY QT_ANDROID_LIB_DEPENDENCIES +- plugins/multimedia/libplugins_multimedia_ffmpegmediaplugin.so +- ) +- +- set_property(TARGET QFFmpegMediaPlugin APPEND PROPERTY QT_ANDROID_PERMISSIONS +- android.permission.CAMERA android.permission.RECORD_AUDIO +- android.permission.BLUETOOTH +- android.permission.MODIFY_AUDIO_SETTINGS +- ) +-endif() ++) +\ No newline at end of file +diff --git a/src/plugins/multimedia/ffmpeg/qavfcamera.mm b/src/plugins/multimedia/ffmpeg/qavfcamera.mm +deleted file mode 100644 +index 37dd4b262..000000000 +--- a/src/plugins/multimedia/ffmpeg/qavfcamera.mm ++++ /dev/null +@@ -1,422 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#include +-#include +-#include +-#include +-#include "avfcamerautility_p.h" +-#include "qavfhelpers_p.h" +-#include +-#include +-#define AVMediaType XAVMediaType +-#include "qffmpegvideobuffer_p.h" +-#include "qffmpegvideosink_p.h" +-extern "C" { +-#include +-#include +-} +-#undef AVMediaType +- +- +- +-#import +-#include +- +-static void releaseHwFrame(void */*opaque*/, uint8_t *data) +-{ +- CVPixelBufferRelease(CVPixelBufferRef(data)); +-} +- +-// Make sure this is compatible with the layout used in ffmpeg's hwcontext_videotoolbox +-static AVFrame *allocHWFrame(AVBufferRef *hwContext, const CVPixelBufferRef &pixbuf) +-{ +- AVHWFramesContext *ctx = (AVHWFramesContext*)hwContext->data; +- AVFrame *frame = av_frame_alloc(); +- frame->hw_frames_ctx = av_buffer_ref(hwContext); +- frame->extended_data = frame->data; +- +- frame->buf[0] = av_buffer_create((uint8_t *)pixbuf, 1, releaseHwFrame, NULL, 0); +- frame->data[3] = (uint8_t *)pixbuf; +- CVPixelBufferRetain(pixbuf); +- frame->width = ctx->width; +- frame->height = ctx->height; +- frame->format = AV_PIX_FMT_VIDEOTOOLBOX; +- if (frame->width != (int)CVPixelBufferGetWidth(pixbuf) || +- frame->height != (int)CVPixelBufferGetHeight(pixbuf)) { +- // This can happen while changing camera format +- av_frame_free(&frame); +- return nullptr; +- } +- return frame; +-} +- +-static AVAuthorizationStatus m_cameraAuthorizationStatus = AVAuthorizationStatusNotDetermined; +- +-@interface QAVFSampleBufferDelegate : NSObject +- +-- (QAVFSampleBufferDelegate *) initWithCamera:(QAVFCamera *)renderer; +- +-- (void) captureOutput:(AVCaptureOutput *)captureOutput +- didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer +- fromConnection:(AVCaptureConnection *)connection; +- +-- (void) setHWAccel:(std::unique_ptr &&)accel; +- +-@end +- +-@implementation QAVFSampleBufferDelegate +-{ +-@private +- QAVFCamera *m_camera; +- AVBufferRef *hwFramesContext; +- std::unique_ptr m_accel; +- qint64 startTime; +- qint64 baseTime; +-} +- +-- (QAVFSampleBufferDelegate *) initWithCamera:(QAVFCamera *)renderer +-{ +- if (!(self = [super init])) +- return nil; +- +- m_camera = renderer; +- hwFramesContext = nullptr; +- startTime = 0; +- baseTime = 0; +- return self; +-} +- +-- (void)captureOutput:(AVCaptureOutput *)captureOutput +- didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer +- fromConnection:(AVCaptureConnection *)connection +-{ +- Q_UNUSED(connection); +- Q_UNUSED(captureOutput); +- +- // NB: on iOS captureOutput/connection can be nil (when recording a video - +- // avfmediaassetwriter). +- +- CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); +- +- CMTime time = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); +- qint64 frameTime = time.timescale ? time.value*1000/time.timescale : 0; +- if (baseTime == 0) { +- // drop the first frame to get a valid frame start time +- baseTime = frameTime; +- startTime = 0; +- return; +- } +- +- if (!m_accel) +- return; +- +- AVFrame *avFrame = allocHWFrame(m_accel->hwFramesContextAsBuffer(), imageBuffer); +- if (!avFrame) +- return; +- +-#ifdef USE_SW_FRAMES +- auto *swFrame = av_frame_alloc(); +- /* retrieve data from GPU to CPU */ +- int ret = av_hwframe_transfer_data(swFrame, avFrame, 0); +- if (ret < 0) { +- qWarning() << "Error transferring the data to system memory\n"; +- av_frame_unref(swFrame); +- } else { +- av_frame_unref(avFrame); +- avFrame = swFrame; +- } +-#endif +- +- QVideoFrameFormat format = QAVFHelpers::videoFormatForImageBuffer(imageBuffer); +- if (!format.isValid()) { +- av_frame_unref(avFrame); +- return; +- } +- +- avFrame->pts = startTime; +- +- QFFmpegVideoBuffer *buffer = new QFFmpegVideoBuffer(avFrame); +- QVideoFrame frame(buffer, format); +- frame.setStartTime(startTime); +- frame.setEndTime(frameTime); +- startTime = frameTime; +- +- m_camera->syncHandleFrame(frame); +-} +- +-- (void) setHWAccel:(std::unique_ptr &&)accel +-{ +- m_accel = std::move(accel); +-} +- +-@end +- +-QT_BEGIN_NAMESPACE +- +-QAVFCamera::QAVFCamera(QCamera *parent) +- : QAVFCameraBase(parent) +-{ +- m_captureSession = [[AVCaptureSession alloc] init]; +- m_sampleBufferDelegate = [[QAVFSampleBufferDelegate alloc] initWithCamera:this]; +-} +- +-QAVFCamera::~QAVFCamera() +-{ +- [m_sampleBufferDelegate release]; +- [m_videoInput release]; +- [m_videoDataOutput release]; +- [m_captureSession release]; +-} +- +-void QAVFCamera::requestCameraPermissionIfNeeded() +-{ +- if (m_cameraAuthorizationStatus == AVAuthorizationStatusAuthorized) +- return; +- +- switch ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]) +- { +- case AVAuthorizationStatusAuthorized: +- { +- m_cameraAuthorizationStatus = AVAuthorizationStatusAuthorized; +- break; +- } +- case AVAuthorizationStatusNotDetermined: +- { +- m_cameraAuthorizationStatus = AVAuthorizationStatusNotDetermined; +- QPointer guard(this); +- [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { +- dispatch_async(dispatch_get_main_queue(), ^{ +- if (guard) +- cameraAuthorizationChanged(granted); +- }); +- }]; +- break; +- } +- case AVAuthorizationStatusDenied: +- case AVAuthorizationStatusRestricted: +- { +- m_cameraAuthorizationStatus = AVAuthorizationStatusDenied; +- return; +- } +- } +-} +- +-void QAVFCamera::cameraAuthorizationChanged(bool authorized) +-{ +- if (authorized) { +- m_cameraAuthorizationStatus = AVAuthorizationStatusAuthorized; +- } else { +- m_cameraAuthorizationStatus = AVAuthorizationStatusDenied; +- qWarning() << "User has denied access to camera"; +- } +-} +- +-void QAVFCamera::updateVideoInput() +-{ +- requestCameraPermissionIfNeeded(); +- if (m_cameraAuthorizationStatus != AVAuthorizationStatusAuthorized) +- return; +- +- [m_captureSession beginConfiguration]; +- +- attachVideoInputDevice(); +- +- if (!m_videoDataOutput) { +- m_videoDataOutput = [[[AVCaptureVideoDataOutput alloc] init] autorelease]; +- +- // Configure video output +- m_delegateQueue = dispatch_queue_create("vf_queue", nullptr); +- [m_videoDataOutput +- setSampleBufferDelegate:m_sampleBufferDelegate +- queue:m_delegateQueue]; +- +- [m_captureSession addOutput:m_videoDataOutput]; +- } +- [m_captureSession commitConfiguration]; +- deviceOrientationChanged(); +-} +- +-void QAVFCamera::deviceOrientationChanged(int angle) +-{ +- AVCaptureConnection *connection = [m_videoDataOutput connectionWithMediaType:AVMediaTypeVideo]; +- if (connection == nil || !m_videoDataOutput) +- return; +- +- if (!connection.supportsVideoOrientation) +- return; +- +- if (angle < 0) +- angle = m_orientationHandler.currentOrientation(); +- +- AVCaptureVideoOrientation orientation = AVCaptureVideoOrientationPortrait; +- switch (angle) { +- default: +- break; +- case 90: +- orientation = AVCaptureVideoOrientationLandscapeRight; +- break; +- case 180: +- // this keeps the last orientation, don't do anything +- return; +- case 270: +- orientation = AVCaptureVideoOrientationLandscapeLeft; +- break; +- } +- +- connection.videoOrientation = orientation; +-} +- +-void QAVFCamera::attachVideoInputDevice() +-{ +- if (m_videoInput) { +- [m_captureSession removeInput:m_videoInput]; +- [m_videoInput release]; +- m_videoInput = nullptr; +- } +- +- QByteArray deviceId = m_cameraDevice.id(); +- if (deviceId.isEmpty()) +- return; +- +- AVCaptureDevice *videoDevice = [AVCaptureDevice deviceWithUniqueID: +- [NSString stringWithUTF8String: deviceId.constData()]]; +- +- if (!videoDevice) +- return; +- +- m_videoInput = [AVCaptureDeviceInput +- deviceInputWithDevice:videoDevice +- error:nil]; +- if (m_videoInput && [m_captureSession canAddInput:m_videoInput]) { +- [m_videoInput retain]; +- [m_captureSession addInput:m_videoInput]; +- } else { +- qWarning() << "Failed to create video device input"; +- } +-} +- +-AVCaptureDevice *QAVFCamera::device() const +-{ +- return m_videoInput ? m_videoInput.device : nullptr; +-} +- +-bool QAVFCamera::isActive() const +-{ +- return m_active; +-} +- +-void QAVFCamera::setActive(bool active) +-{ +- if (m_active == active) +- return; +- requestCameraPermissionIfNeeded(); +- if (m_cameraAuthorizationStatus != AVAuthorizationStatusAuthorized) +- return; +- +- m_active = active; +- +- if (active) { +- // According to the doc, the capture device must be locked before +- // startRunning to prevent the format we set to be overridden by the +- // session preset. +- [m_videoInput.device lockForConfiguration:nil]; +- [m_captureSession startRunning]; +- [m_videoInput.device unlockForConfiguration]; +- } else { +- [m_captureSession stopRunning]; +- } +- +- emit activeChanged(active); +-} +- +-void QAVFCamera::setCaptureSession(QPlatformMediaCaptureSession *session) +-{ +- m_session = session ? session->captureSession() : nullptr; +-} +- +-void QAVFCamera::setCamera(const QCameraDevice &camera) +-{ +- if (m_cameraDevice == camera) +- return; +- +- m_cameraDevice = camera; +- +- requestCameraPermissionIfNeeded(); +- if (m_cameraAuthorizationStatus == AVAuthorizationStatusAuthorized) +- updateVideoInput(); +- setCameraFormat({}); +-} +- +-bool QAVFCamera::setCameraFormat(const QCameraFormat &format) +-{ +- if (m_cameraFormat == format && !format.isNull()) +- return true; +- +- QAVFCameraBase::setCameraFormat(format); +- updateCameraFormat(); +- return true; +-} +- +-void QAVFCamera::updateCameraFormat() +-{ +- AVCaptureDevice *captureDevice = device(); +- if (!captureDevice) +- return; +- +- uint avPixelFormat = 0; +- AVCaptureDeviceFormat *newFormat = qt_convert_to_capture_device_format(captureDevice, m_cameraFormat); +- if (newFormat) { +- qt_set_active_format(captureDevice, newFormat, false); +- avPixelFormat = setPixelFormat(m_cameraFormat.pixelFormat()); +- } +- +- auto hwAccel = QFFmpeg::HWAccel::create(AV_HWDEVICE_TYPE_VIDEOTOOLBOX); +- if (hwAccel) { +- hwAccel->createFramesContext(av_map_videotoolbox_format_to_pixfmt(avPixelFormat), +- m_cameraFormat.resolution()); +- hwPixelFormat = hwAccel->hwFormat(); +- } else { +- hwPixelFormat = AV_PIX_FMT_NONE; +- } +- [m_sampleBufferDelegate setHWAccel:std::move(hwAccel)]; +-} +- +-uint QAVFCamera::setPixelFormat(const QVideoFrameFormat::PixelFormat pixelFormat) +-{ +- // Default to 32BGRA pixel formats on the viewfinder, in case the requested +- // format can't be used (shouldn't happen unless the developers sets a wrong camera +- // format on the camera). +- unsigned avPixelFormat = kCVPixelFormatType_32BGRA; +- if (!QAVFHelpers::toCVPixelFormat(pixelFormat, avPixelFormat)) +- qWarning() << "QCamera::setCameraFormat: couldn't convert requested pixel format, using ARGB32"; +- +- bool isSupported = false; +- NSArray *supportedPixelFormats = m_videoDataOutput.availableVideoCVPixelFormatTypes; +- for (NSNumber *currentPixelFormat in supportedPixelFormats) +- { +- if ([currentPixelFormat unsignedIntValue] == avPixelFormat) { +- isSupported = true; +- break; +- } +- } +- +- if (isSupported) { +- NSDictionary* outputSettings = @{ +- (NSString *)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:avPixelFormat], +- (NSString *)kCVPixelBufferMetalCompatibilityKey: @true +- }; +- m_videoDataOutput.videoSettings = outputSettings; +- } else { +- qWarning() << "QCamera::setCameraFormat: requested pixel format not supported. Did you use a camera format from another camera?"; +- } +- return avPixelFormat; +-} +- +-void QAVFCamera::syncHandleFrame(const QVideoFrame &frame) +-{ +- Q_EMIT newVideoFrame(frame); +-} +- +-QT_END_NAMESPACE +- +-#include "moc_qavfcamera_p.cpp" +diff --git a/src/plugins/multimedia/ffmpeg/qavfcamera_p.h b/src/plugins/multimedia/ffmpeg/qavfcamera_p.h +deleted file mode 100644 +index 40a53dc7c..000000000 +--- a/src/plugins/multimedia/ffmpeg/qavfcamera_p.h ++++ /dev/null +@@ -1,87 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#ifndef QAVFCAMERA_H +-#define QAVFCAMERA_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qavfcamerabase_p.h" +-#include +-#include +-#define AVMediaType XAVMediaType +-#include "qffmpeghwaccel_p.h" +-#undef AVMediaType +- +-#include +-#include +-#include +- +-#include +- +-Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureSession); +-Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureDeviceInput); +-Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureVideoDataOutput); +-Q_FORWARD_DECLARE_OBJC_CLASS(AVCaptureDevice); +-Q_FORWARD_DECLARE_OBJC_CLASS(QAVFSampleBufferDelegate); +- +-QT_BEGIN_NAMESPACE +- +-class QFFmpegVideoSink; +- +-class QAVFCamera : public QAVFCameraBase +-{ +- Q_OBJECT +- +-public: +- explicit QAVFCamera(QCamera *parent); +- ~QAVFCamera(); +- +- bool isActive() const override; +- void setActive(bool active) override; +- +- void setCaptureSession(QPlatformMediaCaptureSession *) override; +- +- void setCamera(const QCameraDevice &camera) override; +- bool setCameraFormat(const QCameraFormat &format) override; +- +- void syncHandleFrame(const QVideoFrame &frame); +- +- void deviceOrientationChanged(int angle = -1); +- +- std::optional ffmpegHWPixelFormat() const override { return hwPixelFormat; } +- +-private: +- void requestCameraPermissionIfNeeded(); +- void cameraAuthorizationChanged(bool authorized); +- void updateCameraFormat(); +- void updateVideoInput(); +- void attachVideoInputDevice(); +- uint setPixelFormat(const QVideoFrameFormat::PixelFormat pixelFormat); +- +- AVCaptureDevice *device() const; +- +- QMediaCaptureSession *m_session = nullptr; +- AVCaptureSession *m_captureSession = nullptr; +- AVCaptureDeviceInput *m_videoInput = nullptr; +- AVCaptureVideoDataOutput *m_videoDataOutput = nullptr; +- QAVFSampleBufferDelegate *m_sampleBufferDelegate = nullptr; +- dispatch_queue_t m_delegateQueue; +- QVideoOutputOrientationHandler m_orientationHandler; +- AVPixelFormat hwPixelFormat = AV_PIX_FMT_NONE; +-}; +- +-QT_END_NAMESPACE +- +- +-#endif // QFFMPEGCAMERA_H +- +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h +deleted file mode 100644 +index 6a1d6ab38..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h ++++ /dev/null +@@ -1,60 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEG_P_H +-#define QFFMPEG_P_H +- +-#include +-#include +- +-extern "C" { +-#include +-#include +-#include +-#include +-#include +-} +- +-#define QT_FFMPEG_OLD_CHANNEL_LAYOUT (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)) +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg +-{ +- +-inline std::optional mul(qint64 a, AVRational b) +-{ +- return b.den != 0 ? (a * b.num + b.den / 2) / b.den : std::optional{}; +-} +- +-inline std::optional mul(qreal a, AVRational b) +-{ +- return b.den != 0 ? a * qreal(b.num) / qreal(b.den) : std::optional{}; +-} +- +-inline std::optional timeStampMs(qint64 ts, AVRational base) +-{ +- return mul(1'000 * ts, base); +-} +- +-inline std::optional timeStampUs(qint64 ts, AVRational base) +-{ +- return mul(1'000'000 * ts, base); +-} +- +-inline std::optional toFloat(AVRational r) +-{ +- return r.den != 0 ? float(r.num) / float(r.den) : std::optional{}; +-} +- +-inline QString err2str(int errnum) +-{ +- char buffer[AV_ERROR_MAX_STRING_SIZE + 1] = {}; +- av_make_error_string(buffer, AV_ERROR_MAX_STRING_SIZE, errnum); +- return QString::fromLocal8Bit(buffer); +-} +- +-QT_END_NAMESPACE +- +-} +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder.cpp +deleted file mode 100644 +index 4dff93d12..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder.cpp ++++ /dev/null +@@ -1,265 +0,0 @@ +-// Copyright (C) 2020 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-//#define DEBUG_DECODER +- +-#include "qffmpegaudiodecoder_p.h" +-#include "qffmpegdecoder_p.h" +-#include "qffmpegmediaformatinfo_p.h" +-#include "qffmpegresampler_p.h" +-#include "qaudiobuffer.h" +- +-#include +- +-Q_LOGGING_CATEGORY(qLcAudioDecoder, "qt.multimedia.ffmpeg.audioDecoder") +- +-#define MAX_BUFFERS_IN_QUEUE 4 +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg +-{ +- +-class SteppingAudioRenderer : public Renderer +-{ +-public: +- SteppingAudioRenderer(AudioDecoder *decoder, const QAudioFormat &format); +- ~SteppingAudioRenderer() +- { +- } +- +- void loop() override; +- AudioDecoder *m_decoder; +- QAudioFormat m_format; +- std::unique_ptr resampler; +- bool atEndEmitted = false; +-}; +- +-class AudioDecoder : public Decoder +-{ +- Q_OBJECT +-public: +- explicit AudioDecoder(QFFmpegAudioDecoder *audioDecoder) : Decoder(), audioDecoder(audioDecoder) +- {} +- +- void setup(const QAudioFormat &format) +- { +- connect(this, &AudioDecoder::newAudioBuffer, audioDecoder, &QFFmpegAudioDecoder::newAudioBuffer); +- connect(this, &AudioDecoder::isAtEnd, audioDecoder, &QFFmpegAudioDecoder::done); +- m_format = format; +- audioRenderer = new SteppingAudioRenderer(this, format); +- audioRenderer->start(); +- auto *stream = demuxer->addStream(avStreamIndex(QPlatformMediaPlayer::AudioStream)); +- audioRenderer->setStream(stream); +- } +- +- void nextBuffer() +- { +- audioRenderer->setPaused(false); +- } +- +-Q_SIGNALS: +- void newAudioBuffer(const QAudioBuffer &b); +- void isAtEnd(); +- +-private: +- QFFmpegAudioDecoder *audioDecoder = nullptr; +- QAudioFormat m_format; +-}; +- +-SteppingAudioRenderer::SteppingAudioRenderer(AudioDecoder *decoder, const QAudioFormat &format) +- : Renderer(QPlatformMediaPlayer::AudioStream) +- , m_decoder(decoder) +- , m_format(format) +-{ +-} +- +- +-void SteppingAudioRenderer::loop() +-{ +- if (!streamDecoder) { +- qCDebug(qLcAudioDecoder) << "no stream"; +- timeOut = -1; // Avoid CPU load before play() +- return; +- } +- +- Frame frame = streamDecoder->takeFrame(); +- if (!frame.isValid()) { +- if (streamDecoder->isAtEnd()) { +- if (!atEndEmitted) +- emit m_decoder->isAtEnd(); +- atEndEmitted = true; +- paused = true; +- doneStep(); +- timeOut = -1; +- return; +- } +- timeOut = 10; +- streamDecoder->wake(); +- return; +- } +- qCDebug(qLcAudioDecoder) << " got frame"; +- +- doneStep(); +- +- if (!resampler) +- resampler.reset(new Resampler(frame.codec(), m_format)); +- +- auto buffer = resampler->resample(frame.avFrame()); +- paused = true; +- timeOut = -1; +- +- emit m_decoder->newAudioBuffer(buffer); +-} +- +-} +- +- +-QFFmpegAudioDecoder::QFFmpegAudioDecoder(QAudioDecoder *parent) +- : QPlatformAudioDecoder(parent) +-{ +-} +- +-QFFmpegAudioDecoder::~QFFmpegAudioDecoder() +-{ +- delete decoder; +-} +- +-QUrl QFFmpegAudioDecoder::source() const +-{ +- return m_url; +-} +- +-void QFFmpegAudioDecoder::setSource(const QUrl &fileName) +-{ +- stop(); +- m_sourceDevice = nullptr; +- +- if (m_url == fileName) +- return; +- m_url = fileName; +- +- emit sourceChanged(); +-} +- +-QIODevice *QFFmpegAudioDecoder::sourceDevice() const +-{ +- return m_sourceDevice; +-} +- +-void QFFmpegAudioDecoder::setSourceDevice(QIODevice *device) +-{ +- stop(); +- m_url.clear(); +- bool isSignalRequired = (m_sourceDevice != device); +- m_sourceDevice = device; +- if (isSignalRequired) +- sourceChanged(); +-} +- +-void QFFmpegAudioDecoder::start() +-{ +- qCDebug(qLcAudioDecoder) << "start"; +- delete decoder; +- decoder = new QFFmpeg::AudioDecoder(this); +- decoder->setMedia(m_url, m_sourceDevice); +- if (error() != QAudioDecoder::NoError) +- goto error; +- +- decoder->setup(m_audioFormat); +- if (error() != QAudioDecoder::NoError) +- goto error; +- decoder->play(); +- if (error() != QAudioDecoder::NoError) +- goto error; +- decoder->nextBuffer(); +- if (error() != QAudioDecoder::NoError) +- goto error; +- +- connect(decoder, &QFFmpeg::Decoder::errorOccured, this, &QFFmpegAudioDecoder::errorSignal); +- durationChanged(duration()); +- setIsDecoding(true); +- return; +- +- error: +- durationChanged(-1); +- positionChanged(-1); +- delete decoder; +- decoder = nullptr; +- +-} +- +-void QFFmpegAudioDecoder::stop() +-{ +- qCDebug(qLcAudioDecoder) << ">>>>> stop"; +- if (decoder) { +- decoder->stop(); +- done(); +- } +-} +- +-QAudioFormat QFFmpegAudioDecoder::audioFormat() const +-{ +- return m_audioFormat; +-} +- +-void QFFmpegAudioDecoder::setAudioFormat(const QAudioFormat &format) +-{ +- if (m_audioFormat == format) +- return; +- +- m_audioFormat = format; +- formatChanged(m_audioFormat); +-} +- +-QAudioBuffer QFFmpegAudioDecoder::read() +-{ +- auto b = m_audioBuffer; +- qCDebug(qLcAudioDecoder) << "reading buffer" << b.startTime(); +- m_audioBuffer = {}; +- bufferAvailableChanged(false); +- if (decoder) +- decoder->nextBuffer(); +- return b; +-} +- +-void QFFmpegAudioDecoder::newAudioBuffer(const QAudioBuffer &b) +-{ +- qCDebug(qLcAudioDecoder) << "new audio buffer" << b.startTime(); +- m_audioBuffer = b; +- const qint64 pos = b.startTime(); +- positionChanged(pos/1000); +- bufferAvailableChanged(b.isValid()); +- bufferReady(); +-} +- +-void QFFmpegAudioDecoder::done() +-{ +- qCDebug(qLcAudioDecoder) << ">>>>> DONE!"; +- finished(); +-} +- +-void QFFmpegAudioDecoder::errorSignal(int err, const QString &errorString) +-{ +- // unfortunately the error enums for QAudioDecoder and QMediaPlayer aren't identical. +- // Map them. +- switch (QMediaPlayer::Error(err)) { +- case QMediaPlayer::NoError: +- error(QAudioDecoder::NoError, errorString); +- break; +- case QMediaPlayer::ResourceError: +- error(QAudioDecoder::ResourceError, errorString); +- break; +- case QMediaPlayer::FormatError: +- error(QAudioDecoder::FormatError, errorString); +- break; +- case QMediaPlayer::NetworkError: +- // fall through, Network error doesn't exist in QAudioDecoder +- case QMediaPlayer::AccessDeniedError: +- error(QAudioDecoder::AccessDeniedError, errorString); +- break; +- } +-} +- +-QT_END_NAMESPACE +- +-#include "qffmpegaudiodecoder.moc" +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder_p.h b/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder_p.h +deleted file mode 100644 +index 0196f88a7..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegaudiodecoder_p.h ++++ /dev/null +@@ -1,69 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#ifndef QFFMPEGAUDIODECODER_H +-#define QFFMPEGAUDIODECODER_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "private/qplatformaudiodecoder_p.h" +-#include +- +-#include +-#include +-#include +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +-class AudioDecoder; +-} +- +-class QFFmpegAudioDecoder : public QPlatformAudioDecoder +-{ +- Q_OBJECT +- +-public: +- QFFmpegAudioDecoder(QAudioDecoder *parent); +- virtual ~QFFmpegAudioDecoder(); +- +- QUrl source() const override; +- void setSource(const QUrl &fileName) override; +- +- QIODevice *sourceDevice() const override; +- void setSourceDevice(QIODevice *device) override; +- +- void start() override; +- void stop() override; +- +- QAudioFormat audioFormat() const override; +- void setAudioFormat(const QAudioFormat &format) override; +- +- QAudioBuffer read() override; +- +-public Q_SLOTS: +- void newAudioBuffer(const QAudioBuffer &b); +- void done(); +- void errorSignal(int err, const QString &errorString); +- +-private: +- QUrl m_url; +- QIODevice *m_sourceDevice = nullptr; +- QFFmpeg::AudioDecoder *decoder = nullptr; +- QAudioFormat m_audioFormat; +- +- QAudioBuffer m_audioBuffer; +-}; +- +-QT_END_NAMESPACE +- +-#endif // QFFMPEGAUDIODECODER_H +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegaudioinput.cpp b/src/plugins/multimedia/ffmpeg/qffmpegaudioinput.cpp +deleted file mode 100644 +index 5c769d524..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegaudioinput.cpp ++++ /dev/null +@@ -1,189 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#include "qffmpegaudioinput_p.h" +-#include +-#include +-#include +-#include +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +- +-class AudioSourceIO : public QIODevice +-{ +- Q_OBJECT +- public: +- AudioSourceIO(QFFmpegAudioInput *audioInput) +- : QIODevice() +- , input(audioInput) +- { +- m_muted = input->muted; +- m_volume = input->volume; +- updateVolume(); +- open(QIODevice::WriteOnly); +- } +- ~AudioSourceIO() +- { +- delete m_src; +- } +- +- void setDevice(const QAudioDevice &device) +- { +- QMutexLocker locker(&mutex); +- if (m_device == device) +- return; +- m_device = device; +- QMetaObject::invokeMethod(this, "updateSource"); +- } +- void setFrameSize(int s) +- { +- QMutexLocker locker(&mutex); +- frameSize = s; +- bufferSize = m_format.bytesForFrames(frameSize); +- } +- void setRunning(bool r) { +- QMutexLocker locker(&mutex); +- if (m_running == r) +- return; +- m_running = r; +- QMetaObject::invokeMethod(this, "updateRunning"); +- } +- +- void setVolume(float vol) { +- QMutexLocker locker(&mutex); +- m_volume = vol; +- QMetaObject::invokeMethod(this, "updateVolume"); +- } +- void setMuted(bool muted) { +- QMutexLocker locker(&mutex); +- m_muted = muted; +- QMetaObject::invokeMethod(this, "updateVolume"); +- } +- +- +-protected: +- qint64 readData(char *, qint64) override +- { +- return 0; +- } +- qint64 writeData(const char *data, qint64 len) override +- { +- int l = len; +- while (len > 0) { +- int toAppend = qMin(len, bufferSize - pcm.size()); +- pcm.append(data, toAppend); +- data += toAppend; +- len -= toAppend; +- if (pcm.size() == bufferSize) +- sendBuffer(); +- } +- +- return l; +- } +- +-private Q_SLOTS: +- void updateSource() { +- QMutexLocker locker(&mutex); +- m_format = m_device.preferredFormat(); +- if (m_src) { +- delete m_src; +- pcm.clear(); +- } +- m_src = new QAudioSource(m_device, m_format); +- updateVolume(); +- if (m_running) +- m_src->start(this); +- } +- void updateVolume() +- { +- if (m_src) +- m_src->setVolume(m_muted ? 0. : m_volume); +- } +- void updateRunning() +- { +- QMutexLocker locker(&mutex); +- if (m_running) { +- if (!m_src) +- updateSource(); +- m_src->start(this); +- } else { +- m_src->stop(); +- } +- } +- +-private: +- +- void sendBuffer() +- { +- QAudioFormat fmt = m_src->format(); +- qint64 time = fmt.durationForBytes(processed); +- QAudioBuffer buffer(pcm, fmt, time); +- emit input->newAudioBuffer(buffer); +- processed += bufferSize; +- pcm.clear(); +- } +- +- QMutex mutex; +- QAudioDevice m_device; +- float m_volume = 1.; +- bool m_muted = false; +- bool m_running = false; +- +- QFFmpegAudioInput *input = nullptr; +- QAudioSource *m_src = nullptr; +- QAudioFormat m_format; +- int frameSize = 0; +- int bufferSize = 0; +- qint64 processed = 0; +- QByteArray pcm; +-}; +- +-} +- +-QFFmpegAudioInput::QFFmpegAudioInput(QAudioInput *qq) +- : QPlatformAudioInput(qq) +-{ +- qRegisterMetaType(); +- +- inputThread = new QThread; +- audioIO = new QFFmpeg::AudioSourceIO(this); +- audioIO->moveToThread(inputThread); +- inputThread->start(); +-} +- +-QFFmpegAudioInput::~QFFmpegAudioInput() +-{ +- inputThread->exit(); +- inputThread->wait(); +- delete inputThread; +-} +- +-void QFFmpegAudioInput::setAudioDevice(const QAudioDevice &device) +-{ +- audioIO->setDevice(device); +-} +- +-void QFFmpegAudioInput::setMuted(bool muted) +-{ +- audioIO->setMuted(muted); +-} +- +-void QFFmpegAudioInput::setVolume(float volume) +-{ +- audioIO->setVolume(volume); +-} +- +-void QFFmpegAudioInput::setFrameSize(int s) +-{ +- audioIO->setFrameSize(s); +-} +- +-void QFFmpegAudioInput::setRunning(bool b) +-{ +- audioIO->setRunning(b); +-} +- +-QT_END_NAMESPACE +- +-#include "qffmpegaudioinput.moc" +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegaudioinput_p.h b/src/plugins/multimedia/ffmpeg/qffmpegaudioinput_p.h +deleted file mode 100644 +index f81549748..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegaudioinput_p.h ++++ /dev/null +@@ -1,54 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGAUDIOINPUT_H +-#define QFFMPEGAUDIOINPUT_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include +-#include "qffmpegthread_p.h" +-#include +- +-QT_BEGIN_NAMESPACE +- +-class QAudioSource; +-class QAudioBuffer; +-namespace QFFmpeg { +-class AudioSourceIO; +-} +- +-class QFFmpegAudioInput : public QObject, public QPlatformAudioInput +-{ +- Q_OBJECT +-public: +- QFFmpegAudioInput(QAudioInput *qq); +- ~QFFmpegAudioInput(); +- +- void setAudioDevice(const QAudioDevice &/*device*/) override; +- void setMuted(bool /*muted*/) override; +- void setVolume(float /*volume*/) override; +- +- void setFrameSize(int s); +- void setRunning(bool b); +- +-Q_SIGNALS: +- void newAudioBuffer(const QAudioBuffer &buffer); +- +-private: +- QThread *inputThread = nullptr; +- QFFmpeg::AudioSourceIO *audioIO = nullptr; +-}; +- +-QT_END_NAMESPACE +- +- +-#endif // QPLATFORMAUDIOINPUT_H +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegclock.cpp b/src/plugins/multimedia/ffmpeg/qffmpegclock.cpp +deleted file mode 100644 +index a3ca04d93..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegclock.cpp ++++ /dev/null +@@ -1,193 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#include +-#include +- +-Q_LOGGING_CATEGORY(qLcClock, "qt.multimedia.ffmpeg.clock") +- +-QT_BEGIN_NAMESPACE +- +-static bool compareClocks(const QFFmpeg::Clock *a, const QFFmpeg::Clock *b) +-{ +- if (!b) +- return false; +- +- if (!a) +- return true; +- +- return a->type() < b->type(); +-} +- +-QFFmpeg::Clock::Clock(ClockController *controller) +- : controller(controller) +-{ +- Q_ASSERT(controller); +- controller->addClock(this); +-} +- +-QFFmpeg::Clock::~Clock() +-{ +- if (controller) +- controller->removeClock(this); +-} +- +-qint64 QFFmpeg::Clock::currentTime() const +-{ +- return controller ? controller->currentTime() : 0; +-} +- +-void QFFmpeg::Clock::syncTo(qint64 time) +-{ +- qCDebug(qLcClock) << "syncTo" << time << isMaster(); +-} +- +-void QFFmpeg::Clock::setPlaybackRate(float rate, qint64 currentTime) +-{ +- qCDebug(qLcClock) << "Clock::setPlaybackRate" << rate; +- Q_UNUSED(rate) +- Q_UNUSED(currentTime) +-} +- +-void QFFmpeg::Clock::setPaused(bool paused) +-{ +- qCDebug(qLcClock) << "Clock::setPaused" << paused; +- Q_UNUSED(paused) +-} +- +-qint64 QFFmpeg::Clock::timeUpdated(qint64 currentTime) +-{ +- if (controller) +- return controller->timeUpdated(this, currentTime); +- return currentTime; +-} +- +-qint64 QFFmpeg::Clock::usecsTo(qint64 currentTime, qint64 displayTime) +-{ +- if (!controller || controller->m_isPaused) +- return -1; +- const qint64 t = qRound64((displayTime - currentTime) / playbackRate()); +- return t < 0 ? 0 : t; +-} +- +-QFFmpeg::Clock::Type QFFmpeg::Clock::type() const +-{ +- return SystemClock; +-} +- +-QFFmpeg::ClockController::~ClockController() +-{ +- for (auto *p : qAsConst(m_clocks)) +- p->setController(nullptr); +-} +- +-qint64 QFFmpeg::ClockController::timeUpdated(Clock *clock, qint64 time) +-{ +- QMutexLocker l(&m_mutex); +- if (!isMaster(clock)) { +- // If the clock isn't the master clock, simply return the current time +- // so we can make adjustments as needed +- return currentTimeNoLock(); +- } +- +- // if the clock is the master, adjust our base timing +- m_baseTime = time; +- m_elapsedTimer.restart(); +- +- return time; +-} +- +-void QFFmpeg::ClockController::addClock(Clock *clock) +-{ +- qCDebug(qLcClock) << "addClock" << clock; +- Q_ASSERT(clock != nullptr); +- +- if (m_clocks.contains(clock)) +- return; +- +- m_clocks.append(clock); +- m_master = std::max(m_master.loadAcquire(), clock, compareClocks); +- +- clock->syncTo(currentTime()); +- clock->setPaused(m_isPaused); +-} +- +-void QFFmpeg::ClockController::removeClock(Clock *clock) +-{ +- qCDebug(qLcClock) << "removeClock" << clock; +- m_clocks.removeAll(clock); +- if (m_master == clock) { +- // find a new master clock +- m_master = m_clocks.empty() +- ? nullptr +- : *std::max_element(m_clocks.begin(), m_clocks.end(), compareClocks); +- } +-} +- +-bool QFFmpeg::ClockController::isMaster(const Clock *clock) const +-{ +- return m_master.loadAcquire() == clock; +-} +- +-qint64 QFFmpeg::ClockController::currentTimeNoLock() const +-{ +- return m_isPaused ? m_baseTime : m_baseTime + m_elapsedTimer.elapsed() / m_playbackRate; +-} +- +-qint64 QFFmpeg::ClockController::currentTime() const +-{ +- QMutexLocker l(&m_mutex); +- return currentTimeNoLock(); +-} +- +-void QFFmpeg::ClockController::syncTo(qint64 usecs) +-{ +- { +- QMutexLocker l(&m_mutex); +- qCDebug(qLcClock) << "syncTo" << usecs; +- m_baseTime = usecs; +- m_seekTime = usecs; +- m_elapsedTimer.restart(); +- } +- +- for (auto *p : qAsConst(m_clocks)) +- p->syncTo(usecs); +-} +- +-void QFFmpeg::ClockController::setPlaybackRate(float rate) +-{ +- qint64 baseTime = 0; +- { +- qCDebug(qLcClock) << "setPlaybackRate" << rate; +- +- QMutexLocker l(&m_mutex); +- +- m_baseTime = baseTime = currentTimeNoLock(); +- m_elapsedTimer.restart(); +- m_playbackRate = rate; +- } +- +- for (auto *p : qAsConst(m_clocks)) +- p->setPlaybackRate(rate, baseTime); +-} +- +-void QFFmpeg::ClockController::setPaused(bool paused) +-{ +- { +- QMutexLocker l(&m_mutex); +- if (m_isPaused == paused) +- return; +- qCDebug(qLcClock) << "setPaused" << paused; +- m_isPaused = paused; +- if (m_isPaused) { +- m_baseTime = currentTimeNoLock(); +- m_seekTime = m_baseTime; +- } else { +- m_elapsedTimer.restart(); +- } +- } +- +- for (auto *p : qAsConst(m_clocks)) +- p->setPaused(paused); +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegclock_p.h b/src/plugins/multimedia/ffmpeg/qffmpegclock_p.h +deleted file mode 100644 +index f8cc0bdf3..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegclock_p.h ++++ /dev/null +@@ -1,113 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGCLOCK_P_H +-#define QFFMPEGCLOCK_P_H +- +-#include "qffmpeg_p.h" +- +-#include +-#include +-#include +-#include +-#include +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +- +-class ClockController; +- +-// Clock runs in displayTime, ie. if playbackRate is not 1, it runs faster or slower +-// than a regular clock. All methods take displayTime +-// Exception: usecsTo() will return the real time that should pass until we will +-// hit the requested display time +-class Clock +-{ +- ClockController *controller = nullptr; +-public: +- enum Type { +- SystemClock, +- AudioClock +- }; +- Clock(ClockController *controller); +- virtual ~Clock(); +- virtual Type type() const; +- +- float playbackRate() const; +- bool isMaster() const; +- +- // all times in usecs +- qint64 currentTime() const; +- qint64 seekTime() const; +- qint64 usecsTo(qint64 currentTime, qint64 displayTime); +- +-protected: +- virtual void syncTo(qint64 usecs); +- virtual void setPlaybackRate(float rate, qint64 currentTime); +- virtual void setPaused(bool paused); +- +- qint64 timeUpdated(qint64 currentTime); +- +-private: +- friend class ClockController; +- void setController(ClockController *c) +- { +- controller = c; +- } +-}; +- +-class ClockController +-{ +- mutable QMutex m_mutex; +- QList m_clocks; +- QAtomicPointer m_master = nullptr; +- +- QElapsedTimer m_elapsedTimer; +- qint64 m_baseTime = 0; +- qint64 m_seekTime = 0; +- float m_playbackRate = 1.; +- bool m_isPaused = true; +- +- qint64 currentTimeNoLock() const; +- +- friend class Clock; +- qint64 timeUpdated(Clock *clock, qint64 time); +- void addClock(Clock *provider); +- void removeClock(Clock *provider); +- bool isMaster(const Clock *clock) const; +- +-public: +- ClockController() = default; +- ~ClockController(); +- +- +- qint64 currentTime() const; +- +- void syncTo(qint64 usecs); +- +- void setPlaybackRate(float s); +- float playbackRate() const { return m_playbackRate; } +- void setPaused(bool paused); +-}; +- +-inline float Clock::playbackRate() const +-{ +- return controller ? controller->m_playbackRate : 1.; +-} +- +-inline bool Clock::isMaster() const +-{ +- return controller && controller->isMaster(this); +-} +- +-inline qint64 Clock::seekTime() const +-{ +- return controller ? controller->m_seekTime : 0; +-} +- +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp +deleted file mode 100644 +index 89a95f5a3..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegdecoder.cpp ++++ /dev/null +@@ -1,1272 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpegdecoder_p.h" +-#include "qffmpegmediaformatinfo_p.h" +-#include "qffmpeg_p.h" +-#include "qffmpegmediametadata_p.h" +-#include "qffmpegvideobuffer_p.h" +-#include "private/qplatformaudiooutput_p.h" +-#include "qffmpeghwaccel_p.h" +-#include "qffmpegvideosink_p.h" +-#include "qvideosink.h" +-#include "qaudiosink.h" +-#include "qaudiooutput.h" +-#include "qffmpegaudiodecoder_p.h" +-#include "qffmpegresampler_p.h" +- +-#include +-#include +- +-#include +- +-extern "C" { +-#include +-} +- +-QT_BEGIN_NAMESPACE +- +-using namespace QFFmpeg; +- +-Q_LOGGING_CATEGORY(qLcDemuxer, "qt.multimedia.ffmpeg.demuxer") +-Q_LOGGING_CATEGORY(qLcDecoder, "qt.multimedia.ffmpeg.decoder") +-Q_LOGGING_CATEGORY(qLcVideoRenderer, "qt.multimedia.ffmpeg.videoRenderer") +-Q_LOGGING_CATEGORY(qLcAudioRenderer, "qt.multimedia.ffmpeg.audioRenderer") +- +-Codec::Data::Data(UniqueAVCodecContext &&context, AVStream *stream, std::unique_ptr &&hwAccel) +- : context(std::move(context)) +- , stream(stream) +- , hwAccel(std::move(hwAccel)) +-{ +-} +- +-Codec::Data::~Data() +-{ +- avcodec_close(context.get()); +-} +- +-QMaybe Codec::create(AVStream *stream) +-{ +- if (!stream) +- return { "Invalid stream" }; +- +- const AVCodec *decoder = +- QFFmpeg::HWAccel::hardwareDecoderForCodecId(stream->codecpar->codec_id); +- if (!decoder) +- return { "Failed to find a valid FFmpeg decoder" }; +- +- //avcodec_free_context +- UniqueAVCodecContext context(avcodec_alloc_context3(decoder)); +- if (!context) +- return { "Failed to allocate a FFmpeg codec context" }; +- +- if (context->codec_type != AVMEDIA_TYPE_AUDIO && +- context->codec_type != AVMEDIA_TYPE_VIDEO && +- context->codec_type != AVMEDIA_TYPE_SUBTITLE) { +- return { "Unknown codec type" }; +- } +- +- int ret = avcodec_parameters_to_context(context.get(), stream->codecpar); +- if (ret < 0) +- return { "Failed to set FFmpeg codec parameters" }; +- +- std::unique_ptr hwAccel; +- if (decoder->type == AVMEDIA_TYPE_VIDEO) { +- hwAccel = QFFmpeg::HWAccel::create(decoder); +- if (hwAccel) +- context->hw_device_ctx = av_buffer_ref(hwAccel->hwDeviceContextAsBuffer()); +- } +- // ### This still gives errors about wrong HW formats (as we accept all of them) +- // But it would be good to get so we can filter out pixel format we don't support natively +- context->get_format = QFFmpeg::getFormat; +- +- /* Init the decoder, with reference counting and threading */ +- AVDictionary *opts = nullptr; +- av_dict_set(&opts, "refcounted_frames", "1", 0); +- av_dict_set(&opts, "threads", "auto", 0); +- ret = avcodec_open2(context.get(), decoder, &opts); +- if (ret < 0) +- return "Failed to open FFmpeg codec context " + err2str(ret); +- +- return Codec(new Data(std::move(context), stream, std::move(hwAccel))); +-} +- +- +-Demuxer::Demuxer(Decoder *decoder, AVFormatContext *context) +- : Thread() +- , decoder(decoder) +- , context(context) +-{ +- QString objectName = QLatin1String("Demuxer"); +- setObjectName(objectName); +- +- streamDecoders.resize(context->nb_streams); +-} +- +-Demuxer::~Demuxer() +-{ +- if (context) { +- if (context->pb) { +- avio_context_free(&context->pb); +- context->pb = nullptr; +- } +- avformat_free_context(context); +- } +-} +- +-StreamDecoder *Demuxer::addStream(int streamIndex) +-{ +- if (streamIndex < 0 || streamIndex >= (int)context->nb_streams) +- return nullptr; +- +- AVStream *avStream = context->streams[streamIndex]; +- if (!avStream) +- return nullptr; +- +- QMutexLocker locker(&mutex); +- auto maybeCodec = Codec::create(avStream); +- if (!maybeCodec) { +- decoder->errorOccured(QMediaPlayer::FormatError, "Cannot open codec; " + maybeCodec.error()); +- return nullptr; +- } +- auto *stream = new StreamDecoder(this, maybeCodec.value()); +- Q_ASSERT(!streamDecoders.at(streamIndex)); +- streamDecoders[streamIndex] = stream; +- stream->start(); +- updateEnabledStreams(); +- return stream; +-} +- +-void Demuxer::removeStream(int streamIndex) +-{ +- if (streamIndex < 0) +- return; +- QMutexLocker locker(&mutex); +- Q_ASSERT(streamIndex < (int)context->nb_streams); +- Q_ASSERT(streamDecoders.at(streamIndex) != nullptr); +- streamDecoders[streamIndex] = nullptr; +- updateEnabledStreams(); +-} +- +-void Demuxer::stopDecoding() +-{ +- qCDebug(qLcDemuxer) << "StopDecoding"; +- QMutexLocker locker(&mutex); +- sendFinalPacketToStreams(); +-} +-int Demuxer::seek(qint64 pos) +-{ +- QMutexLocker locker(&mutex); +- for (StreamDecoder *d : qAsConst(streamDecoders)) { +- if (d) +- d->mutex.lock(); +- } +- for (StreamDecoder *d : qAsConst(streamDecoders)) { +- if (d) +- d->flush(); +- } +- for (StreamDecoder *d : qAsConst(streamDecoders)) { +- if (d) +- d->mutex.unlock(); +- } +- qint64 seekPos = pos*AV_TIME_BASE/1000000; // usecs to AV_TIME_BASE +- av_seek_frame(context, -1, seekPos, AVSEEK_FLAG_BACKWARD); +- last_pts = -1; +- loop(); +- qCDebug(qLcDemuxer) << "Demuxer::seek" << pos << last_pts; +- return last_pts; +-} +- +-void Demuxer::updateEnabledStreams() +-{ +- if (isStopped()) +- return; +- for (uint i = 0; i < context->nb_streams; ++i) { +- AVDiscard discard = AVDISCARD_DEFAULT; +- if (!streamDecoders.at(i)) +- discard = AVDISCARD_ALL; +- context->streams[i]->discard = discard; +- } +-} +- +-void Demuxer::sendFinalPacketToStreams() +-{ +- if (m_isStopped.loadAcquire()) +- return; +- for (auto *streamDecoder : qAsConst(streamDecoders)) { +- qCDebug(qLcDemuxer) << "Demuxer: sending last packet to stream" << streamDecoder; +- if (!streamDecoder) +- continue; +- streamDecoder->addPacket(nullptr); +- } +- m_isStopped.storeRelease(true); +-} +- +-void Demuxer::init() +-{ +- qCDebug(qLcDemuxer) << "Demuxer started"; +-} +- +-void Demuxer::cleanup() +-{ +- qCDebug(qLcDemuxer) << "Demuxer::cleanup"; +-#ifndef QT_NO_DEBUG +- for (auto *streamDecoder : qAsConst(streamDecoders)) { +- Q_ASSERT(!streamDecoder); +- } +-#endif +- avformat_close_input(&context); +- Thread::cleanup(); +-} +- +-bool Demuxer::shouldWait() const +-{ +- if (m_isStopped) +- return true; +-// qCDebug(qLcDemuxer) << "XXXX Demuxer::shouldWait" << this << data->seek_pos.loadRelaxed(); +- // require a minimum of 200ms of data +- qint64 queueSize = 0; +- bool buffersFull = true; +- for (auto *d : streamDecoders) { +- if (!d) +- continue; +- if (d->queuedDuration() < 200) +- buffersFull = false; +- queueSize += d->queuedPacketSize(); +- } +-// qCDebug(qLcDemuxer) << " queue size" << queueSize << MaxQueueSize; +- if (queueSize > MaxQueueSize) +- return true; +-// qCDebug(qLcDemuxer) << " waiting!"; +- return buffersFull; +- +-} +- +-void Demuxer::loop() +-{ +- AVPacket *packet = av_packet_alloc(); +- if (av_read_frame(context, packet) < 0) { +- sendFinalPacketToStreams(); +- av_packet_free(&packet); +- return; +- } +- +- if (last_pts < 0 && packet->pts != AV_NOPTS_VALUE) { +- auto *stream = context->streams[packet->stream_index]; +- auto pts = timeStampMs(packet->pts, stream->time_base); +- if (pts) +- last_pts = *pts; +- } +- +- auto *streamDecoder = streamDecoders.at(packet->stream_index); +- if (!streamDecoder) { +- av_packet_free(&packet); +- return; +- } +- streamDecoder->addPacket(packet); +-} +- +- +-StreamDecoder::StreamDecoder(Demuxer *demuxer, const Codec &codec) +- : Thread() +- , demuxer(demuxer) +- , codec(codec) +-{ +- QString objectName; +- switch (codec.context()->codec_type) { +- case AVMEDIA_TYPE_AUDIO: +- objectName = QLatin1String("AudioDecoderThread"); +- // Queue size: 3 frames for video/subtitle, 9 for audio +- frameQueue.maxSize = 9; +- break; +- case AVMEDIA_TYPE_VIDEO: +- objectName = QLatin1String("VideoDecoderThread"); +- break; +- case AVMEDIA_TYPE_SUBTITLE: +- objectName = QLatin1String("SubtitleDecoderThread"); +- break; +- default: +- Q_UNREACHABLE(); +- } +- setObjectName(objectName); +-} +- +-void StreamDecoder::addPacket(AVPacket *packet) +-{ +- { +- QMutexLocker locker(&packetQueue.mutex); +-// qCDebug(qLcDecoder) << "enqueuing packet of type" << type() +-// << "size" << packet->size +-// << "stream index" << packet->stream_index +-// << "pts" << codec.toMs(packet->pts) +-// << "duration" << codec.toMs(packet->duration); +- packetQueue.queue.enqueue(Packet(packet)); +- if (packet) { +- packetQueue.size += packet->size; +- packetQueue.duration += codec.toMs(packet->duration); +- } +- eos.storeRelease(false); +- } +- wake(); +-} +- +-void StreamDecoder::flush() +-{ +- qCDebug(qLcDecoder) << ">>>> flushing stream decoder" << type(); +- avcodec_flush_buffers(codec.context()); +- { +- QMutexLocker locker(&packetQueue.mutex); +- packetQueue.queue.clear(); +- packetQueue.size = 0; +- packetQueue.duration = 0; +- } +- { +- QMutexLocker locker(&frameQueue.mutex); +- frameQueue.queue.clear(); +- } +- qCDebug(qLcDecoder) << ">>>> done flushing stream decoder" << type(); +-} +- +-void StreamDecoder::setRenderer(Renderer *r) +-{ +- QMutexLocker locker(&mutex); +- m_renderer = r; +- if (m_renderer) +- m_renderer->wake(); +-} +- +-void StreamDecoder::killHelper() +-{ +- m_renderer = nullptr; +- demuxer->removeStream(codec.streamIndex()); +-} +- +-Packet StreamDecoder::peekPacket() +-{ +- QMutexLocker locker(&packetQueue.mutex); +- if (packetQueue.queue.isEmpty()) { +- if (demuxer) +- demuxer->wake(); +- return {}; +- } +- auto packet = packetQueue.queue.first(); +- +- if (demuxer) +- demuxer->wake(); +- return packet; +-} +- +-Packet StreamDecoder::takePacket() +-{ +- QMutexLocker locker(&packetQueue.mutex); +- if (packetQueue.queue.isEmpty()) { +- if (demuxer) +- demuxer->wake(); +- return {}; +- } +- auto packet = packetQueue.queue.dequeue(); +- if (packet.avPacket()) { +- packetQueue.size -= packet.avPacket()->size; +- packetQueue.duration -= codec.toMs(packet.avPacket()->duration); +- } +-// qCDebug(qLcDecoder) << "<<<< dequeuing packet of type" << type() +-// << "size" << packet.avPacket()->size +-// << "stream index" << packet.avPacket()->stream_index +-// << "pts" << codec.toMs(packet.avPacket()->pts) +-// << "duration" << codec.toMs(packet.avPacket()->duration) +-// << "ts" << decoder->clockController.currentTime(); +- if (demuxer) +- demuxer->wake(); +- return packet; +-} +- +-void StreamDecoder::addFrame(const Frame &f) +-{ +- Q_ASSERT(f.isValid()); +- QMutexLocker locker(&frameQueue.mutex); +- frameQueue.queue.append(std::move(f)); +- if (m_renderer) +- m_renderer->wake(); +-} +- +-Frame StreamDecoder::takeFrame() +-{ +- QMutexLocker locker(&frameQueue.mutex); +- // wake up the decoder so it delivers more frames +- if (frameQueue.queue.isEmpty()) { +- wake(); +- return {}; +- } +- auto f = frameQueue.queue.dequeue(); +- wake(); +- return f; +-} +- +-void StreamDecoder::init() +-{ +- qCDebug(qLcDecoder) << "Starting decoder"; +-} +- +-bool StreamDecoder::shouldWait() const +-{ +- if (eos.loadAcquire() || (hasNoPackets() && decoderHasNoFrames) || hasEnoughFrames()) +- return true; +- return false; +-} +- +-void StreamDecoder::loop() +-{ +- if (codec.context()->codec->type == AVMEDIA_TYPE_SUBTITLE) +- decodeSubtitle(); +- else +- decode(); +-} +- +-void StreamDecoder::decode() +-{ +- Q_ASSERT(codec.context()); +- +- AVFrame *frame = av_frame_alloc(); +-// if (type() == 0) +-// qDebug() << "receiving frame"; +- int res = avcodec_receive_frame(codec.context(), frame); +- +- if (res >= 0) { +- qint64 pts; +- if (frame->pts != AV_NOPTS_VALUE) +- pts = codec.toUs(frame->pts); +- else +- pts = codec.toUs(frame->best_effort_timestamp); +- addFrame(Frame{frame, codec, pts}); +- } else if (res == AVERROR(EOF) || res == AVERROR_EOF) { +- eos.storeRelease(true); +- av_frame_free(&frame); +- timeOut = -1; +- return; +- } else if (res != AVERROR(EAGAIN)) { +- qWarning() << "error in decoder" << res << err2str(res); +- av_frame_free(&frame); +- return; +- } else { +- // EAGAIN +- decoderHasNoFrames = true; +- av_frame_free(&frame); +- } +- +- Packet packet = peekPacket(); +- if (!packet.isValid()) { +- timeOut = -1; +- return; +- } +- +- res = avcodec_send_packet(codec.context(), packet.avPacket()); +- if (res != AVERROR(EAGAIN)) { +- takePacket(); +- } +- decoderHasNoFrames = false; +-} +- +-void StreamDecoder::decodeSubtitle() +-{ +- // qCDebug(qLcDecoder) << " decoding subtitle" << "has delay:" << (codec->codec->capabilities & AV_CODEC_CAP_DELAY); +- AVSubtitle subtitle; +- memset(&subtitle, 0, sizeof(subtitle)); +- int gotSubtitle = 0; +- Packet packet = takePacket(); +- if (!packet.isValid()) +- return; +- +- int res = avcodec_decode_subtitle2(codec.context(), &subtitle, &gotSubtitle, packet.avPacket()); +- // qCDebug(qLcDecoder) << " subtitle got:" << res << gotSubtitle << subtitle.format << Qt::hex << (quint64)subtitle.pts; +- if (res >= 0 && gotSubtitle) { +- // apparently the timestamps in the AVSubtitle structure are not always filled in +- // if they are missing, use the packets pts and duration values instead +- qint64 start, end; +- if (subtitle.pts == AV_NOPTS_VALUE) { +- start = codec.toUs(packet.avPacket()->pts); +- end = start + codec.toUs(packet.avPacket()->duration); +- } else { +- auto pts = timeStampUs(subtitle.pts, AVRational{1, AV_TIME_BASE}); +- start = *pts + qint64(subtitle.start_display_time)*1000; +- end = *pts + qint64(subtitle.end_display_time)*1000; +- } +- // qCDebug(qLcDecoder) << " got subtitle (" << start << "--" << end << "):"; +- QString text; +- for (uint i = 0; i < subtitle.num_rects; ++i) { +- const auto *r = subtitle.rects[i]; +- // qCDebug(qLcDecoder) << " subtitletext:" << r->text << "/" << r->ass; +- if (i) +- text += QLatin1Char('\n'); +- if (r->text) +- text += QString::fromUtf8(r->text); +- else { +- const char *ass = r->ass; +- int nCommas = 0; +- while (*ass) { +- if (nCommas == 9) +- break; +- if (*ass == ',') +- ++nCommas; +- ++ass; +- } +- text += QString::fromUtf8(ass); +- } +- } +- text.replace(QLatin1String("\\N"), QLatin1String("\n")); +- text.replace(QLatin1String("\\n"), QLatin1String("\n")); +- text.replace(QLatin1String("\r\n"), QLatin1String("\n")); +- if (text.endsWith(QLatin1Char('\n'))) +- text.chop(1); +- +-// qCDebug(qLcDecoder) << " >>> subtitle adding" << text << start << end; +- Frame sub{text, start, end - start}; +- addFrame(sub); +- } +-} +- +-QPlatformMediaPlayer::TrackType StreamDecoder::type() const +-{ +- switch (codec.stream()->codecpar->codec_type) { +- case AVMEDIA_TYPE_AUDIO: +- return QPlatformMediaPlayer::AudioStream; +- case AVMEDIA_TYPE_VIDEO: +- return QPlatformMediaPlayer::VideoStream; +- case AVMEDIA_TYPE_SUBTITLE: +- return QPlatformMediaPlayer::SubtitleStream; +- default: +- return QPlatformMediaPlayer::NTrackTypes; +- } +-} +- +-Renderer::Renderer(QPlatformMediaPlayer::TrackType type) +- : Thread() +- , type(type) +-{ +- QString objectName; +- if (type == QPlatformMediaPlayer::AudioStream) +- objectName = QLatin1String("AudioRenderThread"); +- else +- objectName = QLatin1String("VideoRenderThread"); +- setObjectName(objectName); +-} +- +-void Renderer::setStream(StreamDecoder *stream) +-{ +- QMutexLocker locker(&mutex); +- if (streamDecoder == stream) +- return; +- if (streamDecoder) +- streamDecoder->kill(); +- streamDecoder = stream; +- if (streamDecoder) +- streamDecoder->setRenderer(this); +- streamChanged(); +- wake(); +-} +- +-void Renderer::killHelper() +-{ +- if (streamDecoder) +- streamDecoder->kill(); +- streamDecoder = nullptr; +-} +- +-bool Renderer::shouldWait() const +-{ +- if (!streamDecoder) +- return true; +- if (!paused) +- return false; +- if (step) +- return false; +- return true; +-} +- +- +-void ClockedRenderer::setPaused(bool paused) +-{ +- Clock::setPaused(paused); +- Renderer::setPaused(paused); +-} +- +-VideoRenderer::VideoRenderer(Decoder *decoder, QVideoSink *sink) +- : ClockedRenderer(decoder, QPlatformMediaPlayer::VideoStream) +- , sink(sink) +-{} +- +-void VideoRenderer::killHelper() +-{ +- if (subtitleStreamDecoder) +- subtitleStreamDecoder->kill(); +- subtitleStreamDecoder = nullptr; +- if (streamDecoder) +- streamDecoder->kill(); +- streamDecoder = nullptr; +-} +- +-void VideoRenderer::setSubtitleStream(StreamDecoder *stream) +-{ +- QMutexLocker locker(&mutex); +- qCDebug(qLcVideoRenderer) << "setting subtitle stream to" << stream; +- if (stream == subtitleStreamDecoder) +- return; +- if (subtitleStreamDecoder) +- subtitleStreamDecoder->kill(); +- subtitleStreamDecoder = stream; +- if (subtitleStreamDecoder) +- subtitleStreamDecoder->setRenderer(this); +- sink->setSubtitleText({}); +- wake(); +-} +- +-void VideoRenderer::init() +-{ +- qCDebug(qLcVideoRenderer) << "starting video renderer"; +- ClockedRenderer::init(); +-} +- +-void VideoRenderer::loop() +-{ +- if (!streamDecoder) { +- timeOut = -1; // Avoid 100% CPU load before play() +- return; +- } +- +- Frame frame = streamDecoder->takeFrame(); +- if (!frame.isValid()) { +- if (streamDecoder->isAtEnd()) { +- timeOut = -1; +- eos.storeRelease(true); +- mutex.unlock(); +- emit atEnd(); +- mutex.lock(); +- return; +- } +- timeOut = 1; +-// qDebug() << "no valid frame" << timer.elapsed(); +- return; +- } +- eos.storeRelease(false); +-// qCDebug(qLcVideoRenderer) << "received video frame" << frame.pts(); +- if (frame.pts() < seekTime()) { +- qCDebug(qLcVideoRenderer) << " discarding" << frame.pts() << seekTime(); +- return; +- } +- +- AVStream *stream = frame.codec()->stream(); +- qint64 startTime = frame.pts(); +- qint64 duration = (1000000*stream->avg_frame_rate.den + (stream->avg_frame_rate.num>>1)) +- /stream->avg_frame_rate.num; +- +- if (sink) { +- qint64 startTime = frame.pts(); +-// qDebug() << "RHI:" << accel.isNull() << accel.rhi() << sink->rhi(); +- +- // in practice this only happens with mediacodec +- if (frame.codec()->hwAccel() && !frame.avFrame()->hw_frames_ctx) { +- HWAccel *hwaccel = frame.codec()->hwAccel(); +- AVFrame *avframe = frame.avFrame(); +- if (!hwaccel->hwFramesContext()) +- hwaccel->createFramesContext(AVPixelFormat(avframe->format), +- { avframe->width, avframe->height }); +- +- avframe->hw_frames_ctx = av_buffer_ref(hwaccel->hwFramesContextAsBuffer()); +- } +- +- QFFmpegVideoBuffer *buffer = new QFFmpegVideoBuffer(frame.takeAVFrame()); +- QVideoFrameFormat format(buffer->size(), buffer->pixelFormat()); +- format.setColorSpace(buffer->colorSpace()); +- format.setColorTransfer(buffer->colorTransfer()); +- format.setColorRange(buffer->colorRange()); +- format.setMaxLuminance(buffer->maxNits()); +- QVideoFrame videoFrame(buffer, format); +- videoFrame.setStartTime(startTime); +- videoFrame.setEndTime(startTime + duration); +-// qDebug() << "Creating video frame" << startTime << (startTime + duration) << subtitleStreamDecoder; +- +- // add in subtitles +- const Frame *currentSubtitle = nullptr; +- if (subtitleStreamDecoder) +- currentSubtitle = subtitleStreamDecoder->lockAndPeekFrame(); +- +- if (currentSubtitle && currentSubtitle->isValid()) { +-// qDebug() << "frame: subtitle" << currentSubtitle->text() << currentSubtitle->pts() << currentSubtitle->duration(); +- qCDebug(qLcVideoRenderer) << " " << currentSubtitle->pts() << currentSubtitle->duration() << currentSubtitle->text(); +- if (currentSubtitle->pts() <= startTime && currentSubtitle->end() > startTime) { +-// qCDebug(qLcVideoRenderer) << " setting text"; +- sink->setSubtitleText(currentSubtitle->text()); +- } +- if (currentSubtitle->end() < startTime) { +-// qCDebug(qLcVideoRenderer) << " removing subtitle item"; +- sink->setSubtitleText({}); +- subtitleStreamDecoder->removePeekedFrame(); +- } +- } else { +- sink->setSubtitleText({}); +- } +- if (subtitleStreamDecoder) +- subtitleStreamDecoder->unlockAndReleaseFrame(); +- +-// qCDebug(qLcVideoRenderer) << " sending a video frame" << startTime << duration << decoder->baseTimer.elapsed(); +- sink->setVideoFrame(videoFrame); +- doneStep(); +- } +- const Frame *nextFrame = streamDecoder->lockAndPeekFrame(); +- qint64 nextFrameTime = 0; +- if (nextFrame) +- nextFrameTime = nextFrame->pts(); +- else +- nextFrameTime = startTime + duration; +- streamDecoder->unlockAndReleaseFrame(); +- qint64 mtime = timeUpdated(startTime); +- timeOut = usecsTo(mtime, nextFrameTime) / 1000; +- // qCDebug(qLcVideoRenderer) << " next video frame in" << startTime << nextFrameTime << +- // currentTime() << timeOut; +-} +- +-AudioRenderer::AudioRenderer(Decoder *decoder, QAudioOutput *output) +- : ClockedRenderer(decoder, QPlatformMediaPlayer::AudioStream) +- , output(output) +-{ +- connect(output, &QAudioOutput::deviceChanged, this, &AudioRenderer::updateAudio); +- connect(output, &QAudioOutput::volumeChanged, this, &AudioRenderer::setSoundVolume); +-} +- +-void AudioRenderer::syncTo(qint64 usecs) +-{ +- QMutexLocker locker(&mutex); +- +- Clock::syncTo(usecs); +- audioBaseTime = usecs; +- processedBase = processedUSecs; +-} +- +-void AudioRenderer::setPlaybackRate(float rate, qint64 currentTime) +-{ +- QMutexLocker locker(&mutex); +- +- audioBaseTime = currentTime; +- processedBase = processedUSecs; +- Clock::setPlaybackRate(rate, currentTime); +- deviceChanged = true; +-} +- +-void AudioRenderer::updateOutput(const Codec *codec) +-{ +- qCDebug(qLcAudioRenderer) << ">>>>>> updateOutput" << currentTime() << seekTime() << processedUSecs << isMaster(); +- freeOutput(); +- qCDebug(qLcAudioRenderer) << " " << currentTime() << seekTime() << processedUSecs; +- +- AVStream *audioStream = codec->stream(); +- +- auto dev = output->device(); +- format = QFFmpegMediaFormatInfo::audioFormatFromCodecParameters(audioStream->codecpar); +- format.setChannelConfig(dev.channelConfiguration()); +- +- initResempler(codec); +- +- audioSink = new QAudioSink(dev, format); +- audioSink->setVolume(output->volume()); +- +- audioSink->setBufferSize(format.bytesForDuration(100000)); +- audioDevice = audioSink->start(); +- +- latencyUSecs = format.durationForBytes(audioSink->bufferSize()); // ### ideally get full latency +- qCDebug(qLcAudioRenderer) << " -> have an audio sink" << audioDevice; +-} +- +-void AudioRenderer::initResempler(const Codec *codec) +-{ +- // init resampler. It's ok to always do this, as the resampler will be a no-op if +- // formats agree. +- AVSampleFormat requiredFormat = QFFmpegMediaFormatInfo::avSampleFormat(format.sampleFormat()); +- +-#if QT_FFMPEG_OLD_CHANNEL_LAYOUT +- qCDebug(qLcAudioRenderer) << "init resampler" << requiredFormat +- << codec->stream()->codecpar->channels; +-#else +- qCDebug(qLcAudioRenderer) << "init resampler" << requiredFormat +- << codec->stream()->codecpar->ch_layout.nb_channels; +-#endif +- +- auto resamplerFormat = format; +- resamplerFormat.setSampleRate(qRound(format.sampleRate() / playbackRate())); +- resampler.reset(new Resampler(codec, resamplerFormat)); +-} +- +-void AudioRenderer::freeOutput() +-{ +- if (audioSink) { +- audioSink->reset(); +- delete audioSink; +- audioSink = nullptr; +- audioDevice = nullptr; +- } +- +- bufferedData = {}; +- bufferWritten = 0; +- +- audioBaseTime = currentTime(); +- processedBase = 0; +- processedUSecs = writtenUSecs = 0; +-} +- +-void AudioRenderer::init() +-{ +- qCDebug(qLcAudioRenderer) << "Starting audio renderer"; +- ClockedRenderer::init(); +-} +- +-void AudioRenderer::cleanup() +-{ +- freeOutput(); +-} +- +-void AudioRenderer::loop() +-{ +- if (!streamDecoder) { +- timeOut = -1; // Avoid 100% CPU load before play() +- return; +- } +- +- if (deviceChanged) +- freeOutput(); +- deviceChanged = false; +- doneStep(); +- +- qint64 bytesWritten = 0; +- if (bufferedData.isValid()) { +- bytesWritten = audioDevice->write(bufferedData.constData() + bufferWritten, bufferedData.byteCount() - bufferWritten); +- bufferWritten += bytesWritten; +- if (bufferWritten == bufferedData.byteCount()) { +- bufferedData = {}; +- bufferWritten = 0; +- } +- processedUSecs = audioSink->processedUSecs(); +- } else { +- Frame frame = streamDecoder->takeFrame(); +- if (!frame.isValid()) { +- if (streamDecoder->isAtEnd()) { +- if (audioSink) +- processedUSecs = audioSink->processedUSecs(); +- timeOut = -1; +- eos.storeRelease(true); +- mutex.unlock(); +- emit atEnd(); +- mutex.lock(); +- return; +- } +- timeOut = 1; +- return; +- } +- eos.storeRelease(false); +- if (!audioSink) +- updateOutput(frame.codec()); +- +- qint64 startTime = frame.pts(); +- if (startTime < seekTime()) +- return; +- +- if (!paused) { +- auto buffer = resampler->resample(frame.avFrame()); +- +- if (output->isMuted()) +- // This is somewhat inefficient, but it'll work +- memset(buffer.data(), 0, buffer.byteCount()); +- +- bytesWritten = audioDevice->write(buffer.constData(), buffer.byteCount()); +- if (bytesWritten < buffer.byteCount()) { +- bufferedData = buffer; +- bufferWritten = bytesWritten; +- } +- +- processedUSecs = audioSink->processedUSecs(); +- } +- } +- +- qint64 duration = format.durationForBytes(bytesWritten); +- writtenUSecs += duration; +- +- timeOut = (writtenUSecs - processedUSecs - latencyUSecs)/1000; +- if (timeOut < 0) +- // Don't use a zero timeout if the sink didn't want any more data, rather wait for 10ms. +- timeOut = bytesWritten > 0 ? 0 : 10; +- +-// if (!bufferedData.isEmpty()) +-// qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>> could not write all data" << (bufferedData.size() - bufferWritten); +-// qDebug() << "Audio: processed" << processedUSecs << "written" << writtenUSecs +-// << "delta" << (writtenUSecs - processedUSecs) << "timeOut" << timeOut; +-// qCDebug(qLcAudioRenderer) << " updating time to" << currentTimeNoLock(); +- timeUpdated(audioBaseTime + qRound((processedUSecs - processedBase) * playbackRate())); +-} +- +-void AudioRenderer::streamChanged() +-{ +- // mutex is already locked +- deviceChanged = true; +-} +- +-void AudioRenderer::updateAudio() +-{ +- QMutexLocker locker(&mutex); +- deviceChanged = true; +-} +- +-void AudioRenderer::setSoundVolume(float volume) +-{ +- QMutexLocker locker(&mutex); +- if (audioSink) +- audioSink->setVolume(volume); +-} +- +-Decoder::Decoder() +-{ +-} +- +-Decoder::~Decoder() +-{ +- pause(); +- if (videoRenderer) +- videoRenderer->kill(); +- if (audioRenderer) +- audioRenderer->kill(); +- if (demuxer) +- demuxer->kill(); +-} +- +-static int read(void *opaque, uint8_t *buf, int buf_size) +-{ +- auto *dev = static_cast(opaque); +- if (dev->atEnd()) +- return AVERROR_EOF; +- return dev->read(reinterpret_cast(buf), buf_size); +-} +- +-static int64_t seek(void *opaque, int64_t offset, int whence) +-{ +- QIODevice *dev = static_cast(opaque); +- +- if (dev->isSequential()) +- return AVERROR(EINVAL); +- +- if (whence & AVSEEK_SIZE) +- return dev->size(); +- +- whence &= ~AVSEEK_FORCE; +- +- if (whence == SEEK_CUR) +- offset += dev->pos(); +- else if (whence == SEEK_END) +- offset += dev->size(); +- +- if (!dev->seek(offset)) +- return AVERROR(EINVAL); +- return offset; +-} +- +-static void insertVideoData(QMediaMetaData &metaData, AVStream *stream) +-{ +- Q_ASSERT(stream); +- auto *codecPar = stream->codecpar; +- metaData.insert(QMediaMetaData::VideoBitRate, (int)codecPar->bit_rate); +- metaData.insert(QMediaMetaData::VideoCodec, QVariant::fromValue(QFFmpegMediaFormatInfo::videoCodecForAVCodecId(codecPar->codec_id))); +- metaData.insert(QMediaMetaData::Resolution, QSize(codecPar->width, codecPar->height)); +- auto fr = toFloat(stream->avg_frame_rate); +- if (fr) +- metaData.insert(QMediaMetaData::VideoFrameRate, *fr); +-}; +- +-static void insertAudioData(QMediaMetaData &metaData, AVStream *stream) +-{ +- Q_ASSERT(stream); +- auto *codecPar = stream->codecpar; +- metaData.insert(QMediaMetaData::AudioBitRate, (int)codecPar->bit_rate); +- metaData.insert(QMediaMetaData::AudioCodec, +- QVariant::fromValue(QFFmpegMediaFormatInfo::audioCodecForAVCodecId(codecPar->codec_id))); +-}; +- +-static int getDefaultStreamIndex(QList &streams) +-{ +- if (streams.empty()) +- return -1; +- for (qsizetype i = 0; i < streams.size(); i++) +- if (streams[i].isDefault) +- return i; +- return 0; +-} +- +-static void readStreams(const AVFormatContext *context, +- QList (&map)[QPlatformMediaPlayer::NTrackTypes], qint64 &maxDuration) +-{ +- maxDuration = 0; +- +- for (unsigned int i = 0; i < context->nb_streams; ++i) { +- auto *stream = context->streams[i]; +- if (!stream) +- continue; +- +- auto *codecPar = stream->codecpar; +- if (!codecPar) +- continue; +- +- QMediaMetaData metaData = QFFmpegMetaData::fromAVMetaData(stream->metadata); +- bool isDefault = stream->disposition & AV_DISPOSITION_DEFAULT; +- QPlatformMediaPlayer::TrackType type = QPlatformMediaPlayer::VideoStream; +- +- switch (codecPar->codec_type) { +- case AVMEDIA_TYPE_UNKNOWN: +- case AVMEDIA_TYPE_DATA: ///< Opaque data information usually continuous +- case AVMEDIA_TYPE_ATTACHMENT: ///< Opaque data information usually sparse +- case AVMEDIA_TYPE_NB: +- continue; +- case AVMEDIA_TYPE_VIDEO: +- type = QPlatformMediaPlayer::VideoStream; +- insertVideoData(metaData, stream); +- break; +- case AVMEDIA_TYPE_AUDIO: +- type = QPlatformMediaPlayer::AudioStream; +- insertAudioData(metaData, stream); +- break; +- case AVMEDIA_TYPE_SUBTITLE: +- type = QPlatformMediaPlayer::SubtitleStream; +- break; +- } +- +- map[type].append({ (int)i, isDefault, metaData }); +- auto maybeDuration = mul(1'000'000ll * stream->duration, stream->time_base); +- if (maybeDuration) +- maxDuration = qMax(maxDuration, *maybeDuration); +- } +-} +- +-void Decoder::setMedia(const QUrl &media, QIODevice *stream) +-{ +- QByteArray url = media.toEncoded(QUrl::PreferLocalFile); +- +- AVFormatContext *context = nullptr; +- if (stream) { +- if (!stream->isOpen()) { +- if (!stream->open(QIODevice::ReadOnly)) { +- emit errorOccured(QMediaPlayer::ResourceError, +- QLatin1String("Could not open source device.")); +- return; +- } +- } +- if (!stream->isSequential()) +- stream->seek(0); +- context = avformat_alloc_context(); +- constexpr int bufferSize = 32768; +- unsigned char *buffer = (unsigned char *)av_malloc(bufferSize); +- context->pb = avio_alloc_context(buffer, bufferSize, false, stream, ::read, nullptr, ::seek); +- } +- +- int ret = avformat_open_input(&context, url.constData(), nullptr, nullptr); +- if (ret < 0) { +- auto code = QMediaPlayer::ResourceError; +- if (ret == AVERROR(EACCES)) +- code = QMediaPlayer::AccessDeniedError; +- else if (ret == AVERROR(EINVAL)) +- code = QMediaPlayer::FormatError; +- +- emit errorOccured(code, QMediaPlayer::tr("Could not open file")); +- return; +- } +- +- ret = avformat_find_stream_info(context, nullptr); +- if (ret < 0) { +- emit errorOccured(QMediaPlayer::FormatError, +- QMediaPlayer::tr("Could not find stream information for media file")); +- avformat_free_context(context); +- return; +- } +- +-#ifndef QT_NO_DEBUG +- av_dump_format(context, 0, url.constData(), 0); +-#endif +- +- readStreams(context, m_streamMap, m_duration); +- +- m_requestedStreams[QPlatformMediaPlayer::VideoStream] = getDefaultStreamIndex(m_streamMap[QPlatformMediaPlayer::VideoStream]); +- m_requestedStreams[QPlatformMediaPlayer::AudioStream] = getDefaultStreamIndex(m_streamMap[QPlatformMediaPlayer::AudioStream]); +- m_requestedStreams[QPlatformMediaPlayer::SubtitleStream] = -1; +- +- m_metaData = QFFmpegMetaData::fromAVMetaData(context->metadata); +- m_metaData.insert(QMediaMetaData::FileFormat, +- QVariant::fromValue(QFFmpegMediaFormatInfo::fileFormatForAVInputFormat(context->iformat))); +- +- if (m_requestedStreams[QPlatformMediaPlayer::VideoStream] >= 0) +- insertVideoData(m_metaData, context->streams[avStreamIndex(QPlatformMediaPlayer::VideoStream)]); +- +- if (m_requestedStreams[QPlatformMediaPlayer::AudioStream] >= 0) +- insertAudioData(m_metaData, context->streams[avStreamIndex(QPlatformMediaPlayer::AudioStream)]); +- +- m_isSeekable = !(context->ctx_flags & AVFMTCTX_UNSEEKABLE); +- +- demuxer = new Demuxer(this, context); +- demuxer->start(); +-} +- +-int Decoder::activeTrack(QPlatformMediaPlayer::TrackType type) +-{ +- return m_requestedStreams[type]; +-} +- +-void Decoder::setActiveTrack(QPlatformMediaPlayer::TrackType type, int streamNumber) +-{ +- if (streamNumber < 0 || streamNumber >= m_streamMap[type].size()) +- streamNumber = -1; +- if (m_requestedStreams[type] == streamNumber) +- return; +- m_requestedStreams[type] = streamNumber; +- changeAVTrack(type); +-} +- +-void Decoder::setState(QMediaPlayer::PlaybackState state) +-{ +- if (m_state == state) +- return; +- +- switch (state) { +- case QMediaPlayer::StoppedState: +- qCDebug(qLcDecoder) << "Decoder::stop"; +- setPaused(true); +- if (demuxer) +- demuxer->stopDecoding(); +- seek(0); +- if (videoSink) +- videoSink->setVideoFrame({}); +- qCDebug(qLcDecoder) << "Decoder::stop: done"; +- break; +- case QMediaPlayer::PausedState: +- qCDebug(qLcDecoder) << "Decoder::pause"; +- setPaused(true); +- if (demuxer) { +- demuxer->startDecoding(); +- demuxer->wake(); +- if (m_state == QMediaPlayer::StoppedState) +- triggerStep(); +- } +- break; +- case QMediaPlayer::PlayingState: +- qCDebug(qLcDecoder) << "Decoder::play"; +- setPaused(false); +- if (demuxer) +- demuxer->startDecoding(); +- break; +- } +- m_state = state; +-} +- +-void Decoder::setPaused(bool b) +-{ +- clockController.setPaused(b); +-} +- +-void Decoder::triggerStep() +-{ +- if (audioRenderer) +- audioRenderer->singleStep(); +- if (videoRenderer) +- videoRenderer->singleStep(); +-} +- +-void Decoder::setVideoSink(QVideoSink *sink) +-{ +- qCDebug(qLcDecoder) << "setVideoSink" << sink; +- if (sink == videoSink) +- return; +- videoSink = sink; +- if (!videoSink || m_requestedStreams[QPlatformMediaPlayer::VideoStream] < 0) { +- if (videoRenderer) { +- videoRenderer->kill(); +- videoRenderer = nullptr; +- } +- } else if (!videoRenderer) { +- videoRenderer = new VideoRenderer(this, sink); +- connect(videoRenderer, &Renderer::atEnd, this, &Decoder::streamAtEnd); +- videoRenderer->start(); +- StreamDecoder *stream = demuxer->addStream(avStreamIndex(QPlatformMediaPlayer::VideoStream)); +- videoRenderer->setStream(stream); +- stream = demuxer->addStream(avStreamIndex(QPlatformMediaPlayer::SubtitleStream)); +- videoRenderer->setSubtitleStream(stream); +- } +-} +- +-void Decoder::setAudioSink(QPlatformAudioOutput *output) +-{ +- if (audioOutput == output) +- return; +- +- qCDebug(qLcDecoder) << "setAudioSink" << audioOutput; +- audioOutput = output; +- if (!output || m_requestedStreams[QPlatformMediaPlayer::AudioStream] < 0) { +- if (audioRenderer) { +- audioRenderer->kill(); +- audioRenderer = nullptr; +- } +- } else if (!audioRenderer) { +- audioRenderer = new AudioRenderer(this, output->q); +- connect(audioRenderer, &Renderer::atEnd, this, &Decoder::streamAtEnd); +- audioRenderer->start(); +- auto *stream = demuxer->addStream(avStreamIndex(QPlatformMediaPlayer::AudioStream)); +- audioRenderer->setStream(stream); +- } +-} +- +-void Decoder::changeAVTrack(QPlatformMediaPlayer::TrackType type) +-{ +- if (!demuxer) +- return; +- qCDebug(qLcDecoder) << " applying to renderer."; +- if (m_state == QMediaPlayer::PlayingState) +- setPaused(true); +- auto *streamDecoder = demuxer->addStream(avStreamIndex(type)); +- switch (type) { +- case QPlatformMediaPlayer::AudioStream: +- audioRenderer->setStream(streamDecoder); +- break; +- case QPlatformMediaPlayer::VideoStream: +- videoRenderer->setStream(streamDecoder); +- break; +- case QPlatformMediaPlayer::SubtitleStream: +- videoRenderer->setSubtitleStream(streamDecoder); +- break; +- default: +- Q_UNREACHABLE(); +- } +- demuxer->seek(clockController.currentTime()); +- if (m_state == QMediaPlayer::PlayingState) +- setPaused(false); +- else +- triggerStep(); +-} +- +-void Decoder::seek(qint64 pos) +-{ +- if (!demuxer) +- return; +- pos = qBound(0, pos, m_duration); +- demuxer->seek(pos); +- clockController.syncTo(pos); +- demuxer->wake(); +- if (m_state == QMediaPlayer::PausedState) +- triggerStep(); +-} +- +-void Decoder::setPlaybackRate(float rate) +-{ +- clockController.setPlaybackRate(rate); +-} +- +-void Decoder::streamAtEnd() +-{ +- if (audioRenderer && !audioRenderer->isAtEnd()) +- return; +- if (videoRenderer && !videoRenderer->isAtEnd()) +- return; +- pause(); +- +- emit endOfStream(); +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegdecoder_p.h b/src/plugins/multimedia/ffmpeg/qffmpegdecoder_p.h +deleted file mode 100644 +index 2ee61a68e..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegdecoder_p.h ++++ /dev/null +@@ -1,501 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGDECODER_P_H +-#define QFFMPEGDECODER_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpegthread_p.h" +-#include "qffmpeg_p.h" +-#include "qffmpegmediaplayer_p.h" +-#include "qffmpeghwaccel_p.h" +-#include "qffmpegclock_p.h" +-#include "qaudiobuffer.h" +-#include "qffmpegresampler_p.h" +- +-#include +-#include +-#include +-#include +- +-QT_BEGIN_NAMESPACE +- +-class QAudioSink; +-class QFFmpegAudioDecoder; +-class QFFmpegMediaPlayer; +- +-namespace QFFmpeg +-{ +- +-class Resampler; +- +-// queue up max 16M of encoded data, that should always be enough +-// (it's around 2 secs of 4K HDR video, longer for almost all other formats) +-enum { MaxQueueSize = 16*1024*1024 }; +- +-struct Packet +-{ +- struct Data { +- Data(AVPacket *p) +- : packet(p) +- {} +- ~Data() { +- if (packet) +- av_packet_free(&packet); +- } +- QAtomicInt ref; +- AVPacket *packet = nullptr; +- }; +- Packet() = default; +- Packet(AVPacket *p) +- : d(new Data(p)) +- {} +- +- bool isValid() const { return !!d; } +- AVPacket *avPacket() const { return d->packet; } +-private: +- QExplicitlySharedDataPointer d; +-}; +- +-struct Codec +-{ +- struct AVCodecFreeContext { void operator()(AVCodecContext *ctx) { avcodec_free_context(&ctx); } }; +- using UniqueAVCodecContext = std::unique_ptr; +- struct Data { +- Data(UniqueAVCodecContext &&context, AVStream *stream, std::unique_ptr &&hwAccel); +- ~Data(); +- QAtomicInt ref; +- UniqueAVCodecContext context; +- AVStream *stream = nullptr; +- std::unique_ptr hwAccel; +- }; +- +- static QMaybe create(AVStream *); +- +- AVCodecContext *context() const { return d->context.get(); } +- AVStream *stream() const { return d->stream; } +- uint streamIndex() const { return d->stream->index; } +- HWAccel *hwAccel() const { return d->hwAccel.get(); } +- qint64 toMs(qint64 ts) const { return timeStampMs(ts, d->stream->time_base).value_or(0); } +- qint64 toUs(qint64 ts) const { return timeStampUs(ts, d->stream->time_base).value_or(0); } +- +-private: +- Codec(Data *data) : d(data) {} +- QExplicitlySharedDataPointer d; +-}; +- +- +-struct Frame +-{ +- struct Data { +- Data(AVFrame *f, const Codec &codec, qint64 pts) +- : codec(codec) +- , frame(f) +- , pts(pts) +- {} +- Data(const QString &text, qint64 pts, qint64 duration) +- : text(text), pts(pts), duration(duration) +- {} +- ~Data() { +- if (frame) +- av_frame_free(&frame); +- } +- QAtomicInt ref; +- std::optional codec; +- AVFrame *frame = nullptr; +- QString text; +- qint64 pts = -1; +- qint64 duration = -1; +- }; +- Frame() = default; +- Frame(AVFrame *f, const Codec &codec, qint64 pts) +- : d(new Data(f, codec, pts)) +- {} +- Frame(const QString &text, qint64 pts, qint64 duration) +- : d(new Data(text, pts, duration)) +- {} +- bool isValid() const { return !!d; } +- +- AVFrame *avFrame() const { return d->frame; } +- AVFrame *takeAVFrame() const { +- AVFrame *f = d->frame; +- d->frame = nullptr; +- return f; +- } +- const Codec *codec() const { return d->codec ? &d->codec.value() : nullptr; } +- qint64 pts() const { return d->pts; } +- qint64 duration() const { return d->duration; } +- qint64 end() const { return d->pts + d->duration; } +- QString text() const { return d->text; } +-private: +- QExplicitlySharedDataPointer d; +-}; +- +-class Demuxer; +-class StreamDecoder; +-class Renderer; +-class AudioRenderer; +-class VideoRenderer; +- +-class Decoder : public QObject +-{ +- Q_OBJECT +-public: +- Decoder(); +- ~Decoder(); +- +- void setMedia(const QUrl &media, QIODevice *stream); +- +- void init(); +- void setState(QMediaPlayer::PlaybackState state); +- void play() { +- setState(QMediaPlayer::PlayingState); +- } +- void pause() { +- setState(QMediaPlayer::PausedState); +- } +- void stop() { +- setState(QMediaPlayer::StoppedState); +- } +- +- void triggerStep(); +- +- void setVideoSink(QVideoSink *sink); +- void setAudioSink(QPlatformAudioOutput *output); +- +- void changeAVTrack(QPlatformMediaPlayer::TrackType type); +- +- void seek(qint64 pos); +- void setPlaybackRate(float rate); +- +- int activeTrack(QPlatformMediaPlayer::TrackType type); +- void setActiveTrack(QPlatformMediaPlayer::TrackType type, int streamNumber); +- +- bool isSeekable() const +- { +- return m_isSeekable; +- } +- +-signals: +- void endOfStream(); +- void errorOccured(int error, const QString &errorString); +- void positionChanged(qint64 time); +- +-public slots: +- void streamAtEnd(); +- +-public: +- struct StreamInfo { +- int avStreamIndex = -1; +- bool isDefault = false; +- QMediaMetaData metaData; +- }; +- +- // Accessed from multiple threads, but API is threadsafe +- ClockController clockController; +- +-private: +- void setPaused(bool b); +- +-protected: +- friend QFFmpegMediaPlayer; +- +- QMediaPlayer::PlaybackState m_state = QMediaPlayer::StoppedState; +- bool m_isSeekable = false; +- +- Demuxer *demuxer = nullptr; +- QVideoSink *videoSink = nullptr; +- Renderer *videoRenderer = nullptr; +- QPlatformAudioOutput *audioOutput = nullptr; +- Renderer *audioRenderer = nullptr; +- +- QList m_streamMap[QPlatformMediaPlayer::NTrackTypes]; +- int m_requestedStreams[QPlatformMediaPlayer::NTrackTypes] = { -1, -1, -1 }; +- qint64 m_duration = 0; +- QMediaMetaData m_metaData; +- +- int avStreamIndex(QPlatformMediaPlayer::TrackType type) +- { +- int i = m_requestedStreams[type]; +- return i < 0 || i >= m_streamMap[type].size() ? -1 : m_streamMap[type][i].avStreamIndex; +- } +-}; +- +-class Demuxer : public Thread +-{ +- Q_OBJECT +-public: +- Demuxer(Decoder *decoder, AVFormatContext *context); +- ~Demuxer(); +- +- StreamDecoder *addStream(int streamIndex); +- void removeStream(int streamIndex); +- +- bool isStopped() const +- { +- return m_isStopped.loadRelaxed(); +- } +- void startDecoding() +- { +- m_isStopped.storeRelaxed(false); +- updateEnabledStreams(); +- wake(); +- } +- void stopDecoding(); +- +- int seek(qint64 pos); +- +-private: +- void updateEnabledStreams(); +- void sendFinalPacketToStreams(); +- +- void init() override; +- void cleanup() override; +- bool shouldWait() const override; +- void loop() override; +- +- Decoder *decoder; +- AVFormatContext *context = nullptr; +- QList streamDecoders; +- +- QAtomicInteger m_isStopped = true; +- qint64 last_pts = -1; +-}; +- +- +-class StreamDecoder : public Thread +-{ +- Q_OBJECT +-protected: +- Demuxer *demuxer = nullptr; +- Renderer *m_renderer = nullptr; +- +- struct PacketQueue { +- mutable QMutex mutex; +- QQueue queue; +- qint64 size = 0; +- qint64 duration = 0; +- }; +- PacketQueue packetQueue; +- +- struct FrameQueue { +- mutable QMutex mutex; +- QQueue queue; +- int maxSize = 3; +- }; +- FrameQueue frameQueue; +- QAtomicInteger eos = false; +- bool decoderHasNoFrames = false; +- +-public: +- StreamDecoder(Demuxer *demuxer, const Codec &codec); +- +- void addPacket(AVPacket *packet); +- +- qint64 queuedPacketSize() const { +- QMutexLocker locker(&packetQueue.mutex); +- return packetQueue.size; +- } +- qint64 queuedDuration() const { +- QMutexLocker locker(&packetQueue.mutex); +- return packetQueue.duration; +- } +- +- const Frame *lockAndPeekFrame() +- { +- frameQueue.mutex.lock(); +- return frameQueue.queue.isEmpty() ? nullptr : &frameQueue.queue.first(); +- } +- void removePeekedFrame() +- { +- frameQueue.queue.takeFirst(); +- wake(); +- } +- void unlockAndReleaseFrame() +- { +- frameQueue.mutex.unlock(); +- } +- Frame takeFrame(); +- +- void flush(); +- +- Codec codec; +- +- void setRenderer(Renderer *r); +- Renderer *renderer() const { return m_renderer; } +- +- bool isAtEnd() const { return eos.loadAcquire(); } +- +- void killHelper() override; +- +-private: +- Packet takePacket(); +- Packet peekPacket(); +- +- void addFrame(const Frame &f); +- +- bool hasEnoughFrames() const +- { +- QMutexLocker locker(&frameQueue.mutex); +- return frameQueue.queue.size() >= frameQueue.maxSize; +- } +- bool hasNoPackets() const +- { +- QMutexLocker locker(&packetQueue.mutex); +- return packetQueue.queue.isEmpty(); +- } +- +- void init() override; +- bool shouldWait() const override; +- void loop() override; +- +- void decode(); +- void decodeSubtitle(); +- +- QPlatformMediaPlayer::TrackType type() const; +-}; +- +-class Renderer : public Thread +-{ +- Q_OBJECT +-protected: +- QPlatformMediaPlayer::TrackType type; +- +- bool step = false; +- bool paused = true; +- StreamDecoder *streamDecoder = nullptr; +- QAtomicInteger eos = false; +- +-public: +- Renderer(QPlatformMediaPlayer::TrackType type); +- +- void setPaused(bool p) { +- QMutexLocker locker(&mutex); +- paused = p; +- if (!p) +- wake(); +- } +- void singleStep() { +- QMutexLocker locker(&mutex); +- if (!paused) +- return; +- step = true; +- wake(); +- } +- void doneStep() { +- step = false; +- } +- bool isAtEnd() { return !streamDecoder || eos.loadAcquire(); } +- +- void setStream(StreamDecoder *stream); +- virtual void setSubtitleStream(StreamDecoder *) {} +- +- void killHelper() override; +- +- virtual void streamChanged() {} +- +-Q_SIGNALS: +- void atEnd(); +- +-protected: +- bool shouldWait() const override; +- +-public: +-}; +- +-class ClockedRenderer : public Renderer, public Clock +-{ +-public: +- ClockedRenderer(Decoder *decoder, QPlatformMediaPlayer::TrackType type) +- : Renderer(type) +- , Clock(&decoder->clockController) +- { +- } +- ~ClockedRenderer() +- { +- } +- void setPaused(bool paused) override; +-}; +- +-class VideoRenderer : public ClockedRenderer +-{ +- Q_OBJECT +- +- StreamDecoder *subtitleStreamDecoder = nullptr; +-public: +- VideoRenderer(Decoder *decoder, QVideoSink *sink); +- +- void killHelper() override; +- +- void setSubtitleStream(StreamDecoder *stream) override; +-private: +- +- void init() override; +- void loop() override; +- +- QVideoSink *sink; +-}; +- +-class AudioRenderer : public ClockedRenderer +-{ +- Q_OBJECT +-public: +- AudioRenderer(Decoder *decoder, QAudioOutput *output); +- ~AudioRenderer() = default; +- +- // Clock interface +- void syncTo(qint64 usecs) override; +- void setPlaybackRate(float rate, qint64 currentTime) override; +- +-private slots: +- void updateAudio(); +- void setSoundVolume(float volume); +- +-private: +- void updateOutput(const Codec *codec); +- void initResempler(const Codec *codec); +- void freeOutput(); +- +- void init() override; +- void cleanup() override; +- void loop() override; +- void streamChanged() override; +- Type type() const override { return AudioClock; } +- +- int outputSamples(int inputSamples) { +- return qRound(inputSamples/playbackRate()); +- } +- +- // Used for timing update calculations based on processed data +- qint64 audioBaseTime = 0; +- qint64 processedBase = 0; +- qint64 processedUSecs = 0; +- +- bool deviceChanged = false; +- QAudioOutput *output = nullptr; +- qint64 writtenUSecs = 0; +- qint64 latencyUSecs = 0; +- +- QAudioFormat format; +- QAudioSink *audioSink = nullptr; +- QIODevice *audioDevice = nullptr; +- std::unique_ptr resampler; +- QAudioBuffer bufferedData; +- qsizetype bufferWritten = 0; +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +- +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegencoder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegencoder.cpp +deleted file mode 100644 +index 86e33c83c..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegencoder.cpp ++++ /dev/null +@@ -1,557 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#include "qffmpegencoder_p.h" +-#include "qffmpegmediaformatinfo_p.h" +-#include "qffmpegvideoframeencoder_p.h" +-#include "private/qmultimediautils_p.h" +- +-#include +-#include +-#include +-#include +-#include "qffmpegaudioinput_p.h" +-#include +-#include "qffmpegvideobuffer_p.h" +-#include "qffmpegmediametadata_p.h" +-#include "qffmpegencoderoptions_p.h" +- +-#include +- +-extern "C" { +-#include +-#include +-} +- +-QT_BEGIN_NAMESPACE +- +-Q_LOGGING_CATEGORY(qLcFFmpegEncoder, "qt.multimedia.ffmpeg.encoder") +- +-namespace QFFmpeg +-{ +- +-Encoder::Encoder(const QMediaEncoderSettings &settings, const QUrl &url) +- : settings(settings) +-{ +- const AVOutputFormat *avFormat = QFFmpegMediaFormatInfo::outputFormatForFileFormat(settings.fileFormat()); +- +- formatContext = avformat_alloc_context(); +- formatContext->oformat = const_cast(avFormat); // constness varies +- +- QByteArray encoded = url.toEncoded(); +- formatContext->url = (char *)av_malloc(encoded.size() + 1); +- memcpy(formatContext->url, encoded.constData(), encoded.size() + 1); +- formatContext->pb = nullptr; +- avio_open2(&formatContext->pb, formatContext->url, AVIO_FLAG_WRITE, nullptr, nullptr); +- qCDebug(qLcFFmpegEncoder) << "opened" << formatContext->url; +- +- muxer = new Muxer(this); +-} +- +-Encoder::~Encoder() +-{ +-} +- +-void Encoder::addAudioInput(QFFmpegAudioInput *input) +-{ +- audioEncode = new AudioEncoder(this, input, settings); +- connect(input, &QFFmpegAudioInput::newAudioBuffer, this, &Encoder::newAudioBuffer); +- input->setRunning(true); +-} +- +-void Encoder::addVideoSource(QPlatformCamera *source) +-{ +- videoEncode = new VideoEncoder(this, source, settings); +- connect(source, &QPlatformCamera::newVideoFrame, this, &Encoder::newVideoFrame); +-} +- +-void Encoder::start() +-{ +- qCDebug(qLcFFmpegEncoder) << "Encoder::start!"; +- +- formatContext->metadata = QFFmpegMetaData::toAVMetaData(metaData); +- +- int res = avformat_write_header(formatContext, nullptr); +- if (res < 0) +- qWarning() << "could not write header" << res; +- +- muxer->start(); +- if (audioEncode) +- audioEncode->start(); +- if (videoEncode) +- videoEncode->start(); +- isRecording = true; +-} +- +-void EncodingFinalizer::run() +-{ +- if (encoder->audioEncode) +- encoder->audioEncode->kill(); +- if (encoder->videoEncode) +- encoder->videoEncode->kill(); +- encoder->muxer->kill(); +- +- int res = av_write_trailer(encoder->formatContext); +- if (res < 0) +- qWarning() << "could not write trailer" << res; +- +- avformat_free_context(encoder->formatContext); +- qDebug() << " done finalizing."; +- emit encoder->finalizationDone(); +- delete encoder; +- deleteLater(); +-} +- +-void Encoder::finalize() +-{ +- qDebug() << ">>>>>>>>>>>>>>> finalize"; +- +- isRecording = false; +- auto *finalizer = new EncodingFinalizer(this); +- finalizer->start(); +-} +- +-void Encoder::setPaused(bool p) +-{ +- if (audioEncode) +- audioEncode->setPaused(p); +- if (videoEncode) +- videoEncode->setPaused(p); +-} +- +-void Encoder::setMetaData(const QMediaMetaData &metaData) +-{ +- this->metaData = metaData; +-} +- +-void Encoder::newAudioBuffer(const QAudioBuffer &buffer) +-{ +- if (audioEncode && isRecording) +- audioEncode->addBuffer(buffer); +-} +- +-void Encoder::newVideoFrame(const QVideoFrame &frame) +-{ +- if (videoEncode && isRecording) +- videoEncode->addFrame(frame); +-} +- +-void Encoder::newTimeStamp(qint64 time) +-{ +- QMutexLocker locker(&timeMutex); +- if (time > timeRecorded) { +- timeRecorded = time; +- emit durationChanged(time); +- } +-} +- +-Muxer::Muxer(Encoder *encoder) +- : encoder(encoder) +-{ +- setObjectName(QLatin1String("Muxer")); +-} +- +-void Muxer::addPacket(AVPacket *packet) +-{ +-// qCDebug(qLcFFmpegEncoder) << "Muxer::addPacket" << packet->pts << packet->stream_index; +- QMutexLocker locker(&queueMutex); +- packetQueue.enqueue(packet); +- wake(); +-} +- +-AVPacket *Muxer::takePacket() +-{ +- QMutexLocker locker(&queueMutex); +- if (packetQueue.isEmpty()) +- return nullptr; +-// qCDebug(qLcFFmpegEncoder) << "Muxer::takePacket" << packetQueue.first()->pts; +- return packetQueue.dequeue(); +-} +- +-void Muxer::init() +-{ +-} +- +-void Muxer::cleanup() +-{ +-} +- +-bool QFFmpeg::Muxer::shouldWait() const +-{ +- QMutexLocker locker(&queueMutex); +- return packetQueue.isEmpty(); +-} +- +-void Muxer::loop() +-{ +- auto *packet = takePacket(); +-// qCDebug(qLcFFmpegEncoder) << "writing packet to file" << packet->pts << packet->duration << packet->stream_index; +- av_interleaved_write_frame(encoder->formatContext, packet); +-} +- +- +-static AVSampleFormat bestMatchingSampleFormat(AVSampleFormat requested, const AVSampleFormat *available) +-{ +- if (!available) +- return requested; +- +- const AVSampleFormat *f = available; +- AVSampleFormat best = *f; +-/* +- enum { +- First, +- Planar, +- Exact, +- } score = First; +-*/ +- for (; *f != AV_SAMPLE_FMT_NONE; ++f) { +- qCDebug(qLcFFmpegEncoder) << "format:" << *f; +- if (*f == requested) { +- best = *f; +-// score = Exact; +- break; +- } +- +- if (av_get_planar_sample_fmt(requested) == *f) { +-// score = Planar; +- best = *f; +- } +- } +- return best; +-} +- +-AudioEncoder::AudioEncoder(Encoder *encoder, QFFmpegAudioInput *input, const QMediaEncoderSettings &settings) +- : input(input) +-{ +- this->encoder = encoder; +- +- setObjectName(QLatin1String("AudioEncoder")); +- qCDebug(qLcFFmpegEncoder) << "AudioEncoder" << settings.audioCodec(); +- +- format = input->device.preferredFormat(); +- auto codecID = QFFmpegMediaFormatInfo::codecIdForAudioCodec(settings.audioCodec()); +- Q_ASSERT(avformat_query_codec(encoder->formatContext->oformat, codecID, FF_COMPLIANCE_NORMAL)); +- +- auto *avCodec = avcodec_find_encoder(codecID); +- +- AVSampleFormat requested = QFFmpegMediaFormatInfo::avSampleFormat(format.sampleFormat()); +- AVSampleFormat bestSampleFormat = bestMatchingSampleFormat(requested, avCodec->sample_fmts); +- +- stream = avformat_new_stream(encoder->formatContext, nullptr); +- stream->id = encoder->formatContext->nb_streams - 1; +- stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; +- stream->codecpar->codec_id = codecID; +-#if QT_FFMPEG_OLD_CHANNEL_LAYOUT +- stream->codecpar->channel_layout = av_get_default_channel_layout(format.channelCount()); +- stream->codecpar->channels = format.channelCount(); +-#else +- av_channel_layout_default(&stream->codecpar->ch_layout, format.channelCount()); +-#endif +- stream->codecpar->sample_rate = format.sampleRate(); +- stream->codecpar->frame_size = 1024; +- stream->codecpar->format = bestSampleFormat; +- stream->time_base = AVRational{ 1, format.sampleRate() }; +- +- Q_ASSERT(avCodec); +- codec = avcodec_alloc_context3(avCodec); +- avcodec_parameters_to_context(codec, stream->codecpar); +- +- AVDictionary *opts = nullptr; +- applyAudioEncoderOptions(settings, avCodec->name, codec, &opts); +- +- int res = avcodec_open2(codec, avCodec, &opts); +- qCDebug(qLcFFmpegEncoder) << "audio codec opened" << res; +- qCDebug(qLcFFmpegEncoder) << "audio codec params: fmt=" << codec->sample_fmt << "rate=" << codec->sample_rate; +- +- if (codec->sample_fmt != requested) { +-#if QT_FFMPEG_OLD_CHANNEL_LAYOUT +- resampler = swr_alloc_set_opts(nullptr, // we're allocating a new context +- codec->channel_layout, // out_ch_layout +- codec->sample_fmt, // out_sample_fmt +- codec->sample_rate, // out_sample_rate +- av_get_default_channel_layout(format.channelCount()), // in_ch_layout +- requested, // in_sample_fmt +- format.sampleRate(), // in_sample_rate +- 0, // log_offset +- nullptr); +-#else +- AVChannelLayout in_ch_layout = {}; +- av_channel_layout_default(&in_ch_layout, format.channelCount()); +- swr_alloc_set_opts2(&resampler, // we're allocating a new context +- &codec->ch_layout, codec->sample_fmt, codec->sample_rate, +- &in_ch_layout, requested, format.sampleRate(), +- 0, nullptr); +-#endif +- +- swr_init(resampler); +- } +-} +- +-void AudioEncoder::addBuffer(const QAudioBuffer &buffer) +-{ +- QMutexLocker locker(&queueMutex); +- if (!paused.loadRelaxed()) { +- audioBufferQueue.enqueue(buffer); +- wake(); +- } +-} +- +-QAudioBuffer AudioEncoder::takeBuffer() +-{ +- QMutexLocker locker(&queueMutex); +- if (audioBufferQueue.isEmpty()) +- return QAudioBuffer(); +- return audioBufferQueue.dequeue(); +-} +- +-void AudioEncoder::init() +-{ +- if (input) { +- input->setFrameSize(codec->frame_size); +- } +- qCDebug(qLcFFmpegEncoder) << "AudioEncoder::init started audio device thread."; +-} +- +-void AudioEncoder::cleanup() +-{ +- while (!audioBufferQueue.isEmpty()) +- loop(); +- while (avcodec_send_frame(codec, nullptr) == AVERROR(EAGAIN)) +- retrievePackets(); +- retrievePackets(); +-} +- +-bool AudioEncoder::shouldWait() const +-{ +- QMutexLocker locker(&queueMutex); +- return audioBufferQueue.isEmpty(); +-} +- +-void AudioEncoder::retrievePackets() +-{ +- while (1) { +- AVPacket *packet = av_packet_alloc(); +- int ret = avcodec_receive_packet(codec, packet); +- if (ret < 0) { +- av_packet_unref(packet); +- if (ret != AVERROR(EOF)) +- break; +- if (ret != AVERROR(EAGAIN)) { +- char errStr[1024]; +- av_strerror(ret, errStr, 1024); +- qCDebug(qLcFFmpegEncoder) << "receive packet" << ret << errStr; +- } +- break; +- } +- +- // qCDebug(qLcFFmpegEncoder) << "writing video packet" << packet->size << packet->pts << timeStamp(packet->pts, stream->time_base) << packet->stream_index; +- packet->stream_index = stream->id; +- encoder->muxer->addPacket(packet); +- } +-} +- +-void AudioEncoder::loop() +-{ +- QAudioBuffer buffer = takeBuffer(); +- if (!buffer.isValid() || paused.loadAcquire()) +- return; +- +-// qCDebug(qLcFFmpegEncoder) << "new audio buffer" << buffer.byteCount() << buffer.format() << buffer.frameCount() << codec->frame_size; +- retrievePackets(); +- +- AVFrame *frame = av_frame_alloc(); +- frame->format = codec->sample_fmt; +-#if QT_FFMPEG_OLD_CHANNEL_LAYOUT +- frame->channel_layout = codec->channel_layout; +- frame->channels = codec->channels; +-#else +- frame->ch_layout = codec->ch_layout; +-#endif +- frame->sample_rate = codec->sample_rate; +- frame->nb_samples = buffer.frameCount(); +- if (frame->nb_samples) +- av_frame_get_buffer(frame, 0); +- +- if (resampler) { +- const uint8_t *data = buffer.constData(); +- swr_convert(resampler, frame->extended_data, frame->nb_samples, &data, frame->nb_samples); +- } else { +- memcpy(frame->buf[0]->data, buffer.constData(), buffer.byteCount()); +- } +- +- frame->pts = samplesWritten; +- samplesWritten += buffer.frameCount(); +- +- qint64 time = format.durationForFrames(samplesWritten); +- encoder->newTimeStamp(time/1000); +- +-// qCDebug(qLcFFmpegEncoder) << "sending audio frame" << buffer.byteCount() << frame->pts << ((double)buffer.frameCount()/frame->sample_rate); +- int ret = avcodec_send_frame(codec, frame); +- if (ret < 0) { +- char errStr[1024]; +- av_strerror(ret, errStr, 1024); +-// qCDebug(qLcFFmpegEncoder) << "error sending frame" << ret << errStr; +- } +-} +- +-VideoEncoder::VideoEncoder(Encoder *encoder, QPlatformCamera *camera, const QMediaEncoderSettings &settings) +- : m_encoderSettings(settings) +- , m_camera(camera) +-{ +- this->encoder = encoder; +- +- setObjectName(QLatin1String("VideoEncoder")); +- qCDebug(qLcFFmpegEncoder) << "VideoEncoder" << settings.videoCodec(); +- +- auto format = m_camera->cameraFormat(); +- std::optional hwFormat = camera->ffmpegHWPixelFormat() +- ? AVPixelFormat(*camera->ffmpegHWPixelFormat()) +- : std::optional{}; +- +- AVPixelFormat swFormat = QFFmpegVideoBuffer::toAVPixelFormat(format.pixelFormat()); +- AVPixelFormat pixelFormat = hwFormat ? *hwFormat : swFormat; +- frameEncoder = new VideoFrameEncoder(settings, format.resolution(), format.maxFrameRate(), pixelFormat, swFormat); +- +- frameEncoder->initWithFormatContext(encoder->formatContext); +-} +- +-VideoEncoder::~VideoEncoder() +-{ +- delete frameEncoder; +-} +- +-void VideoEncoder::addFrame(const QVideoFrame &frame) +-{ +- QMutexLocker locker(&queueMutex); +- if (!paused.loadRelaxed()) { +- videoFrameQueue.enqueue(frame); +- wake(); +- } +-} +- +-QVideoFrame VideoEncoder::takeFrame() +-{ +- QMutexLocker locker(&queueMutex); +- if (videoFrameQueue.isEmpty()) +- return QVideoFrame(); +- return videoFrameQueue.dequeue(); +-} +- +-void VideoEncoder::retrievePackets() +-{ +- if (!frameEncoder) +- return; +- while (AVPacket *packet = frameEncoder->retrievePacket()) +- encoder->muxer->addPacket(packet); +-} +- +-void VideoEncoder::init() +-{ +- qCDebug(qLcFFmpegEncoder) << "VideoEncoder::init started video device thread."; +- bool ok = frameEncoder->open(); +- if (!ok) +- encoder->error(QMediaRecorder::ResourceError, "Could not initialize encoder"); +-} +- +-void VideoEncoder::cleanup() +-{ +- while (!videoFrameQueue.isEmpty()) +- loop(); +- if (frameEncoder) { +- while (frameEncoder->sendFrame(nullptr) == AVERROR(EAGAIN)) +- retrievePackets(); +- retrievePackets(); +- } +-} +- +-bool VideoEncoder::shouldWait() const +-{ +- QMutexLocker locker(&queueMutex); +- return videoFrameQueue.isEmpty(); +-} +- +-struct QVideoFrameHolder +-{ +- QVideoFrame f; +- QImage i; +-}; +- +-static void freeQVideoFrame(void *opaque, uint8_t *) +-{ +- delete reinterpret_cast(opaque); +-} +- +-void VideoEncoder::loop() +-{ +- if (paused.loadAcquire()) +- return; +- +- retrievePackets(); +- +- auto frame = takeFrame(); +- if (!frame.isValid()) +- return; +- +- if (frameEncoder->isNull()) +- return; +- +-// qCDebug(qLcFFmpegEncoder) << "new video buffer" << frame.startTime(); +- +- AVFrame *avFrame = nullptr; +- +- auto *videoBuffer = dynamic_cast(frame.videoBuffer()); +- if (videoBuffer) { +- // ffmpeg video buffer, let's use the native AVFrame stored in there +- auto *hwFrame = videoBuffer->getHWFrame(); +- if (hwFrame && hwFrame->format == frameEncoder->sourceFormat()) +- avFrame = av_frame_clone(hwFrame); +- } +- +- if (!avFrame) { +- frame.map(QVideoFrame::ReadOnly); +- auto size = frame.size(); +- avFrame = av_frame_alloc(); +- avFrame->format = frameEncoder->sourceFormat(); +- avFrame->width = size.width(); +- avFrame->height = size.height(); +- av_frame_get_buffer(avFrame, 0); +- +- for (int i = 0; i < 4; ++i) { +- avFrame->data[i] = const_cast(frame.bits(i)); +- avFrame->linesize[i] = frame.bytesPerLine(i); +- } +- +- QImage img; +- if (frame.pixelFormat() == QVideoFrameFormat::Format_Jpeg) { +- // the QImage is cached inside the video frame, so we can take the pointer to the image data here +- img = frame.toImage(); +- avFrame->data[0] = (uint8_t *)img.bits(); +- avFrame->linesize[0] = img.bytesPerLine(); +- } +- +- Q_ASSERT(avFrame->data[0]); +- // ensure the video frame and it's data is alive as long as it's being used in the encoder +- avFrame->opaque_ref = av_buffer_create(nullptr, 0, freeQVideoFrame, new QVideoFrameHolder{frame, img}, 0); +- } +- +- if (baseTime.loadAcquire() < 0) { +- baseTime.storeRelease(frame.startTime() - lastFrameTime); +-// qCDebug(qLcFFmpegEncoder) << ">>>> adjusting base time to" << baseTime.loadAcquire() << frame.startTime() << lastFrameTime; +- } +- +- qint64 time = frame.startTime() - baseTime.loadAcquire(); +- lastFrameTime = frame.endTime() - baseTime.loadAcquire(); +- avFrame->pts = frameEncoder->getPts(time); +- +- encoder->newTimeStamp(time/1000); +- +-// qCDebug(qLcFFmpegEncoder) << ">>> sending frame" << avFrame->pts << time; +- int ret = frameEncoder->sendFrame(avFrame); +- if (ret < 0) { +- qCDebug(qLcFFmpegEncoder) << "error sending frame" << ret << err2str(ret); +- encoder->error(QMediaRecorder::ResourceError, err2str(ret)); +- } +-} +- +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegencoder_p.h b/src/plugins/multimedia/ffmpeg/qffmpegencoder_p.h +deleted file mode 100644 +index b673b718c..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegencoder_p.h ++++ /dev/null +@@ -1,197 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGENCODER_P_H +-#define QFFMPEGENCODER_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpegthread_p.h" +-#include "qffmpeg_p.h" +-#include "qffmpeghwaccel_p.h" +- +-#include +-#include +-#include +- +-#include +- +-QT_BEGIN_NAMESPACE +- +-class QFFmpegAudioInput; +-class QVideoFrame; +-class QPlatformCamera; +- +-namespace QFFmpeg +-{ +- +-class Encoder; +-class Muxer; +-class AudioEncoder; +-class VideoEncoder; +-class VideoFrameEncoder; +- +-class EncodingFinalizer : public QThread +-{ +-public: +- EncodingFinalizer(Encoder *e) +- : encoder(e) +- {} +- void run() override; +- +- Encoder *encoder = nullptr; +-}; +- +-class Encoder : public QObject +-{ +- Q_OBJECT +-public: +- Encoder(const QMediaEncoderSettings &settings, const QUrl &url); +- ~Encoder(); +- +- void addAudioInput(QFFmpegAudioInput *input); +- void addVideoSource(QPlatformCamera *source); +- +- void start(); +- void finalize(); +- +- void setPaused(bool p); +- +- void setMetaData(const QMediaMetaData &metaData); +- +-public Q_SLOTS: +- void newAudioBuffer(const QAudioBuffer &buffer); +- void newVideoFrame(const QVideoFrame &frame); +- void newTimeStamp(qint64 time); +- +-Q_SIGNALS: +- void durationChanged(qint64 duration); +- void error(QMediaRecorder::Error code, const QString &description); +- void finalizationDone(); +- +-public: +- +- QMediaEncoderSettings settings; +- QMediaMetaData metaData; +- AVFormatContext *formatContext = nullptr; +- Muxer *muxer = nullptr; +- bool isRecording = false; +- +- AudioEncoder *audioEncode = nullptr; +- VideoEncoder *videoEncode = nullptr; +- +- QMutex timeMutex; +- qint64 timeRecorded = 0; +-}; +- +- +-class Muxer : public Thread +-{ +- mutable QMutex queueMutex; +- QQueue packetQueue; +-public: +- Muxer(Encoder *encoder); +- +- void addPacket(AVPacket *); +- +-private: +- AVPacket *takePacket(); +- +- void init() override; +- void cleanup() override; +- bool shouldWait() const override; +- void loop() override; +- +- Encoder *encoder; +-}; +- +-class EncoderThread : public Thread +-{ +-public: +- virtual void setPaused(bool b) +- { +- paused.storeRelease(b); +- } +- +-protected: +- QAtomicInteger paused = false; +- Encoder *encoder = nullptr; +-}; +- +-class AudioEncoder : public EncoderThread +-{ +- mutable QMutex queueMutex; +- QQueue audioBufferQueue; +-public: +- AudioEncoder(Encoder *encoder, QFFmpegAudioInput *input, const QMediaEncoderSettings &settings); +- +- void addBuffer(const QAudioBuffer &buffer); +- +- QFFmpegAudioInput *audioInput() const { return input; } +- +-private: +- QAudioBuffer takeBuffer(); +- void retrievePackets(); +- +- void init() override; +- void cleanup() override; +- bool shouldWait() const override; +- void loop() override; +- +- AVStream *stream = nullptr; +- AVCodecContext *codec = nullptr; +- QFFmpegAudioInput *input; +- QAudioFormat format; +- +- SwrContext *resampler = nullptr; +- qint64 samplesWritten = 0; +-}; +- +- +-class VideoEncoder : public EncoderThread +-{ +- mutable QMutex queueMutex; +- QQueue videoFrameQueue; +-public: +- VideoEncoder(Encoder *encoder, QPlatformCamera *camera, const QMediaEncoderSettings &settings); +- ~VideoEncoder(); +- +- void addFrame(const QVideoFrame &frame); +- +- void setPaused(bool b) override +- { +- EncoderThread::setPaused(b); +- if (b) +- baseTime.storeRelease(-1); +- } +- +-private: +- QVideoFrame takeFrame(); +- void retrievePackets(); +- +- void init() override; +- void cleanup() override; +- bool shouldWait() const override; +- void loop() override; +- +- QMediaEncoderSettings m_encoderSettings; +- QPlatformCamera *m_camera = nullptr; +- VideoFrameEncoder *frameEncoder = nullptr; +- +- QAtomicInteger baseTime = -1; +- qint64 lastFrameTime = 0; +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegencoderoptions.cpp b/src/plugins/multimedia/ffmpeg/qffmpegencoderoptions.cpp +deleted file mode 100644 +index 2535048c3..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegencoderoptions.cpp ++++ /dev/null +@@ -1,272 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#include "qffmpegencoderoptions_p.h" +- +-#if QT_CONFIG(vaapi) +-#include +-#endif +- +-QT_BEGIN_NAMESPACE +- +-// unfortunately there is no common way to specify options for the encoders. The code here tries to map our settings sensibly +-// to options available in different encoders +- +-// For constant quality options, we're trying to map things to approx those bit rates for 1080p@30fps (in Mbps): +-// VeryLow Low Normal High VeryHigh +-// H264: 0.8M 1.5M 3.5M 6M 10M +-// H265: 0.5M 1.0M 2.5M 4M 7M +- +-[[maybe_unused]] +-static int bitrateForSettings(const QMediaEncoderSettings &settings, bool hdr = false) +-{ +- // calculate an acceptable bitrate depending on video codec, resolution, framerate and requested quality +- // The calculations are rather heuristic here, trying to take into account how well codecs compress using +- // the tables above. +- +- // The table here is for 30FPS +- const double bitsPerPixel[int(QMediaFormat::VideoCodec::LastVideoCodec)+1][QMediaRecorder::VeryHighQuality+1] = { +- { 1.2, 2.25, 5, 9, 15 }, // MPEG1, +- { 0.8, 1.5, 3.5, 6, 10 }, // MPEG2 +- { 0.4, 0.75, 1.75, 3, 5 }, // MPEG4 +- { 0.4, 0.75, 1.75, 3, 5 }, // H264 +- { 0.3, 0.5, 0.2, 2, 3 }, // H265 +- { 0.4, 0.75, 1.75, 3, 5 }, // VP8 +- { 0.3, 0.5, 0.2, 2, 3 }, // VP9 +- { 0.2, 0.4, 0.9, 1.5, 2.5 }, // AV1 +- { 0.4, 0.75, 1.75, 3, 5 }, // Theora +- { 0.8, 1.5, 3.5, 6, 10 }, // WMV +- { 16, 24, 32, 40, 48 }, // MotionJPEG +- }; +- +- QSize s = settings.videoResolution(); +- double bitrate = bitsPerPixel[int(settings.videoCodec())][settings.quality()]*s.width()*s.height(); +- +- if (settings.videoCodec() != QMediaFormat::VideoCodec::MotionJPEG) { +- // We assume that doubling the framerate requires 1.5 times the amount of data (not twice, as intraframe +- // differences will be smaller). 4 times the frame rate uses thus 2.25 times the data, etc. +- float rateMultiplier = log2(settings.videoFrameRate()/30.); +- bitrate *= pow(1.5, rateMultiplier); +- } else { +- // MotionJPEG doesn't optimize between frames, so we have a linear dependency on framerate +- bitrate *= settings.videoFrameRate()/30.; +- } +- +- // HDR requires 10bits per pixel instead of 8, so apply a factor of 1.25. +- if (hdr) +- bitrate *= 1.25; +- return bitrate; +-} +- +-static void apply_x264(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **opts) +-{ +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding || settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- } else { +- const char *scales[] = { +- "29", "26", "23", "21", "19" +- }; +- av_dict_set(opts, "crf", scales[settings.quality()], 0); +- } +-} +- +-static void apply_x265(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **opts) +-{ +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding || settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- } else { +- const char *scales[QMediaRecorder::VeryHighQuality+1] = { +- "40", "34", "28", "26", "24", +- }; +- av_dict_set(opts, "crf", scales[settings.quality()], 0); +- } +-} +- +-static void apply_libvpx(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **opts) +-{ +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding || settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- } else { +- const char *scales[QMediaRecorder::VeryHighQuality+1] = { +- "38", "34", "31", "28", "25", +- }; +- av_dict_set(opts, "crf", scales[settings.quality()], 0); +- av_dict_set(opts, "b", 0, 0); +- } +- av_dict_set(opts, "row-mt", "1", 0); // better multithreading +-} +- +-#ifdef Q_OS_DARWIN +-static void apply_videotoolbox(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **) +-{ +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding || settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- } else { +- // only use quality on macOS/ARM, as FFmpeg doesn't support it on the other platforms and would throw +- // an error when initializing the codec +-#if defined(Q_OS_MACOS) && defined(Q_PROCESSOR_ARM_64) +- // Videotoolbox describes quality as a number from 0 to 1, with low == 0.25, normal 0.5, high 0.75 and lossless = 1 +- // ffmpeg uses a different scale going from 0 to 11800. +- // Values here are adjusted to agree approximately with the target bit rates listed above +- const int scales[] = { +- 3000, 4800, 5900, 6900, 7700, +- }; +- codec->global_quality = scales[settings.quality()]; +- codec->flags |= AV_CODEC_FLAG_QSCALE; +-#else +- codec->bit_rate = bitrateForSettings(settings); +-#endif +- } +-} +-#endif +- +-#if QT_CONFIG(vaapi) +-static void apply_vaapi(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **/*opts*/) +-{ +- // See also vaapi_encode_init_rate_control() in libavcodec +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- codec->rc_max_rate = settings.videoBitRate(); +- } else if (settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- } else { +- const int *quality = nullptr; +- // unfortunately, all VA codecs use different quality scales :/ +- switch (settings.videoCodec()) { +- case QMediaFormat::VideoCodec::MPEG2: { +- static const int q[] = { 20, 15, 10, 8, 6 }; +- quality = q; +- break; +- } +- case QMediaFormat::VideoCodec::MPEG4: +- case QMediaFormat::VideoCodec::H264: { +- static const int q[] = { 29, 26, 23, 21, 19 }; +- quality = q; +- break; +- } +- case QMediaFormat::VideoCodec::H265: { +- static const int q[] = { 40, 34, 28, 26, 24 }; +- quality = q; +- break; +- } +- case QMediaFormat::VideoCodec::VP8: { +- static const int q[] = { 56, 48, 40, 34, 28 }; +- quality = q; +- break; +- } +- case QMediaFormat::VideoCodec::VP9: { +- static const int q[] = { 124, 112, 100, 88, 76 }; +- quality = q; +- break; +- } +- case QMediaFormat::VideoCodec::MotionJPEG: { +- static const int q[] = { 40, 60, 80, 90, 95 }; +- quality = q; +- break; +- } +- case QMediaFormat::VideoCodec::AV1: +- case QMediaFormat::VideoCodec::Theora: +- case QMediaFormat::VideoCodec::WMV: +- default: +- break; +- } +- +- if (quality) { +- qDebug() << "using quality" << settings.quality() << quality[settings.quality()]; +- codec->global_quality = quality[settings.quality()]; +- } +- } +-} +-#endif +- +-#ifdef Q_OS_WINDOWS +-static void apply_mf(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **opts) +-{ +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding || settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) { +- codec->bit_rate = settings.videoBitRate(); +- av_dict_set(opts, "rate_control", "cbr", 0); +- } else { +- av_dict_set(opts, "rate_control", "quality", 0); +- const char *scales[] = { +- "25", "50", "75", "90", "100" +- }; +- av_dict_set(opts, "quality", scales[settings.quality()], 0); +- } +-} +-#endif +- +-namespace QFFmpeg { +- +-using ApplyOptions = void (*)(const QMediaEncoderSettings &settings, AVCodecContext *codec, AVDictionary **opts); +- +-const struct { +- const char *name; +- ApplyOptions apply; +-} videoCodecOptionTable[] = { +- { "libx264", apply_x264 }, +- { "libx265xx", apply_x265 }, +- { "libvpx", apply_libvpx }, +- { "libvpx_vp9", apply_libvpx }, +-#ifdef Q_OS_DARWIN +- { "h264_videotoolbox", apply_videotoolbox }, +- { "hevc_videotoolbox", apply_videotoolbox }, +- { "prores_videotoolbox", apply_videotoolbox }, +- { "vp9_videotoolbox", apply_videotoolbox }, +-#endif +-#if QT_CONFIG(vaapi) +- { "mpeg2_vaapi", apply_vaapi }, +- { "mjpeg_vaapi", apply_vaapi }, +- { "h264_vaapi", apply_vaapi }, +- { "hevc_vaapi", apply_vaapi }, +- { "vp8_vaapi", apply_vaapi }, +- { "vp9_vaapi", apply_vaapi }, +-#endif +-#ifdef Q_OS_WINDOWS +- { "hevc_mf", apply_mf }, +- { "h264_mf", apply_mf }, +-#endif +- { nullptr, nullptr } +-}; +- +-const struct { +- const char *name; +- ApplyOptions apply; +-} audioCodecOptionTable[] = { +- { nullptr, nullptr } +-}; +- +-void applyVideoEncoderOptions(const QMediaEncoderSettings &settings, const QByteArray &codecName, AVCodecContext *codec, AVDictionary **opts) +-{ +- av_dict_set(opts, "threads", "auto", 0); // we always want automatic threading +- +- auto *table = videoCodecOptionTable; +- while (table->name) { +- if (codecName == table->name) { +- table->apply(settings, codec, opts); +- return; +- } +- +- ++table; +- } +-} +- +-void applyAudioEncoderOptions(const QMediaEncoderSettings &settings, const QByteArray &codecName, AVCodecContext *codec, AVDictionary **opts) +-{ +- codec->thread_count = -1; // we always want automatic threading +- if (settings.encodingMode() == QMediaRecorder::ConstantBitRateEncoding || settings.encodingMode() == QMediaRecorder::AverageBitRateEncoding) +- codec->bit_rate = settings.audioBitRate(); +- +- auto *table = audioCodecOptionTable; +- while (table->name) { +- if (codecName == table->name) { +- table->apply(settings, codec, opts); +- return; +- } +- +- ++table; +- } +- +-} +- +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegencoderoptions_p.h b/src/plugins/multimedia/ffmpeg/qffmpegencoderoptions_p.h +deleted file mode 100644 +index 005ad7652..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegencoderoptions_p.h ++++ /dev/null +@@ -1,32 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGENCODEROPTIONS_P_H +-#define QFFMPEGENCODEROPTIONS_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeghwaccel_p.h" +-#include "qvideoframeformat.h" +-#include "private/qplatformmediarecorder_p.h" +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +- +-void applyVideoEncoderOptions(const QMediaEncoderSettings &settings, const QByteArray &codecName, AVCodecContext *codec, AVDictionary **opts); +-void applyAudioEncoderOptions(const QMediaEncoderSettings &settings, const QByteArray &codecName, AVCodecContext *codec, AVDictionary **opts); +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel.cpp b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel.cpp +deleted file mode 100644 +index e5d90239b..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel.cpp ++++ /dev/null +@@ -1,372 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpeghwaccel_p.h" +-#if QT_CONFIG(vaapi) +-#include "qffmpeghwaccel_vaapi_p.h" +-#endif +-#ifdef Q_OS_DARWIN +-#include "qffmpeghwaccel_videotoolbox_p.h" +-#endif +-#if QT_CONFIG(wmf) +-#include "qffmpeghwaccel_d3d11_p.h" +-#endif +-#ifdef Q_OS_ANDROID +-# include "qffmpeghwaccel_mediacodec_p.h" +-#endif +-#include "qffmpeg_p.h" +-#include "qffmpegvideobuffer_p.h" +- +-#include +-#include +- +-/* Infrastructure for HW acceleration goes into this file. */ +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +- +-static const AVHWDeviceType preferredHardwareAccelerators[] = { +-#if defined(Q_OS_LINUX) +- AV_HWDEVICE_TYPE_VAAPI, +-// AV_HWDEVICE_TYPE_DRM, +-#elif defined (Q_OS_WIN) +- AV_HWDEVICE_TYPE_D3D11VA, +-#elif defined (Q_OS_DARWIN) +- AV_HWDEVICE_TYPE_VIDEOTOOLBOX, +-#elif defined (Q_OS_ANDROID) +- AV_HWDEVICE_TYPE_MEDIACODEC, +-#endif +-}; +- +-static AVBufferRef *loadHWContext(const AVHWDeviceType type) +-{ +- AVBufferRef *hwContext = nullptr; +- int ret = av_hwdevice_ctx_create(&hwContext, type, nullptr, nullptr, 0); +- qDebug() << " Checking HW context:" << av_hwdevice_get_type_name(type); +- if (ret == 0) { +- qDebug() << " Using above hw context."; +- return hwContext; +- } +- qDebug() << " Could not create hw context:" << ret << strerror(-ret); +- return nullptr; +-} +- +-static AVBufferRef *hardwareContextForCodec(const AVCodec *codec) +-{ +- qDebug() << "Checking HW acceleration for decoder" << codec->name; +- +- // First try our preferred accelerators. Those are the ones where we can +- // set up a zero copy pipeline +- for (auto type : preferredHardwareAccelerators) { +- for (int i = 0;; ++i) { +- const AVCodecHWConfig *config = avcodec_get_hw_config(codec, i); +- if (!config) +- break; +- if (config->device_type == type) { +- auto *hwContext = loadHWContext(config->device_type); +- if (hwContext) +- return hwContext; +- break; +- } +- } +- } +- +- // Ok, let's see if we can get any HW acceleration at all. It'll still involve one buffer copy, +- // as we can't move the data into RHI textures without a CPU copy +- for (int i = 0;; ++i) { +- const AVCodecHWConfig *config = avcodec_get_hw_config(codec, i); +- if (!config) +- break; +- +- auto *hwContext = loadHWContext(config->device_type); +- if (hwContext) +- return hwContext; +- } +- qDebug() << " No HW accelerators found, using SW decoding."; +- return nullptr; +- +-} +- +-// Used for the AVCodecContext::get_format callback +-AVPixelFormat getFormat(AVCodecContext *s, const AVPixelFormat *fmt) +-{ +- // First check HW accelerated codecs, the HW device context must be set +- if (s->hw_device_ctx) { +- auto *device_ctx = (AVHWDeviceContext*)s->hw_device_ctx->data; +- for (int i = 0; const AVCodecHWConfig *config = avcodec_get_hw_config(s->codec, i); i++) { +- if (!(config->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) +- continue; +- if (device_ctx->type != config->device_type) +- continue; +- for (int n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) { +- if (config->pix_fmt == fmt[n]) { +-#if QT_CONFIG(wmf) +- if (fmt[n] == AV_PIX_FMT_D3D11) +- QFFmpeg::D3D11TextureConverter::SetupDecoderTextures(s); +-#endif +-#ifdef Q_OS_ANDROID +- if (fmt[n] == AV_PIX_FMT_MEDIACODEC) +- QFFmpeg::MediaCodecTextureConverter::setupDecoderSurface(s); +-#endif +- return fmt[n]; +- } +- } +- } +- } +- +- // prefer video formats we can handle directly +- for (int n = 0; fmt[n] != AV_PIX_FMT_NONE; n++) { +- bool needsConversion = true; +- QFFmpegVideoBuffer::toQtPixelFormat(fmt[n], &needsConversion); +- if (!needsConversion) +- return fmt[n]; +- } +- +- // take the native format, this will involve one additional format conversion on the CPU side +- return *fmt; +-} +- +-TextureConverter::Data::~Data() +-{ +- delete backend; +-} +- +-HWAccel::~HWAccel() +-{ +- if (m_hwDeviceContext) +- av_buffer_unref(&m_hwDeviceContext); +- if (m_hwFramesContext) +- av_buffer_unref(&m_hwFramesContext); +-} +- +-std::unique_ptr HWAccel::create(const AVCodec *codec) +-{ +- if (codec->type == AVMEDIA_TYPE_VIDEO) { +- if (auto *ctx = hardwareContextForCodec(codec)) +- return std::unique_ptr(new HWAccel(ctx)); +- } +- return {}; +-} +- +-std::unique_ptr HWAccel::create(AVHWDeviceType deviceType) +-{ +- if (auto *ctx = loadHWContext(deviceType)) +- return std::unique_ptr(new HWAccel(ctx)); +- else +- return {}; +-} +- +-AVPixelFormat HWAccel::format(AVFrame *frame) +-{ +- if (!frame->hw_frames_ctx) +- return AVPixelFormat(frame->format); +- +- auto *hwFramesContext = (AVHWFramesContext *)frame->hw_frames_ctx->data; +- Q_ASSERT(hwFramesContext); +- return AVPixelFormat(hwFramesContext->sw_format); +-} +- +-std::pair HWAccel::preferredDeviceTypes() +-{ +- return { preferredHardwareAccelerators, +- sizeof(preferredHardwareAccelerators) / sizeof(AVHWDeviceType) }; +-} +- +-AVHWDeviceContext *HWAccel::hwDeviceContext() const +-{ +- return m_hwDeviceContext ? (AVHWDeviceContext *)m_hwDeviceContext->data : nullptr; +-} +- +-AVPixelFormat HWAccel::hwFormat() const +-{ +- switch (deviceType()) { +- case AV_HWDEVICE_TYPE_VIDEOTOOLBOX: +- return AV_PIX_FMT_VIDEOTOOLBOX; +- case AV_HWDEVICE_TYPE_VAAPI: +- return AV_PIX_FMT_VAAPI; +- case AV_HWDEVICE_TYPE_MEDIACODEC: +- return AV_PIX_FMT_MEDIACODEC; +- default: +- return AV_PIX_FMT_NONE; +- } +-} +- +-const AVCodec *HWAccel::hardwareDecoderForCodecId(AVCodecID id) +-{ +- const AVCodec *codec = nullptr; +-#ifdef Q_OS_ANDROID +- const auto getDecoder = [](AVCodecID id) { +- switch (id) { +- case AV_CODEC_ID_H264: +- return avcodec_find_decoder_by_name("h264_mediacodec"); +- case AV_CODEC_ID_HEVC: +- return avcodec_find_decoder_by_name("hevc_mediacodec"); +- case AV_CODEC_ID_MPEG2VIDEO: +- return avcodec_find_decoder_by_name("mpeg2_mediacodec"); +- case AV_CODEC_ID_MPEG4: +- return avcodec_find_decoder_by_name("mpeg4_mediacodec"); +- case AV_CODEC_ID_VP8: +- return avcodec_find_decoder_by_name("vp8_mediacodec"); +- case AV_CODEC_ID_VP9: +- return avcodec_find_decoder_by_name("vp9_mediacodec"); +- default: +- return avcodec_find_decoder(id); +- } +- }; +- codec = getDecoder(id); +-#endif +- +- if (!codec) +- codec = avcodec_find_decoder(id); +- +- return codec; +-} +- +-const AVCodec *HWAccel::hardwareEncoderForCodecId(AVCodecID id) const +-{ +- const char *codec = nullptr; +- switch (deviceType()) { +-#ifdef Q_OS_DARWIN +- case AV_HWDEVICE_TYPE_VIDEOTOOLBOX: +- switch (id) { +- case AV_CODEC_ID_H264: +- codec = "h264_videotoolbox"; +- break; +- case AV_CODEC_ID_HEVC: +- codec = "hevc_videotoolbox"; +- break; +- case AV_CODEC_ID_PRORES: +- codec = "prores_videotoolbox"; +- break; +- case AV_CODEC_ID_VP9: +- codec = "vp9_videotoolbox"; +- break; +- default: +- break; +- } +- break; +-#endif +- case AV_HWDEVICE_TYPE_VAAPI: +- switch (id) { +- case AV_CODEC_ID_H264: +- codec = "h264_vaapi"; +- break; +- case AV_CODEC_ID_HEVC: +- codec = "hevc_vaapi"; +- break; +- case AV_CODEC_ID_MJPEG: +- codec = "mjpeg_vaapi"; +- break; +- case AV_CODEC_ID_MPEG2VIDEO: +- codec = "mpeg2_vaapi"; +- break; +- case AV_CODEC_ID_VP8: +- codec = "vp8_vaapi"; +- break; +- case AV_CODEC_ID_VP9: +- codec = "vp9_vaapi"; +- break; +- default: +- break; +- } +- break; +- default: +- break; +- } +- if (!codec) +- return nullptr; +- const AVCodec *c = avcodec_find_encoder_by_name(codec); +- qDebug() << "searching for HW codec" << codec << "got" << c; +- return c; +-} +- +-std::unique_ptr HWAccel::findHardwareAccelForCodecID(AVCodecID id) +-{ +- for (auto type : preferredHardwareAccelerators) { +- auto accel = HWAccel::create(type); +- if (accel && accel->hardwareEncoderForCodecId(id)) +- return accel; +- } +- return {}; +-} +- +-AVHWDeviceType HWAccel::deviceType() const +-{ +- return m_hwDeviceContext ? hwDeviceContext()->type : AV_HWDEVICE_TYPE_NONE; +-} +- +-void HWAccel::createFramesContext(AVPixelFormat swFormat, const QSize &size) +-{ +- if (m_hwDeviceContext) +- return; +- m_hwFramesContext = av_hwframe_ctx_alloc(m_hwDeviceContext); +- auto *c = (AVHWFramesContext *)m_hwFramesContext->data; +- c->format = hwFormat(); +- c->sw_format = swFormat; +- c->width = size.width(); +- c->height = size.height(); +- qDebug() << "init frames context"; +- int err = av_hwframe_ctx_init(m_hwFramesContext); +- if (err < 0) +- qWarning() << "failed to init HW frame context" << err << err2str(err); +- else +- qDebug() << "Initialized frames context" << size << c->format << c->sw_format; +-} +- +-AVHWFramesContext *HWAccel::hwFramesContext() const +-{ +- return m_hwFramesContext ? (AVHWFramesContext *)m_hwFramesContext->data : nullptr; +-} +- +- +-TextureConverter::TextureConverter(QRhi *rhi) +- : d(new Data) +-{ +- d->rhi = rhi; +-} +- +-TextureSet *TextureConverter::getTextures(AVFrame *frame) +-{ +- if (!frame || isNull()) +- return nullptr; +- +- Q_ASSERT(frame->format == d->format); +- return d->backend->getTextures(frame); +-} +- +-void TextureConverter::updateBackend(AVPixelFormat fmt) +-{ +- d->backend = nullptr; +- if (!d->rhi) +- return; +- switch (fmt) { +-#if QT_CONFIG(vaapi) +- case AV_PIX_FMT_VAAPI: +- d->backend = new VAAPITextureConverter(d->rhi); +- break; +-#endif +-#ifdef Q_OS_DARWIN +- case AV_PIX_FMT_VIDEOTOOLBOX: +- d->backend = new VideoToolBoxTextureConverter(d->rhi); +- break; +-#endif +-#if QT_CONFIG(wmf) +- case AV_PIX_FMT_D3D11: +- d->backend = new D3D11TextureConverter(d->rhi); +- break; +-#endif +-#ifdef Q_OS_ANDROID +- case AV_PIX_FMT_MEDIACODEC: +- d->backend = new MediaCodecTextureConverter(d->rhi); +- break; +-#endif +- default: +- break; +- } +- d->format = fmt; +-} +- +-} // namespace QFFmpeg +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11.cpp b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11.cpp +deleted file mode 100644 +index f0a6c7b91..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11.cpp ++++ /dev/null +@@ -1,158 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpeghwaccel_d3d11_p.h" +- +-#include +-#include "qffmpegvideobuffer_p.h" +- +- +-#include +-#include +-#include +-#include +- +-#include +-#include +-#include +- +-#include +- +-QT_BEGIN_NAMESPACE +- +-Q_LOGGING_CATEGORY(qLcMediaFFmpegHWAccel, "qt.multimedia.hwaccel") +- +-namespace QFFmpeg { +- +-class D3D11TextureSet : public TextureSet +-{ +-public: +- D3D11TextureSet(QWindowsIUPointer &&tex) +- : m_tex(tex) +- {} +- +- qint64 textureHandle(int plane) override +- { +- return qint64(m_tex.get()); +- } +- +-private: +- QWindowsIUPointer m_tex; +-}; +- +- +-D3D11TextureConverter::D3D11TextureConverter(QRhi *rhi) +- : TextureConverterBackend(rhi) +-{ +-} +- +-static QWindowsIUPointer getSharedTextureForDevice(ID3D11Device *dev, ID3D11Texture2D *tex) +-{ +- QWindowsIUPointer dxgiResource; +- HRESULT hr = tex->QueryInterface(__uuidof(IDXGIResource), reinterpret_cast(dxgiResource.address())); +- if (FAILED(hr)) { +- qCDebug(qLcMediaFFmpegHWAccel) << "Failed to obtain resource handle from FFMpeg texture" << hr; +- return {}; +- } +- HANDLE shared = nullptr; +- hr = dxgiResource->GetSharedHandle(&shared); +- if (FAILED(hr)) { +- qCDebug(qLcMediaFFmpegHWAccel) << "Failed to obtain shared handle for FFmpeg texture" << hr; +- return {}; +- } +- +- QWindowsIUPointer sharedTex; +- hr = dev->OpenSharedResource(shared, __uuidof(ID3D11Texture2D), reinterpret_cast(sharedTex.address())); +- if (FAILED(hr)) +- qCDebug(qLcMediaFFmpegHWAccel) << "Failed to share FFmpeg texture" << hr; +- return sharedTex; +-} +- +-static QWindowsIUPointer copyTextureFromArray(ID3D11Device *dev, ID3D11Texture2D *array, int index) +-{ +- D3D11_TEXTURE2D_DESC arrayDesc = {}; +- array->GetDesc(&arrayDesc); +- +- D3D11_TEXTURE2D_DESC texDesc = {}; +- texDesc.Width = arrayDesc.Width; +- texDesc.Height = arrayDesc.Height; +- texDesc.Format = arrayDesc.Format; +- texDesc.ArraySize = 1; +- texDesc.MipLevels = 1; +- texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; +- texDesc.MiscFlags = 0; +- texDesc.SampleDesc = { 1, 0}; +- +- QWindowsIUPointer texCopy; +- HRESULT hr = dev->CreateTexture2D(&texDesc, nullptr, texCopy.address()); +- if (FAILED(hr)) { +- qCDebug(qLcMediaFFmpegHWAccel) << "Failed to create texture" << hr; +- return {}; +- } +- +- QWindowsIUPointer ctx; +- dev->GetImmediateContext(ctx.address()); +- ctx->CopySubresourceRegion(texCopy.get(), 0, 0, 0, 0, array, index, nullptr); +- +- return texCopy; +-} +- +-TextureSet *D3D11TextureConverter::getTextures(AVFrame *frame) +-{ +- if (!frame || !frame->hw_frames_ctx || frame->format != AV_PIX_FMT_D3D11) +- return nullptr; +- +- auto *fCtx = (AVHWFramesContext *)frame->hw_frames_ctx->data; +- auto *ctx = fCtx->device_ctx; +- if (!ctx || ctx->type != AV_HWDEVICE_TYPE_D3D11VA) +- return nullptr; +- +- auto nh = static_cast(rhi->nativeHandles()); +- if (!nh) +- return nullptr; +- +- auto ffmpegTex = (ID3D11Texture2D *)frame->data[0]; +- int index = (intptr_t)frame->data[1]; +- +- if (rhi->backend() == QRhi::D3D11) { +- auto dev = reinterpret_cast(nh->dev); +- if (!dev) +- return nullptr; +- auto sharedTex = getSharedTextureForDevice(dev, ffmpegTex); +- if (sharedTex) { +- auto tex = copyTextureFromArray(dev, sharedTex.get(), index); +- if (tex) { +- QVideoFrameFormat::PixelFormat format = QFFmpegVideoBuffer::toQtPixelFormat(AVPixelFormat(fCtx->sw_format)); +- return new D3D11TextureSet(std::move(tex)); +- } +- } +- } +- +- return nullptr; +-} +- +-void D3D11TextureConverter::SetupDecoderTextures(AVCodecContext *s) +-{ +- int ret = avcodec_get_hw_frames_parameters(s, +- s->hw_device_ctx, +- AV_PIX_FMT_D3D11, +- &s->hw_frames_ctx); +- if (ret < 0) { +- qCDebug(qLcMediaFFmpegHWAccel) << "Failed to allocate HW frames context" << ret; +- return; +- } +- +- auto *frames_ctx = (AVHWFramesContext *)s->hw_frames_ctx->data; +- auto *hwctx = (AVD3D11VAFramesContext *)frames_ctx->hwctx; +- hwctx->MiscFlags = D3D11_RESOURCE_MISC_SHARED; +- hwctx->BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE; +- ret = av_hwframe_ctx_init(s->hw_frames_ctx); +- if (ret < 0) { +- qCDebug(qLcMediaFFmpegHWAccel) << "Failed to initialize HW frames context" << ret; +- av_buffer_unref(&s->hw_frames_ctx); +- } +-} +- +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11_p.h b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11_p.h +deleted file mode 100644 +index 2e9c77f5b..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_d3d11_p.h ++++ /dev/null +@@ -1,43 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGHWACCEL_D3D11_P_H +-#define QFFMPEGHWACCEL_D3D11_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeghwaccel_p.h" +- +-#if QT_CONFIG(wmf) +- +-QT_BEGIN_NAMESPACE +- +-class QRhi; +- +-namespace QFFmpeg { +- +-class D3D11TextureConverter : public TextureConverterBackend +-{ +-public: +- D3D11TextureConverter(QRhi *rhi); +- +- TextureSet *getTextures(AVFrame *frame) override; +- +- static void SetupDecoderTextures(AVCodecContext *s); +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec.cpp b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec.cpp +deleted file mode 100644 +index 20a06c3ab..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec.cpp ++++ /dev/null +@@ -1,70 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpeghwaccel_mediacodec_p.h" +- +-#include +-#include +- +-extern "C" { +-#include +-} +- +-#if !defined(Q_OS_ANDROID) +-# error "Configuration error" +-#endif +- +-namespace QFFmpeg { +- +-Q_GLOBAL_STATIC(AndroidSurfaceTexture, androidSurfaceTexture, 0); +- +-class MediaCodecTextureSet : public TextureSet +-{ +-public: +- MediaCodecTextureSet(qint64 textureHandle) : handle(textureHandle) { } +- +- qint64 textureHandle(int plane) override { return (plane == 0) ? handle : 0; } +- +-private: +- qint64 handle; +-}; +- +-void MediaCodecTextureConverter::setupDecoderSurface(AVCodecContext *avCodecContext) +-{ +- AVMediaCodecContext *mediacodecContext = av_mediacodec_alloc_context(); +- av_mediacodec_default_init(avCodecContext, mediacodecContext, androidSurfaceTexture->surface()); +-} +- +-TextureSet *MediaCodecTextureConverter::getTextures(AVFrame *frame) +-{ +- if (!androidSurfaceTexture->isValid()) +- return {}; +- +- if (!externalTexture) { +- androidSurfaceTexture->detachFromGLContext(); +- externalTexture = std::unique_ptr( +- rhi->newTexture(QRhiTexture::Format::RGBA8, { frame->width, frame->height }, 1, +- QRhiTexture::ExternalOES)); +- +- if (!externalTexture->create()) { +- qWarning() << "Failed to create the external texture!"; +- return {}; +- } +- +- quint64 textureHandle = externalTexture->nativeTexture().object; +- androidSurfaceTexture->attachToGLContext(textureHandle); +- } +- +- // release a MediaCodec buffer and render it to the surface +- AVMediaCodecBuffer *buffer = (AVMediaCodecBuffer *)frame->data[3]; +- int result = av_mediacodec_release_buffer(buffer, 1); +- if (result < 0) { +- qWarning() << "Failed to render buffer to surface."; +- return {}; +- } +- +- androidSurfaceTexture->updateTexImage(); +- +- return new MediaCodecTextureSet(externalTexture->nativeTexture().object); +-} +-} +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec_p.h b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec_p.h +deleted file mode 100644 +index 95982ba4d..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_mediacodec_p.h ++++ /dev/null +@@ -1,35 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#ifndef QFFMPEGHWACCEL_MEDIACODEC_P_H +-#define QFFMPEGHWACCEL_MEDIACODEC_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeghwaccel_p.h" +-#include +- +-namespace QFFmpeg { +-struct Frame; +- +-class MediaCodecTextureConverter : public TextureConverterBackend +-{ +-public: +- MediaCodecTextureConverter(QRhi *rhi) : TextureConverterBackend(rhi){}; +- TextureSet *getTextures(AVFrame *frame) override; +- +- static void setupDecoderSurface(AVCodecContext *s); +-private: +- std::unique_ptr externalTexture; +-}; +-} +-#endif // QFFMPEGHWACCEL_MEDIACODEC_P_H +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_p.h b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_p.h +deleted file mode 100644 +index 81bb163bb..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_p.h ++++ /dev/null +@@ -1,121 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGHWACCEL_P_H +-#define QFFMPEGHWACCEL_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeg_p.h" +-#include "qvideoframeformat.h" +-#include +-#include +-#include +- +-QT_BEGIN_NAMESPACE +- +-class QRhi; +-class QRhiTexture; +-class QFFmpegVideoBuffer; +- +-namespace QFFmpeg { +- +-// used for the get_format callback for the decoder +-enum AVPixelFormat getFormat(struct AVCodecContext *s, const enum AVPixelFormat * fmt); +- +-class HWAccel; +- +-class TextureSet { +-public: +- // ### Should add QVideoFrameFormat::PixelFormat here +- virtual ~TextureSet() {} +- virtual qint64 textureHandle(int /*plane*/) { return 0; } +-}; +- +-class TextureConverterBackend +-{ +-public: +- TextureConverterBackend(QRhi *rhi) +- : rhi(rhi) +- {} +- virtual ~TextureConverterBackend() {} +- virtual TextureSet *getTextures(AVFrame * /*frame*/) { return nullptr; } +- +- QRhi *rhi = nullptr; +-}; +- +-class TextureConverter +-{ +- class Data final +- { +- public: +- ~Data(); +- QAtomicInt ref = 0; +- QRhi *rhi = nullptr; +- AVPixelFormat format = AV_PIX_FMT_NONE; +- TextureConverterBackend *backend = nullptr; +- }; +-public: +- TextureConverter(QRhi *rhi = nullptr); +- +- void init(AVFrame *frame) { +- AVPixelFormat fmt = frame ? AVPixelFormat(frame->format) : AV_PIX_FMT_NONE; +- if (fmt != d->format) +- updateBackend(fmt); +- } +- TextureSet *getTextures(AVFrame *frame); +- bool isNull() const { return !d->backend || !d->backend->rhi; } +- +-private: +- void updateBackend(AVPixelFormat format); +- +- QExplicitlySharedDataPointer d; +-}; +- +-class HWAccel +-{ +- AVBufferRef *m_hwDeviceContext = nullptr; +- AVBufferRef *m_hwFramesContext = nullptr; +- +-public: +- ~HWAccel(); +- +- static std::unique_ptr create(const AVCodec *decoder); +- static std::unique_ptr create(AVHWDeviceType deviceType); +- static std::unique_ptr findHardwareAccelForCodecID(AVCodecID id); +- +- static const AVCodec *hardwareDecoderForCodecId(AVCodecID id); +- const AVCodec *hardwareEncoderForCodecId(AVCodecID id) const; +- +- AVHWDeviceType deviceType() const; +- +- AVBufferRef *hwDeviceContextAsBuffer() const { return m_hwDeviceContext; } +- AVHWDeviceContext *hwDeviceContext() const; +- AVPixelFormat hwFormat() const; +- +- void createFramesContext(AVPixelFormat swFormat, const QSize &size); +- AVBufferRef *hwFramesContextAsBuffer() const { return m_hwFramesContext; } +- AVHWFramesContext *hwFramesContext() const; +- +- static AVPixelFormat format(AVFrame *frame); +- static std::pair preferredDeviceTypes(); +- +-private: +- HWAccel(AVBufferRef *hwDeviceContext, AVBufferRef *hwFrameContext = nullptr) +- : m_hwDeviceContext(hwDeviceContext), m_hwFramesContext(hwFrameContext) +- {} +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi.cpp b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi.cpp +deleted file mode 100644 +index 7b9976fe0..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi.cpp ++++ /dev/null +@@ -1,346 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpeghwaccel_vaapi_p.h" +- +-#if !QT_CONFIG(vaapi) +-#error "Configuration error" +-#endif +- +-#include +- +-#include +-#include "qffmpegvideobuffer_p.h" +-#include "private/qvideotexturehelper_p.h" +- +-#include +-#include +- +-#include +-#include +- +-#include +- +-//#define VA_EXPORT_USE_LAYERS +- +-#if __has_include("drm/drm_fourcc.h") +-#include +-#elif __has_include("libdrm/drm_fourcc.h") +-#include +-#else +-// keep things building without drm_fourcc.h +-#define fourcc_code(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ +- ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) +- +-#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ +-#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ +-#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ +-#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ +-#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ +-#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ +-#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ +-#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ +-#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ +-#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ +-#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ +-#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ +-#endif +- +-extern "C" { +-#include +-} +- +-#include +-#include +- +-#include +-#include +- +-#include +- +-#include +- +-namespace QFFmpeg { +- +-static const quint32 *fourccFromPixelFormat(const QVideoFrameFormat::PixelFormat format) +-{ +-#if G_BYTE_ORDER == G_LITTLE_ENDIAN +- const quint32 rgba_fourcc = DRM_FORMAT_ABGR8888; +- const quint32 rg_fourcc = DRM_FORMAT_GR88; +- const quint32 rg16_fourcc = DRM_FORMAT_GR1616; +-#else +- const quint32 rgba_fourcc = DRM_FORMAT_RGBA8888; +- const quint32 rg_fourcc = DRM_FORMAT_RG88; +- const quint32 rg16_fourcc = DRM_FORMAT_RG1616; +-#endif +- +-// qDebug() << "Getting DRM fourcc for pixel format" << format; +- +- switch (format) { +- case QVideoFrameFormat::Format_Invalid: +- case QVideoFrameFormat::Format_IMC1: +- case QVideoFrameFormat::Format_IMC2: +- case QVideoFrameFormat::Format_IMC3: +- case QVideoFrameFormat::Format_IMC4: +- case QVideoFrameFormat::Format_SamplerExternalOES: +- case QVideoFrameFormat::Format_Jpeg: +- case QVideoFrameFormat::Format_SamplerRect: +- return nullptr; +- +- case QVideoFrameFormat::Format_ARGB8888: +- case QVideoFrameFormat::Format_ARGB8888_Premultiplied: +- case QVideoFrameFormat::Format_XRGB8888: +- case QVideoFrameFormat::Format_BGRA8888: +- case QVideoFrameFormat::Format_BGRA8888_Premultiplied: +- case QVideoFrameFormat::Format_BGRX8888: +- case QVideoFrameFormat::Format_ABGR8888: +- case QVideoFrameFormat::Format_XBGR8888: +- case QVideoFrameFormat::Format_RGBA8888: +- case QVideoFrameFormat::Format_RGBX8888: +- case QVideoFrameFormat::Format_AYUV: +- case QVideoFrameFormat::Format_AYUV_Premultiplied: +- case QVideoFrameFormat::Format_UYVY: +- case QVideoFrameFormat::Format_YUYV: +- { +- static constexpr quint32 format[] = { rgba_fourcc, 0, 0, 0 }; +- return format; +- } +- +- case QVideoFrameFormat::Format_Y8: +- { +- static constexpr quint32 format[] = { DRM_FORMAT_R8, 0, 0, 0 }; +- return format; +- } +- case QVideoFrameFormat::Format_Y16: +- { +- static constexpr quint32 format[] = { DRM_FORMAT_R16, 0, 0, 0 }; +- return format; +- } +- +- case QVideoFrameFormat::Format_YUV420P: +- case QVideoFrameFormat::Format_YUV422P: +- case QVideoFrameFormat::Format_YV12: +- { +- static constexpr quint32 format[] = { DRM_FORMAT_R8, DRM_FORMAT_R8, DRM_FORMAT_R8, 0 }; +- return format; +- } +- case QVideoFrameFormat::Format_YUV420P10: +- { +- static constexpr quint32 format[] = { DRM_FORMAT_R16, DRM_FORMAT_R16, DRM_FORMAT_R16, 0 }; +- return format; +- } +- +- case QVideoFrameFormat::Format_NV12: +- case QVideoFrameFormat::Format_NV21: +- { +- static constexpr quint32 format[] = { DRM_FORMAT_R8, rg_fourcc, 0, 0 }; +- return format; +- } +- +- case QVideoFrameFormat::Format_P010: +- case QVideoFrameFormat::Format_P016: +- { +- static constexpr quint32 format[] = { DRM_FORMAT_R16, rg16_fourcc, 0, 0 }; +- return format; +- } +- } +- return nullptr; +-} +- +-class VAAPITextureSet : public TextureSet +-{ +-public: +- ~VAAPITextureSet(); +- qint64 textureHandle(int plane) override { +- return textures[plane]; +- } +- +- QRhi *rhi = nullptr; +- QOpenGLContext *glContext = nullptr; +- int nPlanes = 0; +- GLuint textures[4] = {}; +-}; +- +- +-VAAPITextureConverter::VAAPITextureConverter(QRhi *rhi) +- : TextureConverterBackend(nullptr) +-{ +- qDebug() << ">>>> Creating VAAPI HW accelerator"; +- +- if (!rhi || rhi->backend() != QRhi::OpenGLES2) { +- qWarning() << "VAAPITextureConverter: No rhi or non openGL based RHI"; +- this->rhi = nullptr; +- return; +- } +- +- auto *nativeHandles = static_cast(rhi->nativeHandles()); +- glContext = nativeHandles->context; +- if (!glContext) { +- qDebug() << " no GL context, disabling"; +- return; +- } +- const QString platform = QGuiApplication::platformName(); +- QPlatformNativeInterface *pni = QGuiApplication::platformNativeInterface(); +- eglDisplay = pni->nativeResourceForIntegration("egldisplay"); +- qDebug() << " platform is" << platform << eglDisplay; +- +- if (!eglDisplay) { +- qDebug() << " no egl display, disabling"; +- return; +- } +- eglImageTargetTexture2D = eglGetProcAddress("glEGLImageTargetTexture2DOES"); +- if (!eglDisplay) { +- qDebug() << " no eglImageTargetTexture2D, disabling"; +- return; +- } +- +- // everything ok, indicate that we can do zero copy +- this->rhi = rhi; +-} +- +-VAAPITextureConverter::~VAAPITextureConverter() +-{ +-} +- +-//#define VA_EXPORT_USE_LAYERS +-TextureSet *VAAPITextureConverter::getTextures(AVFrame *frame) +-{ +-// qDebug() << "VAAPIAccel::getTextures"; +- if (frame->format != AV_PIX_FMT_VAAPI || !eglDisplay) { +- qDebug() << "format/egl error" << frame->format << eglDisplay; +- return nullptr; +- } +- +- if (!frame->hw_frames_ctx) +- return nullptr; +- +- auto *fCtx = (AVHWFramesContext *)frame->hw_frames_ctx->data; +- auto *ctx = fCtx->device_ctx; +- if (!ctx) +- return nullptr; +- +- auto *vaCtx = (AVVAAPIDeviceContext *)ctx->hwctx; +- auto vaDisplay = vaCtx->display; +- if (!vaDisplay) { +- qDebug() << " no VADisplay, disabling"; +- return nullptr; +- } +- +- VASurfaceID vaSurface = (uintptr_t)frame->data[3]; +- +- VADRMPRIMESurfaceDescriptor prime; +- if (vaExportSurfaceHandle(vaDisplay, vaSurface, +- VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, +- VA_EXPORT_SURFACE_READ_ONLY | +-#ifdef VA_EXPORT_USE_LAYERS +- VA_EXPORT_SURFACE_SEPARATE_LAYERS, +-#else +- VA_EXPORT_SURFACE_COMPOSED_LAYERS, +-#endif +- &prime) != VA_STATUS_SUCCESS) +- { +- qWarning() << "vaExportSurfaceHandle failed"; +- return nullptr; +- } +- // ### Check that prime.fourcc is what we expect +- vaSyncSurface(vaDisplay, vaSurface); +- +-// qDebug() << "VAAPIAccel: vaSufraceDesc: width/height" << prime.width << prime.height << "num objects" +-// << prime.num_objects << "num layers" << prime.num_layers; +- +- QOpenGLFunctions functions(glContext); +- +- AVPixelFormat fmt = HWAccel::format(frame); +- bool needsConversion; +- auto qtFormat = QFFmpegVideoBuffer::toQtPixelFormat(fmt, &needsConversion); +- auto *drm_formats = fourccFromPixelFormat(qtFormat); +- if (!drm_formats || needsConversion) { +- qWarning() << "can't use DMA transfer for pixel format" << fmt << qtFormat; +- return nullptr; +- } +- +- auto *desc = QVideoTextureHelper::textureDescription(qtFormat); +- int nPlanes = 0; +- for (; nPlanes < 5; ++nPlanes) { +- if (drm_formats[nPlanes] == 0) +- break; +- } +- Q_ASSERT(nPlanes == desc->nplanes); +- nPlanes = desc->nplanes; +-// qDebug() << "VAAPIAccel: nPlanes" << nPlanes; +- +- rhi->makeThreadLocalNativeContextCurrent(); +- +- EGLImage images[4]; +- GLuint glTextures[4] = {}; +- functions.glGenTextures(nPlanes, glTextures); +- for (int i = 0; i < nPlanes; ++i) { +-#ifdef VA_EXPORT_USE_LAYERS +-#define LAYER i +-#define PLANE 0 +- if (prime.layers[i].drm_format != drm_formats[i]) { +- qWarning() << "expected DRM format check failed expected" +- << Qt::hex << drm_formats[i] << "got" << prime.layers[i].drm_format; +- } +-#else +-#define LAYER 0 +-#define PLANE i +-#endif +- +- EGLAttrib img_attr[] = { +- EGL_LINUX_DRM_FOURCC_EXT, (EGLint)drm_formats[i], +- EGL_WIDTH, desc->widthForPlane(frame->width, i), +- EGL_HEIGHT, desc->heightForPlane(frame->height, i), +- EGL_DMA_BUF_PLANE0_FD_EXT, prime.objects[prime.layers[LAYER].object_index[PLANE]].fd, +- EGL_DMA_BUF_PLANE0_OFFSET_EXT, (EGLint)prime.layers[LAYER].offset[PLANE], +- EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)prime.layers[LAYER].pitch[PLANE], +- EGL_NONE +- }; +- images[i] = eglCreateImage(eglDisplay, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, img_attr); +- if (!images[i]) { +- qWarning() << "eglCreateImage failed for plane" << i << Qt::hex << eglGetError(); +- return nullptr; +- } +- functions.glActiveTexture(GL_TEXTURE0 + i); +- functions.glBindTexture(GL_TEXTURE_2D, glTextures[i]); +- +- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC eglImageTargetTexture2D = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)this->eglImageTargetTexture2D; +- eglImageTargetTexture2D(GL_TEXTURE_2D, images[i]); +- if (glGetError()) { +- qWarning() << "eglImageTargetTexture2D failed"; +- } +- } +- +- for (int i = 0; i < (int)prime.num_objects; ++i) +- close(prime.objects[i].fd); +- +- for (int i = 0; i < nPlanes; ++i) { +- functions.glActiveTexture(GL_TEXTURE0 + i); +- functions.glBindTexture(GL_TEXTURE_2D, 0); +- eglDestroyImage(eglDisplay, images[i]); +- } +- +- VAAPITextureSet *textureSet = new VAAPITextureSet; +- textureSet->nPlanes = nPlanes; +- textureSet->rhi = rhi; +- textureSet->glContext = glContext; +- +- for (int i = 0; i < 4; ++i) +- textureSet->textures[i] = glTextures[i]; +-// qDebug() << "VAAPIAccel: got textures" << textures[0] << textures[1] << textures[2] << textures[3]; +- +- return textureSet; +-} +- +-VAAPITextureSet::~VAAPITextureSet() +-{ +- if (rhi) { +- rhi->makeThreadLocalNativeContextCurrent(); +- QOpenGLFunctions functions(glContext); +- functions.glDeleteTextures(nPlanes, textures); +- } +-} +- +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi_p.h b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi_p.h +deleted file mode 100644 +index 03084cc72..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_vaapi_p.h ++++ /dev/null +@@ -1,48 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGHWACCEL_VAAPI_P_H +-#define QFFMPEGHWACCEL_VAAPI_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeghwaccel_p.h" +- +-#if QT_CONFIG(vaapi) +- +-#include +- +-QT_BEGIN_NAMESPACE +- +-class QRhi; +-class QOpenGLContext; +- +-namespace QFFmpeg { +- +-class VAAPITextureConverter : public TextureConverterBackend +-{ +-public: +- VAAPITextureConverter(QRhi *rhi); +- ~VAAPITextureConverter(); +- +- TextureSet *getTextures(AVFrame *frame) override; +- +- Qt::HANDLE eglDisplay = nullptr; +- QOpenGLContext *glContext = nullptr; +- QFunctionPointer eglImageTargetTexture2D = nullptr; +-}; +-} +- +-QT_END_NAMESPACE +- +-#endif +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm +deleted file mode 100644 +index db64f2003..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox.mm ++++ /dev/null +@@ -1,281 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpeghwaccel_videotoolbox_p.h" +- +-#if !defined(Q_OS_DARWIN) +-#error "Configuration error" +-#endif +- +-#include +-#include +-#include "private/qvideotexturehelper_p.h" +- +-#include +-#include +-#include +- +-#include +-#include +- +-#include +-#ifdef Q_OS_MACOS +-#import +-#endif +-#import +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg +-{ +- +-static CVMetalTextureCacheRef &mtc(void *&cache) { return reinterpret_cast(cache); } +- +-class VideoToolBoxTextureSet : public TextureSet +-{ +-public: +- ~VideoToolBoxTextureSet(); +- qint64 textureHandle(int plane) override; +- +- QRhi *rhi = nullptr; +- CVMetalTextureRef cvMetalTexture[3] = {}; +- +-#if defined(Q_OS_MACOS) +- CVOpenGLTextureRef cvOpenGLTexture = nullptr; +-#elif defined(Q_OS_IOS) +- CVOpenGLESTextureRef cvOpenGLESTexture = nullptr; +-#endif +- +- CVImageBufferRef m_buffer = nullptr; +-}; +- +-VideoToolBoxTextureConverter::VideoToolBoxTextureConverter(QRhi *rhi) +- : TextureConverterBackend(rhi) +-{ +- if (!rhi) +- return; +- +- if (rhi->backend() == QRhi::Metal) { +- qDebug() << " using metal backend"; +- const auto *metal = static_cast(rhi->nativeHandles()); +- +- // Create a Metal Core Video texture cache from the pixel buffer. +- Q_ASSERT(!cvMetalTextureCache); +- if (CVMetalTextureCacheCreate( +- kCFAllocatorDefault, +- nil, +- (id)metal->dev, +- nil, +- &mtc(cvMetalTextureCache)) != kCVReturnSuccess) { +- qWarning() << "Metal texture cache creation failed"; +- rhi = nullptr; +- } +- } else if (rhi->backend() == QRhi::OpenGLES2) { +-#if QT_CONFIG(opengl) +-#ifdef Q_OS_MACOS +- const auto *gl = static_cast(rhi->nativeHandles()); +- +- auto nsGLContext = gl->context->nativeInterface()->nativeContext(); +- auto nsGLPixelFormat = nsGLContext.pixelFormat.CGLPixelFormatObj; +- +- // Create an OpenGL CoreVideo texture cache from the pixel buffer. +- if (CVOpenGLTextureCacheCreate( +- kCFAllocatorDefault, +- nullptr, +- reinterpret_cast(nsGLContext.CGLContextObj), +- nsGLPixelFormat, +- nil, +- &cvOpenGLTextureCache)) { +- qWarning() << "OpenGL texture cache creation failed"; +- rhi = nullptr; +- } +-#endif +-#ifdef Q_OS_IOS +- // Create an OpenGL CoreVideo texture cache from the pixel buffer. +- if (CVOpenGLESTextureCacheCreate( +- kCFAllocatorDefault, +- nullptr, +- [EAGLContext currentContext], +- nullptr, +- &cvOpenGLESTextureCache)) { +- qWarning() << "OpenGL texture cache creation failed"; +- rhi = nullptr; +- } +-#endif +-#else +- rhi = nullptr; +-#endif // QT_CONFIG(opengl) +- } +-} +- +-VideoToolBoxTextureConverter::~VideoToolBoxTextureConverter() +-{ +- freeTextureCaches(); +-} +- +-void VideoToolBoxTextureConverter::freeTextureCaches() +-{ +- if (cvMetalTextureCache) +- CFRelease(cvMetalTextureCache); +- cvMetalTextureCache = nullptr; +-#if defined(Q_OS_MACOS) +- if (cvOpenGLTextureCache) +- CFRelease(cvOpenGLTextureCache); +- cvOpenGLTextureCache = nullptr; +-#elif defined(Q_OS_IOS) +- if (cvOpenGLESTextureCache) +- CFRelease(cvOpenGLESTextureCache); +- cvOpenGLESTextureCache = nullptr; +-#endif +-} +- +-static MTLPixelFormat rhiTextureFormatToMetalFormat(QRhiTexture::Format f) +-{ +- switch (f) { +- default: +- case QRhiTexture::UnknownFormat: +- return MTLPixelFormatInvalid; +- case QRhiTexture::RGBA8: +- return MTLPixelFormatRGBA8Unorm; +- case QRhiTexture::BGRA8: +- return MTLPixelFormatBGRA8Unorm; +- case QRhiTexture::R8: +- return MTLPixelFormatR8Unorm; +- case QRhiTexture::RG8: +- return MTLPixelFormatRG8Unorm; +- case QRhiTexture::R16: +- return MTLPixelFormatR16Unorm; +- case QRhiTexture::RG16: +- return MTLPixelFormatRG16Unorm; +- +- case QRhiTexture::RGBA16F: +- return MTLPixelFormatRGBA16Float; +- case QRhiTexture::RGBA32F: +- return MTLPixelFormatRGBA32Float; +- case QRhiTexture::R16F: +- return MTLPixelFormatR16Float; +- case QRhiTexture::R32F: +- return MTLPixelFormatR32Float; +- } +-} +- +-TextureSet *VideoToolBoxTextureConverter::getTextures(AVFrame *frame) +-{ +- if (!rhi) +- return nullptr; +- +- bool needsConversion = false; +- QVideoFrameFormat::PixelFormat pixelFormat = QFFmpegVideoBuffer::toQtPixelFormat(HWAccel::format(frame), &needsConversion); +- if (needsConversion) { +- qDebug() << "XXXXXXXXXXXX pixel format needs conversion" << pixelFormat << HWAccel::format(frame); +- return nullptr; +- } +- +- CVPixelBufferRef buffer = (CVPixelBufferRef)frame->data[3]; +- +- VideoToolBoxTextureSet *textureSet = new VideoToolBoxTextureSet; +- textureSet->m_buffer = buffer; +- textureSet->rhi = rhi; +- CVPixelBufferRetain(buffer); +- +- auto *textureDescription = QVideoTextureHelper::textureDescription(pixelFormat); +- int bufferPlanes = CVPixelBufferGetPlaneCount(buffer); +-// qDebug() << "XXXXX getTextures" << pixelFormat << bufferPlanes << buffer; +- +- if (rhi->backend() == QRhi::Metal) { +- for (int plane = 0; plane < bufferPlanes; ++plane) { +- size_t width = CVPixelBufferGetWidth(buffer); +- size_t height = CVPixelBufferGetHeight(buffer); +- width = textureDescription->widthForPlane(width, plane); +- height = textureDescription->heightForPlane(height, plane); +- +- // Create a CoreVideo pixel buffer backed Metal texture image from the texture cache. +- auto ret = CVMetalTextureCacheCreateTextureFromImage( +- kCFAllocatorDefault, +- mtc(cvMetalTextureCache), +- buffer, nil, +- rhiTextureFormatToMetalFormat(textureDescription->textureFormat[plane]), +- width, height, +- plane, +- &textureSet->cvMetalTexture[plane]); +- +- if (ret != kCVReturnSuccess) +- qWarning() << "texture creation failed" << ret; +-// auto t = CVMetalTextureGetTexture(textureSet->cvMetalTexture[plane]); +-// qDebug() << " metal texture for plane" << plane << "is" << quint64(textureSet->cvMetalTexture[plane]) << width << height; +-// qDebug() << " " << t.iosurfacePlane << t.pixelFormat << t.width << t.height; +- } +- } else if (rhi->backend() == QRhi::OpenGLES2) { +-#if QT_CONFIG(opengl) +-#ifdef Q_OS_MACOS +- CVOpenGLTextureCacheFlush(cvOpenGLTextureCache, 0); +- // Create a CVPixelBuffer-backed OpenGL texture image from the texture cache. +- const CVReturn cvret = CVOpenGLTextureCacheCreateTextureFromImage( +- kCFAllocatorDefault, +- cvOpenGLTextureCache, +- buffer, +- nil, +- &textureSet->cvOpenGLTexture); +- if (cvret != kCVReturnSuccess) +- qWarning() << "OpenGL texture creation failed" << cvret; +- +- Q_ASSERT(CVOpenGLTextureGetTarget(textureSet->cvOpenGLTexture) == GL_TEXTURE_RECTANGLE); +-#endif +-#ifdef Q_OS_IOS +- CVOpenGLESTextureCacheFlush(cvOpenGLESTextureCache, 0); +- // Create a CVPixelBuffer-backed OpenGL texture image from the texture cache. +- const CVReturn cvret = CVOpenGLESTextureCacheCreateTextureFromImage( +- kCFAllocatorDefault, +- cvOpenGLESTextureCache, +- buffer, +- nil, +- GL_TEXTURE_2D, +- GL_RGBA, +- CVPixelBufferGetWidth(buffer), +- CVPixelBufferGetHeight(buffer), +- GL_RGBA, +- GL_UNSIGNED_BYTE, +- 0, +- &textureSet->cvOpenGLESTexture); +- if (cvret != kCVReturnSuccess) +- qWarning() << "OpenGL ES texture creation failed" << cvret; +-#endif +-#endif +- } +- +- return textureSet; +-} +- +-VideoToolBoxTextureSet::~VideoToolBoxTextureSet() +-{ +- for (int i = 0; i < 4; ++i) +- if (cvMetalTexture[i]) +- CFRelease(cvMetalTexture[i]); +-#if defined(Q_OS_MACOS) +- if (cvOpenGLTexture) +- CVOpenGLTextureRelease(cvOpenGLTexture); +-#elif defined(Q_OS_IOS) +- if (cvOpenGLESTexture) +- CFRelease(cvOpenGLESTexture); +-#endif +- CVPixelBufferRelease(m_buffer); +-} +- +-qint64 VideoToolBoxTextureSet::textureHandle(int plane) +-{ +- if (rhi->backend() == QRhi::Metal) +- return cvMetalTexture[plane] ? qint64(CVMetalTextureGetTexture(cvMetalTexture[plane])) : 0; +-#if QT_CONFIG(opengl) +- Q_ASSERT(plane == 0); +-#ifdef Q_OS_MACOS +- return CVOpenGLTextureGetName(cvOpenGLTexture); +-#endif +-#ifdef Q_OS_IOS +- return CVOpenGLESTextureGetName(cvOpenGLESTexture); +-#endif +-#endif +-} +- +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox_p.h b/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox_p.h +deleted file mode 100644 +index 44fa32dd2..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpeghwaccel_videotoolbox_p.h ++++ /dev/null +@@ -1,63 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGHWACCEL_VIDEOTOOLBOX_P_H +-#define QFFMPEGHWACCEL_VIDEOTOOLBOX_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeghwaccel_p.h" +- +-#ifdef Q_OS_DARWIN +- +-#include +-#include +-#include +- +-#include +-#if defined(Q_OS_MACOS) +-#include +-#elif defined(Q_OS_IOS) +-#include +-#endif +- +-QT_BEGIN_NAMESPACE +- +-class QRhi; +- +-namespace QFFmpeg { +- +-class VideoToolBoxTextureConverter : public TextureConverterBackend +-{ +-public: +- VideoToolBoxTextureConverter(QRhi *rhi); +- ~VideoToolBoxTextureConverter(); +- TextureSet *getTextures(AVFrame *frame) override; +- +-private: +- void freeTextureCaches(); +- +- // can not forward declare that type from C++ :/ +- void *cvMetalTextureCache = nullptr; +-#if defined(Q_OS_MACOS) +- CVOpenGLTextureCacheRef cvOpenGLTextureCache = nullptr; +-#elif defined(Q_OS_IOS) +- CVOpenGLESTextureCacheRef cvOpenGLESTextureCache = nullptr; +-#endif +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession.cpp b/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession.cpp +index 3d5fbc039..b6865761c 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession.cpp ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession.cpp +@@ -6,7 +6,6 @@ + #include "private/qplatformaudioinput_p.h" + #include "private/qplatformaudiooutput_p.h" + #include "qffmpegimagecapture_p.h" +-#include "qffmpegmediarecorder_p.h" + #include "private/qplatformcamera_p.h" + #include "qvideosink.h" + +@@ -73,22 +72,12 @@ void QFFmpegMediaCaptureSession::setImageCapture(QPlatformImageCapture *imageCap + + void QFFmpegMediaCaptureSession::setMediaRecorder(QPlatformMediaRecorder *recorder) + { +- auto *r = static_cast(recorder); +- if (m_mediaRecorder == r) +- return; +- +- if (m_mediaRecorder) +- m_mediaRecorder->setCaptureSession(nullptr); +- m_mediaRecorder = r; +- if (m_mediaRecorder) +- m_mediaRecorder->setCaptureSession(this); +- +- emit encoderChanged(); ++ return; + } + + QPlatformMediaRecorder *QFFmpegMediaCaptureSession::mediaRecorder() + { +- return m_mediaRecorder; ++ return nullptr; + } + + void QFFmpegMediaCaptureSession::setAudioInput(QPlatformAudioInput *input) +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession_p.h b/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession_p.h +index 9e9c77551..858a537cc 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession_p.h ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediacapturesession_p.h +@@ -54,7 +54,6 @@ private: + QPlatformCamera *m_camera = nullptr; + QPlatformAudioInput *m_audioInput = nullptr; + QFFmpegImageCapture *m_imageCapture = nullptr; +- QFFmpegMediaRecorder *m_mediaRecorder = nullptr; + QPlatformAudioOutput *m_audioOutput = nullptr; + QVideoSink *m_videoSink = nullptr; + }; +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo.cpp b/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo.cpp +index 2561d564d..00b838d50 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo.cpp ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo.cpp +@@ -2,236 +2,13 @@ + // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + #include "qffmpegmediaformatinfo_p.h" +-#include "qffmpeg_p.h" + #include "qaudioformat.h" + #include "qimagewriter.h" + + QT_BEGIN_NAMESPACE + +-static struct { +- AVCodecID id; +- QMediaFormat::VideoCodec codec; +-} videoCodecMap [] = { +- { AV_CODEC_ID_MPEG1VIDEO, QMediaFormat::VideoCodec::MPEG1 }, +- { AV_CODEC_ID_MPEG2VIDEO, QMediaFormat::VideoCodec::MPEG2 }, +- { AV_CODEC_ID_MPEG4, QMediaFormat::VideoCodec::MPEG4 }, +- { AV_CODEC_ID_H264, QMediaFormat::VideoCodec::H264 }, +- { AV_CODEC_ID_HEVC, QMediaFormat::VideoCodec::H265 }, +- { AV_CODEC_ID_VP8, QMediaFormat::VideoCodec::VP8 }, +- { AV_CODEC_ID_VP9, QMediaFormat::VideoCodec::VP9 }, +- { AV_CODEC_ID_AV1, QMediaFormat::VideoCodec::AV1 }, +- { AV_CODEC_ID_THEORA, QMediaFormat::VideoCodec::Theora }, +- { AV_CODEC_ID_WMV3, QMediaFormat::VideoCodec::WMV }, +- { AV_CODEC_ID_MJPEG, QMediaFormat::VideoCodec::MotionJPEG } +-}; +- +-static AVCodecID codecId(QMediaFormat::VideoCodec codec) +-{ +- for (const auto &c : videoCodecMap) { +- if (c.codec == codec) +- return c.id; +- } +- return AV_CODEC_ID_NONE; +-} +- +-static struct { +- AVCodecID id; +- QMediaFormat::AudioCodec codec; +-} audioCodecMap [] = { +- { AV_CODEC_ID_MP3, QMediaFormat::AudioCodec::MP3 }, +- { AV_CODEC_ID_AAC, QMediaFormat::AudioCodec::AAC }, +- { AV_CODEC_ID_AC3, QMediaFormat::AudioCodec::AC3 }, +- { AV_CODEC_ID_EAC3, QMediaFormat::AudioCodec::EAC3 }, +- { AV_CODEC_ID_FLAC, QMediaFormat::AudioCodec::FLAC }, +- { AV_CODEC_ID_TRUEHD, QMediaFormat::AudioCodec::DolbyTrueHD }, +- { AV_CODEC_ID_OPUS, QMediaFormat::AudioCodec::Opus }, +- { AV_CODEC_ID_VORBIS, QMediaFormat::AudioCodec::Vorbis }, +- { AV_CODEC_ID_PCM_S16LE, QMediaFormat::AudioCodec::Wave }, +- { AV_CODEC_ID_WMAPRO, QMediaFormat::AudioCodec::WMA }, +- { AV_CODEC_ID_ALAC, QMediaFormat::AudioCodec::ALAC } +-}; +- +-static AVCodecID codecId(QMediaFormat::AudioCodec codec) +-{ +- for (const auto &c : audioCodecMap) { +- if (c.codec == codec) +- return c.id; +- } +- return AV_CODEC_ID_NONE; +-} +- +-// mimetypes are mostly copied from qmediaformat.cpp. Unfortunately, FFmpeg uses +-// in some cases slightly different mimetypes +-static const struct +-{ +- QMediaFormat::FileFormat fileFormat; +- const char *mimeType; +- const char *name; // disambiguate if we have several muxers/demuxers +-} map[QMediaFormat::LastFileFormat + 1] = { +- { QMediaFormat::WMV, "video/x-ms-asf", "asf" }, +- { QMediaFormat::AVI, "video/x-msvideo", nullptr }, +- { QMediaFormat::Matroska, "video/x-matroska", nullptr }, +- { QMediaFormat::MPEG4, "video/mp4", "mp4" }, +- { QMediaFormat::Ogg, "video/ogg", nullptr }, +- // QuickTime is the same as MP4 +- { QMediaFormat::WebM, "video/webm", "webm" }, +- // Audio Formats +- // Mpeg4Audio is the same as MP4 without the video codecs +- { QMediaFormat::AAC, "audio/aac", nullptr }, +- // WMA is the same as WMV +- { QMediaFormat::FLAC, "audio/x-flac", nullptr }, +- { QMediaFormat::MP3, "audio/mpeg", "mp3" }, +- { QMediaFormat::Wave, "audio/x-wav", nullptr }, +- { QMediaFormat::UnspecifiedFormat, nullptr, nullptr } +-}; +- +-template +-static QMediaFormat::FileFormat formatForAVFormat(AVFormat *format) +-{ +- +- if (!format->mime_type || !*format->mime_type) +- return QMediaFormat::UnspecifiedFormat; +- +- auto *m = map; +- while (m->fileFormat != QMediaFormat::UnspecifiedFormat) { +- if (m->mimeType && !strcmp(m->mimeType, format->mime_type)) { +- // check if the name matches. This is used to disambiguate where FFmpeg provides +- // multiple muxers or demuxers +- if (!m->name || !strcmp(m->name, format->name)) +- return m->fileFormat; +- } +- ++m; +- } +- +- return QMediaFormat::UnspecifiedFormat; +-} +- +-static const AVOutputFormat *avFormatForFormat(QMediaFormat::FileFormat format) +-{ +- if (format == QMediaFormat::QuickTime || format == QMediaFormat::Mpeg4Audio) +- format = QMediaFormat::MPEG4; +- if (format == QMediaFormat::WMA) +- format = QMediaFormat::WMV; +- +- auto *m = map; +- while (m->fileFormat != QMediaFormat::UnspecifiedFormat) { +- if (m->fileFormat == format) +- return av_guess_format(m->name, nullptr, m->mimeType); +- ++m; +- } +- +- return nullptr; +-} +- +- + QFFmpegMediaFormatInfo::QFFmpegMediaFormatInfo() + { +- qDebug() << ">>>> listing codecs"; +- +- QList audioEncoders; +- QList extraAudioDecoders; +- QList videoEncoders; +- QList extraVideoDecoders; +- +- const AVCodecDescriptor *descriptor = nullptr; +- while ((descriptor = avcodec_descriptor_next(descriptor))) { +- bool canEncode = (avcodec_find_encoder(descriptor->id) != nullptr); +- bool canDecode = (avcodec_find_decoder(descriptor->id) != nullptr); +- auto videoCodec = videoCodecForAVCodecId(descriptor->id); +- auto audioCodec = audioCodecForAVCodecId(descriptor->id); +- if (descriptor->type == AVMEDIA_TYPE_VIDEO && videoCodec != QMediaFormat::VideoCodec::Unspecified) { +- if (canEncode) { +- if (!videoEncoders.contains(videoCodec)) +- videoEncoders.append(videoCodec); +- } else if (canDecode) { +- if (!extraVideoDecoders.contains(videoCodec)) +- extraVideoDecoders.append(videoCodec); +- } +- } +- +- else if (descriptor->type == AVMEDIA_TYPE_AUDIO && audioCodec != QMediaFormat::AudioCodec::Unspecified) { +- if (canEncode) { +- if (!audioEncoders.contains(audioCodec)) +- audioEncoders.append(audioCodec); +- } else if (canDecode) { +- if (!extraAudioDecoders.contains(audioCodec)) +- extraAudioDecoders.append(audioCodec); +- } +- } +- } +- +- // get demuxers +-// qDebug() << ">>>> Muxers"; +- void *opaque = nullptr; +- const AVOutputFormat *outputFormat = nullptr; +- while ((outputFormat = av_muxer_iterate(&opaque))) { +- auto mediaFormat = formatForAVFormat(outputFormat); +- if (mediaFormat == QMediaFormat::UnspecifiedFormat) +- continue; +-// qDebug() << " mux:" << outputFormat->name << outputFormat->long_name << outputFormat->mime_type << outputFormat->extensions << mediaFormat; +- +- CodecMap encoder; +- encoder.format = mediaFormat; +- +- for (auto codec : audioEncoders) { +- auto id = codecId(codec); +- // only add the codec if it can be used with this container +- if (avformat_query_codec(outputFormat, id, FF_COMPLIANCE_NORMAL) == 1) { +- // add codec for container +-// qDebug() << " " << codec << Qt::hex << av_codec_get_tag(outputFormat->codec_tag, id); +- encoder.audio.append(codec); +- } +- } +- for (auto codec : videoEncoders) { +- auto id = codecId(codec); +- // only add the codec if it can be used with this container +- if (avformat_query_codec(outputFormat, id, FF_COMPLIANCE_NORMAL) == 1) { +- // add codec for container +-// qDebug() << " " << codec << Qt::hex << av_codec_get_tag(outputFormat->codec_tag, id); +- encoder.video.append(codec); +- } +- } +- +- // sanity checks and handling special cases +- if (encoder.audio.isEmpty() && encoder.video.isEmpty()) +- continue; +- switch (encoder.format) { +- case QMediaFormat::WMV: +- // add WMA +- encoders.append({ QMediaFormat::WMA, encoder.audio, {} }); +- break; +- case QMediaFormat::MPEG4: +- // add Mpeg4Audio and QuickTime +- encoders.append({ QMediaFormat::QuickTime, encoder.audio, encoder.video }); +- encoders.append({ QMediaFormat::Mpeg4Audio, encoder.audio, {} }); +- break; +- case QMediaFormat::Wave: +- // FFmpeg allows other encoded formats in WAV containers, but we do not want that +- if (!encoder.audio.contains(QMediaFormat::AudioCodec::Wave)) +- continue; +- encoder.audio = { QMediaFormat::AudioCodec::Wave }; +- break; +- default: +- break; +- } +- encoders.append(encoder); +- } +- +- // FFmpeg doesn't allow querying supported codecs for decoders +- // we take a simple approximation stating that we can decode what we +- // can encode. That's a safe subset. +- decoders = encoders; +- +-// qDebug() << "extraDecoders:" << extraAudioDecoders << extraVideoDecoders; +- // FFmpeg can currently only decode WMA and WMV, not encode +- if (extraAudioDecoders.contains(QMediaFormat::AudioCodec::WMA)) { +- decoders[QMediaFormat::WMA].audio.append(QMediaFormat::AudioCodec::WMA); +- decoders[QMediaFormat::WMV].audio.append(QMediaFormat::AudioCodec::WMA); +- } +- if (extraVideoDecoders.contains(QMediaFormat::VideoCodec::WMV)) { +- decoders[QMediaFormat::WMV].video.append(QMediaFormat::VideoCodec::WMV); +- } +- + // Add image formats we support. We currently simply use Qt's built-in image write + // to save images. That doesn't give us HDR support or support for larger bit depths, + // but most cameras can currently not generate those anyway. +@@ -251,256 +28,5 @@ QFFmpegMediaFormatInfo::QFFmpegMediaFormatInfo() + + QFFmpegMediaFormatInfo::~QFFmpegMediaFormatInfo() = default; + +-QMediaFormat::AudioCodec QFFmpegMediaFormatInfo::audioCodecForAVCodecId(AVCodecID id) +-{ +- for (const auto &c : audioCodecMap) { +- if (c.id == id) +- return c.codec; +- } +- return QMediaFormat::AudioCodec::Unspecified; +-} +- +-QMediaFormat::VideoCodec QFFmpegMediaFormatInfo::videoCodecForAVCodecId(AVCodecID id) +-{ +- for (const auto &c : videoCodecMap) { +- if (c.id == id) +- return c.codec; +- } +- return QMediaFormat::VideoCodec::Unspecified; +-} +- +-QMediaFormat::FileFormat +-QFFmpegMediaFormatInfo::fileFormatForAVInputFormat(const AVInputFormat *format) +-{ +- // Seems like FFmpeg uses different names for muxers and demuxers of the same format. +- // that makes it somewhat cumbersome to detect things correctly. +- // The input formats have a comma separated list of short names. We check the first one of those +- // as the docs specify that you only append to the list +- static const struct +- { +- QMediaFormat::FileFormat fileFormat; +- const char *name; +- } map[QMediaFormat::LastFileFormat + 1] = { +- { QMediaFormat::WMV, "asf" }, +- { QMediaFormat::AVI, "avi" }, +- { QMediaFormat::Matroska, "matroska" }, +- { QMediaFormat::MPEG4, "mov" }, +- { QMediaFormat::Ogg, "ogg" }, +- { QMediaFormat::WebM, "webm" }, +- // Audio Formats +- // Mpeg4Audio is the same as MP4 without the video codecs +- { QMediaFormat::AAC, "aac"}, +- // WMA is the same as WMV +- { QMediaFormat::FLAC, "flac" }, +- { QMediaFormat::MP3, "mp3" }, +- { QMediaFormat::Wave, "wav" }, +- { QMediaFormat::UnspecifiedFormat, nullptr } +- }; +- +- if (!format->name) +- return QMediaFormat::UnspecifiedFormat; +- +- auto *m = map; +- while (m->fileFormat != QMediaFormat::UnspecifiedFormat) { +- if (!strncmp(m->name, format->name, strlen(m->name))) +- return m->fileFormat; +- ++m; +- } +- +- return QMediaFormat::UnspecifiedFormat; +-} +- +-const AVOutputFormat * +-QFFmpegMediaFormatInfo::outputFormatForFileFormat(QMediaFormat::FileFormat format) +-{ +- return avFormatForFormat(format); +-} +- +-AVCodecID QFFmpegMediaFormatInfo::codecIdForVideoCodec(QMediaFormat::VideoCodec codec) +-{ +- return codecId(codec); +-} +- +-AVCodecID QFFmpegMediaFormatInfo::codecIdForAudioCodec(QMediaFormat::AudioCodec codec) +-{ +- return codecId(codec); +-} +- +-QAudioFormat::SampleFormat QFFmpegMediaFormatInfo::sampleFormat(AVSampleFormat format) +-{ +- switch (format) { +- case AV_SAMPLE_FMT_NONE: +- default: +- return QAudioFormat::Unknown; +- case AV_SAMPLE_FMT_U8: ///< unsigned 8 bits +- case AV_SAMPLE_FMT_U8P: ///< unsigned 8 bits: planar +- return QAudioFormat::UInt8; +- case AV_SAMPLE_FMT_S16: ///< signed 16 bits +- case AV_SAMPLE_FMT_S16P: ///< signed 16 bits: planar +- return QAudioFormat::Int16; +- case AV_SAMPLE_FMT_S32: ///< signed 32 bits +- case AV_SAMPLE_FMT_S32P: ///< signed 32 bits: planar +- return QAudioFormat::Int32; +- case AV_SAMPLE_FMT_FLT: ///< float +- case AV_SAMPLE_FMT_FLTP: ///< float: planar +- return QAudioFormat::Float; +- case AV_SAMPLE_FMT_DBL: ///< double +- case AV_SAMPLE_FMT_DBLP: ///< double: planar +- case AV_SAMPLE_FMT_S64: ///< signed 64 bits +- case AV_SAMPLE_FMT_S64P: ///< signed 64 bits, planar +- // let's use float +- return QAudioFormat::Float; +- } +-} +- +-AVSampleFormat QFFmpegMediaFormatInfo::avSampleFormat(QAudioFormat::SampleFormat format) +-{ +- switch (format) { +- case QAudioFormat::UInt8: +- return AV_SAMPLE_FMT_U8; +- case QAudioFormat::Int16: +- return AV_SAMPLE_FMT_S16; +- case QAudioFormat::Int32: +- return AV_SAMPLE_FMT_S32; +- case QAudioFormat::Float: +- return AV_SAMPLE_FMT_FLT; +- default: +- return AV_SAMPLE_FMT_NONE; +- } +-} +- +-int64_t QFFmpegMediaFormatInfo::avChannelLayout(QAudioFormat::ChannelConfig channelConfig) +-{ +- int64_t avChannelLayout = 0; +- if (channelConfig & (1 << QAudioFormat::FrontLeft)) +- avChannelLayout |= AV_CH_FRONT_LEFT; +- if (channelConfig & (1 << QAudioFormat::FrontRight)) +- avChannelLayout |= AV_CH_FRONT_RIGHT; +- if (channelConfig & (1 << QAudioFormat::FrontCenter)) +- avChannelLayout |= AV_CH_FRONT_CENTER; +- if (channelConfig & (1 << QAudioFormat::LFE)) +- avChannelLayout |= AV_CH_LOW_FREQUENCY; +- if (channelConfig & (1 << QAudioFormat::BackLeft)) +- avChannelLayout |= AV_CH_BACK_LEFT; +- if (channelConfig & (1 << QAudioFormat::BackRight)) +- avChannelLayout |= AV_CH_BACK_RIGHT; +- if (channelConfig & (1 << QAudioFormat::FrontLeftOfCenter)) +- avChannelLayout |= AV_CH_FRONT_LEFT_OF_CENTER; +- if (channelConfig & (1 << QAudioFormat::FrontRightOfCenter)) +- avChannelLayout |= AV_CH_FRONT_RIGHT_OF_CENTER; +- if (channelConfig & (1 << QAudioFormat::BackCenter)) +- avChannelLayout |= AV_CH_BACK_CENTER; +- if (channelConfig & (1 << QAudioFormat::LFE2)) +- avChannelLayout |= AV_CH_LOW_FREQUENCY_2; +- if (channelConfig & (1 << QAudioFormat::SideLeft)) +- avChannelLayout |= AV_CH_SIDE_LEFT; +- if (channelConfig & (1 << QAudioFormat::SideRight)) +- avChannelLayout |= AV_CH_SIDE_RIGHT; +- if (channelConfig & (1 << QAudioFormat::TopFrontLeft)) +- avChannelLayout |= AV_CH_TOP_FRONT_LEFT; +- if (channelConfig & (1 << QAudioFormat::TopFrontRight)) +- avChannelLayout |= AV_CH_TOP_FRONT_RIGHT; +- if (channelConfig & (1 << QAudioFormat::TopFrontCenter)) +- avChannelLayout |= AV_CH_TOP_FRONT_CENTER; +- if (channelConfig & (1 << QAudioFormat::TopCenter)) +- avChannelLayout |= AV_CH_TOP_CENTER; +- if (channelConfig & (1 << QAudioFormat::TopBackLeft)) +- avChannelLayout |= AV_CH_TOP_BACK_LEFT; +- if (channelConfig & (1 << QAudioFormat::TopBackRight)) +- avChannelLayout |= AV_CH_TOP_BACK_RIGHT; +- if (channelConfig & (1 << QAudioFormat::TopBackCenter)) +- avChannelLayout |= AV_CH_TOP_BACK_CENTER; +- // The defines used below got added together for FFmpeg 4.4 +-#ifdef AV_CH_TOP_SIDE_LEFT +- if (channelConfig & (1 << QAudioFormat::TopSideLeft)) +- avChannelLayout |= AV_CH_TOP_SIDE_LEFT; +- if (channelConfig & (1 << QAudioFormat::TopSideRight)) +- avChannelLayout |= AV_CH_TOP_SIDE_RIGHT; +- if (channelConfig & (1 << QAudioFormat::BottomFrontCenter)) +- avChannelLayout |= AV_CH_BOTTOM_FRONT_CENTER; +- if (channelConfig & (1 << QAudioFormat::BottomFrontLeft)) +- avChannelLayout |= AV_CH_BOTTOM_FRONT_LEFT; +- if (channelConfig & (1 << QAudioFormat::BottomFrontRight)) +- avChannelLayout |= AV_CH_BOTTOM_FRONT_RIGHT; +-#endif +- return avChannelLayout; +-} +- +-QAudioFormat::ChannelConfig QFFmpegMediaFormatInfo::channelConfigForAVLayout(int64_t avChannelLayout) +-{ +- quint32 channelConfig = 0; +- if (avChannelLayout & AV_CH_FRONT_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::FrontLeft); +- if (avChannelLayout & AV_CH_FRONT_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::FrontRight); +- if (avChannelLayout & AV_CH_FRONT_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::FrontCenter); +- if (avChannelLayout & AV_CH_LOW_FREQUENCY) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::LFE); +- if (avChannelLayout & AV_CH_BACK_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::BackLeft); +- if (avChannelLayout & AV_CH_BACK_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::BackRight); +- if (avChannelLayout & AV_CH_FRONT_LEFT_OF_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::FrontLeftOfCenter); +- if (avChannelLayout & AV_CH_FRONT_RIGHT_OF_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::FrontRightOfCenter); +- if (avChannelLayout & AV_CH_BACK_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::BackCenter); +- if (avChannelLayout & AV_CH_LOW_FREQUENCY_2) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::LFE2); +- if (avChannelLayout & AV_CH_SIDE_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::SideLeft); +- if (avChannelLayout & AV_CH_SIDE_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::SideRight); +- if (avChannelLayout & AV_CH_TOP_FRONT_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopFrontLeft); +- if (avChannelLayout & AV_CH_TOP_FRONT_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopFrontRight); +- if (avChannelLayout & AV_CH_TOP_FRONT_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopFrontCenter); +- if (avChannelLayout & AV_CH_TOP_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopCenter); +- if (avChannelLayout & AV_CH_TOP_BACK_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopBackLeft); +- if (avChannelLayout & AV_CH_TOP_BACK_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopBackRight); +- if (avChannelLayout & AV_CH_TOP_BACK_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopBackCenter); +- // The defines used below got added together for FFmpeg 4.4 +-#ifdef AV_CH_TOP_SIDE_LEFT +- if (avChannelLayout & AV_CH_TOP_SIDE_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopSideLeft); +- if (avChannelLayout & AV_CH_TOP_SIDE_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::TopSideRight); +- if (avChannelLayout & AV_CH_BOTTOM_FRONT_CENTER) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::BottomFrontCenter); +- if (avChannelLayout & AV_CH_BOTTOM_FRONT_LEFT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::BottomFrontLeft); +- if (avChannelLayout & AV_CH_BOTTOM_FRONT_RIGHT) +- channelConfig |= QAudioFormat::channelConfig(QAudioFormat::BottomFrontRight); +-#endif +- return QAudioFormat::ChannelConfig(channelConfig); +-} +- +-QAudioFormat QFFmpegMediaFormatInfo::audioFormatFromCodecParameters(AVCodecParameters *codecpar) +-{ +- QAudioFormat format; +- format.setSampleFormat(sampleFormat(AVSampleFormat(codecpar->format))); +- format.setSampleRate(codecpar->sample_rate); +-#if QT_FFMPEG_OLD_CHANNEL_LAYOUT +- uint64_t channelLayout = codecpar->channel_layout; +- if (!channelLayout) +- channelLayout = avChannelLayout(QAudioFormat::defaultChannelConfigForChannelCount(codecpar->channels)); +-#else +- uint64_t channelLayout = 0; +- if (codecpar->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) +- channelLayout = codecpar->ch_layout.u.mask; +- else +- channelLayout = avChannelLayout(QAudioFormat::defaultChannelConfigForChannelCount(codecpar->ch_layout.nb_channels)); +-#endif +- format.setChannelConfig(channelConfigForAVLayout(channelLayout)); +- return format; +-} + + QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo_p.h b/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo_p.h +index 52fcf6f72..e34005bbf 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo_p.h ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediaformatinfo_p.h +@@ -19,7 +19,6 @@ + #include + #include + #include +-#include "qffmpeg_p.h" + + QT_BEGIN_NAMESPACE + +@@ -28,23 +27,6 @@ class QFFmpegMediaFormatInfo : public QPlatformMediaFormatInfo + public: + QFFmpegMediaFormatInfo(); + ~QFFmpegMediaFormatInfo(); +- +- static QMediaFormat::VideoCodec videoCodecForAVCodecId(AVCodecID id); +- static QMediaFormat::AudioCodec audioCodecForAVCodecId(AVCodecID id); +- static QMediaFormat::FileFormat fileFormatForAVInputFormat(const AVInputFormat *format); +- +- static const AVOutputFormat *outputFormatForFileFormat(QMediaFormat::FileFormat format); +- +- static AVCodecID codecIdForVideoCodec(QMediaFormat::VideoCodec codec); +- static AVCodecID codecIdForAudioCodec(QMediaFormat::AudioCodec codec); +- +- static QAudioFormat::SampleFormat sampleFormat(AVSampleFormat format); +- static AVSampleFormat avSampleFormat(QAudioFormat::SampleFormat format); +- +- static int64_t avChannelLayout(QAudioFormat::ChannelConfig channelConfig); +- static QAudioFormat::ChannelConfig channelConfigForAVLayout(int64_t avChannelLayout); +- +- static QAudioFormat audioFormatFromCodecParameters(AVCodecParameters *codecPar); + }; + + QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration.cpp b/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration.cpp +index e55444cc2..c07c0ebc7 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration.cpp ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration.cpp +@@ -5,13 +5,9 @@ + #include + #include "qffmpegmediaintegration_p.h" + #include "qffmpegmediaformatinfo_p.h" +-#include "qffmpegmediaplayer_p.h" + #include "qffmpegvideosink_p.h" + #include "qffmpegmediacapturesession_p.h" +-#include "qffmpegmediarecorder_p.h" + #include "qffmpegimagecapture_p.h" +-#include "qffmpegaudioinput_p.h" +-#include "qffmpegaudiodecoder_p.h" + + #ifdef Q_OS_MACOS + #include +@@ -24,13 +20,6 @@ + #include "qwindowsvideodevices_p.h" + #endif + +-#ifdef Q_OS_ANDROID +-# include "jni.h" +-extern "C" { +-# include +-} +-#endif +- + #if QT_CONFIG(linux_v4l) + #include "qv4l2camera_p.h" + #endif +@@ -86,21 +75,11 @@ QPlatformMediaFormatInfo *QFFmpegMediaIntegration::formatInfo() + return m_formatsInfo; + } + +-QMaybe QFFmpegMediaIntegration::createAudioDecoder(QAudioDecoder *decoder) +-{ +- return new QFFmpegAudioDecoder(decoder); +-} +- + QMaybe QFFmpegMediaIntegration::createCaptureSession() + { + return new QFFmpegMediaCaptureSession(); + } + +-QMaybe QFFmpegMediaIntegration::createPlayer(QMediaPlayer *player) +-{ +- return new QFFmpegMediaPlayer(player); +-} +- + QMaybe QFFmpegMediaIntegration::createCamera(QCamera *camera) + { + #ifdef Q_OS_DARWIN +@@ -115,11 +94,6 @@ QMaybe QFFmpegMediaIntegration::createCamera(QCamera *camera) + #endif + } + +-QMaybe QFFmpegMediaIntegration::createRecorder(QMediaRecorder *recorder) +-{ +- return new QFFmpegMediaRecorder(recorder); +-} +- + QMaybe QFFmpegMediaIntegration::createImageCapture(QImageCapture *imageCapture) + { + return new QFFmpegImageCapture(imageCapture); +@@ -130,11 +104,6 @@ QMaybe QFFmpegMediaIntegration::createVideoSink(QVideoSink + return new QFFmpegVideoSink(sink); + } + +-QMaybe QFFmpegMediaIntegration::createAudioInput(QAudioInput *input) +-{ +- return new QFFmpegAudioInput(input); +-} +- + #ifdef Q_OS_ANDROID + Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) + { +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration_p.h b/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration_p.h +index 35c062f16..8b44da741 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration_p.h ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediaintegration_p.h +@@ -30,19 +30,11 @@ public: + static QFFmpegMediaIntegration *instance() { return static_cast(QPlatformMediaIntegration::instance()); } + QPlatformMediaFormatInfo *formatInfo() override; + +- +- QMaybe createAudioDecoder(QAudioDecoder *decoder) override; + QMaybe createCaptureSession() override; +- QMaybe createPlayer(QMediaPlayer *player) override; + QMaybe createCamera(QCamera *) override; +- QMaybe createRecorder(QMediaRecorder *) override; + QMaybe createImageCapture(QImageCapture *) override; +- + QMaybe createVideoSink(QVideoSink *sink) override; + +- QMaybe createAudioInput(QAudioInput *input) override; +-// QPlatformAudioOutput *createAudioOutput(QAudioOutput *) override; +- + QFFmpegMediaFormatInfo *m_formatsInfo = nullptr; + }; + +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediametadata.cpp b/src/plugins/multimedia/ffmpeg/qffmpegmediametadata.cpp +index fecce3f1b..dda577d44 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediametadata.cpp ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediametadata.cpp +@@ -64,114 +64,9 @@ static const char *keyToTag(QMediaMetaData::Key key) + return nullptr; + } + +-//internal +-void QFFmpegMetaData::addEntry(QMediaMetaData &metaData, AVDictionaryEntry *entry) +-{ +-// qDebug() << " checking:" << entry->key << entry->value; +- QByteArray tag(entry->key); +- QMediaMetaData::Key key = tagToKey(tag.toLower()); +- if (key == QMediaMetaData::Key(-1)) +- return; +-// qDebug() << " adding" << key; +- +- auto *map = &metaData; +- +- int metaTypeId = keyType(key).id(); +- switch (metaTypeId) { +- case qMetaTypeId(): +- map->insert(key, QString::fromUtf8(entry->value)); +- return; +- case qMetaTypeId(): +- map->insert(key, QString::fromUtf8(entry->value).split(QLatin1Char(','))); +- return; +- case qMetaTypeId(): { +- QDateTime date; +- if (!qstrcmp(entry->key, "year")) { +- if (map->keys().contains(QMediaMetaData::Date)) +- return; +- date = QDateTime(QDate(QByteArray(entry->value).toInt(), 1, 1), QTime(0, 0, 0)); +- } else { +- date = QDateTime::fromString(QString::fromUtf8(entry->value), Qt::ISODate); +- } +- map->insert(key, date); +- return; +- } +- case qMetaTypeId(): +- map->insert(key, QUrl::fromEncoded(entry->value)); +- return; +- case qMetaTypeId(): +- map->insert(key, (qint64)QByteArray(entry->value).toLongLong()); +- return; +- case qMetaTypeId(): +- map->insert(key, QByteArray(entry->value).toInt()); +- return; +- case qMetaTypeId(): +- map->insert(key, (qreal)QByteArray(entry->value).toDouble()); +- return; +- default: +- break; +- } +- if (metaTypeId == qMetaTypeId()) { +- map->insert(key, QVariant::fromValue(QLocale::codeToLanguage(QString::fromUtf8(entry->value), QLocale::ISO639Part2))); +- } +-} +- +- +-QMediaMetaData QFFmpegMetaData::fromAVMetaData(const AVDictionary *tags) +-{ +- QMediaMetaData metaData; +- AVDictionaryEntry *entry = nullptr; +- while ((entry = av_dict_get(tags, "", entry, AV_DICT_IGNORE_SUFFIX))) +- addEntry(metaData, entry); +- +- return metaData; +-} +- + QByteArray QFFmpegMetaData::value(const QMediaMetaData &metaData, QMediaMetaData::Key key) + { +-// qDebug() << " checking:" << entry->key << entry->value; +- +- const int metaTypeId = keyType(key).id(); +- const QVariant val = metaData.value(key); +- switch (metaTypeId) { +- case qMetaTypeId(): +- return val.toString().toUtf8(); +- case qMetaTypeId(): +- return val.toStringList().join(u",").toUtf8(); +- case qMetaTypeId(): +- return val.toDateTime().toString(Qt::ISODate).toUtf8(); +- case qMetaTypeId(): +- return val.toUrl().toEncoded(); +- case qMetaTypeId(): +- case qMetaTypeId(): +- return QByteArray::number(val.toLongLong()); +- case qMetaTypeId(): +- return QByteArray::number(val.toDouble()); +- default: +- break; +- } +- if (metaTypeId == qMetaTypeId()) +- return QLocale::languageToCode(val.value(), QLocale::ISO639Part2).toUtf8(); + return {}; + } + +- +-AVDictionary *QFFmpegMetaData::toAVMetaData(const QMediaMetaData &metaData) +-{ +- const QList keys = metaData.keys(); +- AVDictionary *dict = nullptr; +- for (const auto &k : keys) { +- const char *key = ::keyToTag(k); +- if (!key) +- continue; +- QByteArray val = value(metaData, k); +- if (val.isEmpty()) +- continue; +- av_dict_set(&dict, key, val.constData(), 0); +- } +- return dict; +-} +- +- +- + QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediametadata_p.h b/src/plugins/multimedia/ffmpeg/qffmpegmediametadata_p.h +index 201287495..95b069b64 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediametadata_p.h ++++ b/src/plugins/multimedia/ffmpeg/qffmpegmediametadata_p.h +@@ -16,18 +16,13 @@ + // + + #include +-#include + + QT_BEGIN_NAMESPACE + + class QFFmpegMetaData : public QMediaMetaData + { + public: +- static void addEntry(QMediaMetaData &metaData, AVDictionaryEntry *entry); +- static QMediaMetaData fromAVMetaData(const AVDictionary *tags); +- + static QByteArray value(const QMediaMetaData &metaData, QMediaMetaData::Key key); +- static AVDictionary *toAVMetaData(const QMediaMetaData &metaData); + }; + + QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer.cpp b/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer.cpp +deleted file mode 100644 +index 5e6062f42..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer.cpp ++++ /dev/null +@@ -1,236 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpegmediaplayer_p.h" +-#include "qffmpegdecoder_p.h" +-#include "qffmpegmediaformatinfo_p.h" +-#include "qlocale.h" +-#include "qffmpeg_p.h" +-#include "qffmpegmediametadata_p.h" +-#include "qffmpegvideobuffer_p.h" +-#include "private/qplatformaudiooutput_p.h" +-#include "qvideosink.h" +-#include "qaudiosink.h" +-#include "qaudiooutput.h" +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include +- +-QT_BEGIN_NAMESPACE +- +-using namespace QFFmpeg; +- +-QFFmpegMediaPlayer::QFFmpegMediaPlayer(QMediaPlayer *player) +- : QPlatformMediaPlayer(player) +-{ +- positionUpdateTimer.setInterval(100); +- positionUpdateTimer.setTimerType(Qt::PreciseTimer); +- connect(&positionUpdateTimer, &QTimer::timeout, this, &QFFmpegMediaPlayer::updatePosition); +-} +- +-QFFmpegMediaPlayer::~QFFmpegMediaPlayer() +-{ +- delete decoder; +-} +- +-qint64 QFFmpegMediaPlayer::duration() const +-{ +- return decoder ? decoder->m_duration/1000 : 0; +-} +- +-void QFFmpegMediaPlayer::setPosition(qint64 position) +-{ +- if (decoder) { +- decoder->seek(position * 1000); +- updatePosition(); +- } +- if (state() == QMediaPlayer::StoppedState) +- mediaStatusChanged(QMediaPlayer::LoadedMedia); +-} +- +-void QFFmpegMediaPlayer::updatePosition() +-{ +- positionChanged(decoder ? decoder->clockController.currentTime() / 1000 : 0); +-} +- +-void QFFmpegMediaPlayer::endOfStream() +-{ +- positionChanged(duration()); +- stateChanged(QMediaPlayer::StoppedState); +- mediaStatusChanged(QMediaPlayer::EndOfMedia); +-} +- +-float QFFmpegMediaPlayer::bufferProgress() const +-{ +- return 1.; +-} +- +-QMediaTimeRange QFFmpegMediaPlayer::availablePlaybackRanges() const +-{ +- return {}; +-} +- +-qreal QFFmpegMediaPlayer::playbackRate() const +-{ +- return m_playbackRate; +-} +- +-void QFFmpegMediaPlayer::setPlaybackRate(qreal rate) +-{ +- if (m_playbackRate == rate) +- return; +- m_playbackRate = rate; +- if (decoder) +- decoder->setPlaybackRate(rate); +-} +- +-QUrl QFFmpegMediaPlayer::media() const +-{ +- return m_url; +-} +- +-const QIODevice *QFFmpegMediaPlayer::mediaStream() const +-{ +- return m_device; +-} +- +-void QFFmpegMediaPlayer::setMedia(const QUrl &media, QIODevice *stream) +-{ +- m_url = media; +- m_device = stream; +- if (decoder) +- delete decoder; +- decoder = nullptr; +- +- positionChanged(0); +- +- if (media.isEmpty() && !stream) { +- seekableChanged(false); +- audioAvailableChanged(false); +- videoAvailableChanged(false); +- metaDataChanged(); +- mediaStatusChanged(QMediaPlayer::NoMedia); +- return; +- } +- +- mediaStatusChanged(QMediaPlayer::LoadingMedia); +- decoder = new Decoder; +- connect(decoder, &Decoder::endOfStream, this, &QFFmpegMediaPlayer::endOfStream); +- connect(decoder, &Decoder::errorOccured, this, &QFFmpegMediaPlayer::error); +- decoder->setMedia(media, stream); +- decoder->setAudioSink(m_audioOutput); +- decoder->setVideoSink(m_videoSink); +- +- durationChanged(duration()); +- tracksChanged(); +- metaDataChanged(); +- seekableChanged(decoder->isSeekable()); +- +- audioAvailableChanged(!decoder->m_streamMap[QPlatformMediaPlayer::AudioStream].isEmpty()); +- videoAvailableChanged(!decoder->m_streamMap[QPlatformMediaPlayer::VideoStream].isEmpty()); +- +- +- QMetaObject::invokeMethod(this, "delayedLoadedStatus", Qt::QueuedConnection); +-} +- +-void QFFmpegMediaPlayer::play() +-{ +- if (!decoder) +- return; +- +- if (mediaStatus() == QMediaPlayer::EndOfMedia && state() == QMediaPlayer::StoppedState) { +- decoder->seek(0); +- positionChanged(0); +- } +- decoder->play(); +- positionUpdateTimer.start(); +- stateChanged(QMediaPlayer::PlayingState); +- mediaStatusChanged(QMediaPlayer::BufferedMedia); +-} +- +-void QFFmpegMediaPlayer::pause() +-{ +- if (!decoder) +- return; +- if (mediaStatus() == QMediaPlayer::EndOfMedia && state() == QMediaPlayer::StoppedState) { +- decoder->seek(0); +- positionChanged(0); +- } +- decoder->pause(); +- positionUpdateTimer.stop(); +- stateChanged(QMediaPlayer::PausedState); +- mediaStatusChanged(QMediaPlayer::BufferedMedia); +-} +- +-void QFFmpegMediaPlayer::stop() +-{ +- if (!decoder) +- return; +- decoder->stop(); +- positionUpdateTimer.stop(); +- positionChanged(0); +- stateChanged(QMediaPlayer::StoppedState); +- mediaStatusChanged(QMediaPlayer::LoadedMedia); +-} +- +-void QFFmpegMediaPlayer::setAudioOutput(QPlatformAudioOutput *output) +-{ +- if (m_audioOutput == output) +- return; +- +- m_audioOutput = output; +- if (decoder) +- decoder->setAudioSink(output); +-} +- +-QMediaMetaData QFFmpegMediaPlayer::metaData() const +-{ +- return decoder ? decoder->m_metaData : QMediaMetaData{}; +-} +- +-void QFFmpegMediaPlayer::setVideoSink(QVideoSink *sink) +-{ +- if (m_videoSink == sink) +- return; +- +- m_videoSink = sink; +- if (decoder) +- decoder->setVideoSink(sink); +-} +- +-QVideoSink *QFFmpegMediaPlayer::videoSink() const +-{ +- return m_videoSink; +-} +- +-int QFFmpegMediaPlayer::trackCount(TrackType type) +-{ +- return decoder ? decoder->m_streamMap[type].count() : 0; +-} +- +-QMediaMetaData QFFmpegMediaPlayer::trackMetaData(TrackType type, int streamNumber) +-{ +- if (!decoder || streamNumber < 0 || streamNumber >= decoder->m_streamMap[type].count()) +- return {}; +- return decoder->m_streamMap[type].at(streamNumber).metaData; +-} +- +-int QFFmpegMediaPlayer::activeTrack(TrackType type) +-{ +- return decoder ? decoder->m_requestedStreams[type] : -1; +-} +- +-void QFFmpegMediaPlayer::setActiveTrack(TrackType type, int streamNumber) +-{ +- if (decoder) +- decoder->setActiveTrack(type, streamNumber); +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer_p.h b/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer_p.h +deleted file mode 100644 +index 8e2753c82..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediaplayer_p.h ++++ /dev/null +@@ -1,98 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#ifndef QFFMPEGMEDIAPLAYER_H +-#define QFFMPEGMEDIAPLAYER_H +- +-#include +-#include +-#include +-#include "qffmpeg_p.h" +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +-class Decoder; +-} +-class QPlatformAudioOutput; +- +-class QFFmpegMediaPlayer : public QObject, public QPlatformMediaPlayer +-{ +- Q_OBJECT +-public: +- QFFmpegMediaPlayer(QMediaPlayer *player); +- ~QFFmpegMediaPlayer(); +- +- qint64 duration() const override; +- +- void setPosition(qint64 position) override; +- +- float bufferProgress() const override; +- +- QMediaTimeRange availablePlaybackRanges() const override; +- +- qreal playbackRate() const override; +- void setPlaybackRate(qreal rate) override; +- +- QUrl media() const override; +- const QIODevice *mediaStream() const override; +- void setMedia(const QUrl &media, QIODevice *stream) override; +- +- void play() override; +- void pause() override; +- void stop() override; +- +-// bool streamPlaybackSupported() const { return false; } +- +- void setAudioOutput(QPlatformAudioOutput *) override; +- +- QMediaMetaData metaData() const override; +- +- void setVideoSink(QVideoSink *sink) override; +- QVideoSink *videoSink() const; +- +- int trackCount(TrackType) override; +- QMediaMetaData trackMetaData(TrackType type, int streamNumber) override; +- int activeTrack(TrackType) override; +- void setActiveTrack(TrackType, int streamNumber) override; +- +- Q_INVOKABLE void delayedLoadedStatus() { mediaStatusChanged(QMediaPlayer::LoadedMedia); } +- +-private slots: +- void updatePosition(); +- void endOfStream(); +- void error(int error, const QString &errorString) +- { +- QPlatformMediaPlayer::error(error, errorString); +- } +- +-private: +- friend class QFFmpeg::Decoder; +- +- QTimer positionUpdateTimer; +- +- QFFmpeg::Decoder *decoder = nullptr; +- QPlatformAudioOutput *m_audioOutput = nullptr; +- QVideoSink *m_videoSink = nullptr; +- +- QUrl m_url; +- QIODevice *m_device = nullptr; +- float m_playbackRate = 1.; +-}; +- +-QT_END_NAMESPACE +- +- +-#endif // QMEDIAPLAYERCONTROL_H +- +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediarecorder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegmediarecorder.cpp +deleted file mode 100644 +index 870b8ad38..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediarecorder.cpp ++++ /dev/null +@@ -1,157 +0,0 @@ +-// Copyright (C) 2016 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpegmediarecorder_p.h" +-#include "qaudiodevice.h" +-#include +-#include +-#include "qaudiosource.h" +-#include "qffmpegaudioinput_p.h" +-#include "qaudiobuffer.h" +-#include "qffmpegencoder_p.h" +-#include "qffmpegmediaformatinfo_p.h" +- +-#include +-#include +-#include +-#include +-#include +- +-Q_LOGGING_CATEGORY(qLcMediaEncoder, "qt.multimedia.encoder") +- +-QFFmpegMediaRecorder::QFFmpegMediaRecorder(QMediaRecorder *parent) +- : QPlatformMediaRecorder(parent) +-{ +-} +- +-QFFmpegMediaRecorder::~QFFmpegMediaRecorder() +-{ +- if (encoder) +- encoder->finalize(); +-} +- +-bool QFFmpegMediaRecorder::isLocationWritable(const QUrl &) const +-{ +- return true; +-} +- +-void QFFmpegMediaRecorder::handleSessionError(QMediaRecorder::Error code, const QString &description) +-{ +- error(code, description); +- stop(); +-} +- +-void QFFmpegMediaRecorder::record(QMediaEncoderSettings &settings) +-{ +- if (!m_session || state() != QMediaRecorder::StoppedState) +- return; +- +- const auto hasVideo = m_session->camera() && m_session->camera()->isActive(); +- const auto hasAudio = m_session->audioInput() != nullptr; +- +- if (!hasVideo && !hasAudio) { +- error(QMediaRecorder::ResourceError, QMediaRecorder::tr("No camera or audio input")); +- return; +- } +- +- const auto audioOnly = settings.videoCodec() == QMediaFormat::VideoCodec::Unspecified; +- +- auto primaryLocation = audioOnly ? QStandardPaths::MusicLocation : QStandardPaths::MoviesLocation; +- auto container = settings.mimeType().preferredSuffix(); +- auto location = QMediaStorageLocation::generateFileName(outputLocation().toLocalFile(), primaryLocation, container); +- +- QUrl actualSink = QUrl::fromLocalFile(QDir::currentPath()).resolved(location); +- qCDebug(qLcMediaEncoder) << "recording new video to" << actualSink; +- qDebug() << "requested format:" << settings.fileFormat() << settings.audioCodec(); +- +- Q_ASSERT(!actualSink.isEmpty()); +- +- encoder = new QFFmpeg::Encoder(settings, actualSink); +- encoder->setMetaData(m_metaData); +- connect(encoder, &QFFmpeg::Encoder::durationChanged, this, &QFFmpegMediaRecorder::newDuration); +- connect(encoder, &QFFmpeg::Encoder::finalizationDone, this, &QFFmpegMediaRecorder::finalizationDone); +- connect(encoder, &QFFmpeg::Encoder::error, this, &QFFmpegMediaRecorder::handleSessionError); +- +- auto *audioInput = m_session->audioInput(); +- if (audioInput) +- encoder->addAudioInput(static_cast(audioInput)); +- +- auto *camera = m_session->camera(); +- if (camera) +- encoder->addVideoSource(camera); +- +- durationChanged(0); +- stateChanged(QMediaRecorder::RecordingState); +- actualLocationChanged(QUrl::fromLocalFile(location)); +- +- encoder->start(); +-} +- +-void QFFmpegMediaRecorder::pause() +-{ +- if (!m_session || state() != QMediaRecorder::RecordingState) +- return; +- +- Q_ASSERT(encoder); +- encoder->setPaused(true); +- +- stateChanged(QMediaRecorder::PausedState); +-} +- +-void QFFmpegMediaRecorder::resume() +-{ +- if (!m_session || state() != QMediaRecorder::PausedState) +- return; +- +- Q_ASSERT(encoder); +- encoder->setPaused(false); +- +- stateChanged(QMediaRecorder::RecordingState); +-} +- +-void QFFmpegMediaRecorder::stop() +-{ +- if (!m_session || state() == QMediaRecorder::StoppedState) +- return; +- auto * input = m_session ? m_session->audioInput() : nullptr; +- if (input) +- static_cast(input)->setRunning(false); +- qCDebug(qLcMediaEncoder) << "stop"; +- // ### all of the below should be done asynchronous. finalize() should do it's work in a thread +- // to avoid blocking the UI in case of slow codecs +- if (encoder) { +- encoder->finalize(); +- encoder = nullptr; +- } +-} +- +-void QFFmpegMediaRecorder::finalizationDone() +-{ +- stateChanged(QMediaRecorder::StoppedState); +-} +- +-void QFFmpegMediaRecorder::setMetaData(const QMediaMetaData &metaData) +-{ +- if (!m_session) +- return; +- m_metaData = metaData; +-} +- +-QMediaMetaData QFFmpegMediaRecorder::metaData() const +-{ +- return m_metaData; +-} +- +-void QFFmpegMediaRecorder::setCaptureSession(QPlatformMediaCaptureSession *session) +-{ +- auto *captureSession = static_cast(session); +- if (m_session == captureSession) +- return; +- +- if (m_session) +- stop(); +- +- m_session = captureSession; +- if (!m_session) +- return; +-} +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegmediarecorder_p.h b/src/plugins/multimedia/ffmpeg/qffmpegmediarecorder_p.h +deleted file mode 100644 +index 26f4c16ad..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegmediarecorder_p.h ++++ /dev/null +@@ -1,68 +0,0 @@ +-// Copyright (C) 2016 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +- +-#ifndef QFFMPEGMEDIARECODER_H +-#define QFFMPEGMEDIARECODER_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include +-#include "qffmpegmediacapturesession_p.h" +- +-#include "qffmpeg_p.h" +- +-QT_BEGIN_NAMESPACE +- +-class QAudioSource; +-class QAudioSourceIO; +-class QAudioBuffer; +-class QMediaMetaData; +- +-namespace QFFmpeg { +-class Encoder; +-} +- +-class QFFmpegMediaRecorder : public QObject, public QPlatformMediaRecorder +-{ +- Q_OBJECT +-public: +- QFFmpegMediaRecorder(QMediaRecorder *parent); +- virtual ~QFFmpegMediaRecorder(); +- +- bool isLocationWritable(const QUrl &sink) const override; +- +- void record(QMediaEncoderSettings &settings) override; +- void pause() override; +- void resume() override; +- void stop() override; +- +- void setMetaData(const QMediaMetaData &) override; +- QMediaMetaData metaData() const override; +- +- void setCaptureSession(QPlatformMediaCaptureSession *session); +- +-private Q_SLOTS: +- void newDuration(qint64 d) { durationChanged(d); } +- void finalizationDone(); +- void handleSessionError(QMediaRecorder::Error code, const QString &description); +- +-private: +- QFFmpegMediaCaptureSession *m_session = nullptr; +- QMediaMetaData m_metaData; +- +- QFFmpeg::Encoder *encoder = nullptr; +-}; +- +-QT_END_NAMESPACE +- +-#endif // QFFMPEGMEDIARECODER_H +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegresampler.cpp b/src/plugins/multimedia/ffmpeg/qffmpegresampler.cpp +deleted file mode 100644 +index bb15aa0e1..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegresampler.cpp ++++ /dev/null +@@ -1,95 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#include "qffmpegresampler_p.h" +-#include "qffmpegdecoder_p.h" +-#include "qffmpegmediaformatinfo_p.h" +-#include +- +-extern "C" { +-#include +-} +- +-Q_LOGGING_CATEGORY(qLcResampler, "qt.multimedia.ffmpeg.resampler") +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg +-{ +- +-Resampler::Resampler(const Codec *codec, const QAudioFormat &outputFormat) +- : m_outputFormat(outputFormat) +-{ +- qCDebug(qLcResampler) << "createResampler"; +- const AVStream *audioStream = codec->stream(); +- const auto *codecpar = audioStream->codecpar; +- +- if (!m_outputFormat.isValid()) +- // want the native format +- m_outputFormat = QFFmpegMediaFormatInfo::audioFormatFromCodecParameters(audioStream->codecpar); +- +- QAudioFormat::ChannelConfig config = m_outputFormat.channelConfig(); +- if (config == QAudioFormat::ChannelConfigUnknown) +- config = QAudioFormat::defaultChannelConfigForChannelCount(m_outputFormat.channelCount()); +- +- +- qCDebug(qLcResampler) << "init resampler" << m_outputFormat.sampleRate() << config << codecpar->sample_rate; +-#if QT_FFMPEG_OLD_CHANNEL_LAYOUT +- auto inConfig = codecpar->channel_layout; +- if (inConfig == 0) +- inConfig = QFFmpegMediaFormatInfo::avChannelLayout(QAudioFormat::defaultChannelConfigForChannelCount(codecpar->channels)); +- resampler = swr_alloc_set_opts(nullptr, // we're allocating a new context +- QFFmpegMediaFormatInfo::avChannelLayout(config), // out_ch_layout +- QFFmpegMediaFormatInfo::avSampleFormat(m_outputFormat.sampleFormat()), // out_sample_fmt +- m_outputFormat.sampleRate(), // out_sample_rate +- inConfig, // in_ch_layout +- AVSampleFormat(codecpar->format), // in_sample_fmt +- codecpar->sample_rate, // in_sample_rate +- 0, // log_offset +- nullptr); +-#else +- AVChannelLayout in_ch_layout = codecpar->ch_layout; +- AVChannelLayout out_ch_layout = {}; +- av_channel_layout_from_mask(&out_ch_layout, QFFmpegMediaFormatInfo::avChannelLayout(config)); +- swr_alloc_set_opts2(&resampler, // we're allocating a new context +- &out_ch_layout, +- QFFmpegMediaFormatInfo::avSampleFormat(m_outputFormat.sampleFormat()), +- m_outputFormat.sampleRate(), +- &in_ch_layout, +- AVSampleFormat(codecpar->format), +- codecpar->sample_rate, +- 0, +- nullptr); +-#endif +- // if we're not the master clock, we might need to handle clock adjustments, initialize for that +- av_opt_set_double(resampler, "async", m_outputFormat.sampleRate()/50, 0); +- +- swr_init(resampler); +-} +- +-Resampler::~Resampler() +-{ +- swr_free(&resampler); +-} +- +-QAudioBuffer Resampler::resample(const AVFrame *frame) +-{ +- const int outSamples = swr_get_out_samples(resampler, frame->nb_samples); +- QByteArray samples(m_outputFormat.bytesForFrames(outSamples), Qt::Uninitialized); +- auto **in = const_cast(frame->extended_data); +- auto *out = reinterpret_cast(samples.data()); +- const int out_samples = swr_convert(resampler, &out, outSamples, +- in, frame->nb_samples); +- samples.resize(m_outputFormat.bytesForFrames(out_samples)); +- +- qint64 startTime = m_outputFormat.durationForFrames(m_samplesProcessed); +- m_samplesProcessed += out_samples; +- +- qCDebug(qLcResampler) << " new frame" << startTime << "in_samples" << frame->nb_samples << out_samples << outSamples; +- QAudioBuffer buffer(samples, m_outputFormat, startTime); +- return buffer; +-} +- +- +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegresampler_p.h b/src/plugins/multimedia/ffmpeg/qffmpegresampler_p.h +deleted file mode 100644 +index 4b5b59537..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegresampler_p.h ++++ /dev/null +@@ -1,46 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGRESAMPLER_P_H +-#define QFFMPEGRESAMPLER_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qaudiobuffer.h" +-#include "qffmpeg_p.h" +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg +-{ +- +-struct Codec; +- +-class Resampler +-{ +-public: +- Resampler(const Codec *codec, const QAudioFormat &outputFormat); +- ~Resampler(); +- +- QAudioBuffer resample(const AVFrame *frame); +- qint64 samplesProcessed() const { return m_samplesProcessed; } +- +-private: +- QAudioFormat m_outputFormat; +- SwrContext *resampler = nullptr; +- qint64 m_samplesProcessed = 0; +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegthread.cpp b/src/plugins/multimedia/ffmpeg/qffmpegthread.cpp +deleted file mode 100644 +index 804ba424f..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegthread.cpp ++++ /dev/null +@@ -1,57 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpegthread_p.h" +- +-#include +- +-QT_BEGIN_NAMESPACE +- +-using namespace QFFmpeg; +- +-void Thread::kill() +-{ +- { +- QMutexLocker locker(&mutex); +- exit.storeRelease(true); +- killHelper(); +- } +- wake(); +- wait(); +- delete this; +-} +- +-void Thread::maybePause() +-{ +- while (timeOut > 0 || shouldWait()) { +- if (exit.loadAcquire()) +- break; +- +- QElapsedTimer timer; +- timer.start(); +- if (condition.wait(&mutex, QDeadlineTimer(timeOut, Qt::PreciseTimer))) { +- if (timeOut >= 0) { +- timeOut -= timer.elapsed(); +- if (timeOut < 0) +- timeOut = -1; +- } +- } else { +- timeOut = -1; +- } +- } +-} +- +-void Thread::run() +-{ +- init(); +- QMutexLocker locker(&mutex); +- while (1) { +- maybePause(); +- if (exit.loadAcquire()) +- break; +- loop(); +- } +- cleanup(); +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegthread_p.h b/src/plugins/multimedia/ffmpeg/qffmpegthread_p.h +deleted file mode 100644 +index e5c87e237..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegthread_p.h ++++ /dev/null +@@ -1,68 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGTHREAD_P_H +-#define QFFMPEGTHREAD_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include +- +-#include +-#include +-#include +- +-QT_BEGIN_NAMESPACE +- +-class QAudioSink; +- +-namespace QFFmpeg +-{ +- +-class Thread : public QThread +-{ +-public: +- mutable QMutex mutex; +- qint64 timeOut = -1; +-private: +- QWaitCondition condition; +- +-protected: +- QAtomicInteger exit = false; +- +-public: +- // public API is thread-safe +- +- void kill(); +- virtual void killHelper() {} +- +- void wake() { +- condition.wakeAll(); +- } +- +-protected: +- virtual void init() {} +- virtual void cleanup() {} +- // loop() should never block, all blocking has to happen in shouldWait() +- virtual void loop() = 0; +- virtual bool shouldWait() const { return false; } +- +-private: +- void maybePause(); +- +- void run() override; +-}; +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp b/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp +deleted file mode 100644 +index b17c04938..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer.cpp ++++ /dev/null +@@ -1,356 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpegvideobuffer_p.h" +-#include "private/qvideotexturehelper_p.h" +-#include "qffmpeghwaccel_p.h" +- +-extern "C" { +-#include +-#include +-#include +-} +- +-QT_BEGIN_NAMESPACE +- +-QFFmpegVideoBuffer::QFFmpegVideoBuffer(AVFrame *frame) +- : QAbstractVideoBuffer(QVideoFrame::NoHandle) +- , frame(frame) +-{ +- if (frame->hw_frames_ctx) { +- hwFrame = frame; +- m_pixelFormat = toQtPixelFormat(QFFmpeg::HWAccel::format(frame)); +- return; +- } +- +- swFrame = frame; +- m_pixelFormat = toQtPixelFormat(AVPixelFormat(swFrame->format)); +- +- convertSWFrame(); +-} +- +-QFFmpegVideoBuffer::~QFFmpegVideoBuffer() +-{ +- delete textures; +- if (swFrame) +- av_frame_free(&swFrame); +- if (hwFrame) +- av_frame_free(&hwFrame); +-} +- +-void QFFmpegVideoBuffer::convertSWFrame() +-{ +- Q_ASSERT(swFrame); +- bool needsConversion = false; +- auto pixelFormat = toQtPixelFormat(AVPixelFormat(swFrame->format), &needsConversion); +-// qDebug() << "SW frame format:" << pixelFormat << swFrame->format << needsConversion; +- +- if (pixelFormat != m_pixelFormat) { +- AVPixelFormat newFormat = toAVPixelFormat(m_pixelFormat); +- // convert the format into something we can handle +- SwsContext *c = sws_getContext(swFrame->width, swFrame->height, AVPixelFormat(swFrame->format), +- swFrame->width, swFrame->height, newFormat, +- SWS_BICUBIC, nullptr, nullptr, nullptr); +- +- AVFrame *newFrame = av_frame_alloc(); +- newFrame->width = swFrame->width; +- newFrame->height = swFrame->height; +- newFrame->format = newFormat; +- av_frame_get_buffer(newFrame, 0); +- +- sws_scale(c, swFrame->data, swFrame->linesize, 0, swFrame->height, newFrame->data, newFrame->linesize); +- av_frame_free(&swFrame); +- swFrame = newFrame; +- sws_freeContext(c); +- } +-} +- +-void QFFmpegVideoBuffer::setTextureConverter(const QFFmpeg::TextureConverter &converter) +-{ +- textureConverter = converter; +- textureConverter.init(hwFrame); +- m_type = converter.isNull() ? QVideoFrame::NoHandle : QVideoFrame::RhiTextureHandle; +-} +- +-QVideoFrameFormat::ColorSpace QFFmpegVideoBuffer::colorSpace() const +-{ +- switch (frame->colorspace) { +- default: +- case AVCOL_SPC_UNSPECIFIED: +- case AVCOL_SPC_RESERVED: +- case AVCOL_SPC_FCC: +- case AVCOL_SPC_SMPTE240M: +- case AVCOL_SPC_YCGCO: +- case AVCOL_SPC_SMPTE2085: +- case AVCOL_SPC_CHROMA_DERIVED_NCL: +- case AVCOL_SPC_CHROMA_DERIVED_CL: +- case AVCOL_SPC_ICTCP: // BT.2100 ICtCp +- return QVideoFrameFormat::ColorSpace_Undefined; +- case AVCOL_SPC_RGB: +- return QVideoFrameFormat::ColorSpace_AdobeRgb; +- case AVCOL_SPC_BT709: +- return QVideoFrameFormat::ColorSpace_BT709; +- case AVCOL_SPC_BT470BG: // BT601 +- case AVCOL_SPC_SMPTE170M: // Also BT601 +- return QVideoFrameFormat::ColorSpace_BT601; +- case AVCOL_SPC_BT2020_NCL: // Non constant luminence +- case AVCOL_SPC_BT2020_CL: // Constant luminence +- return QVideoFrameFormat::ColorSpace_BT2020; +- } +-} +- +-QVideoFrameFormat::ColorTransfer QFFmpegVideoBuffer::colorTransfer() const +-{ +- switch (frame->color_trc) { +- case AVCOL_TRC_BT709: +- // The following three cases have transfer characteristics identical to BT709 +- case AVCOL_TRC_BT1361_ECG: +- case AVCOL_TRC_BT2020_10: +- case AVCOL_TRC_BT2020_12: +- case AVCOL_TRC_SMPTE240M: // almost identical to bt709 +- return QVideoFrameFormat::ColorTransfer_BT709; +- case AVCOL_TRC_GAMMA22: +- case AVCOL_TRC_SMPTE428 : // No idea, let's hope for the best... +- case AVCOL_TRC_IEC61966_2_1: // sRGB, close enough to 2.2... +- case AVCOL_TRC_IEC61966_2_4: // not quite, but probably close enough +- return QVideoFrameFormat::ColorTransfer_Gamma22; +- case AVCOL_TRC_GAMMA28: +- return QVideoFrameFormat::ColorTransfer_Gamma28; +- case AVCOL_TRC_SMPTE170M: +- return QVideoFrameFormat::ColorTransfer_BT601; +- case AVCOL_TRC_LINEAR: +- return QVideoFrameFormat::ColorTransfer_Linear; +- case AVCOL_TRC_SMPTE2084: +- return QVideoFrameFormat::ColorTransfer_ST2084; +- case AVCOL_TRC_ARIB_STD_B67: +- return QVideoFrameFormat::ColorTransfer_STD_B67; +- default: +- break; +- } +- return QVideoFrameFormat::ColorTransfer_Unknown; +-} +- +-QVideoFrameFormat::ColorRange QFFmpegVideoBuffer::colorRange() const +-{ +- switch (frame->color_range) { +- case AVCOL_RANGE_MPEG: +- return QVideoFrameFormat::ColorRange_Video; +- case AVCOL_RANGE_JPEG: +- return QVideoFrameFormat::ColorRange_Full; +- default: +- return QVideoFrameFormat::ColorRange_Unknown; +- } +-} +- +-float QFFmpegVideoBuffer::maxNits() +-{ +- float maxNits = -1; +- for (int i = 0; i nb_side_data; ++i) { +- AVFrameSideData *sd = frame->side_data[i]; +- // TODO: Longer term we might want to also support HDR10+ dynamic metadata +- if (sd->type == AV_FRAME_DATA_MASTERING_DISPLAY_METADATA) { +- auto *data = reinterpret_cast(sd->data); +- auto maybeLum = QFFmpeg::mul(10'000., data->max_luminance); +- if (maybeLum) +- maxNits = float(maybeLum.value()); +- } +- } +- return maxNits; +-} +- +-QVideoFrame::MapMode QFFmpegVideoBuffer::mapMode() const +-{ +- return m_mode; +-} +- +-QAbstractVideoBuffer::MapData QFFmpegVideoBuffer::map(QVideoFrame::MapMode mode) +-{ +- if (!swFrame) { +- Q_ASSERT(hwFrame && hwFrame->hw_frames_ctx); +- swFrame = av_frame_alloc(); +- /* retrieve data from GPU to CPU */ +- int ret = av_hwframe_transfer_data(swFrame, hwFrame, 0); +- if (ret < 0) { +- qWarning() << "Error transferring the data to system memory\n"; +- return {}; +- } +- convertSWFrame(); +- } +- +- m_mode = mode; +- +-// qDebug() << "MAP:"; +- MapData mapData; +- auto *desc = QVideoTextureHelper::textureDescription(pixelFormat()); +- mapData.nPlanes = desc->nplanes; +- for (int i = 0; i < mapData.nPlanes; ++i) { +- mapData.data[i] = swFrame->data[i]; +- mapData.bytesPerLine[i] = swFrame->linesize[i]; +- mapData.size[i] = mapData.bytesPerLine[i]*desc->heightForPlane(swFrame->height, i); +-// qDebug() << " " << i << mapData.data[i] << mapData.size[i]; +- } +- return mapData; +-} +- +-void QFFmpegVideoBuffer::unmap() +-{ +- // nothing to do here for SW buffers +-} +- +-std::unique_ptr QFFmpegVideoBuffer::mapTextures(QRhi *) +-{ +- if (textures) +- return {}; +- if (!hwFrame) +- return {}; +- textures = textureConverter.getTextures(hwFrame); +- if (!textures) +- qWarning() << " failed to get textures for frame" << textureConverter.isNull(); +- return {}; +-} +- +-quint64 QFFmpegVideoBuffer::textureHandle(int plane) const +-{ +- return textures ? textures->textureHandle(plane) : 0; +-} +- +-QVideoFrameFormat::PixelFormat QFFmpegVideoBuffer::pixelFormat() const +-{ +- return m_pixelFormat; +-} +- +-QSize QFFmpegVideoBuffer::size() const +-{ +- return QSize(frame->width, frame->height); +-} +- +-QVideoFrameFormat::PixelFormat QFFmpegVideoBuffer::toQtPixelFormat(AVPixelFormat avPixelFormat, bool *needsConversion) +-{ +- if (needsConversion) +- *needsConversion = false; +- +- switch (avPixelFormat) { +- default: +- break; +- case AV_PIX_FMT_ARGB: +- return QVideoFrameFormat::Format_ARGB8888; +- case AV_PIX_FMT_0RGB: +- return QVideoFrameFormat::Format_XRGB8888; +- case AV_PIX_FMT_BGRA: +- return QVideoFrameFormat::Format_BGRA8888; +- case AV_PIX_FMT_BGR0: +- return QVideoFrameFormat::Format_BGRX8888; +- case AV_PIX_FMT_ABGR: +- return QVideoFrameFormat::Format_ABGR8888; +- case AV_PIX_FMT_0BGR: +- return QVideoFrameFormat::Format_XBGR8888; +- case AV_PIX_FMT_RGBA: +- return QVideoFrameFormat::Format_RGBA8888; +- case AV_PIX_FMT_RGB0: +- return QVideoFrameFormat::Format_RGBX8888; +- +- case AV_PIX_FMT_YUV422P: +- return QVideoFrameFormat::Format_YUV422P; +- case AV_PIX_FMT_YUV420P: +- return QVideoFrameFormat::Format_YUV420P; +- case AV_PIX_FMT_YUV420P10: +- return QVideoFrameFormat::Format_YUV420P10; +- case AV_PIX_FMT_UYVY422: +- return QVideoFrameFormat::Format_UYVY; +- case AV_PIX_FMT_YUYV422: +- return QVideoFrameFormat::Format_YUYV; +- case AV_PIX_FMT_NV12: +- return QVideoFrameFormat::Format_NV12; +- case AV_PIX_FMT_NV21: +- return QVideoFrameFormat::Format_NV21; +- case AV_PIX_FMT_GRAY8: +- return QVideoFrameFormat::Format_Y8; +- case AV_PIX_FMT_GRAY16: +- return QVideoFrameFormat::Format_Y16; +- +- case AV_PIX_FMT_P010: +- return QVideoFrameFormat::Format_P010; +- case AV_PIX_FMT_P016: +- return QVideoFrameFormat::Format_P016; +- case AV_PIX_FMT_MEDIACODEC: +- return QVideoFrameFormat::Format_SamplerExternalOES; +- } +- +- if (needsConversion) +- *needsConversion = true; +- +- const AVPixFmtDescriptor *descriptor = av_pix_fmt_desc_get(avPixelFormat); +- +- if (descriptor->flags & AV_PIX_FMT_FLAG_RGB) +- return QVideoFrameFormat::Format_RGBA8888; +- +- if (descriptor->comp[0].depth > 8) +- return QVideoFrameFormat::Format_P016; +- return QVideoFrameFormat::Format_YUV420P; +-} +- +-AVPixelFormat QFFmpegVideoBuffer::toAVPixelFormat(QVideoFrameFormat::PixelFormat pixelFormat) +-{ +- switch (pixelFormat) { +- default: +- case QVideoFrameFormat::Format_Invalid: +- case QVideoFrameFormat::Format_AYUV: +- case QVideoFrameFormat::Format_AYUV_Premultiplied: +- case QVideoFrameFormat::Format_YV12: +- case QVideoFrameFormat::Format_IMC1: +- case QVideoFrameFormat::Format_IMC2: +- case QVideoFrameFormat::Format_IMC3: +- case QVideoFrameFormat::Format_IMC4: +- return AV_PIX_FMT_NONE; +- case QVideoFrameFormat::Format_Jpeg: +- // We're using the data from the converted QImage here, which is in BGRA. +- return AV_PIX_FMT_BGRA; +- case QVideoFrameFormat::Format_ARGB8888: +- case QVideoFrameFormat::Format_ARGB8888_Premultiplied: +- return AV_PIX_FMT_ARGB; +- case QVideoFrameFormat::Format_XRGB8888: +- return AV_PIX_FMT_0RGB; +- case QVideoFrameFormat::Format_BGRA8888: +- case QVideoFrameFormat::Format_BGRA8888_Premultiplied: +- return AV_PIX_FMT_BGRA; +- case QVideoFrameFormat::Format_BGRX8888: +- return AV_PIX_FMT_BGR0; +- case QVideoFrameFormat::Format_ABGR8888: +- return AV_PIX_FMT_ABGR; +- case QVideoFrameFormat::Format_XBGR8888: +- return AV_PIX_FMT_0BGR; +- case QVideoFrameFormat::Format_RGBA8888: +- return AV_PIX_FMT_RGBA; +- case QVideoFrameFormat::Format_RGBX8888: +- return AV_PIX_FMT_RGB0; +- +- case QVideoFrameFormat::Format_YUV422P: +- return AV_PIX_FMT_YUV422P; +- case QVideoFrameFormat::Format_YUV420P: +- return AV_PIX_FMT_YUV420P; +- case QVideoFrameFormat::Format_YUV420P10: +- return AV_PIX_FMT_YUV420P10; +- case QVideoFrameFormat::Format_UYVY: +- return AV_PIX_FMT_UYVY422; +- case QVideoFrameFormat::Format_YUYV: +- return AV_PIX_FMT_YUYV422; +- case QVideoFrameFormat::Format_NV12: +- return AV_PIX_FMT_NV12; +- case QVideoFrameFormat::Format_NV21: +- return AV_PIX_FMT_NV21; +- case QVideoFrameFormat::Format_Y8: +- return AV_PIX_FMT_GRAY8; +- case QVideoFrameFormat::Format_Y16: +- return AV_PIX_FMT_GRAY16; +- +- case QVideoFrameFormat::Format_P010: +- return AV_PIX_FMT_P010; +- case QVideoFrameFormat::Format_P016: +- return AV_PIX_FMT_P016; +- +- case QVideoFrameFormat::Format_SamplerExternalOES: +- return AV_PIX_FMT_MEDIACODEC; +- } +-} +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer_p.h b/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer_p.h +deleted file mode 100644 +index a981ec245..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegvideobuffer_p.h ++++ /dev/null +@@ -1,72 +0,0 @@ +-// Copyright (C) 2021 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#ifndef QFFMPEGVIDEOBUFFER_P_H +-#define QFFMPEGVIDEOBUFFER_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include +-#include +-#include +-#include +- +-#include "qffmpeg_p.h" +-#include "qffmpeghwaccel_p.h" +- +-QT_BEGIN_NAMESPACE +- +-class QFFmpegVideoBuffer : public QAbstractVideoBuffer +-{ +-public: +- +- QFFmpegVideoBuffer(AVFrame *frame); +- ~QFFmpegVideoBuffer(); +- +- QVideoFrame::MapMode mapMode() const override; +- MapData map(QVideoFrame::MapMode mode) override; +- void unmap() override; +- +- virtual std::unique_ptr mapTextures(QRhi *) override; +- virtual quint64 textureHandle(int plane) const override; +- +- QVideoFrameFormat::PixelFormat pixelFormat() const; +- QSize size() const; +- +- static QVideoFrameFormat::PixelFormat toQtPixelFormat(AVPixelFormat avPixelFormat, bool *needsConversion = nullptr); +- static AVPixelFormat toAVPixelFormat(QVideoFrameFormat::PixelFormat pixelFormat); +- +- void convertSWFrame(); +- +- AVFrame *getHWFrame() const { return hwFrame; } +- +- void setTextureConverter(const QFFmpeg::TextureConverter &converter); +- +- QVideoFrameFormat::ColorSpace colorSpace() const; +- QVideoFrameFormat::ColorTransfer colorTransfer() const; +- QVideoFrameFormat::ColorRange colorRange() const; +- +- float maxNits(); +- +-private: +- QVideoFrameFormat::PixelFormat m_pixelFormat; +- AVFrame *frame = nullptr; +- AVFrame *hwFrame = nullptr; +- AVFrame *swFrame = nullptr; +- QFFmpeg::TextureConverter textureConverter; +- QVideoFrame::MapMode m_mode = QVideoFrame::NotMapped; +- QFFmpeg::TextureSet *textures = nullptr; +-}; +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp +deleted file mode 100644 +index 6cb34f56c..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp ++++ /dev/null +@@ -1,374 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +- +-#include "qffmpegvideoframeencoder_p.h" +-#include "qffmpegvideobuffer_p.h" +-#include "qffmpegmediaformatinfo_p.h" +-#include "qffmpegencoderoptions_p.h" +-#include "private/qplatformmediarecorder_p.h" +-#include "private/qmultimediautils_p.h" +-#include +- +-extern "C" { +-#include +-} +- +-/* Infrastructure for HW acceleration goes into this file. */ +- +-QT_BEGIN_NAMESPACE +- +-Q_LOGGING_CATEGORY(qLcVideoFrameEncoder, "qt.multimedia.ffmpeg.videoencoder") +- +-namespace QFFmpeg { +- +-VideoFrameEncoder::Data::~Data() +-{ +- if (converter) +- sws_freeContext(converter); +- avcodec_free_context(&codecContext); +-} +- +-VideoFrameEncoder::VideoFrameEncoder(const QMediaEncoderSettings &encoderSettings, +- const QSize &sourceSize, float frameRate, AVPixelFormat sourceFormat, AVPixelFormat swFormat) +- : d(new Data) +-{ +- d->settings = encoderSettings; +- d->frameRate = frameRate; +- d->sourceSize = sourceSize; +- +- if (!d->settings.videoResolution().isValid()) +- d->settings.setVideoResolution(d->sourceSize); +- +- d->sourceFormat = sourceFormat; +- d->sourceSWFormat = swFormat; +- +- auto qVideoCodec = encoderSettings.videoCodec(); +- auto codecID = QFFmpegMediaFormatInfo::codecIdForVideoCodec(qVideoCodec); +- +-#ifndef QT_DISABLE_HW_ENCODING +- auto [preferredTypes, size] = HWAccel::preferredDeviceTypes(); +- for (qsizetype i = 0; i < size; i++) { +- auto accel = HWAccel::create(preferredTypes[i]); +- if (!accel) +- continue; +- +- auto matchesSizeConstraints = [&]() -> bool { +- auto *constraints = av_hwdevice_get_hwframe_constraints(accel->hwDeviceContextAsBuffer(), nullptr); +- if (!constraints) +- return true; +- // Check size constraints +- bool result = (d->sourceSize.width() >= constraints->min_width && d->sourceSize.height() >= constraints->min_height && +- d->sourceSize.width() <= constraints->max_width && d->sourceSize.height() <= constraints->max_height); +- av_hwframe_constraints_free(&constraints); +- return result; +- }; +- +- if (!matchesSizeConstraints()) +- continue; +- +- d->codec = accel->hardwareEncoderForCodecId(codecID); +- if (!d->codec) +- continue; +- d->accel = std::move(accel); +- break; +- } +-#endif +- +- if (!d->accel) { +- d->codec = avcodec_find_encoder(codecID); +- if (!d->codec) { +- qWarning() << "Could not find encoder for codecId" << codecID; +- d = {}; +- return; +- } +- } +- auto supportsFormat = [&](AVPixelFormat fmt) { +- auto *f = d->codec->pix_fmts; +- while (*f != -1) { +- if (*f == fmt) +- return true; +- ++f; +- } +- return false; +- }; +- +- d->targetFormat = d->sourceFormat; +- +- if (!supportsFormat(d->sourceFormat)) { +- if (supportsFormat(swFormat)) +- d->targetFormat = swFormat; +- else +- // Take first format the encoder supports. Might want to improve upon this +- d->targetFormat = *d->codec->pix_fmts; +- } +- +- auto desc = av_pix_fmt_desc_get(d->sourceFormat); +- d->sourceFormatIsHWFormat = desc->flags & AV_PIX_FMT_FLAG_HWACCEL; +- desc = av_pix_fmt_desc_get(d->targetFormat); +- d->targetFormatIsHWFormat = desc->flags & AV_PIX_FMT_FLAG_HWACCEL; +- +- bool needToScale = d->sourceSize != d->settings.videoResolution(); +- bool zeroCopy = d->sourceFormatIsHWFormat && d->sourceFormat == d->targetFormat && !needToScale; +- +- if (zeroCopy) +- // no need to initialize any converters +- return; +- +- if (d->sourceFormatIsHWFormat) { +- // if source and target formats don't agree, but the source is a HW format or sizes do't agree, we need to download +- if (d->sourceFormat != d->targetFormat || needToScale) +- d->downloadFromHW = true; +- } else { +- d->sourceSWFormat = d->sourceFormat; +- } +- +- if (d->targetFormatIsHWFormat) { +- Q_ASSERT(d->accel); +- // if source and target formats don't agree, but the target is a HW format, we need to upload +- if (d->sourceFormat != d->targetFormat || needToScale) { +- d->uploadToHW = true; +- +- // determine the format used by the encoder. +- // We prefer YUV422 based formats such as NV12 or P010. Selection trues to find the best matching +- // format for the encoder depending on the bit depth of the source format +- auto desc = av_pix_fmt_desc_get(d->sourceSWFormat); +- int sourceDepth = desc->comp[0].depth; +- +- d->targetSWFormat = AV_PIX_FMT_NONE; +- +- auto *constraints = av_hwdevice_get_hwframe_constraints(d->accel->hwDeviceContextAsBuffer(), nullptr); +- auto *f = constraints->valid_sw_formats; +- int score = INT_MIN; +- while (*f != AV_PIX_FMT_NONE) { +- auto calcScore = [&](AVPixelFormat fmt) -> int { +- auto *desc = av_pix_fmt_desc_get(fmt); +- int s = 0; +- if (fmt == d->sourceSWFormat) +- // prefer exact matches +- s += 10; +- if (desc->comp[0].depth == sourceDepth) +- s += 100; +- else if (desc->comp[0].depth < sourceDepth) +- s -= 100; +- if (desc->log2_chroma_h == 1) +- s += 1; +- if (desc->log2_chroma_w == 1) +- s += 1; +- if (desc->flags & AV_PIX_FMT_FLAG_BE) +- s -= 10; +- if (desc->flags & AV_PIX_FMT_FLAG_PAL) +- // we don't want paletted formats +- s -= 10000; +- if (desc->flags & AV_PIX_FMT_FLAG_RGB) +- // we don't want RGB formats +- s -= 1000; +- if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) +- // we really don't want HW accelerated formats here +- s -= 1000000; +- qCDebug(qLcVideoFrameEncoder) << "checking format" << fmt << Qt::hex << desc->flags << desc->comp[0].depth +- << desc->log2_chroma_h << desc->log2_chroma_w << "score:" << s; +- return s; +- }; +- +- int s = calcScore(*f); +- if (s > score) { +- d->targetSWFormat = *f; +- score = s; +- } +- ++f; +- } +- if (d->targetSWFormat == AV_PIX_FMT_NONE) // shouldn't happen +- d->targetSWFormat = *constraints->valid_sw_formats; +- +- qCDebug(qLcVideoFrameEncoder) << "using format" << d->targetSWFormat << "as transfer format."; +- +- av_hwframe_constraints_free(&constraints); +- // need to create a frames context to convert the input data +- d->accel->createFramesContext(d->targetSWFormat, sourceSize); +- } +- } else { +- d->targetSWFormat = d->targetFormat; +- } +- +- if (d->sourceSWFormat != d->targetSWFormat || needToScale) { +- auto resolution = d->settings.videoResolution(); +- qCDebug(qLcVideoFrameEncoder) << "camera and encoder use different formats:" << d->sourceSWFormat << d->targetSWFormat; +- d->converter = sws_getContext(d->sourceSize.width(), d->sourceSize.height(), d->sourceSWFormat, +- resolution.width(), resolution.height(), d->targetSWFormat, +- SWS_FAST_BILINEAR, nullptr, nullptr, nullptr); +- } +-} +- +-VideoFrameEncoder::~VideoFrameEncoder() +-{ +-} +- +-void QFFmpeg::VideoFrameEncoder::initWithFormatContext(AVFormatContext *formatContext) +-{ +- d->stream = avformat_new_stream(formatContext, nullptr); +- d->stream->id = formatContext->nb_streams - 1; +- //qCDebug(qLcVideoFrameEncoder) << "Video stream: index" << d->stream->id; +- d->stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; +- d->stream->codecpar->codec_id = d->codec->id; +- +- // Apples HEVC decoders don't like the hev1 tag ffmpeg uses by default, use hvc1 as the more commonly accepted tag +- if (d->codec->id == AV_CODEC_ID_HEVC) +- d->stream->codecpar->codec_tag = MKTAG('h','v','c','1'); +- +- // ### Fix hardcoded values +- d->stream->codecpar->format = d->targetFormat; +- d->stream->codecpar->width = d->settings.videoResolution().width(); +- d->stream->codecpar->height = d->settings.videoResolution().height(); +- d->stream->codecpar->sample_aspect_ratio = AVRational{1, 1}; +- float requestedRate = d->frameRate; +- d->stream->time_base = AVRational{ 1, (int)(requestedRate*1000) }; +- +- float delta = 1e10; +- if (d->codec->supported_framerates) { +- // codec only supports fixed frame rates +- auto *best = d->codec->supported_framerates; +- qCDebug(qLcVideoFrameEncoder) << "Finding fixed rate:"; +- for (auto *f = d->codec->supported_framerates; f->num != 0; f++) { +- auto maybeRate = toFloat(*f); +- if (!maybeRate) +- continue; +- float d = qAbs(*maybeRate - requestedRate); +- qCDebug(qLcVideoFrameEncoder) << " " << f->num << f->den << d; +- if (d < delta) { +- best = f; +- delta = d; +- } +- } +- qCDebug(qLcVideoFrameEncoder) << "Fixed frame rate required. Requested:" << requestedRate << "Using:" << best->num << "/" << best->den; +- d->stream->time_base = *best; +- requestedRate = toFloat(*best).value_or(0.f); +- } +- +- Q_ASSERT(d->codec); +- d->codecContext = avcodec_alloc_context3(d->codec); +- if (!d->codecContext) { +- qWarning() << "Could not allocate codec context"; +- d = {}; +- return; +- } +- +- avcodec_parameters_to_context(d->codecContext, d->stream->codecpar); +- d->codecContext->time_base = d->stream->time_base; +- qCDebug(qLcVideoFrameEncoder) << "requesting time base" << d->codecContext->time_base.num << d->codecContext->time_base.den; +- auto [num, den] = qRealToFraction(requestedRate); +- d->codecContext->framerate = { num, den }; +- if (d->accel) { +- auto deviceContext = d->accel->hwDeviceContextAsBuffer(); +- if (deviceContext) +- d->codecContext->hw_device_ctx = av_buffer_ref(deviceContext); +- auto framesContext = d->accel->hwFramesContextAsBuffer(); +- if (framesContext) +- d->codecContext->hw_frames_ctx = av_buffer_ref(framesContext); +- } +-} +- +-bool VideoFrameEncoder::open() +-{ +- AVDictionary *opts = nullptr; +- applyVideoEncoderOptions(d->settings, d->codec->name, d->codecContext, &opts); +- int res = avcodec_open2(d->codecContext, d->codec, &opts); +- if (res < 0) { +- avcodec_free_context(&d->codecContext); +- qWarning() << "Couldn't open codec for writing" << err2str(res); +- return false; +- } +- qCDebug(qLcVideoFrameEncoder) << "video codec opened" << res << "time base" << d->codecContext->time_base.num << d->codecContext->time_base.den; +- d->stream->time_base = d->codecContext->time_base; +- return true; +-} +- +-qint64 VideoFrameEncoder::getPts(qint64 us) +-{ +- Q_ASSERT(d); +- qint64 div = 1'000'000 * d->stream->time_base.num; +- return div != 0 ? (us * d->stream->time_base.den + div / 2) / div : 0; +-} +- +-int VideoFrameEncoder::sendFrame(AVFrame *frame) +-{ +- if (!frame) +- return avcodec_send_frame(d->codecContext, frame); +- auto pts = frame->pts; +- +- if (d->downloadFromHW) { +- auto *f = av_frame_alloc(); +- f->format = d->sourceSWFormat; +- int err = av_hwframe_transfer_data(f, frame, 0); +- if (err < 0) { +- qCDebug(qLcVideoFrameEncoder) << "Error transferring frame data to surface." << err2str(err); +- return err; +- } +- av_frame_free(&frame); +- frame = f; +- } +- +- if (d->converter) { +- auto *f = av_frame_alloc(); +- f->format = d->targetSWFormat; +- f->width = d->settings.videoResolution().width(); +- f->height = d->settings.videoResolution().height(); +- av_frame_get_buffer(f, 0); +- sws_scale(d->converter, frame->data, frame->linesize, 0, f->height, f->data, f->linesize); +- av_frame_free(&frame); +- frame = f; +- } +- +- if (d->uploadToHW) { +- auto *hwFramesContext = d->accel->hwFramesContextAsBuffer(); +- Q_ASSERT(hwFramesContext); +- auto *f = av_frame_alloc(); +- if (!f) +- return AVERROR(ENOMEM); +- int err = av_hwframe_get_buffer(hwFramesContext, f, 0); +- if (err < 0) { +- qCDebug(qLcVideoFrameEncoder) << "Error getting HW buffer" << err2str(err); +- return err; +- } else { +- qCDebug(qLcVideoFrameEncoder) << "got HW buffer"; +- } +- if (!f->hw_frames_ctx) { +- qCDebug(qLcVideoFrameEncoder) << "no hw frames context"; +- return AVERROR(ENOMEM); +- } +- err = av_hwframe_transfer_data(f, frame, 0); +- if (err < 0) { +- qCDebug(qLcVideoFrameEncoder) << "Error transferring frame data to surface." << err2str(err); +- return err; +- } +- av_frame_free(&frame); +- frame = f; +- } +- +- qCDebug(qLcVideoFrameEncoder) << "sending frame" << pts; +- frame->pts = pts; +- int ret = avcodec_send_frame(d->codecContext, frame); +- av_frame_free(&frame); +- return ret; +-} +- +-AVPacket *VideoFrameEncoder::retrievePacket() +-{ +- if (!d || !d->codecContext) +- return nullptr; +- AVPacket *packet = av_packet_alloc(); +- int ret = avcodec_receive_packet(d->codecContext, packet); +- if (ret < 0) { +- av_packet_free(&packet); +- if (ret != AVERROR(EOF) && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) +- qCDebug(qLcVideoFrameEncoder) << "Error receiving packet" << ret << err2str(ret); +- return nullptr; +- } +- auto ts = timeStampMs(packet->pts, d->stream->time_base); +- qCDebug(qLcVideoFrameEncoder) << "got a packet" << packet->pts << (ts ? *ts : 0); +- packet->stream_index = d->stream->id; +- return packet; +-} +- +-} // namespace QFFmpeg +- +-QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder_p.h b/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder_p.h +deleted file mode 100644 +index f71460799..000000000 +--- a/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder_p.h ++++ /dev/null +@@ -1,76 +0,0 @@ +-// Copyright (C) 2022 The Qt Company Ltd. +-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +-#ifndef QFFMPEGVIDEOFRAMEENCODER_P_H +-#define QFFMPEGVIDEOFRAMEENCODER_P_H +- +-// +-// W A R N I N G +-// ------------- +-// +-// This file is not part of the Qt API. It exists purely as an +-// implementation detail. This header file may change from version to +-// version without notice, or even be removed. +-// +-// We mean it. +-// +- +-#include "qffmpeghwaccel_p.h" +-#include "qvideoframeformat.h" +-#include "private/qplatformmediarecorder_p.h" +- +-QT_BEGIN_NAMESPACE +- +-namespace QFFmpeg { +- +-class VideoFrameEncoder +-{ +- class Data final +- { +- public: +- ~Data(); +- QAtomicInt ref = 0; +- QMediaEncoderSettings settings; +- float frameRate = 0.; +- QSize sourceSize; +- +- std::unique_ptr accel; +- const AVCodec *codec = nullptr; +- AVStream *stream = nullptr; +- AVCodecContext *codecContext = nullptr; +- SwsContext *converter = nullptr; +- AVPixelFormat sourceFormat = AV_PIX_FMT_NONE; +- AVPixelFormat sourceSWFormat = AV_PIX_FMT_NONE; +- AVPixelFormat targetFormat = AV_PIX_FMT_NONE; +- AVPixelFormat targetSWFormat = AV_PIX_FMT_NONE; +- bool sourceFormatIsHWFormat = false; +- bool targetFormatIsHWFormat = false; +- bool downloadFromHW = false; +- bool uploadToHW = false; +- }; +- +- QExplicitlySharedDataPointer d; +-public: +- VideoFrameEncoder() = default; +- VideoFrameEncoder(const QMediaEncoderSettings &encoderSettings, const QSize &sourceSize, float frameRate, AVPixelFormat sourceFormat, AVPixelFormat swFormat); +- ~VideoFrameEncoder(); +- +- void initWithFormatContext(AVFormatContext *formatContext); +- bool open(); +- +- bool isNull() const { return !d; } +- +- AVPixelFormat sourceFormat() const { return d ? d->sourceFormat : AV_PIX_FMT_NONE; } +- AVPixelFormat targetFormat() const { return d ? d->targetFormat : AV_PIX_FMT_NONE; } +- +- qint64 getPts(qint64 ms); +- +- int sendFrame(AVFrame *frame); +- AVPacket *retrievePacket(); +-}; +- +- +-} +- +-QT_END_NAMESPACE +- +-#endif +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideosink.cpp b/src/plugins/multimedia/ffmpeg/qffmpegvideosink.cpp +index 3cb31b473..93e7ceeed 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegvideosink.cpp ++++ b/src/plugins/multimedia/ffmpeg/qffmpegvideosink.cpp +@@ -1,7 +1,6 @@ + // Copyright (C) 2021 The Qt Company Ltd. + // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #include +-#include + + QT_BEGIN_NAMESPACE + +@@ -10,21 +9,8 @@ QFFmpegVideoSink::QFFmpegVideoSink(QVideoSink *sink) + { + } + +-void QFFmpegVideoSink::setRhi(QRhi *rhi) +-{ +- if (m_rhi == rhi) +- return; +- m_rhi = rhi; +- textureConverter = QFFmpeg::TextureConverter(rhi); +- emit rhiChanged(rhi); +-} +- + void QFFmpegVideoSink::setVideoFrame(const QVideoFrame &frame) + { +- auto *buffer = dynamic_cast(frame.videoBuffer()); +- if (buffer) +- buffer->setTextureConverter(textureConverter); +- + QPlatformVideoSink::setVideoFrame(frame); + } + +diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideosink_p.h b/src/plugins/multimedia/ffmpeg/qffmpegvideosink_p.h +index dbd9ac7f2..cbaa810d7 100644 +--- a/src/plugins/multimedia/ffmpeg/qffmpegvideosink_p.h ++++ b/src/plugins/multimedia/ffmpeg/qffmpegvideosink_p.h +@@ -16,7 +16,7 @@ + // + + #include +-#include ++//#include + + QT_BEGIN_NAMESPACE + +@@ -29,16 +29,8 @@ class QFFmpegVideoSink : public QPlatformVideoSink + + public: + QFFmpegVideoSink(QVideoSink *sink); +- void setRhi(QRhi *rhi) override; + + void setVideoFrame(const QVideoFrame &frame) override; +- +-Q_SIGNALS: +- void rhiChanged(QRhi *rhi); +- +-private: +- QFFmpeg::TextureConverter textureConverter; +- QRhi *m_rhi = nullptr; + }; + + QT_END_NAMESPACE +diff --git a/src/plugins/multimedia/ffmpeg/qv4l2camera.cpp b/src/plugins/multimedia/ffmpeg/qv4l2camera.cpp +index 4189bdedf..c61c452f3 100644 +--- a/src/plugins/multimedia/ffmpeg/qv4l2camera.cpp ++++ b/src/plugins/multimedia/ffmpeg/qv4l2camera.cpp +@@ -147,7 +147,7 @@ void QV4L2CameraDevices::doCheckCameras() + + while (!ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frameSize)) { + if (frameSize.type != V4L2_FRMSIZE_TYPE_DISCRETE) +- continue; ++ break; + + QSize resolution(frameSize.discrete.width, frameSize.discrete.height); + float min = 1e10; +@@ -160,7 +160,7 @@ void QV4L2CameraDevices::doCheckCameras() + + while (!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &frameInterval)) { + if (frameInterval.type != V4L2_FRMIVAL_TYPE_DISCRETE) +- continue; ++ break; + ++frameInterval.index; + float rate = float(frameInterval.discrete.denominator)/float(frameInterval.discrete.numerator); + if (rate > max) +diff --git a/src/plugins/multimedia/ffmpeg/qwindowscamera.cpp b/src/plugins/multimedia/ffmpeg/qwindowscamera.cpp +index 790c49858..4a4e7a921 100644 +--- a/src/plugins/multimedia/ffmpeg/qwindowscamera.cpp ++++ b/src/plugins/multimedia/ffmpeg/qwindowscamera.cpp +@@ -11,8 +11,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + +diff --git a/src/plugins/multimedia/windows/common/mfmetadata_p.h b/src/plugins/multimedia/windows/common/mfmetadata_p.h +index 81a03b126..9ff196240 100644 +--- a/src/plugins/multimedia/windows/common/mfmetadata_p.h ++++ b/src/plugins/multimedia/windows/common/mfmetadata_p.h +@@ -16,7 +16,7 @@ + // + + #include +-#include "Mfidl.h" ++#include "mfidl.h" + + QT_USE_NAMESPACE + +diff --git a/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp b/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp +index 45bc70d65..0e27a2779 100644 +--- a/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp ++++ b/src/plugins/multimedia/windows/decoder/mfaudiodecodercontrol.cpp +@@ -4,7 +4,7 @@ + #include + #include + #include +-#include "Wmcodecdsp.h" ++#include "wmcodecdsp.h" + #include "mfaudiodecodercontrol_p.h" + #include + +diff --git a/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicereader_p.h b/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicereader_p.h +index 0205eafe2..4699a463a 100644 +--- a/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicereader_p.h ++++ b/src/plugins/multimedia/windows/mediacapture/qwindowsmediadevicereader_p.h +@@ -17,8 +17,8 @@ + + #include + #include +-#include +-#include ++#include ++#include + + #include + #include +diff --git a/src/plugins/multimedia/windows/mediacapture/qwindowsmediaencoder.cpp b/src/plugins/multimedia/windows/mediacapture/qwindowsmediaencoder.cpp +index d5eb07980..dc87afc4b 100644 +--- a/src/plugins/multimedia/windows/mediacapture/qwindowsmediaencoder.cpp ++++ b/src/plugins/multimedia/windows/mediacapture/qwindowsmediaencoder.cpp +@@ -8,7 +8,7 @@ + #include "mfmetadata_p.h" + #include + #include +-#include ++#include + #include + #include + #include +diff --git a/src/plugins/multimedia/windows/player/mfplayercontrol_p.h b/src/plugins/multimedia/windows/player/mfplayercontrol_p.h +index ac60e8c29..78ff71439 100644 +--- a/src/plugins/multimedia/windows/player/mfplayercontrol_p.h ++++ b/src/plugins/multimedia/windows/player/mfplayercontrol_p.h +@@ -15,7 +15,7 @@ + // We mean it. + // + +-#include "QUrl.h" ++#include "qurl.h" + #include "private/qplatformmediaplayer_p.h" + + #include +diff --git a/src/plugins/multimedia/windows/player/mfplayersession.cpp b/src/plugins/multimedia/windows/player/mfplayersession.cpp +index 58efaa87e..5d3372152 100644 +--- a/src/plugins/multimedia/windows/player/mfplayersession.cpp ++++ b/src/plugins/multimedia/windows/player/mfplayersession.cpp +@@ -32,7 +32,7 @@ + + #include + #include +-#include ++#include + + //#define DEBUG_MEDIAFOUNDATION + +diff --git a/src/plugins/multimedia/windows/player/mftvideo.cpp b/src/plugins/multimedia/windows/player/mftvideo.cpp +index 601c51e42..06a8769a7 100644 +--- a/src/plugins/multimedia/windows/player/mftvideo.cpp ++++ b/src/plugins/multimedia/windows/player/mftvideo.cpp +@@ -7,7 +7,7 @@ + #include + #include + #include +-#include ++#include + #include + #include + +diff --git a/src/plugins/multimedia/windows/qwindowsvideodevices.cpp b/src/plugins/multimedia/windows/qwindowsvideodevices.cpp +index 878c4730b..41ccb4733 100644 +--- a/src/plugins/multimedia/windows/qwindowsvideodevices.cpp ++++ b/src/plugins/multimedia/windows/qwindowsvideodevices.cpp +@@ -8,11 +8,11 @@ + #include + #include + +-#include ++#include + + #include + #include +-#include ++#include + + QT_BEGIN_NAMESPACE + +-- +2.39.0 + diff --git a/contrib/depends/patches/qt/rcc_hardcode_timestamp.patch b/contrib/depends/patches/qt/rcc_hardcode_timestamp.patch new file mode 100644 index 0000000..6379112 --- /dev/null +++ b/contrib/depends/patches/qt/rcc_hardcode_timestamp.patch @@ -0,0 +1,24 @@ +Hardcode last modified timestamp in Qt RCC + +This change allows the already built qt package to be reused even with +the SOURCE_DATE_EPOCH variable set, e.g., for Guix builds. + + +--- old/qtbase/src/tools/rcc/rcc.cpp ++++ new/qtbase/src/tools/rcc/rcc.cpp +@@ -229,14 +229,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) + + if (lib.formatVersion() >= 2) { + // last modified time stamp +- const QDateTime lastModified = m_fileInfo.lastModified(); +- quint64 lastmod = quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0); +- static const quint64 sourceDate = 1000 * qgetenv("QT_RCC_SOURCE_DATE_OVERRIDE").toULongLong(); +- if (sourceDate != 0) +- lastmod = sourceDate; +- static const quint64 sourceDate2 = 1000 * qgetenv("SOURCE_DATE_EPOCH").toULongLong(); +- if (sourceDate2 != 0) +- lastmod = sourceDate2; ++ quint64 lastmod = quint64(1); + lib.writeNumber8(lastmod); + if (text || pass1) + lib.writeChar('\n'); diff --git a/contrib/depends/patches/qt/root_CMakeLists.txt b/contrib/depends/patches/qt/root_CMakeLists.txt new file mode 100644 index 0000000..41247a6 --- /dev/null +++ b/contrib/depends/patches/qt/root_CMakeLists.txt @@ -0,0 +1,51 @@ +# The real minimum version will be checked by the qtbase project. +# 3.16 is the absolute minimum though. +cmake_minimum_required(VERSION 3.16...3.20) + +# Include qtbase's .cmake.conf for access to QT_REPO_MODULE_VERSION +set(__qt6_qtbase_src_path "${CMAKE_CURRENT_SOURCE_DIR}/qtbase") +include("${__qt6_qtbase_src_path}/.cmake.conf") + +# Run platform auto-detection /before/ the first project() call and thus +# before the toolchain file is loaded. +include("${__qt6_qtbase_src_path}/cmake/QtAutoDetect.cmake") + +project(Qt + VERSION "${QT_REPO_MODULE_VERSION}" + DESCRIPTION "Qt Libraries" + HOMEPAGE_URL "https://qt.io/" + LANGUAGES CXX C ASM +) + +# Required so we can call ctest from the root build directory +enable_testing() + +set(qt_module_prop_prefix "__qt_prop_") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${__qt6_qtbase_src_path}/cmake") +list(APPEND CMAKE_MODULE_PATH + "${__qt6_qtbase_src_path}/cmake/3rdparty/extra-cmake-modules/find-modules") +list(APPEND CMAKE_MODULE_PATH "${__qt6_qtbase_src_path}/cmake/3rdparty/kwin") + +# Also make sure the CMake config files do not recreate the already-existing targets +set(QT_NO_CREATE_TARGETS TRUE) +set(QT_SUPERBUILD TRUE) + +set(QT_BUILD_SUBMODULES "qtbase;qttranslations;qtsvg;qtwebsockets;qtshadertools;qtmultimedia" CACHE STRING "Submodules to build") + +foreach(module IN LISTS QT_BUILD_SUBMODULES) + message(NOTICE "Configuring '${module}'") + add_subdirectory("${module}") + + if(module STREQUAL "qtbase") + list(APPEND CMAKE_PREFIX_PATH "${QtBase_BINARY_DIR}/lib/cmake") + list(APPEND CMAKE_FIND_ROOT_PATH "${QtBase_BINARY_DIR}") + endif() +endforeach() + +# Display a summary of everything +include(QtBuildInformation) +include(QtPlatformSupport) +qt_print_feature_summary() +qt_print_build_instructions() diff --git a/contrib/depends/patches/qt/windows_func_fix.patch b/contrib/depends/patches/qt/windows_func_fix.patch new file mode 100644 index 0000000..1ea952a --- /dev/null +++ b/contrib/depends/patches/qt/windows_func_fix.patch @@ -0,0 +1,48 @@ +From aaae4d700b339491d9c90d12f38ac26186980305 Mon Sep 17 00:00:00 2001 +From: tobtoht +Date: Tue, 15 Nov 2022 15:48:09 +0100 +Subject: [PATCH] Windows: don't use GetFileVersionInfoSize, + GetFileVersionInfo, VerQueryValue + +--- + src/corelib/kernel/qcoreapplication_win.cpp | 24 --------------------- + 1 file changed, 24 deletions(-) + +diff --git a/qtbase/src/corelib/kernel/qcoreapplication_win.cpp b/qtbase/src/corelib/kernel/qcoreapplication_win.cpp +index 0fe14af798..e46384a6a5 100644 +--- a/qtbase/src/corelib/kernel/qcoreapplication_win.cpp ++++ b/qtbase/src/corelib/kernel/qcoreapplication_win.cpp +@@ -60,30 +60,6 @@ QString QCoreApplicationPrivate::appName() const + QString QCoreApplicationPrivate::appVersion() const + { + QString applicationVersion; +-#ifndef QT_BOOTSTRAPPED +- const QString appFileName = qAppFileName(); +- QVarLengthArray buffer(appFileName.size() + 1); +- buffer[appFileName.toWCharArray(buffer.data())] = 0; +- +- DWORD versionInfoSize = GetFileVersionInfoSize(buffer.data(), nullptr); +- if (versionInfoSize) { +- QVarLengthArray info(static_cast(versionInfoSize)); +- if (GetFileVersionInfo(buffer.data(), 0, versionInfoSize, info.data())) { +- UINT size; +- DWORD *fi; +- +- if (VerQueryValue(info.data(), __TEXT("\\"), +- reinterpret_cast(&fi), &size) && size) { +- const VS_FIXEDFILEINFO *verInfo = reinterpret_cast(fi); +- applicationVersion = QStringLiteral("%1.%2.%3.%4") +- .arg(HIWORD(verInfo->dwProductVersionMS)) +- .arg(LOWORD(verInfo->dwProductVersionMS)) +- .arg(HIWORD(verInfo->dwProductVersionLS)) +- .arg(LOWORD(verInfo->dwProductVersionLS)); +- } +- } +- } +-#endif + return applicationVersion; + } + +-- +2.38.1 + diff --git a/contrib/depends/patches/sodium/ac.patch b/contrib/depends/patches/sodium/ac.patch new file mode 100644 index 0000000..8b48151 --- /dev/null +++ b/contrib/depends/patches/sodium/ac.patch @@ -0,0 +1,110 @@ +diff --git a/configure.ac b/configure.ac +index 9e2de27c..6b17c020 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -44,6 +44,10 @@ AS_IF([pwd | fgrep ' ' > /dev/null 2>&1], + [AC_MSG_ERROR([The build directory contains whitespaces - This can cause tests/installation to fail due to limitations of some libtool versions])] + ) + ++AC_PROG_CC_C99 ++AM_PROG_AS ++AC_USE_SYSTEM_EXTENSIONS ++ + dnl Switches + + AC_ARG_ENABLE(ssp, +@@ -210,17 +214,11 @@ AX_VALGRIND_CHECK + + dnl Checks + +-AC_PROG_CC_C99 +-AM_PROG_AS +-AC_USE_SYSTEM_EXTENSIONS + AC_C_VARARRAYS + + AC_CHECK_DEFINE([__wasi__], [WASI="yes"], []) + +-AC_CHECK_DEFINE([_FORTIFY_SOURCE], [], [ +- AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2], +- [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"]) +-]) ++AS_CASE([$host_os], [linux-gnu], [AX_ADD_FORTIFY_SOURCE], [ ]) + + AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], + [CFLAGS="$CFLAGS -fvisibility=hidden"]) +@@ -343,9 +341,11 @@ AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wswitch-enum], [CWFLAGS="$CWFLAGS -Wswitch-enum + AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wvariable-decl], [CWFLAGS="$CWFLAGS -Wvariable-decl"]) + AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wwrite-strings], [CWFLAGS="$CWFLAGS -Wwrite-strings"]) + +-AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"]) +-AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"]) +-AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"]) ++AS_IF([test "x$EMSCRIPTEN" = "x"], [ ++ AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"]) ++ AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"]) ++ AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"]) ++]) + + AX_CHECK_CATCHABLE_SEGV + AX_CHECK_CATCHABLE_ABRT +@@ -362,10 +362,51 @@ AC_SUBST(LIBTOOL_DEPS) + AC_ARG_VAR([AR], [path to the ar utility]) + AC_CHECK_TOOL([AR], [ar], [ar]) + +-dnl Checks for headers ++dnl Checks for headers and codegen feature flags ++ ++target_cpu_aarch64=no ++AC_MSG_CHECKING(for ARM64 target) ++AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM([ ++#ifndef __aarch64__ ++#error Not aarch64 ++#endif ++#include ++ ], [(void) 0])], ++ [AC_MSG_RESULT(yes) ++ target_cpu_aarch64=yes], ++ [AC_MSG_RESULT(no) ++ target_cpu_aarch64=no]) + + AS_IF([test "x$EMSCRIPTEN" = "x"], [ + ++ AS_IF([test "x$target_cpu_aarch64" = "xyes"], [ ++ have_armcrypto=no ++ AC_MSG_CHECKING(for ARM crypto instructions set) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ vaeseq_u8(vmovq_n_u8(0), vmovq_n_u8(__ARM_FEATURE_CRYPTO)) ]])], ++ [ ++ AC_MSG_RESULT(yes) ++ have_armcrypto=yes ++ ], ++ [ ++ AC_MSG_RESULT(no) ++ oldcflags="$CFLAGS" ++ AX_CHECK_COMPILE_FLAG([-march=armv8-a+crypto], [ ++ CFLAGS="$CFLAGS -march=armv8-a+crypto" ++ AC_MSG_CHECKING(for ARM crypto instructions set with -march=armv8-a+crypto) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ vaeseq_u8(vmovq_n_u8(0), vmovq_n_u8(__ARM_FEATURE_CRYPTO)) ]])], ++ [ ++ AC_MSG_RESULT(yes) ++ have_armcrypto=yes ++ CFLAGS_ARMCRYPTO="-march=armv8-a+crypto" ++ ], ++ [AC_MSG_RESULT(no)]) ++ CFLAGS="$oldcflags" ++ ]) ++ ]) ++ AS_IF([test "$have_armcrypto" = "yes"],[AC_DEFINE([HAVE_ARMCRYPTO], [1], [ARM crypto extensions are available])]) ++ ]) ++ + oldcflags="$CFLAGS" + AX_CHECK_COMPILE_FLAG([-mmmx], [CFLAGS="$CFLAGS -mmmx"]) + AC_MSG_CHECKING(for MMX instructions set) +@@ -542,6 +583,7 @@ __m512i y = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), + + ]) + ++AC_SUBST(CFLAGS_ARMCRYPTO) + AC_SUBST(CFLAGS_MMX) + AC_SUBST(CFLAGS_SSE2) + AC_SUBST(CFLAGS_SSE3) diff --git a/contrib/depends/patches/sodium/disable-glibc-getrandom-getentropy.patch b/contrib/depends/patches/sodium/disable-glibc-getrandom-getentropy.patch new file mode 100644 index 0000000..2f07c10 --- /dev/null +++ b/contrib/depends/patches/sodium/disable-glibc-getrandom-getentropy.patch @@ -0,0 +1,25 @@ +diff --git a/configure.ac b/configure.ac +index 9e2de27c..0fa85c2d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -807,6 +807,10 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[ + # include + #endif + ]], [[ ++#ifdef __linux__ ++# error getrandom() is currently disabled on Linux to support glibc < 2.25 ++#endif ++ + unsigned char buf; + (void) getrandom((void *) &buf, 1U, 0U); + ]])], +@@ -825,6 +829,9 @@ unsigned char buf; + # include + #endif + ]], [[ ++#ifdef __linux__ ++# error getentropy() is currently disabled on Linux to support glibc < 2.25 ++#endif + #ifdef __APPLE__ + # error getentropy() is currently disabled on Apple operating systems + #endif diff --git a/contrib/depends/patches/sodium/fix-arm64.patch b/contrib/depends/patches/sodium/fix-arm64.patch new file mode 100644 index 0000000..a5d739c --- /dev/null +++ b/contrib/depends/patches/sodium/fix-arm64.patch @@ -0,0 +1,25 @@ +From 13214d18c6ea1671dcff3dd62ccf88007b41f112 Mon Sep 17 00:00:00 2001 +From: Frank Denis +Date: Wed, 1 Jul 2020 15:33:52 +0200 +Subject: [PATCH] Recognize the arm + apple combo as aarch64 + +--- + configure.ac | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 05a51fa5..3993dbc1 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -214,6 +214,8 @@ AX_VALGRIND_CHECK + + dnl Checks + ++AS_IF([test "$host_cpu" = "arm" && test "$host_vendor" = "apple"], [host_cpu=aarch64]) ++ + AC_C_VARARRAYS + + AC_CHECK_DEFINE([__wasi__], [WASI="yes"], []) +-- +2.38.1 + diff --git a/contrib/depends/patches/sodium/fix-whitespace.patch b/contrib/depends/patches/sodium/fix-whitespace.patch new file mode 100644 index 0000000..c3d3af0 --- /dev/null +++ b/contrib/depends/patches/sodium/fix-whitespace.patch @@ -0,0 +1,13 @@ +diff --git a/configure b/configure +index b29f769..ca008ae 100755 +--- a/configure ++++ b/configure +@@ -591,7 +591,7 @@ MAKEFLAGS= + PACKAGE_NAME='libsodium' + PACKAGE_TARNAME='libsodium' + PACKAGE_VERSION='1.0.18' +-PACKAGE_STRING='libsodium 1.0.18' ++PACKAGE_STRING='libsodium' + PACKAGE_BUGREPORT='https://github.com/jedisct1/libsodium/issues' + PACKAGE_URL='https://github.com/jedisct1/libsodium' + diff --git a/contrib/depends/patches/unwind/fix_obj_order.patch b/contrib/depends/patches/unwind/fix_obj_order.patch new file mode 100644 index 0000000..e764f0f --- /dev/null +++ b/contrib/depends/patches/unwind/fix_obj_order.patch @@ -0,0 +1,11 @@ +--- config/ltmain.sh.0 2020-11-10 17:25:26.000000000 +0100 ++++ config/ltmain.sh 2021-09-11 19:39:36.000000000 +0200 +@@ -10768,6 +10768,8 @@ + fi + func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 + tool_oldlib=$func_to_tool_file_result ++ oldobjs=`for obj in $oldobjs; do echo $obj; done | sort` ++ oldobjs=" `echo $oldobjs`" + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in new file mode 100644 index 0000000..7c5eaff --- /dev/null +++ b/contrib/depends/toolchain.cmake.in @@ -0,0 +1,195 @@ +# Set the system name to one of Android, Darwin, FreeBSD, Linux, or Windows +SET(CMAKE_SYSTEM_NAME @depends@) +SET(CMAKE_SYSTEM_PROCESSOR @arch@) +SET(CMAKE_BUILD_TYPE @release_type@) + +OPTION(STATIC "Link libraries statically" ON) +OPTION(TREZOR_DEBUG "Main trezor debugging switch" OFF) +OPTION(BUILD_TESTS "Build tests." OFF) + +SET(STATIC ON) +SET(UNBOUND_STATIC ON) +SET(ARCH "default") + +SET(BUILD_TESTS @build_tests@) +SET(TREZOR_DEBUG @build_tests@) + +# where is the target environment +SET(CMAKE_FIND_ROOT_PATH @prefix@ /usr /gnu/store /feather/contrib/depends/SDKs/) + +SET(ENV{PKG_CONFIG_PATH} @prefix@/lib/pkgconfig) + +# use CACHE here because we need to be able to override these later +SET(TOR_DIR @prefix@/Tor CACHE STRING "Tor dir") +SET(TOR_VERSION @tor_version@ CACHE STRING "Tor version") + +SET(Readline_ROOT_DIR @prefix@) +SET(Readline_INCLUDE_DIR @prefix@/include) +SET(Readline_LIBRARY @prefix@/lib/libreadline.a) +SET(Terminfo_LIBRARY @prefix@/lib/libtinfo.a) + +SET(UNBOUND_INCLUDE_DIR @prefix@/include) +SET(UNBOUND_LIBRARIES @prefix@/lib/libunbound.a) + +SET(NATIVE_BIN_PATH @prefix@/native/bin CACHE FILEPATH "path to native binaries" FORCE) +SET(LRELEASE_PATH @prefix@/native/bin CACHE FILEPATH "path to lrelease" FORCE) + +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android") +SET(LIBUNWIND_INCLUDE_DIR @prefix@/include) +SET(LIBUNWIND_LIBRARIES @prefix@/lib/libunwind.a) +SET(LIBUNWIND_LIBRARY_DIRS @prefix@/lib) + +if(NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") +SET(LIBUSB-1.0_LIBRARY @prefix@/lib/libusb-1.0.a) +SET(LIBUDEV_LIBRARY @prefix@/lib/libudev.a) + +SET(Protobuf_FOUND 1) +SET(Protobuf_PROTOC_EXECUTABLE @prefix@/native/bin/protoc CACHE FILEPATH "Path to the native protoc") +SET(Protobuf_INCLUDE_DIR @prefix@/include CACHE PATH "Protobuf include dir") +SET(Protobuf_INCLUDE_DIRS @prefix@/include CACHE PATH "Protobuf include dir") +SET(Protobuf_LIBRARY @prefix@/lib/libprotobuf.a CACHE FILEPATH "Protobuf library") +endif() + +endif() + +SET(ZMQ_INCLUDE_PATH @prefix@/include) +SET(ZMQ_LIB @prefix@/lib/libzmq.a) + +SET(Boost_IGNORE_SYSTEM_PATH ON) +SET(BOOST_ROOT @prefix@) +SET(BOOST_INCLUDEDIR @prefix@/include) +SET(BOOST_LIBRARYDIR @prefix@/lib) +SET(Boost_IGNORE_SYSTEM_PATHS_DEFAULT OFF) +SET(Boost_NO_SYSTEM_PATHS ON) +SET(Boost_USE_STATIC_LIBS ON) +SET(Boost_USE_STATIC_RUNTIME ON) + +SET(OPENSSL_ROOT_DIR @prefix@) +SET(ARCHITECTURE @arch@) + +# for libraries and headers in the target directories +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target + +# specify the cross compiler to be used. Darwin uses clang provided by the SDK. +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + if(ARCHITECTURE STREQUAL "aarch64") + SET(CLANG_TARGET "arm64-apple-darwin") + SET(CONF_TRIPLE "aarch64-apple-darwin") + SET(BUILD_TAG "mac-armv8") + SET(CMAKE_OSX_ARCHITECTURES "arm64") + set(ARM ON) + set(ARM_ID "armv8-a") + else() + SET(CLANG_TARGET "x86_64-apple-darwin") + SET(CONF_TRIPLE "x86_64-apple-darwin") + SET(BUILD_TAG "mac-x64") + SET(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() + SET(_CMAKE_TOOLCHAIN_PREFIX @prefix@/native/bin/${CONF_TRIPLE}-) + SET(CMAKE_C_COMPILER @CC@) + SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET}) + SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX}) + SET(CMAKE_CXX_COMPILER @CXX@ -stdlib=libc++ ) + SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET}) + SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX}) + SET(CMAKE_ASM_COMPILER clang) + SET(CMAKE_ASM-ATT_COMPILER as) + SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET}) + SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET}) + SET(APPLE True) + SET(BUILD_64 ON) + SET(BREW OFF) + SET(PORT OFF) + SET(CMAKE_OSX_SYSROOT "@prefix@/../SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers/") + SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") + SET(CMAKE_CXX_STANDARD 14) + SET(LLVM_ENABLE_PIC OFF) + SET(LLVM_ENABLE_PIE OFF) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") + SET(ANDROID TRUE) + if(ARCHITECTURE STREQUAL "arm") + SET(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a") + SET(CMAKE_SYSTEM_PROCESSOR "armv7-a") + SET(CMAKE_ANDROID_ARM_MODE ON) + SET(CMAKE_C_COMPILER_TARGET arm-linux-androideabi) + SET(CMAKE_CXX_COMPILER_TARGET arm-linux-androideabi) + SET(_CMAKE_TOOLCHAIN_PREFIX arm-linux-androideabi-) + elseif(ARCHITECTURE STREQUAL "aarch64") + SET(CMAKE_ANDROID_ARCH_ABI "arm64-v8a") + SET(CMAKE_SYSTEM_PROCESSOR "aarch64") + endif() + SET(CMAKE_ANDROID_STANDALONE_TOOLCHAIN @prefix@/native) + SET(CMAKE_C_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang") + SET(CMAKE_CXX_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang++") +else() + SET(CMAKE_C_COMPILER @CC@) + SET(CMAKE_CXX_COMPILER @CXX@) +endif() + +if(ARCHITECTURE STREQUAL "arm") + set(ARCH "armv7-a") + set(ARM ON) + set(ARM_ID "armv7-a") + set(BUILD_64 OFF) + set(CMAKE_BUILD_TYPE release) + if(ANDROID) + set(BUILD_TAG "android-armv7") + else() + set(BUILD_TAG "linux-armv7") + endif() + set(ARM7) +elseif(ARCHITECTURE STREQUAL "aarch64") + set(ARCH "armv8-a") + set(ARM ON) + set(ARM_ID "armv8-a") + if(ANDROID) + set(BUILD_TAG "android-armv8") + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(BUILD_TAG "linux-armv8") + endif() + set(BUILD_64 ON) +endif() + +if(ARCHITECTURE STREQUAL "riscv64") + set(NO_AES ON) + set(ARCH "rv64imafdc") +endif() + +if(ARCHITECTURE STREQUAL "i686") + SET(ARCH_ID "i386") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(BUILD_TAG "linux-x86") + SET(LINUX_32 ON) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(BUILD_TAG "win-x32") + endif() +endif() + +if(ARCHITECTURE STREQUAL "x86_64") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(BUILD_TAG "linux-x64") + elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(BUILD_TAG "freebsd-x64") + elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(BUILD_TAG "win-x64") + endif() + SET(ARCH_ID "x86_64") +endif() + +#Create a new global cmake flag that indicates building with depends +set (DEPENDS true) + +set(CMAKE_EXE_LINKER_FLAGS_INIT "@guix_ldflags@") + +if(DEFINED ENV{PYTHONPATH}) + set(PYTHONPATH "@prefix@/native/lib/python3/dist-packages:$ENV{PYTHONPATH}") +else() + set(PYTHONPATH "@prefix@/native/lib/python3/dist-packages") +endif() + +set(CMAKE_INSTALL_NAME_TOOL "@CMAKE_INSTALL_NAME_TOOL@" CACHE FILEPATH "") +set(CMAKE_INSTALL_NAME_TOOL "@CMAKE_INSTALL_NAME_TOOL@") + +set(OTOOL "@OTOOL@") \ No newline at end of file diff --git a/contrib/guix/INSTALL.md b/contrib/guix/INSTALL.md new file mode 100644 index 0000000..f436ebd --- /dev/null +++ b/contrib/guix/INSTALL.md @@ -0,0 +1,786 @@ +# Guix Installation and Setup + +This only needs to be done once per machine. If you have already completed the +installation and setup, please proceed to [perform a build](./README.md). + +Otherwise, you may choose from one of the following options to install Guix: + +1. Using the official **shell installer script** [⤓ skip to section][install-script] + - Maintained by Guix developers + - Easiest (automatically performs *most* setup) + - Works on nearly all Linux distributions + - Only installs latest release + - Binary installation only, requires high level of trust + - Note: The script needs to be run as root, so it should be inspected before it's run +2. Using the official **binary tarball** [⤓ skip to section][install-bin-tarball] + - Maintained by Guix developers + - Normal difficulty (full manual setup required) + - Works on nearly all Linux distributions + - Installs any release + - Binary installation only, requires high level of trust +3. Using a **distribution-maintained package** [⤓ skip to section][install-distro-pkg] + - Maintained by distribution's Guix package maintainer + - Normal difficulty (manual setup required) + - Works only on distributions with Guix packaged, see: https://repology.org/project/guix/versions + - Installs a release decided on by package maintainer + - Source or binary installation depending on the distribution +4. Building **from source** [⤓ skip to section][install-source] + - Maintained by you + - Hard, but rewarding + - Can be made to work on most Linux distributions + - Installs any commit (more granular) + - Source installation, requires lower level of trust + +## Options 1 and 2: Using the official shell installer script or binary tarball + +The installation instructions for both the official shell installer script and +the binary tarballs can be found in the GNU Guix Manual's [Binary Installation +section](https://guix.gnu.org/manual/en/html_node/Binary-Installation.html). + +Note that running through the binary tarball installation steps is largely +equivalent to manually performing what the shell installer script does. + +Note that at the time of writing (July 5th, 2021), the shell installer script +automatically creates an `/etc/profile.d` entry which the binary tarball +installation instructions do not ask you to create. However, you will likely +need this entry for better desktop integration. Please see [this +section](#add-an-etcprofiled-entry) for instructions on how to add a +`/etc/profile.d/guix.sh` entry. + +Regardless of which installation option you chose, the changes to +`/etc/profile.d` will not take effect until the next shell or desktop session, +so you should log out and log back in. + +## Option 3: Using a distribution-maintained package + +Note that this section is based on the distro packaging situation at the time of +writing (July 2021). Guix is expected to be more widely packaged over time. For +an up-to-date view on Guix's package status/version across distros, please see: +https://repology.org/project/guix/versions + +### Debian 11 (Bullseye)/Ubuntu 21.04 (Hirsute Hippo) + +Guix v1.2.0 is available as a distribution package starting in [Debian +11](https://packages.debian.org/bullseye/guix) and [Ubuntu +21.04](https://packages.ubuntu.com/hirsute/guix). + +Note that if you intend on using Guix without using any substitutes (more +details [here][security-model]), v1.2.0 has a known problem when building GnuTLS +from source. Solutions and workarounds are documented +[here](#gnutls-test-suite-fail-status-request-revoked). + + +To install: +```sh +sudo apt install guix +``` + +For up-to-date information on Debian and Ubuntu's release history: +- [Debian release history](https://www.debian.org/releases/) +- [Ubuntu release history](https://ubuntu.com/about/release-cycle) + +### Arch Linux + +Guix is available in the AUR as +[`guix`](https://aur.archlinux.org/packages/guix/), please follow the +installation instructions in the Arch Linux Wiki ([live +link](https://wiki.archlinux.org/index.php/Guix#AUR_Package_Installation), +[2021/03/30 +permalink](https://wiki.archlinux.org/index.php?title=Guix&oldid=637559#AUR_Package_Installation)) +to install Guix. + +At the time of writing (2021/03/30), the `check` phase will fail if the path to +guix's build directory is longer than 36 characters due to an anachronistic +character limit on the shebang line. Since the `check` phase happens after the +`build` phase, which may take quite a long time, it is recommended that users +either: + +1. Skip the `check` phase + - For `makepkg`: `makepkg --nocheck ...` + - For `yay`: `yay --mflags="--nocheck" ...` + - For `paru`: `paru --nocheck ...` +2. Or, check their build directory's length beforehand + - For those building with `makepkg`: `pwd | wc -c` + +## Option 4: Building from source + +Building Guix from source is a rather involved process but a rewarding one for +those looking to minimize trust and maximize customizability (e.g. building a +particular commit of Guix). Previous experience with using autotools-style build +systems to build packages from source will be helpful. *hic sunt dracones.* + +I strongly urge you to at least skim through the entire section once before you +start issuing commands, as it will save you a lot of unnecessary pain and +anguish. + +### Installing common build tools + +There are a few basic build tools that are required for most things we'll build, +so let's install them now: + +Text transformation/i18n: +- `autopoint` (sometimes packaged in `gettext`) +- `help2man` +- `po4a` +- `texinfo` + +Build system tools: +- `g++` w/ C++11 support +- `libtool` +- `autoconf` +- `automake` +- `pkg-config` (sometimes packaged as `pkgconf`) +- `make` +- `cmake` + +Miscellaneous: +- `git` +- `gnupg` +- `python3` + +### Building and Installing Guix's dependencies + +In order to build Guix itself from source, we need to first make sure that the +necessary dependencies are installed and discoverable. The most up-to-date list +of Guix's dependencies is kept in the ["Requirements" +section](https://guix.gnu.org/manual/en/html_node/Requirements.html) of the Guix +Reference Manual. + +Depending on your distribution, most or all of these dependencies may already be +packaged and installable without manually building and installing. + +For reference, the graphic below outlines Guix v1.3.0's dependency graph: + +![bootstrap map](https://user-images.githubusercontent.com/6399679/125064185-a9a59880-e0b0-11eb-82c1-9b8e5dc9950d.png) + +#### Guile + +##### Choosing a Guile version and sticking to it + +One of the first things you need to decide is which Guile version you want to +use: Guile v2.2 or Guile v3.0. Unlike the python2 to python3 transition, Guile +v2.2 and Guile v3.0 are largely compatible, as evidenced by the fact that most +Guile packages and even [Guix +itself](https://guix.gnu.org/en/blog/2020/guile-3-and-guix/) support running on +both. + +What is important here is that you **choose one**, and you **remain consistent** +with your choice throughout **all Guile-related packages**, no matter if they +are installed via the distribution's package manager or installed from source. +This is because the files for Guile packages are installed to directories which +are separated based on the Guile version. + +###### Example: Checking that Ubuntu's `guile-git` is compatible with your chosen Guile version + +On Ubuntu Focal: + +```sh +$ apt show guile-git +Package: guile-git +... +Depends: guile-2.2, guile-bytestructures, libgit2-dev +... +``` + +As you can see, the package `guile-git` depends on `guile-2.2`, meaning that it +was likely built for Guile v2.2. This means that if you decided to use Guile +v3.0 on Ubuntu Focal, you would need to build guile-git from source instead of +using the distribution package. + +On Ubuntu Hirsute: + +```sh +$ apt show guile-git +Package: guile-git +... +Depends: guile-3.0 | guile-2.2, guile-bytestructures (>= 1.0.7-3~), libgit2-dev (>= 1.0) +... +``` + +In this case, `guile-git` depends on either `guile-3.0` or `guile-2.2`, meaning +that it would work no matter what Guile version you decided to use. + +###### Corner case: Multiple versions of Guile on one system + +It is recommended to only install one version of Guile, so that build systems do +not get confused about which Guile to use. + +However, if you insist on having both Guile v2.2 and Guile v3.0 installed on +your system, then you need to **consistently** specify one of +`GUILE_EFFECTIVE_VERSION=3.0` or `GUILE_EFFECTIVE_VERSION=2.2` to all +`./configure` invocations for Guix and its dependencies. + +##### Installing Guile + +Guile is most likely already packaged for your distribution, so after you have +[chosen a Guile version](#choosing-a-guile-version-and-sticking-to-it), install +it via your distribution's package manager. + +If your distribution splits packages into `-dev`-suffixed and +non-`-dev`-suffixed sub-packages (as is the case for Debian-derived +distributions), please make sure to install both. For example, to install Guile +v2.2 on Debian/Ubuntu: + +```sh +apt install guile-2.2 guile-2.2-dev +``` + +#### Mixing distribution packages and source-built packages + +At the time of writing, most distributions have _some_ of Guix's dependencies +packaged, but not all. This means that you may want to install the distribution +package for some dependencies, and manually build-from-source for others. + +Distribution packages usually install to `/usr`, which is different from the +default `./configure` prefix of source-built packages: `/usr/local`. + +This means that if you mix-and-match distribution packages and source-built +packages and do not specify exactly `--prefix=/usr` to `./configure` for +source-built packages, you will need to augment the `GUILE_LOAD_PATH` and +`GUILE_LOAD_COMPILED_PATH` environment variables so that Guile will look +under the right prefix and find your source-built packages. + +For example, if you are using Guile v2.2, and have Guile packages in the +`/usr/local` prefix, either add the following lines to your `.profile` or +`.bash_profile` so that the environment variable is properly set for all future +shell logins, or paste the lines into a POSIX-style shell to temporarily modify +the environment variables of your current shell session. + +```sh +# Help Guile v2.2.x find packages in /usr/local +export GUILE_LOAD_PATH="/usr/local/share/guile/site/2.2${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH" +export GUILE_LOAD_COMPILED_PATH="/usr/local/lib/guile/2.2/site-ccache${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_COMPILED_LOAD_PATH" +``` + +Note that these environment variables are used to check for packages during +`./configure`, so they should be set as soon as possible should you want to use +a prefix other than `/usr`. + +#### Building and installing source-built packages + +***IMPORTANT**: A few dependencies have non-obvious quirks/errata which are +documented in the sub-sections immediately below. Please read these sections +before proceeding to build and install these packages.* + +Although you should always refer to the README or INSTALL files for the most +accurate information, most of these dependencies use autoconf-style build +systems (check if there's a `configure.ac` file), and will likely do the right +thing with the following: + +Clone the repository and check out the latest release: +```sh +git clone /.git +cd +git tag -l # check for the latest release +git checkout +``` + +For autoconf-based build systems (if `./autogen.sh` or `configure.ac` exists at +the root of the repository): + +```sh +./autogen.sh || autoreconf -vfi +./configure --prefix= +make +sudo make install +``` + +For CMake-based build systems (if `CMakeLists.txt` exists at the root of the +repository): + +```sh +mkdir build && cd build +cmake .. -DCMAKE_INSTALL_PREFIX= +sudo cmake --build . --target install +``` + +If you choose not to specify exactly `--prefix=/usr` to `./configure`, please +make sure you've carefully read the [previous section] on mixing distribution +packages and source-built packages. + +##### Binding packages require `-dev`-suffixed packages + +Relevant for: +- Everyone + +When building bindings, the `-dev`-suffixed version of the original package +needs to be installed. For example, building `Guile-zlib` on Debian-derived +distributions requires that `zlib1g-dev` is installed. + +When using bindings, the `-dev`-suffixed version of the original package still +needs to be installed. This is particularly problematic when distribution +packages are mispackaged like `guile-sqlite3` is in Ubuntu Focal such that +installing `guile-sqlite3` does not automatically install `libsqlite3-dev` as a +dependency. + +Below is a list of relevant Guile bindings and their corresponding `-dev` +packages in Debian at the time of writing. + +| Guile binding package | -dev Debian package | +|-----------------------|---------------------| +| guile-gcrypt | libgcrypt-dev | +| guile-git | libgit2-dev | +| guile-lzlib | liblz-dev | +| guile-ssh | libssh-dev | +| guile-sqlite3 | libsqlite3-dev | +| guile-zlib | zlib1g-dev | + +##### `guile-git` actually depends on `libgit2 >= 1.1` + +Relevant for: +- Those building `guile-git` from source against `libgit2 < 1.1` +- Those installing `guile-git` from their distribution where `guile-git` is + built against `libgit2 < 1.1` + +As of v0.4.0, `guile-git` claims to only require `libgit2 >= 0.28.0`, however, +it actually requires `libgit2 >= 1.1`, otherwise, it will be confused by a +reference of `origin/keyring`: instead of interpreting the reference as "the +'keyring' branch of the 'origin' remote", the reference is interpreted as "the +branch literally named 'origin/keyring'" + +This is especially notable because Ubuntu Focal packages `libgit2 v0.28.4`, and +`guile-git` is built against it. + +Should you be in this situation, you need to build both `libgit2 v1.1.x` and +`guile-git` from source. + +Source: https://logs.guix.gnu.org/guix/2020-11-12.log#232527 + +##### `{scheme,guile}-bytestructures` v1.0.8 and v1.0.9 are broken for Guile v2.2 + +Relevant for: +- Those building `{scheme,guile}-bytestructures` from source against Guile v2.2 + +Commit +[707eea3](https://github.com/TaylanUB/scheme-bytestructures/commit/707eea3a85e1e375e86702229ebf73d496377669) +introduced a regression for Guile v2.2 and was first included in v1.0.8, this +was later corrected in commit +[ec9a721](https://github.com/TaylanUB/scheme-bytestructures/commit/ec9a721957c17bcda13148f8faa5f06934431ff7) +and included in v1.1.0. + +TL;DR If you decided to use Guile v2.2, do not use `{scheme,guile}-bytestructures` v1.0.8 or v1.0.9. + +### Building and Installing Guix itself + +Start by cloning Guix: + +``` +git clone https://git.savannah.gnu.org/git/guix.git +cd guix +``` + +You will likely want to build the latest release, however, if the latest release +when you're reading this is still 1.2.0 then you may want to use 95aca29 instead +to avoid a problem in the GnuTLS test suite. + +``` +git branch -a -l 'origin/version-*' # check for the latest release +git checkout +``` + +Bootstrap the build system: +``` +./bootstrap +``` + +Configure with the recommended `--localstatedir` flag: +``` +./configure --localstatedir=/var +``` + +Note: If you intend to hack on Guix in the future, you will need to supply the +same `--localstatedir=` flag for all future Guix `./configure` invocations. See +the last paragraph of this +[section](https://guix.gnu.org/manual/en/html_node/Requirements.html) for more +details. + +Build Guix (this will take a while): +``` +make -j$(nproc) +``` + +Install Guix: + +``` +sudo make install +``` + +### Post-"build from source" Setup + +#### Creating and starting a `guix-daemon-original` service with a fixed `argv[0]` + +At this point, guix will be installed to `${bindir}`, which is likely +`/usr/local/bin` if you did not override directory variables at +`./configure`-time. More information on standard Automake directory variables +can be found +[here](https://www.gnu.org/software/automake/manual/html_node/Standard-Directory-Variables.html). + +However, the Guix init scripts and service configurations for Upstart, systemd, +SysV, and OpenRC are installed (in `${libdir}`) to launch +`${localstatedir}/guix/profiles/per-user/root/current-guix/bin/guix-daemon`, +which does not yet exist, and will only exist after [`root` performs their first +`guix pull`](#guix-pull-as-root). + +We need to create a `-original` version of these init scripts that's pointed to +the binaries we just built and `make install`'ed in `${bindir}` (normally, +`/usr/local/bin`). + +Example for `systemd`, run as `root`: + +```sh +# Create guix-daemon-original.service by modifying guix-daemon.service +libdir=# set according to your PREFIX (default is /usr/local/lib) +bindir="$(dirname $(command -v guix-daemon))" +sed -E -e "s|/\S*/guix/profiles/per-user/root/current-guix/bin/guix-daemon|${bindir}/guix-daemon|" "${libdir}"/systemd/system/guix-daemon.service > /etc/systemd/system/guix-daemon-original.service +chmod 664 /etc/systemd/system/guix-daemon-original.service + +# Make systemd recognize the new service +systemctl daemon-reload + +# Make sure that the non-working guix-daemon.service is stopped and disabled +systemctl stop guix-daemon +systemctl disable guix-daemon + +# Make sure that the working guix-daemon-original.service is started and enabled +systemctl enable guix-daemon-original +systemctl start guix-daemon-original +``` + +#### Creating `guix-daemon` users / groups + +Please see the [relevant +section](https://guix.gnu.org/manual/en/html_node/Build-Environment-Setup.html) +in the Guix Reference Manual for more details. + +## Optional setup + +At this point, you are set up to [use Guix to build Feather Wallet](./README.md#usage). However, if you want to polish your setup a bit and +make it "what Guix intended", then read the next few subsections. + +### Add an `/etc/profile.d` entry + +This section definitely does not apply to you if you installed Guix using: +1. The shell installer script +2. fanquake's Docker image +3. Debian's `guix` package + +#### Background + +Although Guix knows how to update itself and its packages, it does so in a +non-invasive way (it does not modify `/usr/local/bin/guix`). + +Instead, it does the following: + +- After a `guix pull`, it updates + `/var/guix/profiles/per-user/$USER/current-guix`, and creates a symlink + targeting this directory at `$HOME/.config/guix/current` + +- After a `guix install`, it updates + `/var/guix/profiles/per-user/$USER/guix-profile`, and creates a symlink + targeting this directory at `$HOME/.guix-profile` + +Therefore, in order for these operations to affect your shell/desktop sessions +(and for the principle of least astonishment to hold), their corresponding +directories have to be added to well-known environment variables like `$PATH`, +`$INFOPATH`, `$XDG_DATA_DIRS`, etc. + +In other words, if `$HOME/.config/guix/current/bin` does not exist in your +`$PATH`, a `guix pull` will have no effect on what `guix` you are using. Same +goes for `$HOME/.guix-profile/bin`, `guix install`, and installed packages. + +Helpfully, after a `guix pull` or `guix install`, a message will be printed like +so: + +``` +hint: Consider setting the necessary environment variables by running: + + GUIX_PROFILE="$HOME/.guix-profile" + . "$GUIX_PROFILE/etc/profile" + +Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'. +``` + +However, this is somewhat tedious to do for both `guix pull` and `guix install` +for each user on the system that wants to properly use `guix`. I recommend that +you instead add an entry to `/etc/profile.d` instead. This is done by default +when installing the Debian package later than 1.2.0-4 and when using the shell +script installer. + +#### Instructions + +Create `/etc/profile.d/guix.sh` with the following content: +```sh +# _GUIX_PROFILE: `guix pull` profile +_GUIX_PROFILE="$HOME/.config/guix/current" +if [ -L $_GUIX_PROFILE ]; then + export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH" + # Export INFOPATH so that the updated info pages can be found + # and read by both /usr/bin/info and/or $GUIX_PROFILE/bin/info + # When INFOPATH is unset, add a trailing colon so that Emacs + # searches 'Info-default-directory-list'. + export INFOPATH="$_GUIX_PROFILE/share/info:$INFOPATH" +fi + +# GUIX_PROFILE: User's default profile +GUIX_PROFILE="$HOME/.guix-profile" +[ -L $GUIX_PROFILE ] || return +GUIX_LOCPATH="$GUIX_PROFILE/lib/locale" +export GUIX_PROFILE GUIX_LOCPATH + +[ -f "$GUIX_PROFILE/etc/profile" ] && . "$GUIX_PROFILE/etc/profile" + +# set XDG_DATA_DIRS to include Guix installations +export XDG_DATA_DIRS="$GUIX_PROFILE/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}" +``` + +Please note that this will not take effect until the next shell or desktop +session (log out and log back in). + +### `guix pull` as root + +Before you do this, you need to read the section on [choosing your security +model][security-model] and adjust `guix` and `guix-daemon` flags according to +your choice, as invoking `guix pull` may pull substitutes from substitute +servers (which you may not want). + +As mentioned in a previous section, Guix expects +`${localstatedir}/guix/profiles/per-user/root/current-guix` to be populated with +`root`'s Guix profile, `guix pull`-ed and built by some former version of Guix. +However, this is not the case when we build from source. Therefore, we need to +perform a `guix pull` as `root`: + +```sh +sudo --login guix pull --branch=version- +# or +sudo --login guix pull --commit= +``` + +`guix pull` is quite a long process (especially if you're using +`--no-substitute`). If you encounter build problems, please refer to the +[troubleshooting section](#troubleshooting). + +Note that running a bare `guix pull` with no commit or branch specified will +pull the latest commit on Guix's master branch, which is likely fine, but not +recommended. + +If you installed Guix from source, you may get an error like the following: +```sh +error: while creating symlink '/root/.config/guix/current' No such file or directory +``` +To resolve this, simply: +``` +sudo mkdir -p /root/.config/guix +``` +Then try the `guix pull` command again. + +After the `guix pull` finishes successfully, +`${localstatedir}/guix/profiles/per-user/root/current-guix` should be populated. + +#### Using the newly-pulled `guix` by restarting the daemon + +Depending on how you installed Guix, you should now make sure that your init +scripts and service configurations point to the newly-pulled `guix-daemon`. + +##### If you built Guix from source + +If you followed the instructions for [fixing argv\[0\]][fix-argv0], you can now +do the following: + +```sh +systemctl stop guix-daemon-original +systemctl disable guix-daemon-original + +systemctl enable guix-daemon +systemctl start guix-daemon +``` + +##### If you installed Guix via the Debian/Ubuntu distribution packages + +You will need to create a `guix-daemon-latest` service which points to the new +`guix` rather than a pinned one. + +```sh +# Create guix-daemon-latest.service by modifying guix-daemon.service +sed -E -e "s|/usr/bin/guix-daemon|/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon|" /etc/systemd/system/guix-daemon.service > /lib/systemd/system/guix-daemon-latest.service +chmod 664 /lib/systemd/system/guix-daemon-latest.service + +# Make systemd recognize the new service +systemctl daemon-reload + +# Make sure that the old guix-daemon.service is stopped and disabled +systemctl stop guix-daemon +systemctl disable guix-daemon + +# Make sure that the new guix-daemon-latest.service is started and enabled +systemctl enable guix-daemon-latest +systemctl start guix-daemon-latest +``` + +##### If you installed Guix via lantw44's Arch Linux AUR package + +At the time of writing (July 5th, 2021) the systemd unit for "updated Guix" is +`guix-daemon-latest.service`, therefore, you should do the following: + +```sh +systemctl stop guix-daemon +systemctl disable guix-daemon + +systemctl enable guix-daemon-latest +systemctl start guix-daemon-latest +``` + +##### Otherwise... + +Simply do: + +```sh +systemctl restart guix-daemon +``` + +### Checking everything + +If you followed all the steps above to make your Guix setup "prim and proper," +you can check that you did everything properly by running through this +checklist. + +1. `/etc/profile.d/guix.sh` should exist and be sourced at each shell login + +2. `guix describe` should not print `guix describe: error: failed to determine + origin`, but rather something like: + + ``` + Generation 38 Feb 22 2021 16:39:31 (current) + guix f350df4 + repository URL: https://git.savannah.gnu.org/git/guix.git + branch: version-1.2.0 + commit: f350df405fbcd5b9e27e6b6aa500da7f101f41e7 + ``` + +3. `guix-daemon` should be running from `${localstatedir}/guix/profiles/per-user/root/current-guix` + +# Troubleshooting + +## Derivation failed to build + +When you see a build failure like below: + +``` +building /gnu/store/...-foo-3.6.12.drv... +/ 'check' phasenote: keeping build directory `/tmp/guix-build-foo-3.6.12.drv-0' +builder for `/gnu/store/...-foo-3.6.12.drv' failed with exit code 1 +build of /gnu/store/...-foo-3.6.12.drv failed +View build log at '/var/log/guix/drvs/../...-foo-3.6.12.drv.bz2'. +cannot build derivation `/gnu/store/...-qux-7.69.1.drv': 1 dependencies couldn't be built +cannot build derivation `/gnu/store/...-bar-3.16.5.drv': 1 dependencies couldn't be built +cannot build derivation `/gnu/store/...-baz-2.0.5.drv': 1 dependencies couldn't be built +guix time-machine: error: build of `/gnu/store/...-baz-2.0.5.drv' failed +``` + +It means that `guix` failed to build a package named `foo`, which was a +dependency of `qux`, `bar`, and `baz`. Importantly, note that the last "failed" +line is not necessarily the root cause, the first "failed" line is. + +Most of the time, the build failure is due to a spurious test failure or the +package's build system/test suite breaking when running multi-threaded. To +rebuild _just_ this derivation in a single-threaded fashion (please don't forget +to add other `guix` flags like `--no-substitutes` as appropriate): + +```sh +$ guix build --cores=1 /gnu/store/...-foo-3.6.12.drv +``` + +If the single-threaded rebuild did not succeed, you may need to dig deeper. +You may view `foo`'s build logs in `less` like so (please replace paths with the +path you see in the build failure output): + +```sh +$ bzcat /var/log/guix/drvs/../...-foo-3.6.12.drv.bz2 | less +``` + +`foo`'s build directory is also preserved and available at +`/tmp/guix-build-foo-3.6.12.drv-0`. However, if you fail to build `foo` multiple +times, it may be `/tmp/...drv-1` or `/tmp/...drv-2`. Always consult the build +failure output for the most accurate, up-to-date information. + +### python(-minimal): [Errno 84] Invalid or incomplete multibyte or wide character + +This error occurs when your `$TMPDIR` (default: /tmp) exists on a filesystem +which rejects characters not present in the UTF-8 character code set. An example +is ZFS with the utf8only=on option set. + +More information: https://bugs.python.org/issue37584 + +### GnuTLS: test-suite FAIL: status-request-revoked + +*The derivation is likely identified by: `/gnu/store/vhphki5sg9xkdhh2pbc8gi6vhpfzryf0-gnutls-3.6.12.drv`* + +This unfortunate error is most common for non-substitute builders who installed +Guix v1.2.0. The problem stems from the fact that one of GnuTLS's tests uses a +hardcoded certificate which expired on 2020-10-24. + +What's more unfortunate is that this GnuTLS derivation is somewhat special in +Guix's dependency graph and is not affected by the package transformation flags +like `--without-tests=`. + +The easiest solution for those encountering this problem is to install a newer +version of Guix. However, there are ways to work around this issue: + +#### Workaround 1: Using substitutes for this single derivation + +If you've authorized the official Guix build farm's key (more info +[here](./README.md#step-1-authorize-the-signing-keys)), then you can use +substitutes just for this single derivation by invoking the following: + +```sh +guix build --substitute-urls="https://ci.guix.gnu.org" /gnu/store/vhphki5sg9xkdhh2pbc8gi6vhpfzryf0-gnutls-3.6.12.drv +``` + +See [this section](./README.md#removing-authorized-keys) for instructions on how +to remove authorized keys if you don't want to keep the build farm's key +authorized. + +#### Workaround 2: Temporarily setting the system clock back + +This workaround was described [here](https://issues.guix.gnu.org/44559#5). + +Basically: +1. Turn off networking +2. Turn off NTP +3. Set system time to 2020-10-01 +4. guix build --no-substitutes /gnu/store/vhphki5sg9xkdhh2pbc8gi6vhpfzryf0-gnutls-3.6.12.drv +5. Set system time back to accurate current time +6. Turn NTP back on +7. Turn networking back on + +### coreutils: FAIL: tests/tail-2/inotify-dir-recreate + +The inotify-dir-create test fails on "remote" filesystems such as overlayfs +(Docker's default filesystem) due to the filesystem being mistakenly recognized +as non-remote. + +A relatively easy workaround to this is to make sure that a somewhat traditional +filesystem is mounted at `/tmp` (where `guix-daemon` performs its builds). For +Docker users, this might mean [using a volume][docker/volumes], [binding +mounting][docker/bind-mnt] from host, or (for those with enough RAM and swap) +[mounting a tmpfs][docker/tmpfs] using the `--tmpfs` flag. + +Please see the following links for more details: + +- An upstream coreutils bug has been filed: [debbugs#47940](https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47940) +- A Guix bug detailing the underlying problem has been filed: [guix-issues#47935](https://issues.guix.gnu.org/47935) +- A commit to skip this test in Guix has been merged into the core-updates branch: +[savannah/guix@6ba1058](https://git.savannah.gnu.org/cgit/guix.git/commit/?id=6ba1058df0c4ce5611c2367531ae5c3cdc729ab4) + + +[install-script]: #options-1-and-2-using-the-official-shell-installer-script-or-binary-tarball +[install-bin-tarball]: #options-1-and-2-using-the-official-shell-installer-script-or-binary-tarball +[install-fanquake-docker]: #option-3-using-fanquakes-docker-image +[install-distro-pkg]: #option-4-using-a-distribution-maintained-package +[install-source]: #option-5-building-from-source + +[fix-argv0]: #creating-and-starting-a-guix-daemon-original-service-with-a-fixed-argv0 +[security-model]: ./README.md#choosing-your-security-model + +[docker/volumes]: https://docs.docker.com/storage/volumes/ +[docker/bind-mnt]: https://docs.docker.com/storage/bind-mounts/ +[docker/tmpfs]: https://docs.docker.com/storage/tmpfs/ diff --git a/contrib/guix/LICENSE.txt b/contrib/guix/LICENSE.txt new file mode 100644 index 0000000..ac7f46a --- /dev/null +++ b/contrib/guix/LICENSE.txt @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) 2009-2022 The Bitcoin Core developers +Copyright (c) 2009-2022 Bitcoin Developers +Copyright (c) 2022-2022 The Monero Project + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/contrib/guix/README.md b/contrib/guix/README.md new file mode 100644 index 0000000..b0babbe --- /dev/null +++ b/contrib/guix/README.md @@ -0,0 +1,401 @@ +# Bootstrappable Feather Wallet Builds + +This directory contains the files necessary to perform bootstrappable Feather Wallet +builds. + +[Bootstrappability][b17e] furthers our binary security guarantees by allowing us +to _audit and reproduce_ our toolchain instead of blindly _trusting_ binary +downloads. + +We achieve bootstrappability by using Guix as a functional package manager. + +# Requirements + +Conservatively, you will need an x86_64 machine with: + +- 16GB of free disk space on the partition that /gnu/store will reside in +- 8GB of free disk space **per platform triple** you're planning on building + (see the `HOSTS` [environment variable description][env-vars-list]) + +# Installation and Setup + +If you don't have Guix installed and set up, please follow the instructions in +[INSTALL.md](./INSTALL.md) + +# Usage + +If you haven't considered your security model yet, please read [the relevant +section](#choosing-your-security-model) before proceeding to perform a build. + +## Making the Xcode SDK available for macOS cross-compilation + +In order to perform a build for macOS (which is included in the default set of +platform triples to build), you'll need to extract the macOS SDK tarball using +tools found in the [`macdeploy` directory](../macdeploy/README.md). + +You can then either point to the SDK using the `SDK_PATH` environment variable: + +```sh +# Extract the SDK tarball to /path/to/parent/dir/of/extracted/SDK/Xcode---extracted-SDK-with-libcxx-headers +tar -C /path/to/parent/dir/of/extracted/SDK -xaf /path/to/Xcode---extracted-SDK-with-libcxx-headers.tar.gz + +# Indicate where to locate the SDK tarball +export SDK_PATH=/path/to/parent/dir/of/extracted/SDK +``` + +or extract it into `depends/SDKs`: + +```sh +mkdir -p depends/SDKs +tar -C depends/SDKs -xaf /path/to/SDK/tarball +``` + +## Building + +*The author highly recommends at least reading over the [common usage patterns +and examples](#common-guix-build-invocation-patterns-and-examples) section below +before starting a build. For a full list of customization options, see the +[recognized environment variables][env-vars-list] section.* + +To build Feather Wallet reproducibly with all default options, invoke the +following from the top of a clean repository: + +```sh +./contrib/guix/guix-build +``` + +## Cleaning intermediate work directories + +By default, `guix-build` leaves all intermediate files or "work directories" +(e.g. `depends/work`, `guix-build-*/distsrc-*`) intact at the end of a build so +that they are available to the user (to aid in debugging, etc.). However, these +directories usually take up a large amount of disk space. Therefore, a +`guix-clean` convenience script is provided which cleans the current `git` +worktree to save disk space: + +``` +./contrib/guix/guix-clean +``` + +## Common `guix-build` invocation patterns and examples + +### Keeping caches and SDKs outside of the worktree + +If you perform a lot of builds and have a bunch of worktrees, you may find it +more efficient to keep the depends tree's download cache, build cache, and SDKs +outside of the worktrees to avoid duplicate downloads and unnecessary builds. To +help with this situation, the `guix-build` script honours the `SOURCES_PATH`, +`BASE_CACHE`, and `SDK_PATH` environment variables and will pass them on to the +depends tree so that you can do something like: + +```sh +env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build +``` + +Note that the paths that these environment variables point to **must be +directories**, and **NOT symlinks to directories**. + +See the [recognized environment variables][env-vars-list] section for more +details. + +### Building a subset of platform triples + +Sometimes you only want to build a subset of the supported platform triples, in +which case you can override the default list by setting the space-separated +`HOSTS` environment variable: + +```sh +env HOSTS='x86_64-w64-mingw32 x86_64-apple-darwin' ./contrib/guix/guix-build +``` + +See the [recognized environment variables][env-vars-list] section for more +details. + +### Controlling the number of threads used by `guix` build commands + +Depending on your system's RAM capacity, you may want to decrease the number of +threads used to decrease RAM usage or vice versa. + +By default, the scripts under `./contrib/guix` will invoke all `guix` build +commands with `--cores="$JOBS"`. Note that `$JOBS` defaults to `$(nproc)` if not +specified. However, astute manual readers will also notice that `guix` build +commands also accept a `--max-jobs=` flag (which defaults to 1 if unspecified). + +Here is the difference between `--cores=` and `--max-jobs=`: + +> Note: When I say "derivation," think "package" + +`--cores=` + + - controls the number of CPU cores to build each derivation. This is the value + passed to `make`'s `--jobs=` flag. + +`--max-jobs=` + + - controls how many derivations can be built in parallel + - defaults to 1 + +Therefore, the default is for `guix` build commands to build one derivation at a +time, utilizing `$JOBS` threads. + +Specifying the `$JOBS` environment variable will only modify `--cores=`, but you +can also modify the value for `--max-jobs=` by specifying +`$ADDITIONAL_GUIX_COMMON_FLAGS`. For example, if you have a LOT of memory, you +may want to set: + +```sh +export ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8' +``` + +Which allows for a maximum of 8 derivations to be built at the same time, each +utilizing `$JOBS` threads. + +Or, if you'd like to avoid spurious build failures caused by issues with +parallelism within a single package, but would still like to build multiple +packages when the dependency graph allows for it, you may want to try: + +```sh +export JOBS=1 ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8' +``` + +See the [recognized environment variables][env-vars-list] section for more +details. + +## Recognized environment variables + +* _**HOSTS**_ + + Override the space-separated list of platform triples for which to perform a + bootstrappable build. + + _(defaults to "x86\_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu + riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu + x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin")_ + +* _**SOURCES_PATH**_ + + Set the depends tree download cache for sources. This is passed through to the + depends tree. Setting this to the same directory across multiple builds of the + depends tree can eliminate unnecessary redownloading of package sources. + + The path that this environment variable points to **must be a directory**, and + **NOT a symlink to a directory**. + +* _**BASE_CACHE**_ + + Set the depends tree cache for built packages. This is passed through to the + depends tree. Setting this to the same directory across multiple builds of the + depends tree can eliminate unnecessary building of packages. + + The path that this environment variable points to **must be a directory**, and + **NOT a symlink to a directory**. + +* _**SDK_PATH**_ + + Set the path where _extracted_ SDKs can be found. This is passed through to + the depends tree. Note that this is should be set to the _parent_ directory of + the actual SDK (e.g. `SDK_PATH=$HOME/Downloads/macOS-SDKs` instead of + `$HOME/Downloads/macOS-SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers`). + + The path that this environment variable points to **must be a directory**, and + **NOT a symlink to a directory**. + +* _**JOBS**_ + + Override the number of jobs to run simultaneously, you might want to do so on + a memory-limited machine. This may be passed to: + + - `guix` build commands as in `guix environment --cores="$JOBS"` + - `make` as in `make --jobs="$JOBS"` + - `xargs` as in `xargs -P"$JOBS"` + + See [here](#controlling-the-number-of-threads-used-by-guix-build-commands) for + more details. + + _(defaults to the value of `nproc` outside the container)_ + +* _**SOURCE_DATE_EPOCH**_ + + Override the reference UNIX timestamp used for bit-for-bit reproducibility, + the variable name conforms to [standard][r12e/source-date-epoch]. + + _(defaults to the output of `$(git log --format=%at -1)`)_ + +* _**V**_ + + If non-empty, will pass `V=1` to all `make` invocations, making `make` output + verbose. + + Note that any given value is ignored. The variable is only checked for + emptiness. More concretely, this means that `V=` (setting `V` to the empty + string) is interpreted the same way as not setting `V` at all, and that `V=0` + has the same effect as `V=1`. + +* _**SUBSTITUTE_URLS**_ + + A whitespace-delimited list of URLs from which to download pre-built packages. + A URL is only used if its signing key is authorized (refer to the [substitute + servers section](#option-1-building-with-substitutes) for more details). + +* _**ADDITIONAL_GUIX_COMMON_FLAGS**_ + + Additional flags to be passed to all `guix` commands. + +* _**ADDITIONAL_GUIX_TIMEMACHINE_FLAGS**_ + + Additional flags to be passed to `guix time-machine`. + +* _**ADDITIONAL_GUIX_ENVIRONMENT_FLAGS**_ + + Additional flags to be passed to the invocation of `guix environment` inside + `guix time-machine`. + +# Choosing your security model + +No matter how you installed Guix, you need to decide on your security model for +building packages with Guix. + +Guix allows us to achieve better binary security by using our CPU time to build +everything from scratch. However, it doesn't sacrifice user choice in pursuit of +this: users can decide whether or not to use **substitutes** (pre-built +packages). + +## Option 1: Building with substitutes + +### Step 1: Authorize the signing keys + +Depending on the installation procedure you followed, you may have already +authorized the Guix build farm key. In particular, the official shell installer +script asks you if you want the key installed, and the debian distribution +package authorized the key during installation. + +You can check the current list of authorized keys at `/etc/guix/acl`. + +At the time of writing, a `/etc/guix/acl` with just the Guix build farm key +authorized looks something like: + +```lisp +(acl + (entry + (public-key + (ecc + (curve Ed25519) + (q #8D156F295D24B0D9A86FA5741A840FF2D24F60F7B6C4134814AD55625971B394#) + ) + ) + (tag + (guix import) + ) + ) + ) +``` + +If you've determined that the official Guix build farm key hasn't been +authorized, and you would like to authorize it, run the following as root: + +``` +guix archive --authorize < /var/guix/profiles/per-user/root/current-guix/share/guix/ci.guix.gnu.org.pub +``` + +If +`/var/guix/profiles/per-user/root/current-guix/share/guix/ci.guix.gnu.org.pub` +doesn't exist, try: + +```sh +guix archive --authorize < /share/guix/ci.guix.gnu.org.pub +``` + +Where `` is likely: +- `/usr` if you installed from a distribution package +- `/usr/local` if you installed Guix from source and didn't supply any + prefix-modifying flags to Guix's `./configure` + +#### Removing authorized keys + +To remove previously authorized keys, simply edit `/etc/guix/acl` and remove the +`(entry (public-key ...))` entry. + +### Step 2: Specify the substitute servers + +Once its key is authorized, the official Guix build farm at +https://ci.guix.gnu.org is automatically used unless the `--no-substitutes` flag +is supplied. This default list of substitute servers is overridable both on a +`guix-daemon` level and when you invoke `guix` commands. + +## Option 2: Disabling substitutes on an ad-hoc basis + +If you prefer not to use any substitutes, make sure to supply `--no-substitutes` +like in the following snippet. The first build will take a while, but the +resulting packages will be cached for future builds. + +For direct invocations of `guix`: +```sh +guix --no-substitutes +``` + +For the scripts under `./contrib/guix/`: +```sh +export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes' +``` + +## Option 3: Disabling substitutes by default + +`guix-daemon` accepts a `--no-substitutes` flag, which will make sure that, +unless otherwise overridden by a command line invocation, no substitutes will be +used. + +If you start `guix-daemon` using an init script, you can edit said script to +supply this flag. + + +# Purging/Uninstalling Guix + +In the extraordinarily rare case where you messed up your Guix installation in +an irreversible way, you may want to completely purge Guix from your system and +start over. + +1. Uninstall Guix itself according to the way you installed it (e.g. `sudo apt + purge guix` for Ubuntu packaging, `sudo make uninstall` for a build from source). +2. Remove all build users and groups + + You may check for relevant users and groups using: + + ``` + getent passwd | grep guix + getent group | grep guix + ``` + + Then, you may remove users and groups using: + + ``` + sudo userdel + sudo groupdel + ``` + +3. Remove all possible Guix-related directories + - `/var/guix/` + - `/var/log/guix/` + - `/gnu/` + - `/etc/guix/` + - `/home/*/.config/guix/` + - `/home/*/.cache/guix/` + - `/home/*/.guix-profile/` + - `/root/.config/guix/` + - `/root/.cache/guix/` + - `/root/.guix-profile/` + +[b17e]: https://bootstrappable.org/ +[r12e/source-date-epoch]: https://reproducible-builds.org/docs/source-date-epoch/ + +[guix/install.sh]: https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh +[guix/bin-install]: https://www.gnu.org/software/guix/manual/en/html_node/Binary-Installation.html +[guix/env-setup]: https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html +[guix/substitutes]: https://www.gnu.org/software/guix/manual/en/html_node/Substitutes.html +[guix/substitute-server-auth]: https://www.gnu.org/software/guix/manual/en/html_node/Substitute-Server-Authorization.html +[guix/time-machine]: https://guix.gnu.org/manual/en/html_node/Invoking-guix-time_002dmachine.html + +[debian/guix-bullseye]: https://packages.debian.org/bullseye/guix +[ubuntu/guix-hirsute]: https://packages.ubuntu.com/hirsute/guix +[fanquake/guix-docker]: https://github.com/fanquake/core-review/tree/master/guix + +[env-vars-list]: #recognized-environment-variables diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build new file mode 100755 index 0000000..543e715 --- /dev/null +++ b/contrib/guix/guix-build @@ -0,0 +1,466 @@ +#!/usr/bin/env bash +export LC_ALL=C +set -e -o pipefail + +# Source the common prelude, which: +# 1. Checks if we're at the top directory of the Feather Wallet repository +# 2. Defines a few common functions and variables +# +# shellcheck source=libexec/prelude.bash +source "$(dirname "${BASH_SOURCE[0]}")/libexec/prelude.bash" + +################### +## SANITY CHECKS ## +################### + +################ +# Required non-builtin commands should be invocable +################ + +check_tools cat mkdir make getent curl git guix + +################ +# GUIX_BUILD_OPTIONS should be empty +################ +# +# GUIX_BUILD_OPTIONS is an environment variable recognized by guix commands that +# can perform builds. This seems like what we want instead of +# ADDITIONAL_GUIX_COMMON_FLAGS, but the value of GUIX_BUILD_OPTIONS is actually +# _appended_ to normal command-line options. Meaning that they will take +# precedence over the command-specific ADDITIONAL_GUIX__FLAGS. +# +# This seems like a poor user experience. Thus we check for GUIX_BUILD_OPTIONS's +# existence here and direct users of this script to use our (more flexible) +# custom environment variables. +if [ -n "$GUIX_BUILD_OPTIONS" ]; then +cat << EOF +Error: Environment variable GUIX_BUILD_OPTIONS is not empty: + '$GUIX_BUILD_OPTIONS' + +Unfortunately this script is incompatible with GUIX_BUILD_OPTIONS, please unset +GUIX_BUILD_OPTIONS and use ADDITIONAL_GUIX_COMMON_FLAGS to set build options +across guix commands or ADDITIONAL_GUIX__FLAGS to set build options for a +specific guix command. + +See contrib/guix/README.md for more details. +EOF +exit 1 +fi + +################ +# The git worktree should not be dirty +################ + +if ! git diff-index --quiet HEAD -- && [ -z "$FORCE_DIRTY_WORKTREE" ]; then +cat << EOF +ERR: The current git worktree is dirty, which may lead to broken builds. + + Aborting... + +Hint: To make your git worktree clean, You may want to: + 1. Commit your changes, + 2. Stash your changes, or + 3. Set the 'FORCE_DIRTY_WORKTREE' environment variable if you insist on + using a dirty worktree +EOF +exit 1 +fi + +mkdir -p "$VERSION_BASE" + +################ +# Build directories should not exist +################ + +# Default to building for all supported HOSTs (overridable by environment) +export HOSTS="${HOSTS:-x86_64-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf + x86_64-w64-mingw32 x86_64-w64-mingw32.installer + x86_64-apple-darwin}" + +# Usage: distsrc_for_host HOST +# +# HOST: The current platform triple we're building for +# +distsrc_for_host() { + echo "${DISTSRC_BASE}/distsrc-${VERSION}-${1}" +} + +# Accumulate a list of build directories that already exist... +hosts_distsrc_exists="" +for host in $HOSTS; do + if [ -e "$(distsrc_for_host "$host")" ]; then + hosts_distsrc_exists+=" ${host}" + fi +done + +if [ -n "$hosts_distsrc_exists" ]; then +# ...so that we can print them out nicely in an error message +cat << EOF +ERR: Build directories for this commit already exist for the following platform + triples you're attempting to build, probably because of previous builds. + Please remove, or otherwise deal with them prior to starting another build. + + Aborting... + +Hint: To blow everything away, you may want to use: + + $ ./contrib/guix/guix-clean + +Specifically, this will remove all files without an entry in the index, +excluding the SDK directory, the depends download cache, the depends built +packages cache, the garbage collector roots for Guix environments, and the +output directory. +EOF +for host in $hosts_distsrc_exists; do + echo " ${host} '$(distsrc_for_host "$host")'" +done +exit 1 +else + mkdir -p "$DISTSRC_BASE" +fi + +################ +# When building for darwin, the macOS SDK should exist +################ + +for host in $HOSTS; do + case "$host" in + *darwin*) + OSX_SDK="$(make -C "${PWD}/contrib/depends" --no-print-directory HOST="$host" print-OSX_SDK | sed 's@^[^=]\+=@@g')" + if [ -e "$OSX_SDK" ]; then + echo "Found macOS SDK at '${OSX_SDK}', using..." + break + else + echo "macOS SDK does not exist at '${OSX_SDK}', please place the extracted, untarred SDK there to perform darwin builds, or define SDK_PATH environment variable. Exiting..." + exit 1 + fi + ;; + esac +done + +################ +# VERSION_BASE should have enough space +################ + +avail_KiB="$(df -Pk "$VERSION_BASE" | sed 1d | tr -s ' ' | cut -d' ' -f4)" +total_required_KiB=0 +for host in $HOSTS; do + case "$host" in + *darwin*) required_KiB=440000 ;; + *mingw*) required_KiB=7600000 ;; + *) required_KiB=6400000 ;; + esac + total_required_KiB=$((total_required_KiB+required_KiB)) +done + +if (( total_required_KiB > avail_KiB )); then + total_required_GiB=$((total_required_KiB / 1048576)) + avail_GiB=$((avail_KiB / 1048576)) + echo "Performing a Feather Wallet Guix build for the selected HOSTS requires ${total_required_GiB} GiB, however, only ${avail_GiB} GiB is available. Please free up some disk space before performing the build." + exit 1 +fi + +################ +# Check that we can connect to the guix-daemon +################ + +cat << EOF +Checking that we can connect to the guix-daemon... + +Hint: If this hangs, you may want to try turning your guix-daemon off and on + again. + +EOF +if ! guix gc --list-failures > /dev/null; then +cat << EOF + +ERR: Failed to connect to the guix-daemon, please ensure that one is running and + reachable. +EOF +exit 1 +fi + +# Developer note: we could use `guix repl` for this check and run: +# +# (import (guix store)) (close-connection (open-connection)) +# +# However, the internal API is likely to change more than the CLI invocation + +################ +# Services database must have basic entries +################ + +if ! getent services http https ftp > /dev/null 2>&1; then +cat << EOF +ERR: Your system's C library cannot find service database entries for at least + one of the following services: http, https, ftp. + +Hint: Most likely, /etc/services does not exist yet (common for docker images + and minimal distros), or you don't have permissions to access it. + + If /etc/services does not exist yet, you may want to install the + appropriate package for your distro which provides it. + + On Debian/Ubuntu: netbase + On Arch Linux: iana-etc + + For more information, see: getent(1), services(5) + +EOF + +fi + +######### +# SETUP # +######### + +# Determine the maximum number of jobs to run simultaneously (overridable by +# environment) +JOBS="${JOBS:-$(nproc)}" + +# Usage: host_to_commonname HOST +# +# HOST: The current platform triple we're building for +# +host_to_commonname() { + case "$1" in + *darwin*) echo osx ;; + *mingw*) echo win ;; + *linux*) echo linux ;; + *) exit 1 ;; + esac +} + +SOURCE_DATE_EPOCH="1672070414" + +# Precious directories are those which should not be cleaned between successive +# guix builds +depends_precious_dir_names='SOURCES_PATH BASE_CACHE SDK_PATH' +precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE" + +# Usage: contains IFS-SEPARATED-LIST ITEM +contains() { + for i in ${1}; do + if [ "$i" = "${2}" ]; then + return 0 # Found! + fi + done + return 1 +} + +# If the user explicitly specified a precious directory, create it so we +# can map it into the container +for precious_dir_name in $precious_dir_names; do + precious_dir_path="${!precious_dir_name}" + if [ -n "$precious_dir_path" ]; then + if [ ! -e "$precious_dir_path" ]; then + mkdir -p "$precious_dir_path" + elif [ -L "$precious_dir_path" ]; then + echo "ERR: ${precious_dir_name} cannot be a symbolic link" + exit 1 + elif [ ! -d "$precious_dir_path" ]; then + echo "ERR: ${precious_dir_name} must be a directory" + exit 1 + fi + fi +done + +mkdir -p "$VAR_BASE" + +# Record the _effective_ values of precious directories such that guix-clean can +# avoid clobbering them if appropriate. +# +# shellcheck disable=SC2046,SC2086 +{ + # Get depends precious dir definitions from depends + make -C "${PWD}/contrib/depends" \ + --no-print-directory \ + -- $(printf "print-%s\n" $depends_precious_dir_names) + + # Get remaining precious dir definitions from the environment + for precious_dir_name in $precious_dir_names; do + precious_dir_path="${!precious_dir_name}" + if ! contains "$depends_precious_dir_names" "$precious_dir_name"; then + echo "${precious_dir_name}=${precious_dir_path}" + fi + done +} > "${VAR_BASE}/precious_dirs" + +# Make sure an output directory exists for our builds +OUTDIR_BASE="${OUTDIR_BASE:-${VERSION_BASE}/output}" +mkdir -p "$OUTDIR_BASE" + +# Download the depends sources now as we won't have internet access in the build +# container +for host in $HOSTS; do + host_split=(${host//./ }) + make -C "${PWD}/contrib/depends" -j"$JOBS" download-"$(host_to_commonname "${host_split[0]}")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} +done + +# Usage: outdir_for_host HOST SUFFIX +# +# HOST: The current platform triple we're building for +# +outdir_for_host() { + echo "${OUTDIR_BASE}/${1}${2:+-${2}}" +} + +# Usage: profiledir_for_host HOST SUFFIX +# +# HOST: The current platform triple we're building for +# +profiledir_for_host() { + echo "${PROFILES_BASE}/${1}${2:+-${2}}" +} + + +######### +# BUILD # +######### + +# Function to be called when building for host ${1} and the user interrupts the +# build +int_trap() { +cat << EOF +** INT received while building ${1}, you may want to clean up the relevant + work directories (e.g. distsrc-*) before rebuilding + +Hint: To blow everything away, you may want to use: + + $ ./contrib/guix/guix-clean + +Specifically, this will remove all files without an entry in the index, +excluding the SDK directory, the depends download cache, the depends built +packages cache, the garbage collector roots for Guix environments, and the +output directory. +EOF +} + +# Deterministically build Feather Wallet +# shellcheck disable=SC2153 +for host in $HOSTS; do + + # Display proper warning when the user interrupts the build + trap 'int_trap ${host}' INT + + ( + host_split=(${host//./ }) + + # Required for 'contrib/guix/manifest.scm' to output the right manifest + # for the particular $HOST we're building for + export HOST="${host_split[0]}" + + # shellcheck disable=SC2030 +cat << EOF +INFO: Building ${VERSION:?not set} for platform triple ${HOST:?not set}: + ...using reference timestamp: ${SOURCE_DATE_EPOCH:?not set} + ...running at most ${JOBS:?not set} jobs + ...from worktree directory: '${PWD}' + ...bind-mounted in container to: '/feather' + ...in build directory: '$(distsrc_for_host "$HOST")' + ...bind-mounted in container to: '$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$HOST")' + ...outputting in: '$(outdir_for_host "$HOST")' + ...bind-mounted in container to: '$(OUTDIR_BASE=/outdir-base && outdir_for_host "$HOST")' +EOF + + # Run the build script 'contrib/guix/libexec/build.sh' in the build + # container specified by 'contrib/guix/manifest.scm'. + # + # Explanation of `guix environment` flags: + # + # --container run command within an isolated container + # + # Running in an isolated container minimizes build-time differences + # between machines and improves reproducibility + # + # --pure unset existing environment variables + # + # Same rationale as --container + # + # --no-cwd do not share current working directory with an + # isolated container + # + # When --container is specified, the default behavior is to share + # the current working directory with the isolated container at the + # same exact path (e.g. mapping '/home/user/feather/' to + # '/home/user/feather/'). This means that the $PWD inside the + # container becomes a source of irreproducibility. --no-cwd disables + # this behaviour. + # + # --share=SPEC for containers, share writable host file system + # according to SPEC + # + # --share="$PWD"=/feather + # + # maps our current working directory to /feather + # inside the isolated container, which we later cd + # into. + # + # While we don't want to map our current working directory to the + # same exact path (as this introduces irreproducibility), we do want + # it to be at a _fixed_ path _somewhere_ inside the isolated + # container so that we have something to build. '/feather' was + # chosen arbitrarily. + # + # ${SOURCES_PATH:+--share="$SOURCES_PATH"} + # + # make the downloaded depends sources path available + # inside the isolated container + # + # The isolated container has no network access as it's in a + # different network namespace from the main machine, so we have to + # make the downloaded depends sources available to it. The sources + # should have been downloaded prior to this invocation. + # + # --keep-failed keep build tree of failed builds + # + # When builds of the Guix environment itself (not Feather Wallet) + # fail, it is useful for the build tree to be kept for debugging + # purposes. + # + # ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} + # + # fetch substitute from SUBSTITUTE_URLS if they are + # authorized + # + # Depending on the user's security model, it may be desirable to use + # substitutes (pre-built packages) from servers that the user trusts. + # Please read the README.md in the same directory as this file for + # more information. + # + # shellcheck disable=SC2086,SC2031 + time-machine environment --manifest="${PWD}/contrib/guix/manifest.scm" \ + --container \ + --pure \ + --no-cwd \ + --share="$PWD"=/feather \ + --share="$DISTSRC_BASE"=/distsrc-base \ + --share="$OUTDIR_BASE"=/outdir-base \ + --expose="$(git rev-parse --git-common-dir)" \ + ${SOURCES_PATH:+--share="$SOURCES_PATH"} \ + ${BASE_CACHE:+--share="$BASE_CACHE"} \ + ${SDK_PATH:+--share="$SDK_PATH"} \ + --cores="$JOBS" \ + --keep-failed \ + --fallback \ + --link-profile \ + --user="user" \ + --root="$(profiledir_for_host "${HOST}")" \ + ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ + ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ + -- env HOST="$HOST" \ + DISTNAME="$DISTNAME" \ + JOBS="$JOBS" \ + SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ + ${V:+V=1} \ + ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE:+BASE_CACHE="$BASE_CACHE"} \ + ${SDK_PATH:+SDK_PATH="$SDK_PATH"} \ + DISTSRC="$(DISTSRC_BASE=/distsrc-base && distsrc_for_host "$host")" \ + OUTDIR="$(OUTDIR_BASE=/outdir-base && outdir_for_host "$host")" \ + DIST_ARCHIVE_BASE=/outdir-base/dist-archive \ + OPTIONS="${host_split[1]}" \ + bash -c "cd /feather && bash contrib/guix/libexec/build.sh" + ) + +done diff --git a/contrib/guix/guix-clean b/contrib/guix/guix-clean new file mode 100755 index 0000000..14631f7 --- /dev/null +++ b/contrib/guix/guix-clean @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +export LC_ALL=C +set -e -o pipefail + +# Source the common prelude, which: +# 1. Checks if we're at the top directory of the Feather Wallet repository +# 2. Defines a few common functions and variables +# +# shellcheck source=libexec/prelude.bash +source "$(dirname "${BASH_SOURCE[0]}")/libexec/prelude.bash" + + +################### +## Sanity Checks ## +################### + +################ +# Required non-builtin commands should be invokable +################ + +check_tools cat mkdir make git guix + + +############# +## Clean ## +############# + +# Usage: under_dir MAYBE_PARENT MAYBE_CHILD +# +# If MAYBE_CHILD is a subdirectory of MAYBE_PARENT, print the relative path +# from MAYBE_PARENT to MAYBE_CHILD. Otherwise, return 1 as the error code. +# +# NOTE: This does not perform any symlink-resolving or path canonicalization. +# +under_dir() { + local path_residue + path_residue="${2##"${1}"}" + if [ -z "$path_residue" ] || [ "$path_residue" = "$2" ]; then + return 1 + else + echo "$path_residue" + fi +} + +# Usage: dir_under_git_root MAYBE_CHILD +# +# If MAYBE_CHILD is under the current git repository and exists, print the +# relative path from the git repository's top-level directory to MAYBE_CHILD, +# otherwise, exit with an error code. +# +dir_under_git_root() { + local rv + rv="$(under_dir "$(git_root)" "$1")" + [ -n "$rv" ] && echo "$rv" +} + +shopt -s nullglob +found_precious_dirs_files=( "${version_base_prefix}"*/"${var_base_basename}/precious_dirs" ) # This expands to an array of directories... +shopt -u nullglob + +exclude_flags=() + +for precious_dirs_file in "${found_precious_dirs_files[@]}"; do + # Make sure the precious directories (e.g. SOURCES_PATH, BASE_CACHE, SDK_PATH) + # are excluded from git-clean + echo "Found precious_dirs file: '${precious_dirs_file}'" + + # Exclude the precious_dirs file itself + if dirs_file_exclude_fragment=$(dir_under_git_root "$(dirname "$precious_dirs_file")"); then + exclude_flags+=( --exclude="${dirs_file_exclude_fragment}/precious_dirs" ) + fi + + # Read each 'name=dir' pair from the precious_dirs file + while IFS='=' read -r name dir; do + # Add an exclusion flag if the precious directory is under the git root. + if under=$(dir_under_git_root "$dir"); then + echo "Avoiding ${name}: ${under}" + exclude_flags+=( --exclude="$under" ) + fi + done < "$precious_dirs_file" +done + +git clean -xdff "${exclude_flags[@]}" diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh new file mode 100755 index 0000000..4bc23a8 --- /dev/null +++ b/contrib/guix/libexec/build.sh @@ -0,0 +1,412 @@ +#!/usr/bin/env bash +# Copyright (c) 2019-2021 The Bitcoin Core developers +# Copyright (c) 2022-2022 The Monero Project +# Distributed under the MIT software license, see the accompanying +# file ../LICENSE.txt or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C +set -e -o pipefail +export TZ=UTC + +# shellcheck source=contrib/shell/git-utils.bash +source contrib/shell/git-utils.bash + +# Although Guix _does_ set umask when building its own packages (in our case, +# this is all packages in manifest.scm), it does not set it for `guix +# environment`. It does make sense for at least `guix environment --container` +# to set umask, so if that change gets merged upstream and we bump the +# time-machine to a commit which includes the aforementioned change, we can +# remove this line. +# +# This line should be placed before any commands which creates files. +umask 0022 + +if [ -n "$V" ]; then + # Print both unexpanded (-v) and expanded (-x) forms of commands as they are + # read from this file. + set -vx + # Set VERBOSE for CMake-based builds + export VERBOSE="$V" +fi + +# Check that required environment variables are set +cat << EOF +Required environment variables as seen inside the container: + DIST_ARCHIVE_BASE: ${DIST_ARCHIVE_BASE:?not set} + DISTNAME: ${DISTNAME:?not set} + HOST: ${HOST:?not set} + SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH:?not set} + JOBS: ${JOBS:?not set} + DISTSRC: ${DISTSRC:?not set} + OUTDIR: ${OUTDIR:?not set} + OPTIONS: ${OPTIONS} +EOF + +ACTUAL_OUTDIR="${OUTDIR}" +OUTDIR="${DISTSRC}/output" + +##################### +# Environment Setup # +##################### + +# The depends folder also serves as a base-prefix for depends packages for +# $HOSTs after successfully building. +BASEPREFIX="${PWD}/contrib/depends" + +# Given a package name and an output name, return the path of that output in our +# current guix environment +store_path() { + grep --extended-regexp "/[^-]{32}-${1}-[^-]+${2:+-${2}}" "${GUIX_ENVIRONMENT}/manifest" \ + | head --lines=1 \ + | sed --expression='s|^[[:space:]]*"||' \ + --expression='s|"[[:space:]]*$||' +} + + +# Set environment variables to point the NATIVE toolchain to the right +# includes/libs +NATIVE_GCC="$(store_path gcc-toolchain)" +NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)" + +unset LIBRARY_PATH +unset CPATH +unset C_INCLUDE_PATH +unset CPLUS_INCLUDE_PATH +unset OBJC_INCLUDE_PATH +unset OBJCPLUS_INCLUDE_PATH + +export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC}/lib64:${NATIVE_GCC_STATIC}/lib:${NATIVE_GCC_STATIC}/lib64" +export C_INCLUDE_PATH="${NATIVE_GCC}/include" +export CPLUS_INCLUDE_PATH="${NATIVE_GCC}/include/c++:${NATIVE_GCC}/include" +export OBJC_INCLUDE_PATH="${NATIVE_GCC}/include" +export OBJCPLUS_INCLUDE_PATH="${NATIVE_GCC}/include/c++:${NATIVE_GCC}/include" + +prepend_to_search_env_var() { + export "${1}=${2}${!1:+:}${!1}" +} + +# Set environment variables to point the CROSS toolchain to the right +# includes/libs for $HOST +case "$HOST" in + *mingw*) + # Determine output paths to use in CROSS_* environment variables + CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")" + CROSS_GCC="$(store_path "gcc-cross-${HOST}")" + CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" + CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... + CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) + + # The search path ordering is generally: + # 1. gcc-related search paths + # 2. libc-related search paths + # 2. kernel-header-related search paths (not applicable to mingw-w64 hosts) + export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include" + export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" + export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib" + ;; + *darwin*) + # The CROSS toolchain for darwin uses the SDK and ignores environment variables. + # See depends/hosts/darwin.mk for more details. + ;; + *linux*) + CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")" + CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)" + CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")" + CROSS_GCC="$(store_path "gcc-cross-${HOST}")" + CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)" + CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories... + CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one) + + export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include" + export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" + export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib" + ;; + *) + exit 1 ;; +esac + +# Sanity check CROSS_*_PATH directories +IFS=':' read -ra PATHS <<< "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" +for p in "${PATHS[@]}"; do + if [ -n "$p" ] && [ ! -d "$p" ]; then + echo "'$p' doesn't exist or isn't a directory... Aborting..." + exit 1 + fi +done + +# Disable Guix ld auto-rpath behavior +case "$HOST" in + *darwin*) + # The auto-rpath behavior is necessary for darwin builds as some native + # tools built by depends refer to and depend on Guix-built native + # libraries + # + # After the native packages in depends are built, the ld wrapper should + # no longer affect our build, as clang would instead reach for + # x86_64-apple-darwin-ld from cctools + ;; + *) export GUIX_LD_WRAPPER_DISABLE_RPATH=yes ;; +esac + +# Make /usr/bin if it doesn't exist +[ -e /usr/bin ] || mkdir -p /usr/bin + +# Symlink file and env to a conventional path +[ -e /usr/bin/file ] || ln -s --no-dereference "$(command -v file)" /usr/bin/file +[ -e /usr/bin/env ] || ln -s --no-dereference "$(command -v env)" /usr/bin/env + +# Determine the correct value for -Wl,--dynamic-linker for the current $HOST +case "$HOST" in + *linux*) + glibc_dynamic_linker=$( + case "$HOST" in + x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;; + arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;; + aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;; + riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;; + powerpc64-linux-gnu) echo /lib64/ld64.so.1;; + powerpc64le-linux-gnu) echo /lib64/ld64.so.2;; + *) exit 1 ;; + esac + ) + ;; +esac + +export GLIBC_DYNAMIC_LINKER=${glibc_dynamic_linker} + +# Environment variables for determinism +export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name" +export TZ="UTC" +case "$HOST" in + *darwin*) + # cctools AR, unlike GNU binutils AR, does not have a deterministic mode + # or a configure flag to enable determinism by default, it only + # understands if this env-var is set or not. See: + # + # https://github.com/tpoechtrager/cctools-port/blob/55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/ar/archive.c#L334 + export ZERO_AR_DATE=yes + ;; +esac + +#################### +# Depends Building # +#################### + +# LDFLAGS +case "$HOST" in + *linux*) HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -static-libstdc++ -Wl,-O2" ;; + *mingw*) HOST_LDFLAGS="-Wl,--no-insert-timestamp" ;; +esac + +# Using --no-tls-get-addr-optimize retains compatibility with glibc 2.18, by +# avoiding a PowerPC64 optimisation available in glibc 2.22 and later. +# https://sourceware.org/binutils/docs-2.35/ld/PowerPC64-ELF64.html +case "$HOST" in + *powerpc64*) HOST_LDFLAGS="${HOST_LDFLAGS} -Wl,--no-tls-get-addr-optimize" ;; +esac + +# Build the depends tree, overriding variables that assume multilib gcc +make -C contrib/depends --jobs="$JOBS" HOST="$HOST" \ + ${V:+V=1} \ + ${SOURCES_PATH+SOURCES_PATH="$SOURCES_PATH"} \ + ${BASE_CACHE+BASE_CACHE="$BASE_CACHE"} \ + ${SDK_PATH+SDK_PATH="$SDK_PATH"} \ + x86_64_linux_CC=x86_64-linux-gnu-gcc \ + x86_64_linux_CXX=x86_64-linux-gnu-g++ \ + x86_64_linux_AR=x86_64-linux-gnu-ar \ + x86_64_linux_RANLIB=x86_64-linux-gnu-ranlib \ + x86_64_linux_NM=x86_64-linux-gnu-nm \ + x86_64_linux_STRIP=x86_64-linux-gnu-strip \ + FORCE_USE_SYSTEM_CLANG=1 \ + qt_config_opts_x86_64_linux='-platform linux-g++ -xplatform bitcoin-linux-g++' \ + guix_ldflags="$HOST_LDFLAGS" + + +########################### +# Source Tarball Building # +########################### + +GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}.tar.gz" + +# Create the source tarball if not already there +if [ ! -e "$GIT_ARCHIVE" ]; then + mkdir -p "$(dirname "$GIT_ARCHIVE")" + echo "$(git_head_version)" > githash.txt + ( git ls-files --recurse-submodules ; echo "githash.txt" ) | cat | tar --transform 's,^,$DISTNAME/,' -caf ${GIT_ARCHIVE} -T- + sha256sum "$GIT_ARCHIVE" +fi + +mkdir -p "$OUTDIR" + +########################### +# Binary Tarball Building # +########################### + +# CFLAGS +HOST_CFLAGS="-O2 -g" +HOST_CFLAGS+=$(find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) +case "$HOST" in + *linux*) HOST_CFLAGS+=" -ffile-prefix-map=${PWD}=." ;; + *mingw*) HOST_CFLAGS+=" -fno-ident" ;; + *darwin*) unset HOST_CFLAGS ;; +esac + +# CXXFLAGS +HOST_CXXFLAGS="$HOST_CFLAGS" + +case "$HOST" in + arm-linux-gnueabihf) HOST_CXXFLAGS="${HOST_CXXFLAGS} -Wno-psabi" ;; +esac + +# Make $HOST-specific native binaries from depends available in $PATH +export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" +mkdir -p "$DISTSRC" +( + cd "$DISTSRC" + + # Extract the source tarball + tar --strip-components=1 -xf "${GIT_ARCHIVE}" + + # Setup the directory where our Bitcoin Core build for HOST will be + # installed. This directory will also later serve as the input for our + # binary tarballs. + INSTALLPATH="${DISTSRC}/installed" + mkdir -p "${INSTALLPATH}" + + + # Set appropriate CMake options for build type + CMAKEVARS="-DWITH_SCANNER=On" + case "$HOST" in + *mingw32) + case "$OPTIONS" in + installer) + CMAKEVARS+=" -DPLATFORM_INSTALLER=On -DTOR_DIR=Off -DTOR_VERSION=Off" + ;; + esac + ;; + *linux*) + case "$OPTIONS" in + tails) + CMAKEVARS+=" -DTOR_DIR=Off -DTOR_VERSION=Off" + ;; + esac + ;; + *gnueabihf) + CMAKEVARS+=" -DNO_AES=On" # Raspberry Pi + ;; + esac + + # Configure this DISTSRC for $HOST + # shellcheck disable=SC2086 + env CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" \ + cmake --toolchain "${BASEPREFIX}/${HOST}/share/toolchain.cmake" -S . -B build \ + -DCMAKE_INSTALL_PREFIX="${INSTALLPATH}" \ + -DCCACHE=OFF \ + ${CONFIGFLAGS} \ + -DCMAKE_EXE_LINKER_FLAGS="${HOST_LDFLAGS}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${HOST_LDFLAGS}" \ + ${CMAKEVARS} + + make -C build --jobs="$JOBS" + + case "$HOST" in + *linux*) + bash contrib/AppImage/build-appimage.sh + mv feather.AppImage ${DISTNAME}.AppImage + cp ${DISTNAME}.AppImage "${INSTALLPATH}/" + cp ${DISTNAME}.AppImage "${OUTDIR}/" + ;; + esac + + mkdir -p "$OUTDIR" + + # Make the os-specific installers + case "$HOST" in + *mingw*) + case "$OPTIONS" in + installer) + makensis -DCUR_PATH=$PWD -V2 contrib/installers/windows/setup.nsi + cp contrib/installers/windows/FeatherWalletSetup-*.exe "${INSTALLPATH}/" + mv contrib/installers/windows/FeatherWalletSetup-*.exe "${OUTDIR}/" + ;; + esac + ;; + esac + + # Install built Feather to $INSTALLPATH + case "$HOST" in + *darwin*) + make -C build install/strip ${V:+V=1} + ;; + *) + make -C build install ${V:+V=1} + ;; + esac + + # Make macOS DMG + case "$HOST" in + *darwin*) + make -C build deploy ${V:+V=1} + mv build/feather.dmg "${OUTDIR}/${DISTNAME}.dmg" + ;; + esac + + ( + cd installed + + # Finally, deterministically produce {non-,}debug binary tarballs ready + # for release + case "$HOST" in + *mingw*) + case "$OPTIONS" in + installer) + find . -print0 \ + | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" + find . \ + | sort \ + | zip -X@ "${OUTDIR}/${DISTNAME}-win-installer.zip" \ + || ( rm -f "${OUTDIR}/${DISTNAME}-win-installer.zip" && exit 1 ) + ;; + "") + mv feather.exe ${DISTNAME}.exe && \ + find . -print0 \ + | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" + find . \ + | sort \ + | zip -X@ "${OUTDIR}/${DISTNAME}-win.zip" \ + || ( rm -f "${OUTDIR}/${DISTNAME}-win.zip" && exit 1 ) + ;; + esac + ;; + *linux*) + find . -not -name "*.AppImage" -print0 \ + | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" + find . -not -name "*.AppImage" \ + | sort \ + | zip -X@ "${OUTDIR}/${DISTNAME}-linux.zip" \ + || ( rm -f "${OUTDIR}/${DISTNAME}-linux.zip" && exit 1 ) + find . -name "*.AppImage" -print0 \ + | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" + find . -name "*.AppImage" \ + | sort \ + | zip -X@ "${OUTDIR}/${DISTNAME}-linux-appimage.zip" \ + || ( rm -f "${OUTDIR}/${DISTNAME}-linux-appimage.zip" && exit 1 ) + ;; + esac + + ) +) # $DISTSRC + +rm -rf "$ACTUAL_OUTDIR" +mv --no-target-directory "$OUTDIR" "$ACTUAL_OUTDIR" \ + || ( rm -rf "$ACTUAL_OUTDIR" && exit 1 ) + +( + cd /outdir-base + { + echo "$GIT_ARCHIVE" + find "$ACTUAL_OUTDIR" -type f + } | xargs realpath --relative-base="$PWD" \ + | xargs sha256sum \ + | sort -k2 \ + | sponge "$ACTUAL_OUTDIR"/SHA256SUMS.part +) diff --git a/contrib/guix/libexec/prelude.bash b/contrib/guix/libexec/prelude.bash new file mode 100644 index 0000000..07b2bc7 --- /dev/null +++ b/contrib/guix/libexec/prelude.bash @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +export LC_ALL=C +set -e -o pipefail + +# shellcheck source=contrib/shell/realpath.bash +source contrib/shell/realpath.bash + +# shellcheck source=contrib/shell/git-utils.bash +source contrib/shell/git-utils.bash + +################ +# Required non-builtin commands should be invocable +################ + +check_tools() { + for cmd in "$@"; do + if ! command -v "$cmd" > /dev/null 2>&1; then + echo "ERR: This script requires that '$cmd' is installed and available in your \$PATH" + exit 1 + fi + done +} + +check_tools cat env readlink dirname basename git + +################ +# We should be at the top directory of the repository +################ + +same_dir() { + local resolved1 resolved2 + resolved1="$(bash_realpath "${1}")" + resolved2="$(bash_realpath "${2}")" + [ "$resolved1" = "$resolved2" ] +} + +if ! same_dir "${PWD}" "$(git_root)"; then +cat << EOF +ERR: This script must be invoked from the top level of the git repository + +Hint: This may look something like: + env FOO=BAR ./contrib/guix/guix- + +EOF +exit 1 +fi + +################ +# Execute "$@" in a pinned, possibly older version of Guix, for reproducibility +# across time. +time-machine() { + # shellcheck disable=SC2086 + guix time-machine --url=https://git.savannah.gnu.org/git/guix.git \ + --commit=998eda3067c7d21e0d9bb3310d2f5a14b8f1c681 \ + --cores="$JOBS" \ + --keep-failed \ + --fallback \ + ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ + ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_TIMEMACHINE_FLAGS} \ + -- "$@" +} + + +################ +# Set common variables +################ + +VERSION="${FORCE_VERSION:-$(git_head_version)}" +DISTNAME="${DISTNAME:-feather-${VERSION}}" + +VERSION_BASE_DIR="${VERSION_BASE_DIR:-${PWD}}" +version_base_prefix="${VERSION_BASE_DIR}/guix-build-" +VERSION_BASE="${version_base_prefix}${VERSION}" # TOP + +DISTSRC_BASE="${DISTSRC_BASE:-${VERSION_BASE}}" + +OUTDIR_BASE="${OUTDIR_BASE:-${VERSION_BASE}/output}" + +var_base_basename="var" +VAR_BASE="${VAR_BASE:-${VERSION_BASE}/${var_base_basename}}" + +profiles_base_basename="profiles" +PROFILES_BASE="${PROFILES_BASE:-${VAR_BASE}/${profiles_base_basename}}" diff --git a/contrib/guix/manifest.scm b/contrib/guix/manifest.scm new file mode 100644 index 0000000..5fbe6ae --- /dev/null +++ b/contrib/guix/manifest.scm @@ -0,0 +1,707 @@ +(use-modules (gnu) + (gnu packages) + (gnu packages autotools) + (gnu packages assembly) + (gnu packages base) + (gnu packages bash) + (gnu packages bison) + (gnu packages certs) + (gnu packages cdrom) + (gnu packages check) + (gnu packages cmake) + (gnu packages commencement) + (gnu packages compression) + (gnu packages cross-base) + (gnu packages curl) + (gnu packages elf) + (gnu packages file) + (gnu packages gawk) + (gnu packages gcc) + (gnu packages gettext) + (gnu packages gnome) + (gnu packages gperf) + (gnu packages installers) + (gnu packages linux) + (gnu packages llvm) + (gnu packages mingw) + (gnu packages moreutils) + (gnu packages perl) + (gnu packages pkg-config) + (gnu packages python) + (gnu packages python-crypto) + (gnu packages python-web) + (gnu packages shells) + (gnu packages tls) + (gnu packages version-control) + (gnu packages qt) + (guix build-system gnu) + (guix build-system perl) + (guix build-system python) + (guix build-system trivial) + (guix download) + (guix gexp) + (guix git-download) + ((guix licenses) #:prefix license:) + (guix packages) + (guix profiles) + (guix utils)) + +(define-syntax-rule (search-our-patches file-name ...) + "Return the list of absolute file names corresponding to each +FILE-NAME found in ./patches relative to the current file." + (parameterize + ((%patch-path (list (string-append (dirname (current-filename)) "/patches")))) + (list (search-patch file-name) ...))) + +;(define (make-ssp-fixed-gcc xgcc) +; "Given a XGCC package, return a modified package that uses the SSP function +;from glibc instead of from libssp.so. Our `symbol-check' script will complain if +;we link against libssp.so, and thus will ensure that this works properly. +; +;Taken from: +;http://www.linuxfromscratch.org/hlfs/view/development/chapter05/gcc-pass1.html" +; (package +; (inherit xgcc) +; (arguments +; (substitute-keyword-arguments (package-arguments xgcc) +; ((#:make-flags flags) +; `(cons "gcc_cv_libc_provides_ssp=yes" ,flags)))))) + +(define-public mingw-w64-x86_64-winpthreads-10.0.0 + (package (inherit mingw-w64-x86_64-winpthreads) + (name "mingw-w64-x86_64-winpthreads-10.0.0") + (version "10.0.0") + (source + (origin + (method url-fetch) + (uri (string-append + "mirror://sourceforge/mingw-w64/mingw-w64/" + "mingw-w64-release/mingw-w64-v" version ".tar.bz2")) + (sha256 + (base32 "15089y4rlj6g1m2m3cm3awndw3rbzhznl7skd0vkmikjxl546sxs")) + (patches + (search-patches "mingw-w64-6.0.0-gcc.patch" + "mingw-w64-dlltool-temp-prefix.patch" + "mingw-w64-reproducible-gendef.patch")))) + (arguments + (substitute-keyword-arguments (package-arguments mingw-w64-x86_64-winpthreads) + ((#:parallel-build? _ #f) #f))))) + +(define (make-gcc-rpath-link xgcc) + "Given a XGCC package, return a modified package that replace each instance of +-rpath in the default system spec that's inserted by Guix with -rpath-link" + (package + (inherit xgcc) + (arguments + (substitute-keyword-arguments (package-arguments xgcc) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'pre-configure 'replace-rpath-with-rpath-link + (lambda _ + (substitute* (cons "gcc/config/rs6000/sysv4.h" + (find-files "gcc/config" + "^gnu-user.*\\.h$")) + (("-rpath=") "-rpath-link=")) + #t)))))))) + +(define (make-cross-toolchain target + base-gcc-for-libc + base-kernel-headers + base-libc + base-gcc) + "Create a cross-compilation toolchain package for TARGET" + (let* ((xbinutils (cross-binutils target)) + ;; 1. Build a cross-compiling gcc without targeting any libc, derived + ;; from BASE-GCC-FOR-LIBC + (xgcc-sans-libc (cross-gcc target + #:xgcc base-gcc-for-libc + #:xbinutils xbinutils)) + ;; 2. Build cross-compiled kernel headers with XGCC-SANS-LIBC, derived + ;; from BASE-KERNEL-HEADERS + (xkernel (cross-kernel-headers target + base-kernel-headers + xgcc-sans-libc + xbinutils)) + ;; 3. Build a cross-compiled libc with XGCC-SANS-LIBC and XKERNEL, + ;; derived from BASE-LIBC + (xlibc (cross-libc target + base-libc + xgcc-sans-libc + xbinutils + xkernel)) + ;; 4. Build a cross-compiling gcc targeting XLIBC, derived from + ;; BASE-GCC + (xgcc (cross-gcc target + #:xgcc base-gcc + #:xbinutils xbinutils + #:libc xlibc))) + ;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and + ;; XGCC + (package + (name (string-append target "-toolchain")) + (version (package-version xgcc)) + (source #f) + (build-system trivial-build-system) + (arguments '(#:builder (begin (mkdir %output) #t))) + (propagated-inputs + `(("binutils" ,xbinutils) + ("libc" ,xlibc) + ("libc:static" ,xlibc "static") + ("gcc" ,xgcc) + ("gcc-lib" ,xgcc "lib"))) + (synopsis (string-append "Complete GCC tool chain for " target)) + (description (string-append "This package provides a complete GCC tool +chain for " target " development.")) + (home-page (package-home-page xgcc)) + (license (package-license xgcc))))) + +(define base-gcc gcc-10) +(define base-linux-kernel-headers linux-libre-headers-5.15) + +;; https://gcc.gnu.org/install/configure.html +(define (hardened-gcc gcc) + (package-with-extra-configure-variable ( + package-with-extra-configure-variable gcc + "--enable-default-ssp" "yes") + "--enable-default-pie" "yes")) + +(define* (make-bitcoin-cross-toolchain target + #:key + (base-gcc-for-libc base-gcc) + (base-kernel-headers base-linux-kernel-headers) + (base-libc (make-glibc-with-bind-now (make-glibc-without-werror glibc-2.24))) + (base-gcc (make-gcc-rpath-link (hardened-gcc base-gcc)))) + "Convenience wrapper around MAKE-CROSS-TOOLCHAIN with default values +desirable for building Feather Wallet release binaries." + (make-cross-toolchain target + base-gcc-for-libc + base-kernel-headers + base-libc + base-gcc)) + +(define (make-gcc-with-pthreads gcc) + (package-with-extra-configure-variable + (package-with-extra-patches gcc + (search-our-patches "gcc-10-remap-guix-store.patch")) + "--enable-threads" "posix")) + +(define (make-mingw-w64-cross-gcc cross-gcc) + (package-with-extra-patches cross-gcc + (search-our-patches "vmov-alignment.patch" + "gcc-broken-longjmp.patch"))) + +(define (make-mingw-pthreads-cross-toolchain target) + "Create a cross-compilation toolchain package for TARGET" + (let* ((xbinutils (cross-binutils target)) + (pthreads-xlibc mingw-w64-x86_64-winpthreads-10.0.0) + (pthreads-xgcc (make-gcc-with-pthreads + (cross-gcc target + #:xgcc (make-mingw-w64-cross-gcc base-gcc) + #:xbinutils xbinutils + #:libc pthreads-xlibc)))) + ;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and + ;; XGCC + (package + (name (string-append target "-posix-toolchain")) + (version (package-version pthreads-xgcc)) + (source #f) + (build-system trivial-build-system) + (arguments '(#:builder (begin (mkdir %output) #t))) + (propagated-inputs + `(("binutils" ,xbinutils) + ("libc" ,pthreads-xlibc) + ("gcc" ,pthreads-xgcc) + ("gcc-lib" ,pthreads-xgcc "lib"))) + (synopsis (string-append "Complete GCC tool chain for " target)) + (description (string-append "This package provides a complete GCC tool +chain for " target " development.")) + (home-page (package-home-page pthreads-xgcc)) + (license (package-license pthreads-xgcc))))) + +(define (make-nsis-for-gcc-10 base-nsis) + (package-with-extra-patches base-nsis + (search-our-patches "nsis-gcc-10-memmove.patch" + "nsis-disable-installer-reloc.patch"))) + +(define (fix-ppc64-nx-default lief) + (package-with-extra-patches lief + (search-our-patches "lief-fix-ppc64-nx-default.patch"))) + +(define-public lief + (package + (name "python-lief") + (version "0.12.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/lief-project/LIEF.git") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1xzbh3bxy4rw1yamnx68da1v5s56ay4g081cyamv67256g0qy2i1")))) + (build-system python-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'parallel-jobs + ;; build with multiple cores + (lambda _ + (substitute* "setup.py" (("self.parallel if self.parallel else 1") (number->string (parallel-job-count))))))))) + (native-inputs + `(("cmake" ,cmake))) + (home-page "https://github.com/lief-project/LIEF") + (synopsis "Library to Instrument Executable Formats") + (description "Python library to to provide a cross platform library which can +parse, modify and abstract ELF, PE and MachO formats.") + (license license:asl2.0))) + +(define osslsigncode + (package + (name "osslsigncode") + (version "2.0") + (source (origin + (method url-fetch) + (uri (string-append "https://github.com/mtrojnar/" + name "/archive/" version ".tar.gz")) + (sha256 + (base32 + "0byri6xny770wwb2nciq44j5071122l14bvv65axdd70nfjf0q2s")))) + (build-system gnu-build-system) + (native-inputs + `(("pkg-config" ,pkg-config) + ("autoconf" ,autoconf) + ("automake" ,automake) + ("libtool" ,libtool))) + (inputs + `(("openssl" ,openssl))) + (arguments + `(#:configure-flags + `("--without-gsf" + "--without-curl" + "--disable-dependency-tracking"))) + (home-page "https://github.com/mtrojnar/osslsigncode") + (synopsis "Authenticode signing and timestamping tool") + (description "osslsigncode is a small tool that implements part of the +functionality of the Microsoft tool signtool.exe - more exactly the Authenticode +signing and timestamping. But osslsigncode is based on OpenSSL and cURL, and +thus should be able to compile on most platforms where these exist.") + (license license:gpl3+))) ; license is with openssl exception + +(define-public python-elfesteem + (let ((commit "2eb1e5384ff7a220fd1afacd4a0170acff54fe56")) + (package + (name "python-elfesteem") + (version (git-version "0.1" "1" commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/LRGH/elfesteem") + (commit commit))) + (file-name (git-file-name name commit)) + (sha256 + (base32 + "07x6p8clh11z8s1n2kdxrqwqm2almgc5qpkcr9ckb6y5ivjdr5r6")))) + (build-system python-build-system) + ;; There are no tests, but attempting to run python setup.py test leads to + ;; PYTHONPATH problems, just disable the test + (arguments '(#:tests? #f)) + (home-page "https://github.com/LRGH/elfesteem") + (synopsis "ELF/PE/Mach-O parsing library") + (description "elfesteem parses ELF, PE and Mach-O files.") + (license license:lgpl2.1)))) + +(define-public python-oscrypto + (package + (name "python-oscrypto") + (version "1.2.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/wbond/oscrypto") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1d4d8s4z340qhvb3g5m5v3436y3a71yc26wk4749q64m09kxqc3l")) + (patches (search-our-patches "oscrypto-hard-code-openssl.patch")))) + (build-system python-build-system) + (native-search-paths + (list (search-path-specification + (variable "SSL_CERT_FILE") + (file-type 'regular) + (separator #f) ;single entry + (files '("etc/ssl/certs/ca-certificates.crt"))))) + + (propagated-inputs + `(("python-asn1crypto" ,python-asn1crypto) + ("openssl" ,openssl))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'hard-code-path-to-libscrypt + (lambda* (#:key inputs #:allow-other-keys) + (let ((openssl (assoc-ref inputs "openssl"))) + (substitute* "oscrypto/__init__.py" + (("@GUIX_OSCRYPTO_USE_OPENSSL@") + (string-append openssl "/lib/libcrypto.so" "," openssl "/lib/libssl.so"))) + #t))) + (add-after 'unpack 'disable-broken-tests + (lambda _ + ;; This test is broken as there is no keyboard interrupt. + (substitute* "tests/test_trust_list.py" + (("^(.*)class TrustListTests" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "tests/test_tls.py" + (("^(.*)class TLSTests" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + #t)) + (replace 'check + (lambda _ + (invoke "python" "run.py" "tests") + #t))))) + (home-page "https://github.com/wbond/oscrypto") + (synopsis "Compiler-free Python crypto library backed by the OS") + (description "oscrypto is a compilation-free, always up-to-date encryption library for Python.") + (license license:expat))) + +(define-public python-oscryptotests + (package (inherit python-oscrypto) + (name "python-oscryptotests") + (propagated-inputs + `(("python-oscrypto" ,python-oscrypto))) + (arguments + `(#:tests? #f + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'hard-code-path-to-libscrypt + (lambda* (#:key inputs #:allow-other-keys) + (chdir "tests") + #t))))))) + +(define-public python-certvalidator + (let ((commit "a145bf25eb75a9f014b3e7678826132efbba6213")) + (package + (name "python-certvalidator") + (version (git-version "0.1" "1" commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/achow101/certvalidator") + (commit commit))) + (file-name (git-file-name name commit)) + (sha256 + (base32 + "1qw2k7xis53179lpqdqyylbcmp76lj7sagp883wmxg5i7chhc96k")))) + (build-system python-build-system) + (propagated-inputs + `(("python-asn1crypto" ,python-asn1crypto) + ("python-oscrypto" ,python-oscrypto) + ("python-oscryptotests", python-oscryptotests))) ;; certvalidator tests import oscryptotests + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'disable-broken-tests + (lambda _ + (substitute* "tests/test_certificate_validator.py" + (("^(.*)class CertificateValidatorTests" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "tests/test_crl_client.py" + (("^(.*)def test_fetch_crl" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "tests/test_ocsp_client.py" + (("^(.*)def test_fetch_ocsp" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "tests/test_registry.py" + (("^(.*)def test_build_paths" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "tests/test_validate.py" + (("^(.*)def test_revocation_mode_hard" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "tests/test_validate.py" + (("^(.*)def test_revocation_mode_soft" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + #t)) + (replace 'check + (lambda _ + (invoke "python" "run.py" "tests") + #t))))) + (home-page "https://github.com/wbond/certvalidator") + (synopsis "Python library for validating X.509 certificates and paths") + (description "certvalidator is a Python library for validating X.509 +certificates or paths. Supports various options, including: validation at a +specific moment in time, whitelisting and revocation checks.") + (license license:expat)))) + +(define-public python-altgraph + (package + (name "python-altgraph") + (version "0.17") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ronaldoussoren/altgraph") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "09sm4srvvkw458pn48ga9q7ykr4xlz7q8gh1h9w7nxpf001qgpwb")))) + (build-system python-build-system) + (home-page "https://github.com/ronaldoussoren/altgraph") + (synopsis "Python graph (network) package") + (description "altgraph is a fork of graphlib: a graph (network) package for +constructing graphs, BFS and DFS traversals, topological sort, shortest paths, +etc. with graphviz output.") + (license license:expat))) + +(define-public python-macholib + (package + (name "python-macholib") + (version "1.14") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ronaldoussoren/macholib") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0aislnnfsza9wl4f0vp45ivzlc0pzhp9d4r08700slrypn5flg42")))) + (build-system python-build-system) + (propagated-inputs + `(("python-altgraph" ,python-altgraph))) + (arguments + '(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'disable-broken-tests + (lambda _ + ;; This test is broken as there is no keyboard interrupt. + (substitute* "macholib_tests/test_command_line.py" + (("^(.*)class TestCmdLine" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line))) + (substitute* "macholib_tests/test_dyld.py" + (("^(.*)def test_\\S+_find" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line)) + (("^(.*)def testBasic" line indent) + (string-append indent + "@unittest.skip(\"Disabled by Guix\")\n" + line)) + ) + #t))))) + (home-page "https://github.com/ronaldoussoren/macholib") + (synopsis "Python library for analyzing and editing Mach-O headers") + (description "macholib is a Macho-O header analyzer and editor. It's +typically used as a dependency analysis tool, and also to rewrite dylib +references in Mach-O headers to be @executable_path relative. Though this tool +targets a platform specific file format, it is pure python code that is platform +and endian independent.") + (license license:expat))) + +(define-public python-signapple + (let ((commit "8a945a2e7583be2665cf3a6a89d665b70ecd1ab6")) + (package + (name "python-signapple") + (version (git-version "0.1" "1" commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/achow101/signapple") + (commit commit))) + (file-name (git-file-name name commit)) + (sha256 + (base32 + "0fr1hangvfyiwflca6jg5g8zvg3jc9qr7vd2c12ff89pznf38dlg")))) + (build-system python-build-system) + (propagated-inputs + `(("python-asn1crypto" ,python-asn1crypto) + ("python-oscrypto" ,python-oscrypto) + ("python-certvalidator" ,python-certvalidator) + ("python-elfesteem" ,python-elfesteem) + ("python-requests" ,python-requests) + ("python-macholib" ,python-macholib))) + ;; There are no tests, but attempting to run python setup.py test leads to + ;; problems, just disable the test + (arguments '(#:tests? #f)) + (home-page "https://github.com/achow101/signapple") + (synopsis "Mach-O binary signature tool") + (description "signapple is a Python tool for creating, verifying, and +inspecting signatures in Mach-O binaries.") + (license license:expat)))) + +(define (make-glibc-without-werror glibc) + (package-with-extra-configure-variable glibc "enable_werror" "no")) + +(define (make-glibc-with-stack-protector glibc) + (package-with-extra-configure-variable glibc "--enable-stack-protector" "all")) + +(define (make-glibc-with-bind-now glibc) + (package-with-extra-configure-variable glibc "--enable-bind-now" "yes")) + +(define-public glibc-2.24 + (package + (inherit glibc-2.31) + (version "2.24") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://sourceware.org/git/glibc.git") + (commit "0d7f1ed30969886c8dde62fbf7d2c79967d4bace"))) + (file-name (git-file-name "glibc" "0d7f1ed30969886c8dde62fbf7d2c79967d4bace")) + (sha256 + (base32 + "0g5hryia5v1k0qx97qffgwzrz4lr4jw3s5kj04yllhswsxyjbic3")) + (patches (search-our-patches "glibc-ldd-x86_64.patch" + "glibc-versioned-locpath.patch" + "glibc-2.24-elfm-loadaddr-dynamic-rewrite.patch" + "glibc-2.24-no-build-time-cxx-header-run.patch" + "glibc-2.24-fcommon.patch" + "glibc-2.24-guix-prefix.patch")))))) + +(define-public glibc-2.27/bitcoin-patched + (package + (inherit glibc-2.31) + (version "2.27") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://sourceware.org/git/glibc.git") + (commit "23158b08a0908f381459f273a984c6fd328363cb"))) + (file-name (git-file-name "glibc" "23158b08a0908f381459f273a984c6fd328363cb")) + (sha256 + (base32 + "1b2n1gxv9f4fd5yy68qjbnarhf8mf4vmlxk10i3328c1w5pmp0ca")) + (patches (search-our-patches "glibc-ldd-x86_64.patch" + "glibc-2.27-riscv64-Use-__has_include-to-include-asm-syscalls.h.patch" + "glibc-2.27-dont-redefine-nss-database.patch" + "glibc-2.27-guix-prefix.patch")))))) + +(define-public linuxdeployqt + (package + (name "linuxdeployqt") + (version "b4697483c98120007019c3456914cfd1dba58384") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/probonopd/linuxdeployqt") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0zp1c5pya39g5nwkly1ix58svj08lfsfmv530jyf2ya7m4vvkhfs")))) + (build-system gnu-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (replace 'configure + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (invoke "qmake" + (string-append "PREFIX=" out) + "linuxdeployqt.pro")))) + (replace 'install + ;; Messes up for some reason. + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin"))) + (install-file "bin/linuxdeployqt" bin) + #t)))))) + (native-inputs (list qtbase-5)) + (home-page "https://github.com/probonopd/linuxdeployqt") + (synopsis "Linux deploy tool") + (description "Makes Linux applications self-contained by copying in the libraries + and plugins that the application uses, and optionally generates an AppImage. + Can be used for Qt and other applications ") + (license license:gpl3+))) + +(packages->manifest + (append + (list ;; The Basics + bash + which + coreutils + util-linux + ;; File(system) inspection + file + grep + diffutils + findutils + ;; File transformation + patch + gawk + sed + moreutils + patchelf + ;; Compression and archiving + tar + bzip2 + gzip + xz + p7zip + zip + unzip + ;; Build tools + gnu-make + libtool + autoconf-2.71 + automake + pkg-config + bison + gperf + gettext-minimal + squashfs-tools + linuxdeployqt + ;; Native GCC 10 toolchain + gcc-toolchain-10 + (list gcc-toolchain-10 "static") + ;; Scripting + perl + python-3 + ;; Git + git + ;; Tests + lief + ) + (let ((target (getenv "HOST"))) + (cond ((string-suffix? "-mingw32" target) + ;; Windows + (list (make-mingw-pthreads-cross-toolchain "x86_64-w64-mingw32") + (make-nsis-for-gcc-10 nsis-x86_64) + osslsigncode)) + ((string-contains target "-linux-") + (list (cond ((string-contains target "riscv64-") + (make-bitcoin-cross-toolchain target + #:base-libc (make-glibc-with-stack-protector + (make-glibc-with-bind-now (make-glibc-without-werror glibc-2.27/bitcoin-patched))))) + (else + (make-bitcoin-cross-toolchain target))))) + ((string-contains target "darwin") + (list clang-toolchain-10 binutils cmake xorriso python-signapple)) + (else '()))))) diff --git a/contrib/guix/patches/gcc-10-remap-guix-store.patch b/contrib/guix/patches/gcc-10-remap-guix-store.patch new file mode 100644 index 0000000..a47ef7a --- /dev/null +++ b/contrib/guix/patches/gcc-10-remap-guix-store.patch @@ -0,0 +1,25 @@ +From aad25427e74f387412e8bc9a9d7bbc6c496c792f Mon Sep 17 00:00:00 2001 +From: Andrew Chow +Date: Wed, 6 Jul 2022 16:49:41 -0400 +Subject: [PATCH] guix: remap guix store paths to /usr + +--- + libgcc/Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in +index 851e7657d07..476c2becd1c 100644 +--- a/libgcc/Makefile.in ++++ b/libgcc/Makefile.in +@@ -854,7 +854,7 @@ endif + # libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and + # LIB2ADDEHSHARED matter. (Usually all three are identical.) + +-c_flags := -fexceptions ++c_flags := -fexceptions $(shell find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;) + + ifeq ($(enable_shared),yes) + +-- +2.37.0 + diff --git a/contrib/guix/patches/gcc-broken-longjmp.patch b/contrib/guix/patches/gcc-broken-longjmp.patch new file mode 100644 index 0000000..1cfc091 --- /dev/null +++ b/contrib/guix/patches/gcc-broken-longjmp.patch @@ -0,0 +1,68 @@ +commit eb5698897c52702498938592d7f76e67d126451f +Author: Eric Botcazou +Date: Wed May 5 22:48:51 2021 +0200 + + Fix PR target/100402 + + This is a regression for 64-bit Windows present from mainline down to the 9 + branch and introduced by the fix for PR target/99234. Again SEH, but with + a twist related to the way MinGW implements setjmp/longjmp, which turns out + to be piggybacked on SEH with recent versions of MinGW, i.e. the longjmp + performs a bona-fide unwinding of the stack, because it calls RtlUnwindEx + with the second argument initially passed to setjmp, which is the result of + __builtin_frame_address (0) in the MinGW header file: + + define setjmp(BUF) _setjmp((BUF), __builtin_frame_address (0)) + + This means that we directly expose the frame pointer to the SEH machinery + here (unlike with regular exception handling where we use an intermediate + CFA) and thus that we cannot do whatever we want with it. The old code + would leave it unaligned, i.e. not multiple of 16, whereas the new code + aligns it, but this breaks for some reason; at least it appears that a + .seh_setframe directive with 0 as second argument always works, so the + fix aligns it this way. + + gcc/ + PR target/100402 + * config/i386/i386.c (ix86_compute_frame_layout): For a SEH target, + always return the establisher frame for __builtin_frame_address (0). + gcc/testsuite/ + * gcc.c-torture/execute/20210505-1.c: New test. + +diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c +index 2f838840e96..06ad1b2274e 100644 +--- a/gcc/config/i386/i386.c ++++ b/gcc/config/i386/i386.c +@@ -6356,12 +6356,29 @@ ix86_compute_frame_layout (void) + area, see the SEH code in config/i386/winnt.c for the rationale. */ + frame->hard_frame_pointer_offset = frame->sse_reg_save_offset; + +- /* If we can leave the frame pointer where it is, do so. Also, return ++ /* If we can leave the frame pointer where it is, do so; however return + the establisher frame for __builtin_frame_address (0) or else if the +- frame overflows the SEH maximum frame size. */ ++ frame overflows the SEH maximum frame size. ++ ++ Note that the value returned by __builtin_frame_address (0) is quite ++ constrained, because setjmp is piggybacked on the SEH machinery with ++ recent versions of MinGW: ++ ++ # elif defined(__SEH__) ++ # if defined(__aarch64__) || defined(_ARM64_) ++ # define setjmp(BUF) _setjmp((BUF), __builtin_sponentry()) ++ # elif (__MINGW_GCC_VERSION < 40702) ++ # define setjmp(BUF) _setjmp((BUF), mingw_getsp()) ++ # else ++ # define setjmp(BUF) _setjmp((BUF), __builtin_frame_address (0)) ++ # endif ++ ++ and the second argument passed to _setjmp, if not null, is forwarded ++ to the TargetFrame parameter of RtlUnwindEx by longjmp (after it has ++ built an ExceptionRecord on the fly describing the setjmp buffer). */ + const HOST_WIDE_INT diff + = frame->stack_pointer_offset - frame->hard_frame_pointer_offset; +- if (diff <= 255) ++ if (diff <= 255 && !crtl->accesses_prior_frames) + { + /* The resulting diff will be a multiple of 16 lower than 255, + i.e. at most 240 as required by the unwind data structure. */ diff --git a/contrib/guix/patches/glibc-2.24-elfm-loadaddr-dynamic-rewrite.patch b/contrib/guix/patches/glibc-2.24-elfm-loadaddr-dynamic-rewrite.patch new file mode 100644 index 0000000..5c4d0c6 --- /dev/null +++ b/contrib/guix/patches/glibc-2.24-elfm-loadaddr-dynamic-rewrite.patch @@ -0,0 +1,62 @@ +https://sourceware.org/git/?p=glibc.git;a=commit;h=a68ba2f3cd3cbe32c1f31e13c20ed13487727b32 + +commit 6b02af31e9a721bb15a11380cd22d53b621711f8 +Author: Szabolcs Nagy +Date: Wed Oct 18 17:26:23 2017 +0100 + + [AARCH64] Rewrite elf_machine_load_address using _DYNAMIC symbol + + This patch rewrites aarch64 elf_machine_load_address to use special _DYNAMIC + symbol instead of _dl_start. + + The static address of _DYNAMIC symbol is stored in the first GOT entry. + Here is the change which makes this solution work (part of binutils 2.24): + https://sourceware.org/ml/binutils/2013-06/msg00248.html + + i386, x86_64 targets use the same method to do this as well. + + The original implementation relies on a trick that R_AARCH64_ABS32 relocation + being resolved at link time and the static address fits in the 32bits. + However, in LP64, normally, the address is defined to be 64 bit. + + Here is the C version one which should be portable in all cases. + + * sysdeps/aarch64/dl-machine.h (elf_machine_load_address): Use + _DYNAMIC symbol to calculate load address. + +diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h +index e86d8b5b63..5a5b8a5de5 100644 +--- a/sysdeps/aarch64/dl-machine.h ++++ b/sysdeps/aarch64/dl-machine.h +@@ -49,26 +49,11 @@ elf_machine_load_address (void) + /* To figure out the load address we use the definition that for any symbol: + dynamic_addr(symbol) = static_addr(symbol) + load_addr + +- The choice of symbol is arbitrary. The static address we obtain +- by constructing a non GOT reference to the symbol, the dynamic +- address of the symbol we compute using adrp/add to compute the +- symbol's address relative to the PC. +- This depends on 32bit relocations being resolved at link time +- and that the static address fits in the 32bits. */ +- +- ElfW(Addr) static_addr; +- ElfW(Addr) dynamic_addr; +- +- asm (" \n" +-" adrp %1, _dl_start; \n" +-" add %1, %1, #:lo12:_dl_start \n" +-" ldr %w0, 1f \n" +-" b 2f \n" +-"1: \n" +-" .word _dl_start \n" +-"2: \n" +- : "=r" (static_addr), "=r" (dynamic_addr)); +- return dynamic_addr - static_addr; ++ _DYNAMIC sysmbol is used here as its link-time address stored in ++ the special unrelocated first GOT entry. */ ++ ++ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden; ++ return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic (); + } + + /* Set up the loaded object described by L so its unrelocated PLT diff --git a/contrib/guix/patches/glibc-2.24-fcommon.patch b/contrib/guix/patches/glibc-2.24-fcommon.patch new file mode 100644 index 0000000..2bc32ed --- /dev/null +++ b/contrib/guix/patches/glibc-2.24-fcommon.patch @@ -0,0 +1,32 @@ +commit 264a4a0dbe1f4369db315080034b500bed66016c +Author: fanquake +Date: Fri May 6 11:03:04 2022 +0100 + + build: use -fcommon to retain legacy behaviour with GCC 10 + + GCC 10 started using -fno-common by default, which causes issues with + the powerpc builds using gibc 2.24. A patch was commited to glibc to fix + the issue, 18363b4f010da9ba459b13310b113ac0647c2fcc but is non-trvial + to backport, and was broken in at least one way, see the followup in + commit 7650321ce037302bfc2f026aa19e0213b8d02fe6. + + For now, retain the legacy GCC behaviour by passing -fcommon when + building glibc. + + https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html. + https://sourceware.org/git/?p=glibc.git;a=commit;h=18363b4f010da9ba459b13310b113ac0647c2fcc + https://sourceware.org/git/?p=glibc.git;a=commit;h=7650321ce037302bfc2f026aa19e0213b8d02fe6 + +diff --git a/Makeconfig b/Makeconfig +index ee379f5852..63c4a2f234 100644 +--- a/Makeconfig ++++ b/Makeconfig +@@ -824,7 +824,7 @@ ifeq "$(strip $(+cflags))" "" + +cflags := $(default_cflags) + endif # $(+cflags) == "" + +-+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) +++cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) -fcommon + +gcc-nowarn := -w + + # Don't duplicate options if we inherited variables from the parent. diff --git a/contrib/guix/patches/glibc-2.24-guix-prefix.patch b/contrib/guix/patches/glibc-2.24-guix-prefix.patch new file mode 100644 index 0000000..875e8cd --- /dev/null +++ b/contrib/guix/patches/glibc-2.24-guix-prefix.patch @@ -0,0 +1,25 @@ +Without ffile-prefix-map, the debug symbols will contain paths for the +guix store which will include the hashes of each package. However, the +hash for the same package will differ when on different architectures. +In order to be reproducible regardless of the architecture used to build +the package, map all guix store prefixes to something fixed, e.g. /usr. + +We might be able to drop this in favour of using --with-nonshared-cflags +when we being using newer versions of glibc. + +--- a/Makeconfig ++++ b/Makeconfig +@@ -950,6 +950,10 @@ object-suffixes-for-libc += .oS + # shared objects. We don't want to use CFLAGS-os because users may, for + # example, make that processor-specific. + CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) ++ ++# Map Guix store paths to /usr ++CFLAGS-.oS += `find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;` ++ + CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1 + libtype.oS = lib%_nonshared.a + endif +-- +2.35.1 + diff --git a/contrib/guix/patches/glibc-2.24-no-build-time-cxx-header-run.patch b/contrib/guix/patches/glibc-2.24-no-build-time-cxx-header-run.patch new file mode 100644 index 0000000..11fe7fd --- /dev/null +++ b/contrib/guix/patches/glibc-2.24-no-build-time-cxx-header-run.patch @@ -0,0 +1,100 @@ +https://sourceware.org/git/?p=glibc.git;a=commit;h=fc3e1337be1c6935ab58bd13520f97a535cf70cc + +commit dc23a45db566095e83ff0b7a57afc87fb5ca89a1 +Author: Florian Weimer +Date: Wed Sep 21 10:45:32 2016 +0200 + + Avoid running $(CXX) during build to obtain header file paths + + This reduces the build time somewhat and is particularly noticeable + during rebuilds with few code changes. + +diff --git a/Makerules b/Makerules +index 7e4077ee50..c338850de5 100644 +--- a/Makerules ++++ b/Makerules +@@ -121,14 +121,10 @@ ifneq (,$(CXX)) + # will be used instead of /usr/include/stdlib.h and /usr/include/math.h. + before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \ + $(before-compile) +-cstdlib=$(shell echo "\#include " | $(CXX) -M -MP -x c++ - \ +- | sed -n "/cstdlib:/{s/:$$//;p}") +-$(common-objpfx)cstdlib: $(cstdlib) ++$(common-objpfx)cstdlib: $(c++-cstdlib-header) + $(INSTALL_DATA) $< $@T + $(move-if-change) $@T $@ +-cmath=$(shell echo "\#include " | $(CXX) -M -MP -x c++ - \ +- | sed -n "/cmath:/{s/:$$//;p}") +-$(common-objpfx)cmath: $(cmath) ++$(common-objpfx)cmath: $(c++-cmath-header) + $(INSTALL_DATA) $< $@T + $(move-if-change) $@T $@ + endif +diff --git a/config.make.in b/config.make.in +index 95c6f36876..04a8b3ed7f 100644 +--- a/config.make.in ++++ b/config.make.in +@@ -45,6 +45,8 @@ defines = @DEFINES@ + sysheaders = @sysheaders@ + sysincludes = @SYSINCLUDES@ + c++-sysincludes = @CXX_SYSINCLUDES@ ++c++-cstdlib-header = @CXX_CSTDLIB_HEADER@ ++c++-cmath-header = @CXX_CMATH_HEADER@ + all-warnings = @all_warnings@ + enable-werror = @enable_werror@ + +diff --git a/configure b/configure +index 17625e1041..6ff252744b 100755 +--- a/configure ++++ b/configure +@@ -635,6 +635,8 @@ BISON + INSTALL_INFO + PERL + BASH_SHELL ++CXX_CMATH_HEADER ++CXX_CSTDLIB_HEADER + CXX_SYSINCLUDES + SYSINCLUDES + AUTOCONF +@@ -5054,6 +5056,18 @@ fi + + + ++# Obtain some C++ header file paths. This is used to make a local ++# copy of those headers in Makerules. ++if test -n "$CXX"; then ++ find_cxx_header () { ++ echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}" ++ } ++ CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)" ++ CXX_CMATH_HEADER="$(find_cxx_header cmath)" ++fi ++ ++ ++ + # Test if LD_LIBRARY_PATH contains the notation for the current directory + # since this would lead to problems installing/building glibc. + # LD_LIBRARY_PATH contains the current directory if one of the following +diff --git a/configure.ac b/configure.ac +index 33bcd62180..9938ab0dc2 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1039,6 +1039,18 @@ fi + AC_SUBST(SYSINCLUDES) + AC_SUBST(CXX_SYSINCLUDES) + ++# Obtain some C++ header file paths. This is used to make a local ++# copy of those headers in Makerules. ++if test -n "$CXX"; then ++ find_cxx_header () { ++ echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}" ++ } ++ CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)" ++ CXX_CMATH_HEADER="$(find_cxx_header cmath)" ++fi ++AC_SUBST(CXX_CSTDLIB_HEADER) ++AC_SUBST(CXX_CMATH_HEADER) ++ + # Test if LD_LIBRARY_PATH contains the notation for the current directory + # since this would lead to problems installing/building glibc. + # LD_LIBRARY_PATH contains the current directory if one of the following diff --git a/contrib/guix/patches/glibc-2.27-dont-redefine-nss-database.patch b/contrib/guix/patches/glibc-2.27-dont-redefine-nss-database.patch new file mode 100644 index 0000000..16a595d --- /dev/null +++ b/contrib/guix/patches/glibc-2.27-dont-redefine-nss-database.patch @@ -0,0 +1,87 @@ +commit 78a90c2f74a2012dd3eff302189e47ff6779a757 +Author: Andreas Schwab +Date: Fri Mar 2 23:07:14 2018 +0100 + + Fix multiple definitions of __nss_*_database (bug 22918) + + (cherry picked from commit eaf6753f8aac33a36deb98c1031d1bad7b593d2d) + +diff --git a/nscd/gai.c b/nscd/gai.c +index d081747797..576fd0045b 100644 +--- a/nscd/gai.c ++++ b/nscd/gai.c +@@ -45,3 +45,6 @@ + #ifdef HAVE_LIBIDN + # include + #endif ++ ++/* Some variables normally defined in libc. */ ++service_user *__nss_hosts_database attribute_hidden; +diff --git a/nss/nsswitch.c b/nss/nsswitch.c +index d5e655974f..b0f0c11a3e 100644 +--- a/nss/nsswitch.c ++++ b/nss/nsswitch.c +@@ -62,7 +62,7 @@ static service_library *nss_new_service (name_database *database, + + /* Declare external database variables. */ + #define DEFINE_DATABASE(name) \ +- extern service_user *__nss_##name##_database attribute_hidden; \ ++ service_user *__nss_##name##_database attribute_hidden; \ + weak_extern (__nss_##name##_database) + #include "databases.def" + #undef DEFINE_DATABASE +diff --git a/nss/nsswitch.h b/nss/nsswitch.h +index eccb535ef5..63573b9ebc 100644 +--- a/nss/nsswitch.h ++++ b/nss/nsswitch.h +@@ -226,10 +226,10 @@ libc_hidden_proto (__nss_hostname_digits_dots) + #define MAX_NR_ADDRS 48 + + /* Prototypes for __nss_*_lookup2 functions. */ +-#define DEFINE_DATABASE(arg) \ +- service_user *__nss_##arg##_database attribute_hidden; \ +- int __nss_##arg##_lookup2 (service_user **, const char *, \ +- const char *, void **); \ ++#define DEFINE_DATABASE(arg) \ ++ extern service_user *__nss_##arg##_database attribute_hidden; \ ++ int __nss_##arg##_lookup2 (service_user **, const char *, \ ++ const char *, void **); \ + libc_hidden_proto (__nss_##arg##_lookup2) + #include "databases.def" + #undef DEFINE_DATABASE +diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c +index f509534ca9..8c64ac59ff 100644 +--- a/posix/tst-rfc3484-2.c ++++ b/posix/tst-rfc3484-2.c +@@ -58,6 +58,7 @@ _res_hconf_init (void) + #undef USE_NSCD + #include "../sysdeps/posix/getaddrinfo.c" + ++service_user *__nss_hosts_database attribute_hidden; + + /* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ +diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c +index ae44087a10..1c61aaf844 100644 +--- a/posix/tst-rfc3484-3.c ++++ b/posix/tst-rfc3484-3.c +@@ -58,6 +58,7 @@ _res_hconf_init (void) + #undef USE_NSCD + #include "../sysdeps/posix/getaddrinfo.c" + ++service_user *__nss_hosts_database attribute_hidden; + + /* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ +diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c +index 7f191abbbc..8f45848e44 100644 +--- a/posix/tst-rfc3484.c ++++ b/posix/tst-rfc3484.c +@@ -58,6 +58,7 @@ _res_hconf_init (void) + #undef USE_NSCD + #include "../sysdeps/posix/getaddrinfo.c" + ++service_user *__nss_hosts_database attribute_hidden; + + /* This is the beginning of the real test code. The above defines + (among other things) the function rfc3484_sort. */ diff --git a/contrib/guix/patches/glibc-2.27-guix-prefix.patch b/contrib/guix/patches/glibc-2.27-guix-prefix.patch new file mode 100644 index 0000000..d777af7 --- /dev/null +++ b/contrib/guix/patches/glibc-2.27-guix-prefix.patch @@ -0,0 +1,25 @@ +Without ffile-prefix-map, the debug symbols will contain paths for the +guix store which will include the hashes of each package. However, the +hash for the same package will differ when on different architectures. +In order to be reproducible regardless of the architecture used to build +the package, map all guix store prefixes to something fixed, e.g. /usr. + +We might be able to drop this in favour of using --with-nonshared-cflags +when we being using newer versions of glibc. + +--- a/Makeconfig ++++ b/Makeconfig +@@ -992,6 +992,10 @@ object-suffixes := + CPPFLAGS-.o = $(pic-default) + # libc.a must be compiled with -fPIE/-fpie for static PIE. + CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default) ++ ++# Map Guix store paths to /usr ++CFLAGS-.o += `find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;` ++ + libtype.o := lib%.a + object-suffixes += .o + ifeq (yes,$(build-shared)) +-- +2.35.1 + diff --git a/contrib/guix/patches/glibc-2.27-riscv64-Use-__has_include-to-include-asm-syscalls.h.patch b/contrib/guix/patches/glibc-2.27-riscv64-Use-__has_include-to-include-asm-syscalls.h.patch new file mode 100644 index 0000000..c0f8495 --- /dev/null +++ b/contrib/guix/patches/glibc-2.27-riscv64-Use-__has_include-to-include-asm-syscalls.h.patch @@ -0,0 +1,76 @@ +Note that this has been modified from the original commit, to use __has_include +instead of __has_include__, as the later was causing build failures with GCC 10. +See also: http://lists.busybox.net/pipermail/buildroot/2020-July/590376.html. + +https://sourceware.org/git/?p=glibc.git;a=commit;h=0b9c84906f653978fb8768c7ebd0ee14a47e662e + +From 562c52cc81a4e456a62e6455feb32732049e9070 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Mon, 31 Dec 2018 09:26:42 -0800 +Subject: [PATCH] riscv: Use __has_include__ to include [BZ + #24022] + + has been removed by + +commit 27f8899d6002e11a6e2d995e29b8deab5aa9cc25 +Author: David Abdurachmanov +Date: Thu Nov 8 20:02:39 2018 +0100 + + riscv: add asm/unistd.h UAPI header + + Marcin Juszkiewicz reported issues while generating syscall table for riscv + using 4.20-rc1. The patch refactors our unistd.h files to match some other + architectures. + + - Add asm/unistd.h UAPI header, which has __ARCH_WANT_NEW_STAT only for 64-bit + - Remove asm/syscalls.h UAPI header and merge to asm/unistd.h + - Adjust kernel asm/unistd.h + + So now asm/unistd.h UAPI header should show all syscalls for riscv. + + may be restored by + +Subject: [PATCH] riscv: restore asm/syscalls.h UAPI header +Date: Tue, 11 Dec 2018 09:09:35 +0100 + +UAPI header asm/syscalls.h was merged into UAPI asm/unistd.h header, +which did resolve issue with missing syscalls macros resulting in +glibc (2.28) build failure. It also broke glibc in a different way: +asm/syscalls.h is being used by glibc. I noticed this while doing +Fedora 30/Rawhide mass rebuild. + +The patch returns asm/syscalls.h header and incl. it into asm/unistd.h. +I plan to send a patch to glibc to use asm/unistd.h instead of +asm/syscalls.h + +In the meantime, we use __has_include__, which was added to GCC 5, to +check if exists before including it. Tested with +build-many-glibcs.py for riscv against kernel 4.19.12 and 4.20-rc7. + + [BZ #24022] + * sysdeps/unix/sysv/linux/riscv/flush-icache.c: Check if + exists with __has_include__ before including it. +--- + sysdeps/unix/sysv/linux/riscv/flush-icache.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/sysdeps/unix/sysv/linux/riscv/flush-icache.c b/sysdeps/unix/sysv/linux/riscv/flush-icache.c +index d612ef4c6c..0b2042620b 100644 +--- a/sysdeps/unix/sysv/linux/riscv/flush-icache.c ++++ b/sysdeps/unix/sysv/linux/riscv/flush-icache.c +@@ -21,7 +21,11 @@ + #include + #include + #include +-#include ++#if __has_include () ++# include ++#else ++# include ++#endif + + typedef int (*func_type) (void *, void *, unsigned long int); + +-- +2.31.1 + diff --git a/contrib/guix/patches/glibc-ldd-x86_64.patch b/contrib/guix/patches/glibc-ldd-x86_64.patch new file mode 100644 index 0000000..b1b6d5a --- /dev/null +++ b/contrib/guix/patches/glibc-ldd-x86_64.patch @@ -0,0 +1,10 @@ +By default, 'RTDLLIST' in 'ldd' refers to 'lib64/ld-linux-x86-64.so', whereas +it's in 'lib/' for us. This patch fixes that. + +--- glibc-2.17/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed 2012-12-25 04:02:13.000000000 +0100 ++++ glibc-2.17/sysdeps/unix/sysv/linux/x86_64/ldd-rewrite.sed 2013-09-15 23:08:03.000000000 +0200 +@@ -1,3 +1,3 @@ + /LD_TRACE_LOADED_OBJECTS=1/a\ + add_env="$add_env LD_LIBRARY_VERSION=\\$verify_out" +-s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|x32\)\(/[^/]*\)\(-x86-64\|-x32\)\(\.so\.[0-9.]*\)[ ]*$_\1"\2\4\6 \264\4-x86-64\6 \2x32\4-x32\6"_ ++s_^\(RTLDLIST=\)\(.*lib\)\(\|64\|x32\)\(/[^/]*\)\(-x86-64\|-x32\)\(\.so\.[0-9.]*\)[ ]*$_\1"\2\4\6 \2\4-x86-64\6 \2x32\4-x32\6"_ diff --git a/contrib/guix/patches/glibc-versioned-locpath.patch b/contrib/guix/patches/glibc-versioned-locpath.patch new file mode 100644 index 0000000..bc76521 --- /dev/null +++ b/contrib/guix/patches/glibc-versioned-locpath.patch @@ -0,0 +1,240 @@ +The format of locale data can be incompatible between libc versions, and +loading incompatible data can lead to 'setlocale' returning EINVAL at best +or triggering an assertion failure at worst. See +https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00717.html +for background information. + +To address that, this patch changes libc to honor a new 'GUIX_LOCPATH' +variable, and to look for locale data in version-specific sub-directories of +that variable. So, if GUIX_LOCPATH=/foo:/bar, locale data is searched for in +/foo/X.Y and /bar/X.Y, where X.Y is the libc version number. + +That way, a single 'GUIX_LOCPATH' setting can work even if different libc +versions coexist on the system. + +--- a/locale/newlocale.c ++++ b/locale/newlocale.c +@@ -30,6 +30,7 @@ + /* Lock for protecting global data. */ + __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden) + ++extern error_t compute_locale_search_path (char **, size_t *); + + /* Use this when we come along an error. */ + #define ERROR_RETURN \ +@@ -48,7 +49,6 @@ __newlocale (int category_mask, const char *locale, __locale_t base) + __locale_t result_ptr; + char *locale_path; + size_t locale_path_len; +- const char *locpath_var; + int cnt; + size_t names_len; + +@@ -102,17 +102,8 @@ __newlocale (int category_mask, const char *locale, __locale_t base) + locale_path = NULL; + locale_path_len = 0; + +- locpath_var = getenv ("LOCPATH"); +- if (locpath_var != NULL && locpath_var[0] != '\0') +- { +- if (__argz_create_sep (locpath_var, ':', +- &locale_path, &locale_path_len) != 0) +- return NULL; +- +- if (__argz_add_sep (&locale_path, &locale_path_len, +- _nl_default_locale_path, ':') != 0) +- return NULL; +- } ++ if (compute_locale_search_path (&locale_path, &locale_path_len) != 0) ++ return NULL; + + /* Get the names for the locales we are interested in. We either + allow a composite name or a single name. */ +diff --git a/locale/setlocale.c b/locale/setlocale.c +index ead030d..0c0e314 100644 +--- a/locale/setlocale.c ++++ b/locale/setlocale.c +@@ -215,12 +215,65 @@ setdata (int category, struct __locale_data *data) + } + } + ++/* Return in *LOCALE_PATH and *LOCALE_PATH_LEN the locale data search path as ++ a colon-separated list. Return ENOMEN on error, zero otherwise. */ ++error_t ++compute_locale_search_path (char **locale_path, size_t *locale_path_len) ++{ ++ char* guix_locpath_var = getenv ("GUIX_LOCPATH"); ++ char *locpath_var = getenv ("LOCPATH"); ++ ++ if (guix_locpath_var != NULL && guix_locpath_var[0] != '\0') ++ { ++ /* Entries in 'GUIX_LOCPATH' take precedence over 'LOCPATH'. These ++ entries are systematically prefixed with "/X.Y" where "X.Y" is the ++ libc version. */ ++ if (__argz_create_sep (guix_locpath_var, ':', ++ locale_path, locale_path_len) != 0 ++ || __argz_suffix_entries (locale_path, locale_path_len, ++ "/" VERSION) != 0) ++ goto bail_out; ++ } ++ ++ if (locpath_var != NULL && locpath_var[0] != '\0') ++ { ++ char *reg_locale_path = NULL; ++ size_t reg_locale_path_len = 0; ++ ++ if (__argz_create_sep (locpath_var, ':', ++ ®_locale_path, ®_locale_path_len) != 0) ++ goto bail_out; ++ ++ if (__argz_append (locale_path, locale_path_len, ++ reg_locale_path, reg_locale_path_len) != 0) ++ goto bail_out; ++ ++ free (reg_locale_path); ++ } ++ ++ if (*locale_path != NULL) ++ { ++ /* Append the system default locale directory. */ ++ if (__argz_add_sep (locale_path, locale_path_len, ++ _nl_default_locale_path, ':') != 0) ++ goto bail_out; ++ } ++ ++ return 0; ++ ++ bail_out: ++ free (*locale_path); ++ *locale_path = NULL; ++ *locale_path_len = 0; ++ ++ return ENOMEM; ++} ++ + char * + setlocale (int category, const char *locale) + { + char *locale_path; + size_t locale_path_len; +- const char *locpath_var; + char *composite; + + /* Sanity check for CATEGORY argument. */ +@@ -251,17 +304,10 @@ setlocale (int category, const char *locale) + locale_path = NULL; + locale_path_len = 0; + +- locpath_var = getenv ("LOCPATH"); +- if (locpath_var != NULL && locpath_var[0] != '\0') ++ if (compute_locale_search_path (&locale_path, &locale_path_len) != 0) + { +- if (__argz_create_sep (locpath_var, ':', +- &locale_path, &locale_path_len) != 0 +- || __argz_add_sep (&locale_path, &locale_path_len, +- _nl_default_locale_path, ':') != 0) +- { +- __libc_rwlock_unlock (__libc_setlocale_lock); +- return NULL; +- } ++ __libc_rwlock_unlock (__libc_setlocale_lock); ++ return NULL; + } + + if (category == LC_ALL) +diff --git a/string/Makefile b/string/Makefile +index 8424a61..f925503 100644 +--- a/string/Makefile ++++ b/string/Makefile +@@ -38,7 +38,7 @@ routines := strcat strchr strcmp strcoll strcpy strcspn \ + swab strfry memfrob memmem rawmemchr strchrnul \ + $(addprefix argz-,append count create ctsep next \ + delete extract insert stringify \ +- addsep replace) \ ++ addsep replace suffix) \ + envz basename \ + strcoll_l strxfrm_l string-inlines memrchr \ + xpg-strerror strerror_l +diff --git a/string/argz-suffix.c b/string/argz-suffix.c +new file mode 100644 +index 0000000..505b0f2 +--- /dev/null ++++ b/string/argz-suffix.c +@@ -0,0 +1,56 @@ ++/* Copyright (C) 2015 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ Contributed by Ludovic Courtès . ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++#include ++ ++ ++error_t ++__argz_suffix_entries (char **argz, size_t *argz_len, const char *suffix) ++ ++{ ++ size_t suffix_len = strlen (suffix); ++ size_t count = __argz_count (*argz, *argz_len); ++ size_t new_argz_len = *argz_len + count * suffix_len; ++ char *new_argz = malloc (new_argz_len); ++ ++ if (new_argz) ++ { ++ char *p = new_argz, *entry; ++ ++ for (entry = *argz; ++ entry != NULL; ++ entry = argz_next (*argz, *argz_len, entry)) ++ { ++ p = stpcpy (p, entry); ++ p = stpcpy (p, suffix); ++ p++; ++ } ++ ++ free (*argz); ++ *argz = new_argz; ++ *argz_len = new_argz_len; ++ ++ return 0; ++ } ++ else ++ return ENOMEM; ++} ++weak_alias (__argz_suffix_entries, argz_suffix_entries) +diff --git a/string/argz.h b/string/argz.h +index bb62a31..d276a35 100644 +--- a/string/argz.h ++++ b/string/argz.h +@@ -134,6 +134,16 @@ extern error_t argz_replace (char **__restrict __argz, + const char *__restrict __str, + const char *__restrict __with, + unsigned int *__restrict __replace_count); ++ ++/* Suffix each entry of ARGZ & ARGZ_LEN with SUFFIX. Return 0 on success, ++ and ENOMEN if memory cannot be allocated. */ ++extern error_t __argz_suffix_entries (char **__restrict __argz, ++ size_t *__restrict __argz_len, ++ const char *__restrict __suffix); ++extern error_t argz_suffix_entries (char **__restrict __argz, ++ size_t *__restrict __argz_len, ++ const char *__restrict __suffix); ++ + + /* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there + are no more. If entry is NULL, then the first entry is returned. This diff --git a/contrib/guix/patches/lief-fix-ppc64-nx-default.patch b/contrib/guix/patches/lief-fix-ppc64-nx-default.patch new file mode 100644 index 0000000..101bc1d --- /dev/null +++ b/contrib/guix/patches/lief-fix-ppc64-nx-default.patch @@ -0,0 +1,29 @@ +Correct default for Binary::has_nx on ppc64 + +From the Linux kernel source: + + * This is the default if a program doesn't have a PT_GNU_STACK + * program header entry. The PPC64 ELF ABI has a non executable stack + * stack by default, so in the absence of a PT_GNU_STACK program header + * we turn execute permission off. + +This patch can be dropped the next time we update LIEF. + +diff --git a/src/ELF/Binary.cpp b/src/ELF/Binary.cpp +index a90be1ab..fd2d9764 100644 +--- a/src/ELF/Binary.cpp ++++ b/src/ELF/Binary.cpp +@@ -1084,7 +1084,12 @@ bool Binary::has_nx() const { + return segment->type() == SEGMENT_TYPES::PT_GNU_STACK; + }); + if (it_stack == std::end(segments_)) { +- return false; ++ if (header().machine_type() == ARCH::EM_PPC64) { ++ // The PPC64 ELF ABI has a non-executable stack by default. ++ return true; ++ } else { ++ return false; ++ } + } + + return !(*it_stack)->has(ELF_SEGMENT_FLAGS::PF_X); diff --git a/contrib/guix/patches/nsis-disable-installer-reloc.patch b/contrib/guix/patches/nsis-disable-installer-reloc.patch new file mode 100644 index 0000000..4914527 --- /dev/null +++ b/contrib/guix/patches/nsis-disable-installer-reloc.patch @@ -0,0 +1,30 @@ +Patch NSIS so that it's installer stubs, produced at NSIS build time, +do not contain .reloc sections, which will exist by default when using +binutils/ld 2.36+. + +This ultimately fixes an issue when running the installer with the +"Force randomization for images (Mandatory ASLR)" setting active. + +This patch has not yet been sent upstream, because it's not clear if this +is the best fix, for the underlying issue, which seems to be that makensis +doesn't account for .reloc sections when it builds installers. + +The existence of a reloc section shouldn't be a problem, and, if anything, +is actually a requirement for working ASLR. All other Windows binaries we +produce contain them, and function correctly when under the same +"Force randomization for images (Mandatory ASLR)" setting. + +See: +https://github.com/bitcoin/bitcoin/issues/25726 +https://sourceforge.net/p/nsis/bugs/1131/ + +--- a/SCons/Config/gnu ++++ b/SCons/Config/gnu +@@ -102,6 +102,7 @@ stub_env.Append(LINKFLAGS = ['-mwindows']) # build windows executables + stub_env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) # no standard libraries + stub_env.Append(LINKFLAGS = ['$ALIGN_FLAG']) # 512 bytes align + stub_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file ++stub_env.Append(LINKFLAGS = ['-Wl,--disable-reloc-section']) + + conf = FlagsConfigure(stub_env) + conf.CheckCompileFlag('-fno-tree-loop-distribute-patterns') # GCC 10: Don't generate msvcrt!memmove calls (bug #1248) diff --git a/contrib/guix/patches/nsis-gcc-10-memmove.patch b/contrib/guix/patches/nsis-gcc-10-memmove.patch new file mode 100644 index 0000000..a1aadfd --- /dev/null +++ b/contrib/guix/patches/nsis-gcc-10-memmove.patch @@ -0,0 +1,23 @@ +commit f6df41524e703dc471e283e566a48e05a735b7f2 +Author: Anders +Date: Sat Jun 27 23:18:45 2020 +0000 + + Don't let GCC 10 generate memmove calls (bug #1248) + + git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7189 212acab6-be3b-0410-9dea-997c60f758d6 + +diff --git a/SCons/Config/gnu b/SCons/Config/gnu +index bfcb362d..21fa446b 100644 +--- a/SCons/Config/gnu ++++ b/SCons/Config/gnu +@@ -103,6 +103,10 @@ stub_env.Append(LINKFLAGS = ['$NODEFLIBS_FLAG']) # no standard libraries + stub_env.Append(LINKFLAGS = ['$ALIGN_FLAG']) # 512 bytes align + stub_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file + ++conf = FlagsConfigure(stub_env) ++conf.CheckCompileFlag('-fno-tree-loop-distribute-patterns') # GCC 10: Don't generate msvcrt!memmove calls (bug #1248) ++conf.Finish() ++ + stub_uenv = stub_env.Clone() + stub_uenv.Append(CPPDEFINES = ['_UNICODE', 'UNICODE']) + diff --git a/contrib/guix/patches/oscrypto-hard-code-openssl.patch b/contrib/guix/patches/oscrypto-hard-code-openssl.patch new file mode 100644 index 0000000..32027f2 --- /dev/null +++ b/contrib/guix/patches/oscrypto-hard-code-openssl.patch @@ -0,0 +1,13 @@ +diff --git a/oscrypto/__init__.py b/oscrypto/__init__.py +index eb27313..371ab24 100644 +--- a/oscrypto/__init__.py ++++ b/oscrypto/__init__.py +@@ -302,3 +302,8 @@ def load_order(): + 'oscrypto._win.tls', + 'oscrypto.tls', + ] ++ ++ ++paths = '@GUIX_OSCRYPTO_USE_OPENSSL@'.split(',') ++assert len(paths) == 2, 'Value for OSCRYPTO_USE_OPENSSL env var must be two paths separated by a comma' ++use_openssl(*paths) diff --git a/contrib/guix/patches/vmov-alignment.patch b/contrib/guix/patches/vmov-alignment.patch new file mode 100644 index 0000000..072f76e --- /dev/null +++ b/contrib/guix/patches/vmov-alignment.patch @@ -0,0 +1,267 @@ +Description: Use unaligned VMOV instructions +Author: Stephen Kitt +Bug-Debian: https://bugs.debian.org/939559 + +Based on a patch originally by Claude Heiland-Allen + +--- a/gcc/config/i386/sse.md ++++ b/gcc/config/i386/sse.md +@@ -1058,17 +1058,11 @@ + { + if (FLOAT_MODE_P (GET_MODE_INNER (mode))) + { +- if (misaligned_operand (operands[1], mode)) +- return "vmovu\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"; +- else +- return "vmova\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"; ++ return "vmovu\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"; + } + else + { +- if (misaligned_operand (operands[1], mode)) +- return "vmovdqu\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"; +- else +- return "vmovdqa\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"; ++ return "vmovdqu\t{%1, %0%{%3%}%N2|%0%{%3%}%N2, %1}"; + } + } + [(set_attr "type" "ssemov") +@@ -1184,17 +1178,11 @@ + { + if (FLOAT_MODE_P (GET_MODE_INNER (mode))) + { +- if (misaligned_operand (operands[0], mode)) +- return "vmovu\t{%1, %0%{%2%}|%0%{%2%}, %1}"; +- else +- return "vmova\t{%1, %0%{%2%}|%0%{%2%}, %1}"; ++ return "vmovu\t{%1, %0%{%2%}|%0%{%2%}, %1}"; + } + else + { +- if (misaligned_operand (operands[0], mode)) +- return "vmovdqu\t{%1, %0%{%2%}|%0%{%2%}, %1}"; +- else +- return "vmovdqa\t{%1, %0%{%2%}|%0%{%2%}, %1}"; ++ return "vmovdqu\t{%1, %0%{%2%}|%0%{%2%}, %1}"; + } + } + [(set_attr "type" "ssemov") +@@ -7806,7 +7794,7 @@ + "TARGET_SSE && !(MEM_P (operands[0]) && MEM_P (operands[1]))" + "@ + %vmovlps\t{%1, %0|%q0, %1} +- %vmovaps\t{%1, %0|%0, %1} ++ %vmovups\t{%1, %0|%0, %1} + %vmovlps\t{%1, %d0|%d0, %q1}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "maybe_vex") +@@ -13997,29 +13985,15 @@ + switch (mode) + { + case E_V8DFmode: +- if (misaligned_operand (operands[2], mode)) +- return "vmovupd\t{%2, %x0|%x0, %2}"; +- else +- return "vmovapd\t{%2, %x0|%x0, %2}"; ++ return "vmovupd\t{%2, %x0|%x0, %2}"; + case E_V16SFmode: +- if (misaligned_operand (operands[2], mode)) +- return "vmovups\t{%2, %x0|%x0, %2}"; +- else +- return "vmovaps\t{%2, %x0|%x0, %2}"; ++ return "vmovups\t{%2, %x0|%x0, %2}"; + case E_V8DImode: +- if (misaligned_operand (operands[2], mode)) +- return which_alternative == 2 ? "vmovdqu64\t{%2, %x0|%x0, %2}" ++ return which_alternative == 2 ? "vmovdqu64\t{%2, %x0|%x0, %2}" + : "vmovdqu\t{%2, %x0|%x0, %2}"; +- else +- return which_alternative == 2 ? "vmovdqa64\t{%2, %x0|%x0, %2}" +- : "vmovdqa\t{%2, %x0|%x0, %2}"; + case E_V16SImode: +- if (misaligned_operand (operands[2], mode)) +- return which_alternative == 2 ? "vmovdqu32\t{%2, %x0|%x0, %2}" ++ return which_alternative == 2 ? "vmovdqu32\t{%2, %x0|%x0, %2}" + : "vmovdqu\t{%2, %x0|%x0, %2}"; +- else +- return which_alternative == 2 ? "vmovdqa32\t{%2, %x0|%x0, %2}" +- : "vmovdqa\t{%2, %x0|%x0, %2}"; + default: + gcc_unreachable (); + } +@@ -21225,63 +21199,27 @@ + switch (get_attr_mode (insn)) + { + case MODE_V16SF: +- if (misaligned_operand (operands[1], mode)) +- return "vmovups\t{%1, %t0|%t0, %1}"; +- else +- return "vmovaps\t{%1, %t0|%t0, %1}"; ++ return "vmovups\t{%1, %t0|%t0, %1}"; + case MODE_V8DF: +- if (misaligned_operand (operands[1], mode)) +- return "vmovupd\t{%1, %t0|%t0, %1}"; +- else +- return "vmovapd\t{%1, %t0|%t0, %1}"; ++ return "vmovupd\t{%1, %t0|%t0, %1}"; + case MODE_V8SF: +- if (misaligned_operand (operands[1], mode)) +- return "vmovups\t{%1, %x0|%x0, %1}"; +- else +- return "vmovaps\t{%1, %x0|%x0, %1}"; ++ return "vmovups\t{%1, %x0|%x0, %1}"; + case MODE_V4DF: +- if (misaligned_operand (operands[1], mode)) +- return "vmovupd\t{%1, %x0|%x0, %1}"; +- else +- return "vmovapd\t{%1, %x0|%x0, %1}"; ++ return "vmovupd\t{%1, %x0|%x0, %1}"; + case MODE_XI: +- if (misaligned_operand (operands[1], mode)) +- { +- if (which_alternative == 2) +- return "vmovdqu\t{%1, %t0|%t0, %1}"; +- else if (GET_MODE_SIZE (mode) == 8) +- return "vmovdqu64\t{%1, %t0|%t0, %1}"; +- else +- return "vmovdqu32\t{%1, %t0|%t0, %1}"; +- } ++ if (which_alternative == 2) ++ return "vmovdqu\t{%1, %t0|%t0, %1}"; ++ else if (GET_MODE_SIZE (mode) == 8) ++ return "vmovdqu64\t{%1, %t0|%t0, %1}"; + else +- { +- if (which_alternative == 2) +- return "vmovdqa\t{%1, %t0|%t0, %1}"; +- else if (GET_MODE_SIZE (mode) == 8) +- return "vmovdqa64\t{%1, %t0|%t0, %1}"; +- else +- return "vmovdqa32\t{%1, %t0|%t0, %1}"; +- } ++ return "vmovdqu32\t{%1, %t0|%t0, %1}"; + case MODE_OI: +- if (misaligned_operand (operands[1], mode)) +- { +- if (which_alternative == 2) +- return "vmovdqu\t{%1, %x0|%x0, %1}"; +- else if (GET_MODE_SIZE (mode) == 8) +- return "vmovdqu64\t{%1, %x0|%x0, %1}"; +- else +- return "vmovdqu32\t{%1, %x0|%x0, %1}"; +- } ++ if (which_alternative == 2) ++ return "vmovdqu\t{%1, %x0|%x0, %1}"; ++ else if (GET_MODE_SIZE (mode) == 8) ++ return "vmovdqu64\t{%1, %x0|%x0, %1}"; + else +- { +- if (which_alternative == 2) +- return "vmovdqa\t{%1, %x0|%x0, %1}"; +- else if (GET_MODE_SIZE (mode) == 8) +- return "vmovdqa64\t{%1, %x0|%x0, %1}"; +- else +- return "vmovdqa32\t{%1, %x0|%x0, %1}"; +- } ++ return "vmovdqu32\t{%1, %x0|%x0, %1}"; + default: + gcc_unreachable (); + } +--- a/gcc/config/i386/i386.c ++++ b/gcc/config/i386/i386.c +@@ -4981,13 +4981,13 @@ + switch (type) + { + case opcode_int: +- opcode = misaligned_p ? "vmovdqu32" : "vmovdqa32"; ++ opcode = "vmovdqu32"; + break; + case opcode_float: +- opcode = misaligned_p ? "vmovups" : "vmovaps"; ++ opcode = "vmovups"; + break; + case opcode_double: +- opcode = misaligned_p ? "vmovupd" : "vmovapd"; ++ opcode = "vmovupd"; + break; + } + } +@@ -4996,16 +4996,16 @@ + switch (scalar_mode) + { + case E_SFmode: +- opcode = misaligned_p ? "%vmovups" : "%vmovaps"; ++ opcode = "%vmovups"; + break; + case E_DFmode: +- opcode = misaligned_p ? "%vmovupd" : "%vmovapd"; ++ opcode = "%vmovupd"; + break; + case E_TFmode: + if (evex_reg_p) +- opcode = misaligned_p ? "vmovdqu64" : "vmovdqa64"; ++ opcode = "vmovdqu64"; + else +- opcode = misaligned_p ? "%vmovdqu" : "%vmovdqa"; ++ opcode = "%vmovdqu"; + break; + default: + gcc_unreachable (); +@@ -5017,48 +5017,32 @@ + { + case E_QImode: + if (evex_reg_p) +- opcode = (misaligned_p +- ? (TARGET_AVX512BW +- ? "vmovdqu8" +- : "vmovdqu64") +- : "vmovdqa64"); ++ opcode = TARGET_AVX512BW ? "vmovdqu8" : "vmovdqu64"; + else +- opcode = (misaligned_p +- ? (TARGET_AVX512BW +- ? "vmovdqu8" +- : "%vmovdqu") +- : "%vmovdqa"); ++ opcode = TARGET_AVX512BW ? "vmovdqu8" : "%vmovdqu"; + break; + case E_HImode: + if (evex_reg_p) +- opcode = (misaligned_p +- ? (TARGET_AVX512BW +- ? "vmovdqu16" +- : "vmovdqu64") +- : "vmovdqa64"); ++ opcode = TARGET_AVX512BW ? "vmovdqu16" : "vmovdqu64"; + else +- opcode = (misaligned_p +- ? (TARGET_AVX512BW +- ? "vmovdqu16" +- : "%vmovdqu") +- : "%vmovdqa"); ++ opcode = TARGET_AVX512BW ? "vmovdqu16" : "%vmovdqu"; + break; + case E_SImode: + if (evex_reg_p) +- opcode = misaligned_p ? "vmovdqu32" : "vmovdqa32"; ++ opcode = "vmovdqu32"; + else +- opcode = misaligned_p ? "%vmovdqu" : "%vmovdqa"; ++ opcode = "%vmovdqu"; + break; + case E_DImode: + case E_TImode: + case E_OImode: + if (evex_reg_p) +- opcode = misaligned_p ? "vmovdqu64" : "vmovdqa64"; ++ opcode = "vmovdqu64"; + else +- opcode = misaligned_p ? "%vmovdqu" : "%vmovdqa"; ++ opcode = "%vmovdqu"; + break; + case E_XImode: +- opcode = misaligned_p ? "vmovdqu64" : "vmovdqa64"; ++ opcode = "vmovdqu64"; + break; + default: + gcc_unreachable (); diff --git a/contrib/installers/windows/feather.iss b/contrib/installers/windows/feather.iss deleted file mode 100644 index 8d8dd13..0000000 --- a/contrib/installers/windows/feather.iss +++ /dev/null @@ -1,68 +0,0 @@ -; Feather Wallet Installer for Windows -; Copyright (c) 2021-2022, The Monero Project - -#define AppName "Feather Wallet" -#define AppVersion "2.0.0" -#define AppPublisher "Feather Wallet" -#define AppURL "https://featherwallet.org" -#define AppExeName "feather.exe" - -[Setup] -AppId={{E3C599C7-4DF1-49F2-9C35-918A288677A4} -AppName={#AppName} -AppVersion={#AppVersion} -;AppVerName={#AppName} {#AppVersion} -AppPublisher={#AppPublisher} -AppPublisherURL={#AppURL} -AppSupportURL={#AppURL} -AppUpdatesURL={#AppURL} -DefaultDirName={autopf}\{#AppName} -DisableDirPage=no -DisableProgramGroupPage=yes -; Uncomment the following line to run in non administrative install mode (install for current user only.) -;PrivilegesRequired=lowest -OutputBaseFilename=FeatherWalletSetup -SetupIconFile=appicon.ico -Compression=lzma -SolidCompression=yes -WizardStyle=modern - -ArchitecturesInstallIn64BitMode=x64 -ArchitecturesAllowed=x64 -DisableReadyPage=yes - -WizardSmallImageFile=compiler:WizClassicSmallImage.bmp -WizardImageFile=compiler:WizClassicImage.bmp - -UninstallDisplayIcon={app}\{#AppExeName} - -[Messages] -SetupWindowTitle=Setup - Feather Wallet {#AppVersion} - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; - -[Files] -Source: "bin\{#AppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "tor\*"; DestDir: "{app}\tor"; Flags: ignoreversion - -;Source: "C:\Users\dev\Desktop\feather setup\finishbanner.bmp"; Flags: dontcopy -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[Code] -procedure CurPageChanged(CurPageID: Integer); -begin - if CurPageID = wpSelectTasks then - WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall) -end; - -[Icons] -Name: "{autoprograms}\{#AppName}"; Filename: "{app}\{#AppExeName}" -Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon - -[Run] -Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent diff --git a/contrib/installers/windows/setup.nsi.in b/contrib/installers/windows/setup.nsi.in new file mode 100644 index 0000000..32a5dc6 --- /dev/null +++ b/contrib/installers/windows/setup.nsi.in @@ -0,0 +1,121 @@ +Name "Feather Wallet" + +OutFile "${CUR_PATH}\contrib\installers\windows\FeatherWalletSetup-@PROJECT_VERSION@.exe" +RequestExecutionLevel highest +SetCompressor /SOLID lzma +SetDateSave off +Unicode true + +# Uncomment these lines when investigating reproducibility errors +#SetCompress off +#SetDatablockOptimize off + +# MUI Symbol Definitions +!define MUI_ICON "${CUR_PATH}\contrib\installers\windows\appicon.ico" +!define MUI_FINISHPAGE_NOAUTOCLOSE +!define MUI_STARTMENUPAGE_DEFAULTFOLDER "$(^Name)" +!define MUI_FINISHPAGE_RUN "$WINDIR\explorer.exe" +!define MUI_FINISHPAGE_RUN_PARAMETERS $INSTDIR\feather.exe +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" +!define MUI_UNFINISHPAGE_NOAUTOCLOSE + +# Included files +!include Sections.nsh +!include MUI2.nsh +!include x64.nsh + +# Variables +Var StartMenuGroup + +# Installer pages +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +# Installer languages +!insertmacro MUI_LANGUAGE English + +# Installer attributes +InstallDir "$PROGRAMFILES64\Feather Wallet" +CRCCheck force +XPStyle on +BrandingText " " +ShowInstDetails show +VIProductVersion @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0 +VIAddVersionKey ProductName "Feather Wallet" +VIAddVersionKey ProductVersion "@PROJECT_VERSION@" +VIAddVersionKey CompanyName "Feather Wallet" +VIAddVersionKey CompanyWebsite "https://featherwallet.org" +VIAddVersionKey FileVersion "@PROJECT_VERSION@" +VIAddVersionKey FileDescription "Installer for Feather Wallet" +VIAddVersionKey LegalCopyright "Copyright (C) 2020-@COPYRIGHT_YEAR@ @COPYRIGHT_HOLDERS@" +ShowUninstDetails show + +# Installer sections +Section -Main SEC0000 + SetOutPath $INSTDIR + SetOverwrite on + File "${CUR_PATH}\build\bin\feather.exe" + File /oname=LICENSE.txt "${CUR_PATH}\LICENSE" + SetOutPath $INSTDIR\tor + File /r \feather\contrib\depends\x86_64-w64-mingw32\Tor\*.* + SetOutPath $INSTDIR +SectionEnd + +Section -post SEC0001 + SetOutPath $INSTDIR + Delete /REBOOTOK "$INSTDIR\unins000.exe" + Delete /REBOOTOK "$INSTDIR\unins000.dat" + WriteUninstaller "$INSTDIR\uninstall.exe" + SetShellVarContext all + Delete /REBOOTOK "$SMPROGRAMS\Feather Wallet.lnk" + SetShellVarContext current + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + CreateDirectory $SMPROGRAMS\$StartMenuGroup + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" $INSTDIR\feather.exe + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe + CreateShortcut "$Desktop\$(^Name).lnk" "$InstDir\feather.exe" + !insertmacro MUI_STARTMENU_WRITE_END +SectionEnd + +# Uninstaller sections +Section /o -un.Main UNSEC0000 + Delete /REBOOTOK $INSTDIR\feather.exe + Delete /REBOOTOK $INSTDIR\LICENSE.txt + RMDir /r /REBOOTOK $INSTDIR\tor +SectionEnd + +Section -un.post UNSEC0001 + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" + Delete /REBOOTOK "$Desktop\$(^Name).lnk" + Delete /REBOOTOK $INSTDIR\uninstall.exe + RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup + RmDir /REBOOTOK $INSTDIR + Push $R0 + StrCpy $R0 $StartMenuGroup 1 + StrCmp $R0 ">" no_smgroup +no_smgroup: + Pop $R0 +SectionEnd + +# Installer functions +Function .onInit + InitPluginsDir + ${If} ${RunningX64} + ; disable registry redirection (enable access to 64-bit portion of registry) + SetRegView 64 + ${Else} + MessageBox MB_OK|MB_ICONSTOP "Cannot install 64-bit version on a 32-bit system." + Abort + ${EndIf} +FunctionEnd + +# Uninstaller functions +Function un.onInit + !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup + !insertmacro SelectSection ${UNSEC0000} +FunctionEnd \ No newline at end of file diff --git a/utils/Info.plist b/contrib/macdeploy/Info.plist.in similarity index 69% rename from utils/Info.plist rename to contrib/macdeploy/Info.plist.in index 4517bdc..c3e4f24 100644 --- a/utils/Info.plist +++ b/contrib/macdeploy/Info.plist.in @@ -1,12 +1,14 @@ - - + + LSMinimumSystemVersion - 10.10.0 + 10.15.0 - NSPrincipalClass - NSApplication + LSArchitecturePriority + + x86_64 + CFBundleIconFile appicon.icns @@ -14,6 +16,20 @@ CFBundlePackageType APPL + CFBundleSupportedPlatforms + + MacOSX + + + NSHumanReadableCopyright + Copyright © 2014-@COPYRIGHT_YEAR@ @COPYRIGHT_HOLDERS@ + + CFBundleShortVersionString + @VERSION@ + + CFBundleVersion + @VERSION@ + CFBundleSignature ???? @@ -23,20 +39,11 @@ CFBundleName Feather - NSHumanReadableCopyright - Copyright © 2014-2021 The Monero Project - - NSCameraUsageDescription - Camera is used to scan QR codes on demand. - CFBundleIdentifier org.monero-project.feather - CFBundleVersion - @VERSION_LONG@ - - CFBundleShortVersionString - @VERSION@ + NSCameraUsageDescription + Camera is used to scan QR codes on demand. NSSupportsAutomaticGraphicsSwitching @@ -60,5 +67,14 @@ + + NSPrincipalClass + NSApplication + + NSHighResolutionCapable + True + + LSApplicationCategoryType + public.app-category.finance diff --git a/contrib/macdeploy/README.md b/contrib/macdeploy/README.md new file mode 100644 index 0000000..599a0bf --- /dev/null +++ b/contrib/macdeploy/README.md @@ -0,0 +1,112 @@ +# MacOS Deployment + +The `macdeployqtplus` script should not be run manually. Instead, after building as usual: + +```bash +make deploy +``` + +When complete, it will have produced `Bitcoin-Core.dmg`. + +## SDK Extraction + +### Step 1: Obtaining `Xcode.app` + +A free Apple Developer Account is required to proceed. + +Our current macOS SDK +(`Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz`) +can be extracted from +[Xcode_12.2.xip](https://download.developer.apple.com/Developer_Tools/Xcode_12.2/Xcode_12.2.xip). + +Alternatively, after logging in to your account go to 'Downloads', then 'More' +and search for [`Xcode 12.2`](https://developer.apple.com/download/all/?q=Xcode%2012.2). + +An Apple ID and cookies enabled for the hostname are needed to download this. + +The `sha256sum` of the downloaded XIP archive should be `28d352f8c14a43d9b8a082ac6338dc173cb153f964c6e8fb6ba389e5be528bd0`. + +After Xcode version 7.x, Apple started shipping the `Xcode.app` in a `.xip` +archive. This makes the SDK less-trivial to extract on non-macOS machines. One +approach (tested on Debian Buster) is outlined below: + +```bash +# Install/clone tools needed for extracting Xcode.app +apt install cpio +git clone https://github.com/bitcoin-core/apple-sdk-tools.git + +# Unpack Xcode_12.2.xip and place the resulting Xcode.app in your current +# working directory +python3 apple-sdk-tools/extract_xcode.py -f Xcode_12.2.xip | cpio -d -i +``` + +On macOS the process is more straightforward: + +```bash +xip -x Xcode_12.2.xip +``` + +### Step 2: Generating `Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz` from `Xcode.app` + +To generate `Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz`, run +the script [`gen-sdk`](./gen-sdk) with the path to `Xcode.app` (extracted in the +previous stage) as the first argument. + +```bash +# Generate a Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz from +# the supplied Xcode.app +./contrib/macdeploy/gen-sdk '/path/to/Xcode.app' +``` + +The `sha256sum` of the generated TAR.GZ archive should be `df75d30ecafc429e905134333aeae56ac65fac67cb4182622398fd717df77619`. + +## Deterministic macOS DMG Notes + +Working macOS DMGs are created in Linux by combining a recent `clang`, the Apple +`binutils` (`ld`, `ar`, etc) and DMG authoring tools. + +Apple uses `clang` extensively for development and has upstreamed the necessary +functionality so that a vanilla clang can take advantage. It supports the use of `-F`, +`-target`, `-mmacosx-version-min`, and `-isysroot`, which are all necessary when +building for macOS. + +Apple's version of `binutils` (called `cctools`) contains lots of functionality missing in the +FSF's `binutils`. In addition to extra linker options for frameworks and sysroots, several +other tools are needed as well such as `install_name_tool`, `lipo`, and `nmedit`. These +do not build under Linux, so they have been patched to do so. The work here was used as +a starting point: [mingwandroid/toolchain4](https://github.com/mingwandroid/toolchain4). + +In order to build a working toolchain, the following source packages are needed from +Apple: `cctools`, `dyld`, and `ld64`. + +These tools inject timestamps by default, which produce non-deterministic binaries. The +`ZERO_AR_DATE` environment variable is used to disable that. + +This version of `cctools` has been patched to use the current version of `clang`'s headers +and its `libLTO.so` rather than those from `llvmgcc`, as it was originally done in `toolchain4`. + +To complicate things further, all builds must target an Apple SDK. These SDKs are free to +download, but not redistributable. See the SDK Extraction notes above for how to obtain it. + +The Guix process builds 2 sets of files: Linux tools, then Apple binaries which are +created using these tools. The build process has been designed to avoid including the +SDK's files in Guix's outputs. All interim tarballs are fully deterministic and may be freely +redistributed. + +[`xorrisofs`](https://www.gnu.org/software/xorriso/) is used to create the DMG. + +A background image is added to DMG files by inserting a `.DS_Store` during creation. + +As of OS X 10.9 Mavericks, using an Apple-blessed key to sign binaries is a requirement in +order to satisfy the new Gatekeeper requirements. Because this private key cannot be +shared, we'll have to be a bit creative in order for the build process to remain somewhat +deterministic. Here's how it works: + +- Builders use Guix to create an unsigned release. This outputs an unsigned DMG which + users may choose to bless and run. It also outputs an unsigned app structure in the form + of a tarball, which also contains all of the tools that have been previously (deterministically) + built in order to create a final DMG. +- The Apple keyholder uses this unsigned app to create a detached signature, using the + script that is also included there. Detached signatures are available from this [repository](https://github.com/bitcoin-core/bitcoin-detached-sigs). +- Builders feed the unsigned app + detached signature back into Guix. It uses the + pre-built tools to recombine the pieces into a deterministic DMG. diff --git a/contrib/macdeploy/background.tiff b/contrib/macdeploy/background.tiff new file mode 100644 index 0000000..1fb088c Binary files /dev/null and b/contrib/macdeploy/background.tiff differ diff --git a/contrib/macdeploy/detached-sig-create.sh b/contrib/macdeploy/detached-sig-create.sh new file mode 100755 index 0000000..f393331 --- /dev/null +++ b/contrib/macdeploy/detached-sig-create.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright (c) 2014-2021 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +export LC_ALL=C +set -e + +ROOTDIR=dist +BUNDLE="${ROOTDIR}/Bitcoin-Qt.app" +BINARY="${BUNDLE}/Contents/MacOS/Bitcoin-Qt" +SIGNAPPLE=signapple +TEMPDIR=sign.temp +ARCH=$(${SIGNAPPLE} info ${BINARY} | head -n 1 | cut -d " " -f 1) +OUT="signature-osx-${ARCH}.tar.gz" +OUTROOT=osx/dist + +if [ -z "$1" ]; then + echo "usage: $0 " + echo "example: $0 " + exit 1 +fi + +rm -rf ${TEMPDIR} +mkdir -p ${TEMPDIR} + +${SIGNAPPLE} sign -f --detach "${TEMPDIR}/${OUTROOT}" "$@" "${BUNDLE}" + +tar -C "${TEMPDIR}" -czf "${OUT}" . +rm -rf "${TEMPDIR}" +echo "Created ${OUT}" diff --git a/contrib/macdeploy/gen-sdk b/contrib/macdeploy/gen-sdk new file mode 100755 index 0000000..6efaacc --- /dev/null +++ b/contrib/macdeploy/gen-sdk @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +import argparse +import plistlib +import pathlib +import sys +import tarfile +import gzip +import os +import contextlib + +# monkey-patch Python 3.8 and older to fix wrong TAR header handling +# see https://github.com/bitcoin/bitcoin/pull/24534 +# and https://github.com/python/cpython/pull/18080 for more info +if sys.version_info < (3, 9): + _old_create_header = tarfile.TarInfo._create_header + def _create_header(info, format, encoding, errors): + buf = _old_create_header(info, format, encoding, errors) + # replace devmajor/devminor with binary zeroes + buf = buf[:329] + bytes(16) + buf[345:] + # recompute checksum + chksum = tarfile.calc_chksums(buf)[0] + buf = buf[:-364] + bytes("%06o\0" % chksum, "ascii") + buf[-357:] + return buf + tarfile.TarInfo._create_header = staticmethod(_create_header) + +@contextlib.contextmanager +def cd(path): + """Context manager that restores PWD even if an exception was raised.""" + old_pwd = os.getcwd() + os.chdir(str(path)) + try: + yield + finally: + os.chdir(old_pwd) + +def run(): + parser = argparse.ArgumentParser( + description=__doc__, formatter_class=argparse.RawTextHelpFormatter) + + parser.add_argument('xcode_app', metavar='XCODEAPP', nargs=1) + parser.add_argument("-o", metavar='OUTSDKTGZ', nargs=1, dest='out_sdktgz', required=False) + + args = parser.parse_args() + + xcode_app = pathlib.Path(args.xcode_app[0]).resolve() + assert xcode_app.is_dir(), "The supplied Xcode.app path '{}' either does not exist or is not a directory".format(xcode_app) + + xcode_app_plist = xcode_app.joinpath("Contents/version.plist") + with xcode_app_plist.open('rb') as fp: + pl = plistlib.load(fp) + xcode_version = pl['CFBundleShortVersionString'] + xcode_build_id = pl['ProductBuildVersion'] + print("Found Xcode (version: {xcode_version}, build id: {xcode_build_id})".format(xcode_version=xcode_version, xcode_build_id=xcode_build_id)) + + sdk_dir = xcode_app.joinpath("Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk") + sdk_plist = sdk_dir.joinpath("System/Library/CoreServices/SystemVersion.plist") + with sdk_plist.open('rb') as fp: + pl = plistlib.load(fp) + sdk_version = pl['ProductVersion'] + sdk_build_id = pl['ProductBuildVersion'] + print("Found MacOSX SDK (version: {sdk_version}, build id: {sdk_build_id})".format(sdk_version=sdk_version, sdk_build_id=sdk_build_id)) + + out_name = "Xcode-{xcode_version}-{xcode_build_id}-extracted-SDK-with-libcxx-headers".format(xcode_version=xcode_version, xcode_build_id=xcode_build_id) + + xcode_libcxx_dir = xcode_app.joinpath("Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1") + assert xcode_libcxx_dir.is_dir() + + if args.out_sdktgz: + out_sdktgz_path = pathlib.Path(args.out_sdktgz_path) + else: + # Construct our own out_sdktgz if not specified on the command line + out_sdktgz_path = pathlib.Path("./{}.tar.gz".format(out_name)) + + def tarfp_add_with_base_change(tarfp, dir_to_add, alt_base_dir): + """Add all files in dir_to_add to tarfp, but prepent MEMBERPREFIX to the files' + names + + e.g. if the only file under /root/bazdir is /root/bazdir/qux, invoking: + + tarfp_add_with_base_change(tarfp, "foo/bar", "/root/bazdir") + + would result in the following members being added to tarfp: + + foo/bar/ -> corresponding to /root/bazdir + foo/bar/qux -> corresponding to /root/bazdir/qux + + """ + def change_tarinfo_base(tarinfo): + if tarinfo.name and tarinfo.name.startswith("./"): + tarinfo.name = str(pathlib.Path(alt_base_dir, tarinfo.name)) + if tarinfo.linkname and tarinfo.linkname.startswith("./"): + tarinfo.linkname = str(pathlib.Path(alt_base_dir, tarinfo.linkname)) + # make metadata deterministic + tarinfo.mtime = 0 + tarinfo.uid, tarinfo.uname = 0, '' + tarinfo.gid, tarinfo.gname = 0, '' + # don't use isdir() as there are also executable files present + tarinfo.mode = 0o0755 if tarinfo.mode & 0o0100 else 0o0644 + return tarinfo + with cd(dir_to_add): + # recursion already adds entries in sorted order + tarfp.add(".", recursive=True, filter=change_tarinfo_base) + + print("Creating output .tar.gz file...") + with out_sdktgz_path.open("wb") as fp: + with gzip.GzipFile(fileobj=fp, mode='wb', compresslevel=9, mtime=0) as gzf: + with tarfile.open(mode="w", fileobj=gzf, format=tarfile.GNU_FORMAT) as tarfp: + print("Adding MacOSX SDK {} files...".format(sdk_version)) + tarfp_add_with_base_change(tarfp, sdk_dir, out_name) + print("Adding libc++ headers...") + tarfp_add_with_base_change(tarfp, xcode_libcxx_dir, "{}/usr/include/c++/v1".format(out_name)) + print("Done! Find the resulting gzipped tarball at:") + print(out_sdktgz_path.resolve()) + +if __name__ == '__main__': + run() diff --git a/contrib/macdeploy/macdeployqtplus b/contrib/macdeploy/macdeployqtplus new file mode 100755 index 0000000..62ece56 --- /dev/null +++ b/contrib/macdeploy/macdeployqtplus @@ -0,0 +1,597 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2011 Patrick "p2k" Schneider +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import sys, re, os, platform, shutil, stat, subprocess, os.path +from argparse import ArgumentParser +from ds_store import DSStore +from mac_alias import Alias +from pathlib import Path +from subprocess import PIPE, run +from typing import List, Optional + +# This is ported from the original macdeployqt with modifications + +class FrameworkInfo(object): + def __init__(self): + self.frameworkDirectory = "" + self.frameworkName = "" + self.frameworkPath = "" + self.binaryDirectory = "" + self.binaryName = "" + self.binaryPath = "" + self.version = "" + self.installName = "" + self.deployedInstallName = "" + self.sourceFilePath = "" + self.destinationDirectory = "" + self.sourceResourcesDirectory = "" + self.sourceVersionContentsDirectory = "" + self.sourceContentsDirectory = "" + self.destinationResourcesDirectory = "" + self.destinationVersionContentsDirectory = "" + + def __eq__(self, other): + if self.__class__ == other.__class__: + return self.__dict__ == other.__dict__ + else: + return False + + def __str__(self): + return f""" Framework name: {self.frameworkName} + Framework directory: {self.frameworkDirectory} + Framework path: {self.frameworkPath} + Binary name: {self.binaryName} + Binary directory: {self.binaryDirectory} + Binary path: {self.binaryPath} + Version: {self.version} + Install name: {self.installName} + Deployed install name: {self.deployedInstallName} + Source file Path: {self.sourceFilePath} + Deployed Directory (relative to bundle): {self.destinationDirectory} +""" + + def isDylib(self): + return self.frameworkName.endswith(".dylib") + + def isQtFramework(self): + if self.isDylib(): + return self.frameworkName.startswith("libQt") + else: + return self.frameworkName.startswith("Qt") + + reOLine = re.compile(r'^(.+) \(compatibility version [0-9.]+, current version [0-9.]+\)$') + bundleFrameworkDirectory = "Contents/Frameworks" + bundleBinaryDirectory = "Contents/MacOS" + + @classmethod + def fromOtoolLibraryLine(cls, line: str) -> Optional['FrameworkInfo']: + # Note: line must be trimmed + if line == "": + return None + + # Don't deploy system libraries + if line.startswith("/System/Library/") or line.startswith("@executable_path") or line.startswith("/usr/lib/"): + return None + + m = cls.reOLine.match(line) + if m is None: + raise RuntimeError(f"otool line could not be parsed: {line}") + + path = m.group(1) + + info = cls() + info.sourceFilePath = path + info.installName = path + + if path.endswith(".dylib"): + dirname, filename = os.path.split(path) + info.frameworkName = filename + info.frameworkDirectory = dirname + info.frameworkPath = path + + info.binaryDirectory = dirname + info.binaryName = filename + info.binaryPath = path + info.version = "-" + + info.installName = path + info.deployedInstallName = f"@executable_path/../Frameworks/{info.binaryName}" + info.sourceFilePath = path + info.destinationDirectory = cls.bundleFrameworkDirectory + else: + parts = path.split("/") + i = 0 + # Search for the .framework directory + for part in parts: + if part.endswith(".framework"): + break + i += 1 + if i == len(parts): + raise RuntimeError(f"Could not find .framework or .dylib in otool line: {line}") + + info.frameworkName = parts[i] + info.frameworkDirectory = "/".join(parts[:i]) + info.frameworkPath = os.path.join(info.frameworkDirectory, info.frameworkName) + + info.binaryName = parts[i+3] + info.binaryDirectory = "/".join(parts[i+1:i+3]) + info.binaryPath = os.path.join(info.binaryDirectory, info.binaryName) + info.version = parts[i+2] + + info.deployedInstallName = f"@executable_path/../Frameworks/{os.path.join(info.frameworkName, info.binaryPath)}" + info.destinationDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, info.binaryDirectory) + + info.sourceResourcesDirectory = os.path.join(info.frameworkPath, "Resources") + info.sourceContentsDirectory = os.path.join(info.frameworkPath, "Contents") + info.sourceVersionContentsDirectory = os.path.join(info.frameworkPath, "Versions", info.version, "Contents") + info.destinationResourcesDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Resources") + info.destinationVersionContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Versions", info.version, "Contents") + + return info + +class ApplicationBundleInfo(object): + def __init__(self, path: str): + self.path = path + self.binaryPath = os.path.join(path, "Contents", "MacOS", "feather") + if not os.path.exists(self.binaryPath): + raise RuntimeError(f"Could not find bundle binary for {path}") + self.resourcesPath = os.path.join(path, "Contents", "Resources") + self.pluginPath = os.path.join(path, "Contents", "PlugIns") + +class DeploymentInfo(object): + def __init__(self): + self.qtPath = None + self.pluginPath = None + self.deployedFrameworks = [] + + def detectQtPath(self, frameworkDirectory: str): + parentDir = os.path.dirname(frameworkDirectory) + if os.path.exists(os.path.join(parentDir, "translations")): + # Classic layout, e.g. "/usr/local/Trolltech/Qt-4.x.x" + self.qtPath = parentDir + else: + self.qtPath = os.getenv("QTDIR", None) + + if self.qtPath is not None: + pluginPath = os.path.join(self.qtPath, "plugins") + if os.path.exists(pluginPath): + self.pluginPath = pluginPath + + def usesFramework(self, name: str) -> bool: + for framework in self.deployedFrameworks: + if framework.endswith(".framework"): + if framework.startswith(f"{name}."): + return True + elif framework.endswith(".dylib"): + if framework.startswith(f"lib{name}."): + return True + return False + +def getFrameworks(binaryPath: str, verbose: int) -> List[FrameworkInfo]: + if verbose: + print(f"Inspecting with otool: {binaryPath}") + otoolbin=os.getenv("OTOOL", "otool") + otool = run([otoolbin, "-L", binaryPath], stdout=PIPE, stderr=PIPE, universal_newlines=True) + if otool.returncode != 0: + sys.stderr.write(otool.stderr) + sys.stderr.flush() + raise RuntimeError(f"otool failed with return code {otool.returncode}") + + otoolLines = otool.stdout.split("\n") + otoolLines.pop(0) # First line is the inspected binary + if ".framework" in binaryPath or binaryPath.endswith(".dylib"): + otoolLines.pop(0) # Frameworks and dylibs list themselves as a dependency. + + libraries = [] + for line in otoolLines: + line = line.replace("@loader_path", os.path.dirname(binaryPath)) + info = FrameworkInfo.fromOtoolLibraryLine(line.strip()) + if info is not None: + if verbose: + print("Found framework:") + print(info) + libraries.append(info) + + return libraries + +def runInstallNameTool(action: str, *args): + installnametoolbin=os.getenv("INSTALL_NAME_TOOL", "install_name_tool") + run([installnametoolbin, "-"+action] + list(args), check=True) + +def changeInstallName(oldName: str, newName: str, binaryPath: str, verbose: int): + if verbose: + print("Using install_name_tool:") + print(" in", binaryPath) + print(" change reference", oldName) + print(" to", newName) + runInstallNameTool("change", oldName, newName, binaryPath) + +def changeIdentification(id: str, binaryPath: str, verbose: int): + if verbose: + print("Using install_name_tool:") + print(" change identification in", binaryPath) + print(" to", id) + runInstallNameTool("id", id, binaryPath) + +def runStrip(binaryPath: str, verbose: int): + stripbin=os.getenv("STRIP", "strip") + if verbose: + print("Using strip:") + print(" stripped", binaryPath) + run([stripbin, "-x", binaryPath], check=True) + +def copyFramework(framework: FrameworkInfo, path: str, verbose: int) -> Optional[str]: + if framework.sourceFilePath.startswith("Qt"): + #standard place for Nokia Qt installer's frameworks + fromPath = f"/Library/Frameworks/{framework.sourceFilePath}" + else: + fromPath = framework.sourceFilePath + toDir = os.path.join(path, framework.destinationDirectory) + toPath = os.path.join(toDir, framework.binaryName) + + if framework.isDylib(): + if not os.path.exists(fromPath): + raise RuntimeError(f"No file at {fromPath}") + + if os.path.exists(toPath): + return None # Already there + + if not os.path.exists(toDir): + os.makedirs(toDir) + + shutil.copy2(fromPath, toPath) + if verbose: + print("Copied:", fromPath) + print(" to:", toPath) + else: + to_dir = os.path.join(path, "Contents", "Frameworks", framework.frameworkName) + if os.path.exists(to_dir): + return None # Already there + + from_dir = framework.frameworkPath + if not os.path.exists(from_dir): + raise RuntimeError(f"No directory at {from_dir}") + + shutil.copytree(from_dir, to_dir, symlinks=True) + if verbose: + print("Copied:", from_dir) + print(" to:", to_dir) + + headers_link = os.path.join(to_dir, "Headers") + if os.path.exists(headers_link): + os.unlink(headers_link) + + headers_dir = os.path.join(to_dir, framework.binaryDirectory, "Headers") + if os.path.exists(headers_dir): + shutil.rmtree(headers_dir) + + permissions = os.stat(toPath) + if not permissions.st_mode & stat.S_IWRITE: + os.chmod(toPath, permissions.st_mode | stat.S_IWRITE) + + return toPath + +def deployFrameworks(frameworks: List[FrameworkInfo], bundlePath: str, binaryPath: str, strip: bool, verbose: int, deploymentInfo: Optional[DeploymentInfo] = None) -> DeploymentInfo: + if deploymentInfo is None: + deploymentInfo = DeploymentInfo() + + while len(frameworks) > 0: + framework = frameworks.pop(0) + deploymentInfo.deployedFrameworks.append(framework.frameworkName) + + print("Processing", framework.frameworkName, "...") + + # Get the Qt path from one of the Qt frameworks + if deploymentInfo.qtPath is None and framework.isQtFramework(): + deploymentInfo.detectQtPath(framework.frameworkDirectory) + + if framework.installName.startswith("@executable_path") or framework.installName.startswith(bundlePath): + print(framework.frameworkName, "already deployed, skipping.") + continue + + # install_name_tool the new id into the binary + changeInstallName(framework.installName, framework.deployedInstallName, binaryPath, verbose) + + # Copy framework to app bundle. + deployedBinaryPath = copyFramework(framework, bundlePath, verbose) + # Skip the rest if already was deployed. + if deployedBinaryPath is None: + continue + + if strip: + runStrip(deployedBinaryPath, verbose) + + # install_name_tool it a new id. + changeIdentification(framework.deployedInstallName, deployedBinaryPath, verbose) + # Check for framework dependencies + dependencies = getFrameworks(deployedBinaryPath, verbose) + + for dependency in dependencies: + changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath, verbose) + + # Deploy framework if necessary. + if dependency.frameworkName not in deploymentInfo.deployedFrameworks and dependency not in frameworks: + frameworks.append(dependency) + + return deploymentInfo + +def deployFrameworksForAppBundle(applicationBundle: ApplicationBundleInfo, strip: bool, verbose: int) -> DeploymentInfo: + frameworks = getFrameworks(applicationBundle.binaryPath, verbose) + if len(frameworks) == 0: + print(f"Warning: Could not find any external frameworks to deploy in {applicationBundle.path}.") + return DeploymentInfo() + else: + return deployFrameworks(frameworks, applicationBundle.path, applicationBundle.binaryPath, strip, verbose) + +def deployPlugins(appBundleInfo: ApplicationBundleInfo, deploymentInfo: DeploymentInfo, strip: bool, verbose: int): + plugins = [] + if deploymentInfo.pluginPath is None: + return + for dirpath, dirnames, filenames in os.walk(deploymentInfo.pluginPath): + pluginDirectory = os.path.relpath(dirpath, deploymentInfo.pluginPath) + + if pluginDirectory not in ['styles', 'platforms']: + continue + + for pluginName in filenames: + pluginPath = os.path.join(pluginDirectory, pluginName) + + if pluginName.split('.')[0] not in ['libqminimal', 'libqcocoa', 'libqmacstyle']: + continue + + plugins.append((pluginDirectory, pluginName)) + + for pluginDirectory, pluginName in plugins: + print("Processing plugin", os.path.join(pluginDirectory, pluginName), "...") + + sourcePath = os.path.join(deploymentInfo.pluginPath, pluginDirectory, pluginName) + destinationDirectory = os.path.join(appBundleInfo.pluginPath, pluginDirectory) + if not os.path.exists(destinationDirectory): + os.makedirs(destinationDirectory) + + destinationPath = os.path.join(destinationDirectory, pluginName) + shutil.copy2(sourcePath, destinationPath) + if verbose: + print("Copied:", sourcePath) + print(" to:", destinationPath) + + if strip: + runStrip(destinationPath, verbose) + + dependencies = getFrameworks(destinationPath, verbose) + + for dependency in dependencies: + changeInstallName(dependency.installName, dependency.deployedInstallName, destinationPath, verbose) + + # Deploy framework if necessary. + if dependency.frameworkName not in deploymentInfo.deployedFrameworks: + deployFrameworks([dependency], appBundleInfo.path, destinationPath, strip, verbose, deploymentInfo) + +ap = ArgumentParser(description="""Improved version of macdeployqt. + +Outputs a ready-to-deploy app in a folder "dist" and optionally wraps it in a .dmg file. +Note, that the "dist" folder will be deleted before deploying on each run. + +Optionally, Qt translation files (.qm) can be added to the bundle.""") + +ap.add_argument("app_bundle", nargs=1, metavar="app-bundle", help="application bundle to be deployed") +ap.add_argument("appname", nargs=1, metavar="appname", help="name of the app being deployed") +ap.add_argument("-verbose", nargs="?", const=True, help="Output additional debugging information") +ap.add_argument("-no-plugins", dest="plugins", action="store_false", default=True, help="skip plugin deployment") +ap.add_argument("-no-strip", dest="strip", action="store_false", default=True, help="don't run 'strip' on the binaries") +ap.add_argument("-dmg", nargs="?", const="", metavar="basename", help="create a .dmg disk image") +ap.add_argument("-translations-dir", nargs=1, metavar="path", default=None, help="Path to Qt's translations. Base translations will automatically be added to the bundle's resources.") + +config = ap.parse_args() + +verbose = config.verbose + +# ------------------------------------------------ + +app_bundle = config.app_bundle[0] +appname = config.appname[0] + +if not os.path.exists(app_bundle): + sys.stderr.write(f"Error: Could not find app bundle \"{app_bundle}\"\n") + sys.exit(1) + +# ------------------------------------------------ + +if os.path.exists("dist"): + print("+ Removing existing dist folder +") + shutil.rmtree("dist") + +if os.path.exists(appname + ".dmg"): + print("+ Removing existing DMG +") + os.unlink(appname + ".dmg") + +if os.path.exists(appname + ".temp.dmg"): + os.unlink(appname + ".temp.dmg") + +# ------------------------------------------------ + +target = os.path.join("dist", "feather.app") + +print("+ Copying source bundle +") +if verbose: + print(app_bundle, "->", target) + +os.mkdir("dist") +shutil.copytree(app_bundle, target, symlinks=True) + +applicationBundle = ApplicationBundleInfo(target) + +# ------------------------------------------------ + +print("+ Deploying frameworks +") + +try: + deploymentInfo = deployFrameworksForAppBundle(applicationBundle, config.strip, verbose) + if deploymentInfo.qtPath is None: + deploymentInfo.qtPath = os.getenv("QTDIR", None) + if deploymentInfo.qtPath is None: + sys.stderr.write("Warning: Could not detect Qt's path, skipping plugin deployment!\n") + config.plugins = False +except RuntimeError as e: + sys.stderr.write(f"Error: {str(e)}\n") + sys.exit(1) + +# ------------------------------------------------ + +if config.plugins: + print("+ Deploying plugins +") + + try: + deployPlugins(applicationBundle, deploymentInfo, config.strip, verbose) + except RuntimeError as e: + sys.stderr.write(f"Error: {str(e)}\n") + sys.exit(1) + +# ------------------------------------------------ + +if config.translations_dir: + if not Path(config.translations_dir[0]).exists(): + sys.stderr.write(f"Error: Could not find translation dir \"{config.translations_dir[0]}\"\n") + sys.exit(1) + + print("+ Adding Qt translations +") + + translations = Path(config.translations_dir[0]) + + regex = re.compile('qt_[a-z]*(.qm|_[A-Z]*.qm)') + + lang_files = [x for x in translations.iterdir() if regex.match(x.name)] + + for file in lang_files: + if verbose: + print(file.as_posix(), "->", os.path.join(applicationBundle.resourcesPath, file.name)) + shutil.copy2(file.as_posix(), os.path.join(applicationBundle.resourcesPath, file.name)) + +# ------------------------------------------------ + +print("+ Installing qt.conf +") + +qt_conf="""[Paths] +Translations=Resources +Plugins=PlugIns +""" + +with open(os.path.join(applicationBundle.resourcesPath, "qt.conf"), "wb") as f: + f.write(qt_conf.encode()) + +# ------------------------------------------------ + +print("+ Generating .DS_Store +") + +output_file = os.path.join("dist", ".DS_Store") + +ds = DSStore.open(output_file, 'w+') + +ds['.']['bwsp'] = { + 'WindowBounds': '{{300, 280}, {500, 343}}', + 'PreviewPaneVisibility': False, +} + +icvp = { + 'gridOffsetX': 0.0, + 'textSize': 12.0, + 'viewOptionsVersion': 1, + 'backgroundImageAlias': b'\x00\x00\x00\x00\x02\x1e\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd1\x94\\\xb0H+\x00\x05\x00\x00\x00\x98\x0fbackground.tiff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x99\xd19\xb0\xf8\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\r\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b.background\x00\x00\x10\x00\x08\x00\x00\xd1\x94\\\xb0\x00\x00\x00\x11\x00\x08\x00\x00\xd19\xb0\xf8\x00\x00\x00\x01\x00\x04\x00\x00\x00\x98\x00\x0e\x00 \x00\x0f\x00b\x00a\x00c\x00k\x00g\x00r\x00o\x00u\x00n\x00d\x00.\x00t\x00i\x00f\x00f\x00\x0f\x00\x02\x00\x00\x00\x12\x00\x1c/.background/background.tiff\x00\x14\x01\x06\x00\x00\x00\x00\x01\x06\x00\x02\x00\x00\x0cMacintosh HD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xce\x97\xab\xc3H+\x00\x00\x01\x88[\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02u\xab\x8d\xd1\x94\\\xb0devrddsk\xff\xff\xff\xff\x00\x00\t \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07bitcoin\x00\x00\x10\x00\x08\x00\x00\xce\x97\xab\xc3\x00\x00\x00\x11\x00\x08\x00\x00\xd1\x94\\\xb0\x00\x00\x00\x01\x00\x14\x01\x88[\x88\x00\x16\xa9\t\x00\x08\xfaR\x00\x08\xfaQ\x00\x02d\x8e\x00\x0e\x00\x02\x00\x00\x00\x0f\x00\x1a\x00\x0c\x00M\x00a\x00c\x00i\x00n\x00t\x00o\x00s\x00h\x00 \x00H\x00D\x00\x13\x00\x01/\x00\x00\x15\x00\x02\x00\x14\xff\xff\x00\x00\xff\xff\x00\x00', + 'backgroundColorBlue': 1.0, + 'iconSize': 96.0, + 'backgroundColorGreen': 1.0, + 'arrangeBy': 'none', + 'showIconPreview': True, + 'gridSpacing': 100.0, + 'gridOffsetY': 0.0, + 'showItemInfo': False, + 'labelOnBottom': True, + 'backgroundType': 2, + 'backgroundColorRed': 1.0 +} +alias = Alias().from_bytes(icvp['backgroundImageAlias']) +alias.volume.name = appname +alias.volume.posix_path = '/Volumes/' + appname +icvp['backgroundImageAlias'] = alias.to_bytes() +ds['.']['icvp'] = icvp + +ds['.']['vSrn'] = ('long', 1) + +ds['Applications']['Iloc'] = (370, 156) +ds['feather.app']['Iloc'] = (128, 156) + +ds.flush() +ds.close() + +# ------------------------------------------------ + +if platform.system() == "Darwin": + subprocess.check_call(f"codesign --deep --force --sign - {target}", shell=True) + +print("+ Installing background.tiff +") + +bg_path = os.path.join('dist', '.background', 'background.tiff') +os.mkdir(os.path.dirname(bg_path)) + +tiff_path = os.path.join('contrib', 'macdeploy', 'background.tiff') +shutil.copy2(tiff_path, bg_path) + +# ------------------------------------------------ + +print("+ Generating symlink for /Applications +") + +os.symlink("/Applications", os.path.join('dist', "Applications")) + +# ------------------------------------------------ + +if config.dmg is not None: + + print("+ Preparing .dmg disk image +") + + if verbose: + print("Determining size of \"dist\"...") + size = 0 + for path, dirs, files in os.walk("dist"): + for file in files: + size += os.path.getsize(os.path.join(path, file)) + size += int(size * 0.15) + + if verbose: + print("Creating temp image for modification...") + + tempname: str = appname + ".temp.dmg" + + run(["hdiutil", "create", tempname, "-srcfolder", "dist", "-format", "UDRW", "-size", str(size), "-volname", appname], check=True, universal_newlines=True) + + if verbose: + print("Attaching temp image...") + output = run(["hdiutil", "attach", tempname, "-readwrite"], check=True, universal_newlines=True, stdout=PIPE).stdout + + print("+ Finalizing .dmg disk image +") + + run(["hdiutil", "detach", f"/Volumes/{appname}"], universal_newlines=True) + + run(["hdiutil", "convert", tempname, "-format", "UDZO", "-o", appname, "-imagekey", "zlib-level=9"], check=True, universal_newlines=True) + + os.unlink(tempname) + +# ------------------------------------------------ + +print("+ Done +") + +sys.exit(0) diff --git a/contrib/monero-seed/CMakeLists.txt b/contrib/monero-seed/CMakeLists.txt deleted file mode 100644 index 2028ceb..0000000 --- a/contrib/monero-seed/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2020, tevador - -cmake_minimum_required(VERSION 3.13) - -option(MONERO_SEED_DEMO "Build a demo executable for monero-seed") - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) - message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}") -endif() - -project(monero-seed) - -include(GNUInstallDirs) - -add_library(${PROJECT_NAME} -src/argon2/blake2/blake2b.c -src/argon2/argon2.c -src/argon2/core.c -src/argon2/ref.c -src/galois_field.cpp -src/gf_elem.cpp -src/gf_poly.cpp -src/monero_seed.cpp -src/pbkdf2.c -src/reed_solomon_code.cpp -src/secure_random.cpp -src/wordlist.cpp) - -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $) - -if(MONERO_SEED_DEMO) - add_executable(demo src/main.cpp) - set_property(TARGET demo PROPERTY CXX_STANDARD 11) - target_link_libraries(demo -Wl,--whole-archive ${PROJECT_NAME} -Wl,--no-whole-archive) -endif() - -install(TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(EXPORT ${PROJECT_NAME} - FILE ${PROJECT_NAME}Config.cmake - NAMESPACE ${PROJECT_NAME}:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) diff --git a/contrib/monero-seed/src/main.cpp b/contrib/monero-seed/src/main.cpp deleted file mode 100644 index 577b40c..0000000 --- a/contrib/monero-seed/src/main.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (c) 2020 tevador - All rights reserved. -*/ - -#include -#include -#include -#include -#include -#include - -static inline void read_string_option(const char* option, int argc, - const char** argv, const char** out, const char* def_val = nullptr) { - for (int i = 0; i < argc - 1; ++i) { - if (strcmp(argv[i], option) == 0) { - *out = argv[i + 1]; - return; - } - } - *out = def_val; -} - -static inline void read_option(const char* option, int argc, const char** argv, - bool& out) { - for (int i = 0; i < argc; ++i) { - if (strcmp(argv[i], option) == 0) { - out = true; - return; - } - } - out = false; -} - -static time_t parse_date(const char* s) { - std::istringstream iss(s); - char delimiter; - int day, month, year; - if (iss >> year >> delimiter >> month >> delimiter >> day) { - struct tm t = { 0 }; - t.tm_mday = day; - t.tm_mon = month - 1; - t.tm_year = year - 1900; - t.tm_isdst = -1; - - time_t dt = mktime(&t); - if (dt != -1) { - return dt; - } - } - throw std::runtime_error("invalid date"); -} - -void print_seed(const monero_seed& seed, const char* coin, bool phrase) { - if (!seed.correction().empty()) { - std::cout << "Warning: corrected erasure: " << monero_seed::erasure << " -> " << seed.correction() << std::endl; - } - if (phrase) { - std::cout << "Mnemonic phrase: " << seed << std::endl; - } - std::cout << "- coin: " << coin << std::endl; - std::cout << "- private key: " << seed.key() << std::endl; - auto created_on = seed.date(); - std::tm tm = *std::localtime(&created_on); - std::cout << "- created on or after: " << std::put_time(&tm, "%d/%b/%Y") << std::endl; -} - -int main(int argc, const char* argv[]) { - bool create; - const char* create_date; - const char* coin; - const char* restore; - read_option("--create", argc, argv, create); - read_string_option("--date", argc, argv, &create_date); - read_string_option("--coin", argc, argv, &coin, "monero"); - read_string_option("--restore", argc, argv, &restore); - - try { - if (create) { - time_t time; - if (create_date != nullptr) { - time = parse_date(create_date); - } - else { - time = std::time(nullptr); - } - monero_seed seed(time, coin); - print_seed(seed, coin, true); - } - else if (restore != nullptr) { - monero_seed seed(restore, coin); - print_seed(seed, coin, false); - } - else { - std::cout << "Monero 14-word mnemonic seed proof of concept" << std::endl; - std::cout << "Usage: " << std::endl; - std::cout << argv[0] << " --create [--date ] [--coin ]" << std::endl; - std::cout << argv[0] << " --restore \"<14-word seed>\" [--coin ]" << std::endl; - } - } - catch (const std::exception & ex) { - std::cout << "ERROR: " << ex.what() << std::endl; - return 1; - } - return 0; -} diff --git a/contrib/shell/git-utils.bash b/contrib/shell/git-utils.bash new file mode 100644 index 0000000..37bac1f --- /dev/null +++ b/contrib/shell/git-utils.bash @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +git_root() { + git rev-parse --show-toplevel 2> /dev/null +} + +git_head_version() { + local recent_tag + if recent_tag="$(git describe --exact-match HEAD 2> /dev/null)"; then + echo "${recent_tag#v}" + else + git rev-parse --short=12 HEAD + fi +} diff --git a/contrib/shell/realpath.bash b/contrib/shell/realpath.bash new file mode 100644 index 0000000..389b77b --- /dev/null +++ b/contrib/shell/realpath.bash @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# Based on realpath.sh written by Michael Kropat +# Found at: https://github.com/mkropat/sh-realpath/blob/65512368b8155b176b67122aa395ac580d9acc5b/realpath.sh + +bash_realpath() { + canonicalize_path "$(resolve_symlinks "$1")" +} + +resolve_symlinks() { + _resolve_symlinks "$1" +} + +_resolve_symlinks() { + _assert_no_path_cycles "$@" || return + + local dir_context path + if path=$(readlink -- "$1"); then + dir_context=$(dirname -- "$1") + _resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@" + else + printf '%s\n' "$1" + fi +} + +_prepend_dir_context_if_necessary() { + if [ "$1" = . ]; then + printf '%s\n' "$2" + else + _prepend_path_if_relative "$1" "$2" + fi +} + +_prepend_path_if_relative() { + case "$2" in + /* ) printf '%s\n' "$2" ;; + * ) printf '%s\n' "$1/$2" ;; + esac +} + +_assert_no_path_cycles() { + local target path + + target=$1 + shift + + for path in "$@"; do + if [ "$path" = "$target" ]; then + return 1 + fi + done +} + +canonicalize_path() { + if [ -d "$1" ]; then + _canonicalize_dir_path "$1" + else + _canonicalize_file_path "$1" + fi +} + +_canonicalize_dir_path() { + (cd "$1" 2>/dev/null && pwd -P) +} + +_canonicalize_file_path() { + local dir file + dir=$(dirname -- "$1") + file=$(basename -- "$1") + (cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file") +} diff --git a/monero b/monero index b45c66e..87340ca 160000 --- a/monero +++ b/monero @@ -1 +1 @@ -Subproject commit b45c66e9c62d7e8f24abbcb447f408e618bfd450 +Subproject commit 87340caaa64846bc5c8d52820722f3f94c74974c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 481874d..dac430d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) # pthread find_package(Threads REQUIRED) @@ -11,7 +11,6 @@ set(QT_COMPONENTS Gui Network Svg - Xml WebSockets ) @@ -33,6 +32,10 @@ add_subdirectory(openpgp) qt_add_resources(RESOURCES assets.qrc assets_tor.qrc) +if (DEPENDS) + find_library(ICONV_LIBRARIES iconv) +endif() + # Compile source files (.h/.cpp) file(GLOB SOURCE_FILES "*.h" @@ -66,19 +69,30 @@ file(GLOB SOURCE_FILES "polyseed/*.h" "polyseed/*.cpp" "polyseed/*.c" - "qrcode_scanner/QrCodeUtils.cpp" - "qrcode_scanner/QrCodeUtils.h" + "qrcode_utils/QrCodeUtils.cpp" + "qrcode_utils/QrCodeUtils.h" + "monero_seed/argon2/blake2/*.c" + "monero_seed/argon2/*.c" + "monero_seed/*.cpp" + "monero_seed/*.c" + "monero_seed/*.hpp" ) if (WITH_SCANNER AND NOT Qt6_FOUND) file(GLOB SCANNER_FILES "qrcode_scanner/*.h" "qrcode_scanner/*.cpp") - - list(APPEND SOURCE_FILES - ${SCANNER_FILES}) endif() +if (WITH_SCANNER AND Qt6_FOUND) + file(GLOB SCANNER_FILES + "qrcode_scanner_qt6/*.h" + "qrcode_scanner_qt6/*.cpp") +endif() + +list(APPEND SOURCE_FILES + ${SCANNER_FILES}) + set(EXECUTABLE_FLAG) if(MINGW) set(EXECUTABLE_FLAG WIN32) @@ -92,31 +106,17 @@ if(MINGW) list(APPEND RESOURCES ${ICON_RES}) endif() -# mac os bundle -if(APPLE) - set(ICON ${PROJECT_SOURCE_DIR}/src/assets/images/appicons/appicon.icns) - set_source_files_properties(${ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") - list(APPEND RESOURCES ${ICON}) -endif() - add_executable(feather ${EXECUTABLE_FLAG} main.cpp ${SOURCE_FILES} ${RESOURCES} ${ASSETS_TOR} ) -# mac os bundle set_target_properties(feather PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" - MACOSX_BUNDLE TRUE - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/utils/Info.plist" LINK_FLAGS_RELEASE -s ) -set_property(TARGET feather PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - -target_include_directories(feather PUBLIC ${QtGui_PRIVATE_INCLUDE_DIRS}) - target_include_directories(feather PUBLIC ${CMAKE_BINARY_DIR}/src/feather_autogen/include ${CMAKE_SOURCE_DIR}/monero/include @@ -125,12 +125,10 @@ target_include_directories(feather PUBLIC ${CMAKE_SOURCE_DIR}/monero/contrib/epee/include ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/daemon ${CMAKE_CURRENT_SOURCE_DIR}/libwalletqt ${CMAKE_CURRENT_SOURCE_DIR}/model ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_CURRENT_SOURCE_DIR}/qrcode - ${X11_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${QtCore_INCLUDE_DIRS} ${QtWidgets_INCLUDE_DIRS} @@ -140,11 +138,11 @@ target_include_directories(feather PUBLIC ${QtSvgWidgets_INCLUDE_DIRS} ${QtXml_INCLUDE_DIRS} ${QtWebSockets_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIRS} ${LIBZIP_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} ${ZBAR_INCLUDE_DIR} ${POLYSEED_INCLUDE_DIR} - ) +) if(WITH_SCANNER) target_include_directories(feather PUBLIC @@ -177,7 +175,7 @@ if(XMRIG) target_compile_definitions(feather PRIVATE HAS_XMRIG=1) endif() -if(WITH_SCANNER AND NOT Qt6_FOUND) +if(WITH_SCANNER) target_compile_definitions(feather PRIVATE WITH_SCANNER=1) endif() @@ -219,16 +217,6 @@ if (WITH_SCANNER) ) endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QtWidgets_EXECUTABLE_COMPILE_FLAGS}") - -if(UNIX AND NOT APPLE) - # https://stackoverflow.com/questions/57766620/cmake-add-library-doesnt-initialize-static-global-variable - # so that contrib/monero-seed/src/gf_elem.cpp properly initializes. A better solution is welcome. - target_link_libraries(feather -Wl,--whole-archive monero-seed -Wl,--no-whole-archive) -else() - target_link_libraries(feather monero-seed) -endif() - target_link_libraries(feather wallet_merged ${LMDB_LIBRARY} @@ -246,18 +234,21 @@ target_link_libraries(feather Qt::Gui Qt::Network Qt::Svg - Qt::Xml Qt::WebSockets - ${ICU_LIBRARIES} openpgp Threads::Threads ${QRENCODE_LIBRARY} - ${ZLIB_LIBRARIES} - ${LIBZIP_LIBRARIES} ${ZBAR_LIBRARIES} ${POLYSEED_LIBRARY} SingleApplication::SingleApplication - ) + ${ICU_LIBRARIES} + ${LIBZIP_LIBRARIES} + ${ZLIB_LIBRARIES} +) + +if(DEPENDS) + target_link_libraries(feather ${ICONV_LIBRARIES}) +endif() if(Qt6_FOUND) target_link_libraries(feather Qt::SvgWidgets) @@ -293,14 +284,6 @@ if(STATIC AND NOT Qt6_FOUND) endif() endif() -if(X11_FOUND) - target_link_libraries(feather ${X11_LIBRARIES}) -endif() - -if(APPLE) - include(Deploy) -endif() - install(TARGETS feather DESTINATION ${CMAKE_INSTALL_PREFIX} ) diff --git a/src/CalcWidget.cpp b/src/CalcWidget.cpp index 6e0bef7..dc6e7b1 100644 --- a/src/CalcWidget.cpp +++ b/src/CalcWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CalcWidget.h" #include "ui_CalcWidget.h" diff --git a/src/CalcWidget.h b/src/CalcWidget.h index 3c5da01..2f2fe4b 100644 --- a/src/CalcWidget.h +++ b/src/CalcWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CALCWIDGET_H #define FEATHER_CALCWIDGET_H diff --git a/src/CalcWindow.cpp b/src/CalcWindow.cpp index e736d65..a12376c 100644 --- a/src/CalcWindow.cpp +++ b/src/CalcWindow.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CalcWindow.h" #include "ui_CalcWindow.h" diff --git a/src/CalcWindow.h b/src/CalcWindow.h index 90cb3eb..5300be9 100644 --- a/src/CalcWindow.h +++ b/src/CalcWindow.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CALCWINDOW_H #define FEATHER_CALCWINDOW_H diff --git a/src/CoinsWidget.cpp b/src/CoinsWidget.cpp index 6b623a4..955e7c9 100644 --- a/src/CoinsWidget.cpp +++ b/src/CoinsWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CoinsWidget.h" #include "ui_CoinsWidget.h" diff --git a/src/CoinsWidget.h b/src/CoinsWidget.h index bb45e74..f598e98 100644 --- a/src/CoinsWidget.h +++ b/src/CoinsWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COINSWIDGET_H #define FEATHER_COINSWIDGET_H diff --git a/src/ContactsWidget.cpp b/src/ContactsWidget.cpp index a586c33..a438ed4 100644 --- a/src/ContactsWidget.cpp +++ b/src/ContactsWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ContactsWidget.h" #include "ui_ContactsWidget.h" diff --git a/src/ContactsWidget.h b/src/ContactsWidget.h index e9eee47..704a9ef 100644 --- a/src/ContactsWidget.h +++ b/src/ContactsWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CONTACTSWIDGET_H #define FEATHER_CONTACTSWIDGET_H diff --git a/src/HistoryWidget.cpp b/src/HistoryWidget.cpp index 91677c7..e272894 100644 --- a/src/HistoryWidget.cpp +++ b/src/HistoryWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "HistoryWidget.h" #include "ui_HistoryWidget.h" diff --git a/src/HistoryWidget.h b/src/HistoryWidget.h index ae3c964..6399dd9 100644 --- a/src/HistoryWidget.h +++ b/src/HistoryWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_HISTORYWIDGET_H #define FEATHER_HISTORYWIDGET_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c9276ee..3f64f94 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "MainWindow.h" #include "ui_MainWindow.h" @@ -46,6 +46,8 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa { ui->setupUi(this); + qDebug() << "Platform tag: " << this->getPlatformTag(); + // Ensure the destructor is called after closeEvent() setAttribute(Qt::WA_DeleteOnClose); @@ -1518,10 +1520,22 @@ QString MainWindow::getPlatformTag() { return "win"; #endif #ifdef Q_OS_LINUX - if (!qEnvironmentVariableIsEmpty("APPIMAGE")) { - return "linux-appimage"; + QString tag = ""; + + QString arch = QSysInfo::buildCpuArchitecture(); + if (arch == "arm64") { + tag += "linux-arm64"; + } else if (arch == "arm") { + tag += "linux-arm"; + } else { + tag += "linux"; } - return "linux"; + + if (!qEnvironmentVariableIsEmpty("APPIMAGE")) { + tag += "-appimage"; + } + + return tag; #endif return ""; } diff --git a/src/MainWindow.h b/src/MainWindow.h index 6e5b9c3..6079715 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_MAINWINDOW_H #define FEATHER_MAINWINDOW_H diff --git a/src/ReceiveWidget.cpp b/src/ReceiveWidget.cpp index 95ecd59..6d9a058 100644 --- a/src/ReceiveWidget.cpp +++ b/src/ReceiveWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ReceiveWidget.h" #include "ui_ReceiveWidget.h" diff --git a/src/ReceiveWidget.h b/src/ReceiveWidget.h index 9bd19e0..969863d 100644 --- a/src/ReceiveWidget.h +++ b/src/ReceiveWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_RECEIVEWIDGET_H #define FEATHER_RECEIVEWIDGET_H diff --git a/src/SendWidget.cpp b/src/SendWidget.cpp index a48c5d7..5fd063a 100644 --- a/src/SendWidget.cpp +++ b/src/SendWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SendWidget.h" #include "ui_SendWidget.h" @@ -11,9 +11,12 @@ #include "utils/AppData.h" #include "Icons.h" -#ifdef WITH_SCANNER +#if defined(WITH_SCANNER) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include "qrcode_scanner/QrCodeScanDialog.h" #include +#elif defined(WITH_SCANNER) +#include "qrcode_scanner_qt6/QrCodeScanDialog.h" +#include #endif SendWidget::SendWidget(QSharedPointer ctx, QWidget *parent) @@ -112,7 +115,7 @@ void SendWidget::fillAddress(const QString &address) { } void SendWidget::scanClicked() { -#ifdef WITH_SCANNER +#if defined(WITH_SCANNER) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) auto cameras = QCameraInfo::availableCameras(); if (cameras.count() < 1) { QMessageBox::warning(this, "QR code scanner", "No available cameras found."); @@ -123,6 +126,17 @@ void SendWidget::scanClicked() { dialog->exec(); ui->lineAddress->setText(dialog->decodedString); dialog->deleteLater(); +#elif defined(WITH_SCANNER) + auto cameras = QMediaDevices::videoInputs(); + if (cameras.empty()) { + QMessageBox::warning(this, "QR code scanner", "No available cameras found."); + return; + } + + auto dialog = new QrCodeScanDialog(this); + dialog->exec(); + ui->lineAddress->setText(dialog->decodedString); + dialog->deleteLater(); #else QMessageBox::warning(this, "QR scanner", "Feather was built without webcam QR scanner support."); #endif diff --git a/src/SendWidget.h b/src/SendWidget.h index bc9bc73..0df426e 100644 --- a/src/SendWidget.h +++ b/src/SendWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SENDWIDGET_H #define FEATHER_SENDWIDGET_H diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index de9bbe6..8621487 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SettingsDialog.h" #include "ui_SettingsDialog.h" diff --git a/src/SettingsDialog.h b/src/SettingsDialog.h index dacfe6e..9bae5d9 100644 --- a/src/SettingsDialog.h +++ b/src/SettingsDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SETTINGS_H #define FEATHER_SETTINGS_H diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index efba573..1a088a9 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WindowManager.h" diff --git a/src/WindowManager.h b/src/WindowManager.h index 3eca7f3..c73997e 100644 --- a/src/WindowManager.h +++ b/src/WindowManager.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WINDOWMANAGER_H #define FEATHER_WINDOWMANAGER_H diff --git a/src/api/LocalMoneroApi.cpp b/src/api/LocalMoneroApi.cpp index 52b3fc6..ad61b3b 100644 --- a/src/api/LocalMoneroApi.cpp +++ b/src/api/LocalMoneroApi.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "LocalMoneroApi.h" diff --git a/src/api/LocalMoneroApi.h b/src/api/LocalMoneroApi.h index a92aa7f..56a8bf0 100644 --- a/src/api/LocalMoneroApi.h +++ b/src/api/LocalMoneroApi.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_LOCALMONEROAPI_H #define FEATHER_LOCALMONEROAPI_H diff --git a/src/appcontext.cpp b/src/appcontext.cpp index 52a5694..5959556 100644 --- a/src/appcontext.cpp +++ b/src/appcontext.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include diff --git a/src/appcontext.h b/src/appcontext.h index db83198..81a612a 100644 --- a/src/appcontext.h +++ b/src/appcontext.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_APPCONTEXT_H #define FEATHER_APPCONTEXT_H diff --git a/src/cli.cpp b/src/cli.cpp deleted file mode 100644 index 0ca825c..0000000 --- a/src/cli.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project - -#include "cli.h" - -// libwalletqt -#include "libwalletqt/TransactionHistory.h" -#include "libwalletqt/WalletManager.h" -#include "model/AddressBookModel.h" -#include "model/TransactionHistoryModel.h" -#include "utils/brute.h" -#include "utils/Utils.h" -#include "constants.h" - -CLI::CLI(Mode mode, QCommandLineParser *cmdargs, QObject *parent) - : QObject(parent) - , m_mode(mode) - , m_cmdargs(cmdargs) -{ - m_walletManager = WalletManager::instance(); - connect(m_walletManager, &WalletManager::walletOpened, this, &CLI::onWalletOpened); - - if (m_mode == Mode::ExportContacts || m_mode == Mode::ExportTxHistory) - { - if (!cmdargs->isSet("wallet-file")) { - this->finished("--wallet-file argument missing"); - return; - } - if (!cmdargs->isSet("password")) { - this->finished("--password argument missing"); - return; - } - - QString walletFile = cmdargs->value("wallet-file"); - QString password = cmdargs->value("password"); - - - m_walletManager->openWalletAsync(walletFile, password, constants::networkType, constants::kdfRounds, Utils::ringDatabasePath()); - } - else if (mode == Mode::BruteforcePassword) - { - QString keys_file = m_cmdargs->value("bruteforce-password"); - if (!keys_file.endsWith(".keys")) { - this->finished("Wallet file does not end with .keys"); - return; - } - - QStringList words; - if (m_cmdargs->isSet("bruteforce-dict")) { - QString data = Utils::barrayToString(Utils::fileOpen(m_cmdargs->value("bruteforce-dict"))); - words = data.split("\n"); - } - - if (!m_cmdargs->isSet("bruteforce-chars")) { - this->finished("--bruteforce-chars argument missing"); - return; - } - QString chars = m_cmdargs->value("bruteforce-chars"); - - brute b(chars.toStdString()); - if (words.isEmpty()) { - qDebug() << "No dictionairy specified, bruteforcing all chars"; - while (true) { - QString pass = QString::fromStdString(b.next()); - if (m_walletManager->verifyWalletPassword(keys_file, pass, false)) { - this->finished(QString("Found password: %1").arg(pass)); - break; - } - qDebug() << pass; - } - } - else { - bruteword bb(chars.toStdString()); - bool foundPass = false; - for (const auto& word: words) { - if (word.isEmpty()) { - continue; - } - bb.setWord(word.toStdString()); - - while (true) { - QString pass = QString::fromStdString(bb.next()); - if (pass == "") { - break; - } - if (m_walletManager->verifyWalletPassword(keys_file, pass, false)) { - this->finished(QString("Found password: %1").arg(pass)); - foundPass = true; - break; - } - qDebug() << pass; - } - if (foundPass) { - break; - } - } - - if (!foundPass) { - this->finished("Search space exhausted"); - } - } - } - else { - this->finished("Invalid mode"); - } -} - -void CLI::onWalletOpened(Wallet *w) { - QScopedPointer wallet{w}; - - if (wallet->status() != Wallet::Status_Ok) { - this->finished(wallet->errorString()); - return; - } - - if (m_mode == Mode::ExportContacts) { - auto *model = wallet->addressBookModel(); - QString fileName = m_cmdargs->value("export-contacts"); - if (model->writeCSV(fileName)) - this->finished(QString("Contacts exported to %1").arg(fileName)); - else - this->finished("Failed to export contacts"); - } - else if (m_mode == Mode::ExportTxHistory) { - wallet->history()->refresh(wallet->currentSubaddressAccount()); - auto *model = wallet->history(); - QString fileName = m_cmdargs->value("export-txhistory"); - if (model->writeCSV(fileName)) - this->finished(QString("Transaction history exported to %1").arg(fileName)); - else - this->finished("Failed to export transaction history"); - } -} - -void CLI::finished(const QString &message) { - qInfo() << message; - QApplication::quit(); -} diff --git a/src/cli.h b/src/cli.h deleted file mode 100644 index 4b4c957..0000000 --- a/src/cli.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project - -#ifndef FEATHER_CLI_H -#define FEATHER_CLI_H - -#include -#include "appcontext.h" - -class CLI : public QObject -{ - Q_OBJECT - -public: - enum Mode { - Invalid, - ExportContacts, - ExportTxHistory, - BruteforcePassword - }; - - explicit CLI(Mode mode, QCommandLineParser *cmdargs, QObject *parent = nullptr); - -private slots: - void onWalletOpened(Wallet *wallet); - -private: - void finished(const QString &message); - - Mode m_mode; - QCommandLineParser *m_cmdargs; - WalletManager *m_walletManager; -}; - -#endif //FEATHER_CLI_H diff --git a/src/components.cpp b/src/components.cpp index 87a7eab..acba61a 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "components.h" diff --git a/src/components.h b/src/components.h index 938a006..26b66df 100644 --- a/src/components.h +++ b/src/components.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COMPONENTS_H #define FEATHER_COMPONENTS_H diff --git a/src/constants.cpp b/src/constants.cpp index b9b10dd..86ed214 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "constants.h" diff --git a/src/constants.h b/src/constants.h index 140166d..a01cc0c 100644 --- a/src/constants.h +++ b/src/constants.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CONSTANTS_H #define FEATHER_CONSTANTS_H diff --git a/src/dialog/AboutDialog.cpp b/src/dialog/AboutDialog.cpp index 14bca8b..bda3821 100644 --- a/src/dialog/AboutDialog.cpp +++ b/src/dialog/AboutDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "AboutDialog.h" #include "ui_AboutDialog.h" diff --git a/src/dialog/AboutDialog.h b/src/dialog/AboutDialog.h index aeeb77e..6a98db9 100644 --- a/src/dialog/AboutDialog.h +++ b/src/dialog/AboutDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_ABOUT_H #define FEATHER_ABOUT_H diff --git a/src/dialog/AccountSwitcherDialog.cpp b/src/dialog/AccountSwitcherDialog.cpp index 62780d0..76a48aa 100644 --- a/src/dialog/AccountSwitcherDialog.cpp +++ b/src/dialog/AccountSwitcherDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "AccountSwitcherDialog.h" #include "ui_AccountSwitcherDialog.h" diff --git a/src/dialog/AccountSwitcherDialog.h b/src/dialog/AccountSwitcherDialog.h index 6c9ada3..5fea3de 100644 --- a/src/dialog/AccountSwitcherDialog.h +++ b/src/dialog/AccountSwitcherDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_ACCOUNTSWITCHERDIALOG_H #define FEATHER_ACCOUNTSWITCHERDIALOG_H diff --git a/src/dialog/BalanceDialog.cpp b/src/dialog/BalanceDialog.cpp index c64d22a..0647530 100644 --- a/src/dialog/BalanceDialog.cpp +++ b/src/dialog/BalanceDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "BalanceDialog.h" #include "ui_BalanceDialog.h" diff --git a/src/dialog/BalanceDialog.h b/src/dialog/BalanceDialog.h index 9ee31ec..4c7e36c 100644 --- a/src/dialog/BalanceDialog.h +++ b/src/dialog/BalanceDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_BALANCEDIALOG_H #define FEATHER_BALANCEDIALOG_H diff --git a/src/dialog/CalcConfigDialog.cpp b/src/dialog/CalcConfigDialog.cpp index 74516ec..ec39964 100644 --- a/src/dialog/CalcConfigDialog.cpp +++ b/src/dialog/CalcConfigDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CalcConfigDialog.h" #include "ui_CalcConfigDialog.h" diff --git a/src/dialog/CalcConfigDialog.h b/src/dialog/CalcConfigDialog.h index 1664a10..f609572 100644 --- a/src/dialog/CalcConfigDialog.h +++ b/src/dialog/CalcConfigDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CALCCONFIGDIALOG_H #define FEATHER_CALCCONFIGDIALOG_H diff --git a/src/dialog/ContactsDialog.cpp b/src/dialog/ContactsDialog.cpp index 25adf09..5d39599 100644 --- a/src/dialog/ContactsDialog.cpp +++ b/src/dialog/ContactsDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ui_ContactsDialog.h" #include "ContactsDialog.h" diff --git a/src/dialog/ContactsDialog.h b/src/dialog/ContactsDialog.h index 38bb33c..e888cea 100644 --- a/src/dialog/ContactsDialog.h +++ b/src/dialog/ContactsDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CONTACTSDIALOG_H #define FEATHER_CONTACTSDIALOG_H diff --git a/src/dialog/DebugInfoDialog.cpp b/src/dialog/DebugInfoDialog.cpp index 58b7468..5ad6b75 100644 --- a/src/dialog/DebugInfoDialog.cpp +++ b/src/dialog/DebugInfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "DebugInfoDialog.h" #include "ui_DebugInfoDialog.h" diff --git a/src/dialog/DebugInfoDialog.h b/src/dialog/DebugInfoDialog.h index 37f295b..baf2745 100644 --- a/src/dialog/DebugInfoDialog.h +++ b/src/dialog/DebugInfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_DEBUGINFODIALOG_H #define FEATHER_DEBUGINFODIALOG_H diff --git a/src/dialog/InfoDialog.cpp b/src/dialog/InfoDialog.cpp index 0acacc6..f95fa77 100644 --- a/src/dialog/InfoDialog.cpp +++ b/src/dialog/InfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "InfoDialog.h" #include "ui_InfoDialog.h" diff --git a/src/dialog/InfoDialog.h b/src/dialog/InfoDialog.h index b7be614..a4475b9 100644 --- a/src/dialog/InfoDialog.h +++ b/src/dialog/InfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_INFODIALOG_H #define FEATHER_INFODIALOG_H diff --git a/src/dialog/KeysDialog.cpp b/src/dialog/KeysDialog.cpp index dfb45a1..149dc76 100644 --- a/src/dialog/KeysDialog.cpp +++ b/src/dialog/KeysDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "KeysDialog.h" #include "ui_KeysDialog.h" diff --git a/src/dialog/KeysDialog.h b/src/dialog/KeysDialog.h index a8a358a..1a92eaf 100644 --- a/src/dialog/KeysDialog.h +++ b/src/dialog/KeysDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_KEYSDIALOG_H #define FEATHER_KEYSDIALOG_H diff --git a/src/dialog/LocalMoneroInfoDialog.cpp b/src/dialog/LocalMoneroInfoDialog.cpp index 1871ab0..e0cc299 100644 --- a/src/dialog/LocalMoneroInfoDialog.cpp +++ b/src/dialog/LocalMoneroInfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "LocalMoneroInfoDialog.h" #include "ui_LocalMoneroInfoDialog.h" diff --git a/src/dialog/LocalMoneroInfoDialog.h b/src/dialog/LocalMoneroInfoDialog.h index 7fa863c..fa01844 100644 --- a/src/dialog/LocalMoneroInfoDialog.h +++ b/src/dialog/LocalMoneroInfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_LOCALMONEROINFODIALOG_H #define FEATHER_LOCALMONEROINFODIALOG_H diff --git a/src/dialog/OutputInfoDialog.cpp b/src/dialog/OutputInfoDialog.cpp index 0c90178..2a139d7 100644 --- a/src/dialog/OutputInfoDialog.cpp +++ b/src/dialog/OutputInfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "OutputInfoDialog.h" #include "ui_OutputInfoDialog.h" diff --git a/src/dialog/OutputInfoDialog.h b/src/dialog/OutputInfoDialog.h index af44f7a..729d5d0 100644 --- a/src/dialog/OutputInfoDialog.h +++ b/src/dialog/OutputInfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_OUTPUTINFODIALOG_H #define FEATHER_OUTPUTINFODIALOG_H diff --git a/src/dialog/OutputSweepDialog.cpp b/src/dialog/OutputSweepDialog.cpp index 5ecfd4d..538f24a 100644 --- a/src/dialog/OutputSweepDialog.cpp +++ b/src/dialog/OutputSweepDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "OutputSweepDialog.h" #include "ui_OutputSweepDialog.h" diff --git a/src/dialog/OutputSweepDialog.h b/src/dialog/OutputSweepDialog.h index f3287aa..7907b2c 100644 --- a/src/dialog/OutputSweepDialog.h +++ b/src/dialog/OutputSweepDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_OUTPUTSWEEPDIALOG_H #define FEATHER_OUTPUTSWEEPDIALOG_H diff --git a/src/dialog/PasswordChangeDialog.cpp b/src/dialog/PasswordChangeDialog.cpp index 984f067..f7c9920 100644 --- a/src/dialog/PasswordChangeDialog.cpp +++ b/src/dialog/PasswordChangeDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PasswordChangeDialog.h" #include "ui_PasswordChangeDialog.h" diff --git a/src/dialog/PasswordChangeDialog.h b/src/dialog/PasswordChangeDialog.h index 9a28fc5..26397b3 100644 --- a/src/dialog/PasswordChangeDialog.h +++ b/src/dialog/PasswordChangeDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PASSWORDCHANGEDIALOG_H #define FEATHER_PASSWORDCHANGEDIALOG_H diff --git a/src/dialog/PasswordDialog.cpp b/src/dialog/PasswordDialog.cpp index 42417f1..4398720 100644 --- a/src/dialog/PasswordDialog.cpp +++ b/src/dialog/PasswordDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PasswordDialog.h" #include "ui_PasswordDialog.h" diff --git a/src/dialog/PasswordDialog.h b/src/dialog/PasswordDialog.h index 73fc746..565c87d 100644 --- a/src/dialog/PasswordDialog.h +++ b/src/dialog/PasswordDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PASSWORDDIALOG_H #define FEATHER_PASSWORDDIALOG_H diff --git a/src/dialog/PaymentRequestDialog.cpp b/src/dialog/PaymentRequestDialog.cpp index 6eeb3b0..6457676 100644 --- a/src/dialog/PaymentRequestDialog.cpp +++ b/src/dialog/PaymentRequestDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PaymentRequestDialog.h" #include "ui_PaymentRequestDialog.h" diff --git a/src/dialog/PaymentRequestDialog.h b/src/dialog/PaymentRequestDialog.h index 7298102..f60c811 100644 --- a/src/dialog/PaymentRequestDialog.h +++ b/src/dialog/PaymentRequestDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PAYMENTREQUESTDIALOG_H #define FEATHER_PAYMENTREQUESTDIALOG_H diff --git a/src/dialog/QrCodeDialog.cpp b/src/dialog/QrCodeDialog.cpp index 1842b3f..6950aab 100644 --- a/src/dialog/QrCodeDialog.cpp +++ b/src/dialog/QrCodeDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "QrCodeDialog.h" #include "ui_QrCodeDialog.h" diff --git a/src/dialog/QrCodeDialog.h b/src/dialog/QrCodeDialog.h index 77429bb..87adce9 100644 --- a/src/dialog/QrCodeDialog.h +++ b/src/dialog/QrCodeDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_QRCODEDIALOG_H #define FEATHER_QRCODEDIALOG_H diff --git a/src/dialog/SeedDialog.cpp b/src/dialog/SeedDialog.cpp index 892c8ed..60fc0ba 100644 --- a/src/dialog/SeedDialog.cpp +++ b/src/dialog/SeedDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SeedDialog.h" #include "ui_SeedDialog.h" diff --git a/src/dialog/SeedDialog.h b/src/dialog/SeedDialog.h index c292f7f..e2bdc2a 100644 --- a/src/dialog/SeedDialog.h +++ b/src/dialog/SeedDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SEEDDIALOG_H #define FEATHER_SEEDDIALOG_H diff --git a/src/dialog/SignVerifyDialog.cpp b/src/dialog/SignVerifyDialog.cpp index 2ca8fce..98d600d 100644 --- a/src/dialog/SignVerifyDialog.cpp +++ b/src/dialog/SignVerifyDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SignVerifyDialog.h" #include "ui_SignVerifyDialog.h" diff --git a/src/dialog/SignVerifyDialog.h b/src/dialog/SignVerifyDialog.h index f9c633b..b994f1e 100644 --- a/src/dialog/SignVerifyDialog.h +++ b/src/dialog/SignVerifyDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SIGNVERIFYDIALOG_H #define FEATHER_SIGNVERIFYDIALOG_H diff --git a/src/dialog/SplashDialog.cpp b/src/dialog/SplashDialog.cpp index 90bdcb0..7759e71 100644 --- a/src/dialog/SplashDialog.cpp +++ b/src/dialog/SplashDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SplashDialog.h" #include "ui_SplashDialog.h" diff --git a/src/dialog/SplashDialog.h b/src/dialog/SplashDialog.h index c37adef..f089e5b 100644 --- a/src/dialog/SplashDialog.h +++ b/src/dialog/SplashDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SPLASHDIALOG_H #define FEATHER_SPLASHDIALOG_H diff --git a/src/dialog/TorInfoDialog.cpp b/src/dialog/TorInfoDialog.cpp index 1e24f6b..1f26233 100644 --- a/src/dialog/TorInfoDialog.cpp +++ b/src/dialog/TorInfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TorInfoDialog.h" #include "ui_TorInfoDialog.h" diff --git a/src/dialog/TorInfoDialog.h b/src/dialog/TorInfoDialog.h index 05870fc..617ba3d 100644 --- a/src/dialog/TorInfoDialog.h +++ b/src/dialog/TorInfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TORINFODIALOG_H #define FEATHER_TORINFODIALOG_H diff --git a/src/dialog/TxBroadcastDialog.cpp b/src/dialog/TxBroadcastDialog.cpp index 6028e87..6f530d6 100644 --- a/src/dialog/TxBroadcastDialog.cpp +++ b/src/dialog/TxBroadcastDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxBroadcastDialog.h" #include "ui_TxBroadcastDialog.h" diff --git a/src/dialog/TxBroadcastDialog.h b/src/dialog/TxBroadcastDialog.h index 5d2ea64..4d82632 100644 --- a/src/dialog/TxBroadcastDialog.h +++ b/src/dialog/TxBroadcastDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXBROADCASTDIALOG_H #define FEATHER_TXBROADCASTDIALOG_H diff --git a/src/dialog/TxConfAdvDialog.cpp b/src/dialog/TxConfAdvDialog.cpp index 82daaac..4c3fb9b 100644 --- a/src/dialog/TxConfAdvDialog.cpp +++ b/src/dialog/TxConfAdvDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxConfAdvDialog.h" #include "ui_TxConfAdvDialog.h" diff --git a/src/dialog/TxConfAdvDialog.h b/src/dialog/TxConfAdvDialog.h index 1973b8f..803fba9 100644 --- a/src/dialog/TxConfAdvDialog.h +++ b/src/dialog/TxConfAdvDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXCONFADVDIALOG_H #define FEATHER_TXCONFADVDIALOG_H diff --git a/src/dialog/TxConfDialog.cpp b/src/dialog/TxConfDialog.cpp index c9cb1a9..1b345d4 100644 --- a/src/dialog/TxConfDialog.cpp +++ b/src/dialog/TxConfDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxConfDialog.h" #include "ui_TxConfDialog.h" diff --git a/src/dialog/TxConfDialog.h b/src/dialog/TxConfDialog.h index b5e8274..7e148f9 100644 --- a/src/dialog/TxConfDialog.h +++ b/src/dialog/TxConfDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXCONFDIALOG_H #define FEATHER_TXCONFDIALOG_H diff --git a/src/dialog/TxImportDialog.cpp b/src/dialog/TxImportDialog.cpp index 1ffdd92..f6a8217 100644 --- a/src/dialog/TxImportDialog.cpp +++ b/src/dialog/TxImportDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxImportDialog.h" #include "ui_TxImportDialog.h" diff --git a/src/dialog/TxImportDialog.h b/src/dialog/TxImportDialog.h index ad1af0a..6373328 100644 --- a/src/dialog/TxImportDialog.h +++ b/src/dialog/TxImportDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXIMPORTDIALOG_H #define FEATHER_TXIMPORTDIALOG_H diff --git a/src/dialog/TxInfoDialog.cpp b/src/dialog/TxInfoDialog.cpp index 83315f7..8c8b5ab 100644 --- a/src/dialog/TxInfoDialog.cpp +++ b/src/dialog/TxInfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxInfoDialog.h" #include "ui_TxInfoDialog.h" diff --git a/src/dialog/TxInfoDialog.h b/src/dialog/TxInfoDialog.h index e00381f..2f1cc79 100644 --- a/src/dialog/TxInfoDialog.h +++ b/src/dialog/TxInfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXINFODIALOG_H #define FEATHER_TXINFODIALOG_H diff --git a/src/dialog/TxProofDialog.cpp b/src/dialog/TxProofDialog.cpp index 6685aa2..e2dd843 100644 --- a/src/dialog/TxProofDialog.cpp +++ b/src/dialog/TxProofDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxProofDialog.h" #include "ui_TxProofDialog.h" diff --git a/src/dialog/TxProofDialog.h b/src/dialog/TxProofDialog.h index 4f2d9fa..cb69719 100644 --- a/src/dialog/TxProofDialog.h +++ b/src/dialog/TxProofDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXPROOFDIALOG_H #define FEATHER_TXPROOFDIALOG_H diff --git a/src/dialog/UpdateDialog.cpp b/src/dialog/UpdateDialog.cpp index 57cb9ec..1af5841 100644 --- a/src/dialog/UpdateDialog.cpp +++ b/src/dialog/UpdateDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "UpdateDialog.h" #include "ui_UpdateDialog.h" diff --git a/src/dialog/UpdateDialog.h b/src/dialog/UpdateDialog.h index 6738a24..a6641ac 100644 --- a/src/dialog/UpdateDialog.h +++ b/src/dialog/UpdateDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_UPDATEDIALOG_H #define FEATHER_UPDATEDIALOG_H diff --git a/src/dialog/VerifyProofDialog.cpp b/src/dialog/VerifyProofDialog.cpp index eacb72f..f28f86b 100644 --- a/src/dialog/VerifyProofDialog.cpp +++ b/src/dialog/VerifyProofDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "VerifyProofDialog.h" #include "ui_VerifyProofDialog.h" diff --git a/src/dialog/VerifyProofDialog.h b/src/dialog/VerifyProofDialog.h index 2cccf5c..3703bda 100644 --- a/src/dialog/VerifyProofDialog.h +++ b/src/dialog/VerifyProofDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_VERIFYPROOFDIALOG_H #define FEATHER_VERIFYPROOFDIALOG_H diff --git a/src/dialog/ViewOnlyDialog.cpp b/src/dialog/ViewOnlyDialog.cpp index 0b58009..f8f7429 100644 --- a/src/dialog/ViewOnlyDialog.cpp +++ b/src/dialog/ViewOnlyDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ViewOnlyDialog.h" #include "ui_ViewOnlyDialog.h" diff --git a/src/dialog/ViewOnlyDialog.h b/src/dialog/ViewOnlyDialog.h index e84a21f..940e3ae 100644 --- a/src/dialog/ViewOnlyDialog.h +++ b/src/dialog/ViewOnlyDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_VIEWONLYDIALOG_H #define FEATHER_VIEWONLYDIALOG_H diff --git a/src/dialog/WalletCacheDebugDialog.cpp b/src/dialog/WalletCacheDebugDialog.cpp index 0f6ee6a..d245ea0 100644 --- a/src/dialog/WalletCacheDebugDialog.cpp +++ b/src/dialog/WalletCacheDebugDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletCacheDebugDialog.h" #include "ui_WalletCacheDebugDialog.h" diff --git a/src/dialog/WalletCacheDebugDialog.h b/src/dialog/WalletCacheDebugDialog.h index c175ade..bee1510 100644 --- a/src/dialog/WalletCacheDebugDialog.h +++ b/src/dialog/WalletCacheDebugDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WALLETCACHEDEBUGDIALOG_H #define FEATHER_WALLETCACHEDEBUGDIALOG_H diff --git a/src/dialog/WalletInfoDialog.cpp b/src/dialog/WalletInfoDialog.cpp index 3724b61..1f7339d 100644 --- a/src/dialog/WalletInfoDialog.cpp +++ b/src/dialog/WalletInfoDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletInfoDialog.h" #include "ui_WalletInfoDialog.h" diff --git a/src/dialog/WalletInfoDialog.h b/src/dialog/WalletInfoDialog.h index 53bee79..b25af70 100644 --- a/src/dialog/WalletInfoDialog.h +++ b/src/dialog/WalletInfoDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WALLETINFODIALOG_H #define FEATHER_WALLETINFODIALOG_H diff --git a/src/libwalletqt/AddressBook.cpp b/src/libwalletqt/AddressBook.cpp index 52e2b6e..d423045 100644 --- a/src/libwalletqt/AddressBook.cpp +++ b/src/libwalletqt/AddressBook.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "AddressBook.h" #include diff --git a/src/libwalletqt/AddressBook.h b/src/libwalletqt/AddressBook.h index 539f64b..2b7fd30 100644 --- a/src/libwalletqt/AddressBook.h +++ b/src/libwalletqt/AddressBook.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef ADDRESSBOOK_H #define ADDRESSBOOK_H diff --git a/src/libwalletqt/AddressBookInfo.cpp b/src/libwalletqt/AddressBookInfo.cpp index 436f0bf..b2e4ee7 100644 --- a/src/libwalletqt/AddressBookInfo.cpp +++ b/src/libwalletqt/AddressBookInfo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "AddressBookInfo.h" diff --git a/src/libwalletqt/AddressBookInfo.h b/src/libwalletqt/AddressBookInfo.h index 1dfec73..cd653bf 100644 --- a/src/libwalletqt/AddressBookInfo.h +++ b/src/libwalletqt/AddressBookInfo.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_ADDRESSBOOKINFO_H #define FEATHER_ADDRESSBOOKINFO_H diff --git a/src/libwalletqt/Coins.cpp b/src/libwalletqt/Coins.cpp index 66f5206..fb60966 100644 --- a/src/libwalletqt/Coins.cpp +++ b/src/libwalletqt/Coins.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "Coins.h" diff --git a/src/libwalletqt/Coins.h b/src/libwalletqt/Coins.h index 3af24cf..4ab9688 100644 --- a/src/libwalletqt/Coins.h +++ b/src/libwalletqt/Coins.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COINS_H #define FEATHER_COINS_H diff --git a/src/libwalletqt/CoinsInfo.cpp b/src/libwalletqt/CoinsInfo.cpp index f107cbf..925d6c6 100644 --- a/src/libwalletqt/CoinsInfo.cpp +++ b/src/libwalletqt/CoinsInfo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CoinsInfo.h" #include "libwalletqt/WalletManager.h" diff --git a/src/libwalletqt/CoinsInfo.h b/src/libwalletqt/CoinsInfo.h index 9410abb..42c39db 100644 --- a/src/libwalletqt/CoinsInfo.h +++ b/src/libwalletqt/CoinsInfo.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COINSINFO_H #define FEATHER_COINSINFO_H diff --git a/src/libwalletqt/ConstructionInfo.cpp b/src/libwalletqt/ConstructionInfo.cpp index bd63fc4..75eee7d 100644 --- a/src/libwalletqt/ConstructionInfo.cpp +++ b/src/libwalletqt/ConstructionInfo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ConstructionInfo.h" diff --git a/src/libwalletqt/ConstructionInfo.h b/src/libwalletqt/ConstructionInfo.h index a86485d..ccc36d2 100644 --- a/src/libwalletqt/ConstructionInfo.h +++ b/src/libwalletqt/ConstructionInfo.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CONSTRUCTIONINFO_H #define FEATHER_CONSTRUCTIONINFO_H diff --git a/src/libwalletqt/Input.h b/src/libwalletqt/Input.h index 7961970..774d4b0 100644 --- a/src/libwalletqt/Input.h +++ b/src/libwalletqt/Input.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_INPUT_H #define FEATHER_INPUT_H diff --git a/src/libwalletqt/PassphraseHelper.cpp b/src/libwalletqt/PassphraseHelper.cpp index a262d1a..c6798a7 100644 --- a/src/libwalletqt/PassphraseHelper.cpp +++ b/src/libwalletqt/PassphraseHelper.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PassphraseHelper.h" #include diff --git a/src/libwalletqt/PassphraseHelper.h b/src/libwalletqt/PassphraseHelper.h index 3d02f87..dba5d40 100644 --- a/src/libwalletqt/PassphraseHelper.h +++ b/src/libwalletqt/PassphraseHelper.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef MONERO_GUI_PASSPHRASEHELPER_H #define MONERO_GUI_PASSPHRASEHELPER_H diff --git a/src/libwalletqt/PendingTransaction.cpp b/src/libwalletqt/PendingTransaction.cpp index 6725b16..0e07144 100644 --- a/src/libwalletqt/PendingTransaction.cpp +++ b/src/libwalletqt/PendingTransaction.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PendingTransaction.h" diff --git a/src/libwalletqt/PendingTransaction.h b/src/libwalletqt/PendingTransaction.h index 202b3a4..87fff2c 100644 --- a/src/libwalletqt/PendingTransaction.h +++ b/src/libwalletqt/PendingTransaction.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef PENDINGTRANSACTION_H #define PENDINGTRANSACTION_H diff --git a/src/libwalletqt/PendingTransactionInfo.cpp b/src/libwalletqt/PendingTransactionInfo.cpp index 7e9f996..945ea99 100644 --- a/src/libwalletqt/PendingTransactionInfo.cpp +++ b/src/libwalletqt/PendingTransactionInfo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PendingTransactionInfo.h" diff --git a/src/libwalletqt/PendingTransactionInfo.h b/src/libwalletqt/PendingTransactionInfo.h index 28ec382..cf1cf02 100644 --- a/src/libwalletqt/PendingTransactionInfo.h +++ b/src/libwalletqt/PendingTransactionInfo.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PENDINGTRANSACTIONINFO_H #define FEATHER_PENDINGTRANSACTIONINFO_H diff --git a/src/libwalletqt/Ring.h b/src/libwalletqt/Ring.h index 7063434..ceb2714 100644 --- a/src/libwalletqt/Ring.h +++ b/src/libwalletqt/Ring.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_RINGS_H #define FEATHER_RINGS_H diff --git a/src/libwalletqt/Subaddress.cpp b/src/libwalletqt/Subaddress.cpp index 4b635b0..d8e6378 100644 --- a/src/libwalletqt/Subaddress.cpp +++ b/src/libwalletqt/Subaddress.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "Subaddress.h" #include diff --git a/src/libwalletqt/Subaddress.h b/src/libwalletqt/Subaddress.h index a27e435..3f2cd1c 100644 --- a/src/libwalletqt/Subaddress.h +++ b/src/libwalletqt/Subaddress.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef SUBADDRESS_H #define SUBADDRESS_H diff --git a/src/libwalletqt/SubaddressAccount.cpp b/src/libwalletqt/SubaddressAccount.cpp index 0232646..60f6fd0 100644 --- a/src/libwalletqt/SubaddressAccount.cpp +++ b/src/libwalletqt/SubaddressAccount.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SubaddressAccount.h" #include diff --git a/src/libwalletqt/SubaddressAccount.h b/src/libwalletqt/SubaddressAccount.h index 7ab8cc3..fd3add9 100644 --- a/src/libwalletqt/SubaddressAccount.h +++ b/src/libwalletqt/SubaddressAccount.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef SUBADDRESSACCOUNT_H #define SUBADDRESSACCOUNT_H diff --git a/src/libwalletqt/TransactionHistory.cpp b/src/libwalletqt/TransactionHistory.cpp index b6aacc2..31a63db 100644 --- a/src/libwalletqt/TransactionHistory.cpp +++ b/src/libwalletqt/TransactionHistory.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TransactionHistory.h" #include "TransactionInfo.h" diff --git a/src/libwalletqt/TransactionHistory.h b/src/libwalletqt/TransactionHistory.h index fce1308..1ee3c14 100644 --- a/src/libwalletqt/TransactionHistory.h +++ b/src/libwalletqt/TransactionHistory.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef TRANSACTIONHISTORY_H #define TRANSACTIONHISTORY_H diff --git a/src/libwalletqt/TransactionInfo.cpp b/src/libwalletqt/TransactionInfo.cpp index ac23003..fe78e91 100644 --- a/src/libwalletqt/TransactionInfo.cpp +++ b/src/libwalletqt/TransactionInfo.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TransactionInfo.h" #include "libwalletqt/WalletManager.h" diff --git a/src/libwalletqt/TransactionInfo.h b/src/libwalletqt/TransactionInfo.h index 0b2fabc..9e496c4 100644 --- a/src/libwalletqt/TransactionInfo.h +++ b/src/libwalletqt/TransactionInfo.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef TRANSACTIONINFO_H #define TRANSACTIONINFO_H diff --git a/src/libwalletqt/Transfer.h b/src/libwalletqt/Transfer.h index 65fe73c..f3d961b 100644 --- a/src/libwalletqt/Transfer.h +++ b/src/libwalletqt/Transfer.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef TRANSFER_H #define TRANSFER_H diff --git a/src/libwalletqt/UnsignedTransaction.cpp b/src/libwalletqt/UnsignedTransaction.cpp index 4de81c9..14effc6 100644 --- a/src/libwalletqt/UnsignedTransaction.cpp +++ b/src/libwalletqt/UnsignedTransaction.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "UnsignedTransaction.h" #include diff --git a/src/libwalletqt/UnsignedTransaction.h b/src/libwalletqt/UnsignedTransaction.h index 8e5f95c..b79076f 100644 --- a/src/libwalletqt/UnsignedTransaction.h +++ b/src/libwalletqt/UnsignedTransaction.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef UNSIGNEDTRANSACTION_H #define UNSIGNEDTRANSACTION_H diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 4d398f5..7b4402d 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "Wallet.h" diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index 9129f12..3626082 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef WALLET_H #define WALLET_H diff --git a/src/libwalletqt/WalletListenerImpl.cpp b/src/libwalletqt/WalletListenerImpl.cpp index 34fe9f6..c1ec41f 100644 --- a/src/libwalletqt/WalletListenerImpl.cpp +++ b/src/libwalletqt/WalletListenerImpl.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletListenerImpl.h" #include "Wallet.h" diff --git a/src/libwalletqt/WalletListenerImpl.h b/src/libwalletqt/WalletListenerImpl.h index 1e386dc..e18a466 100644 --- a/src/libwalletqt/WalletListenerImpl.h +++ b/src/libwalletqt/WalletListenerImpl.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef MONERO_GUI_WALLETLISTENERIMPL_H #define MONERO_GUI_WALLETLISTENERIMPL_H diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index f092749..7785dbe 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "libwalletqt/WalletManager.h" #include "Wallet.h" diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 0611fba..15f44b0 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef WALLETMANAGER_H #define WALLETMANAGER_H diff --git a/src/main.cpp b/src/main.cpp index 477df63..8227ad5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include @@ -7,7 +7,6 @@ #include #include -#include "cli.h" #include "config-feather.h" #include "constants.h" #include "MainWindow.h" @@ -38,6 +37,11 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { } #endif +// Disable High DPI scaling on Linux for now +#if defined(Q_OS_LINUX) + qputenv("QT_ENABLE_HIGHDPI_SCALING", "0"); +#endif + QStringList argv_; for(int i = 0; i != argc; i++){ argv_ << QString::fromStdString(argv[i]); @@ -66,44 +70,15 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { QCommandLineOption testnetOption(QStringList() << "testnet", "Testnet is for development purposes only."); parser.addOption(testnetOption); - QCommandLineOption walletPathOption(QStringList() << "wallet-file", "Path to wallet keys file.", "file"); - parser.addOption(walletPathOption); - - QCommandLineOption walletPasswordOption(QStringList() << "password", "Wallet password (escape/quote as needed)", "password"); - parser.addOption(walletPasswordOption); - - QCommandLineOption daemonAddressOption(QStringList() << "daemon-address", "Daemon address (IPv4:port)", "daemonAddress"); - parser.addOption(daemonAddressOption); - - QCommandLineOption exportContactsOption(QStringList() << "export-contacts", "Output wallet contacts as CSV to specified path.", "file"); - parser.addOption(exportContactsOption); - - QCommandLineOption exportTxHistoryOption(QStringList() << "export-txhistory", "Output wallet transaction history as CSV to specified path.", "file"); - parser.addOption(exportTxHistoryOption); - - QCommandLineOption bruteforcePasswordOption(QStringList() << "bruteforce-password", "Bruteforce wallet password", "file"); - parser.addOption(bruteforcePasswordOption); - - QCommandLineOption bruteforceCharsOption(QStringList() << "bruteforce-chars", "Chars used to bruteforce password", "string"); - parser.addOption(bruteforceCharsOption); - - QCommandLineOption bruteforceDictionairy(QStringList() << "bruteforce-dict", "Bruteforce dictionairy", "file"); - parser.addOption(bruteforceDictionairy); - bool parsed = parser.parse(argv_); if (!parsed) { qCritical() << parser.errorText(); exit(1); } - const QStringList args = parser.positionalArguments(); bool stagenet = parser.isSet(stagenetOption); bool testnet = parser.isSet(testnetOption); bool quiet = parser.isSet(quietModeOption); - bool exportContacts = parser.isSet(exportContactsOption); - bool exportTxHistory = parser.isSet(exportTxHistoryOption); - bool bruteforcePassword = parser.isSet(bruteforcePasswordOption); - bool cliMode = exportContacts || exportTxHistory || bruteforcePassword; // Setup networkType if (stagenet) @@ -177,21 +152,6 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { if (parser.isSet("use-local-tor")) config()->set(Config::useLocalTor, true); - if (cliMode) { - CLI::Mode mode = [&]{ - if (exportContacts) - return CLI::Mode::ExportContacts; - if (exportTxHistory) - return CLI::Mode::ExportTxHistory; - if (bruteforcePassword) - return CLI::Mode::BruteforcePassword; - return CLI::Mode::Invalid; - }(); - - CLI cli{mode, &parser, &app}; - return QCoreApplication::exec(); - } - parser.process(app); // Parse again for --help and --version if (!quiet) { @@ -235,7 +195,5 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { windowManager.raise(); }); - - return QApplication::exec(); } diff --git a/src/model/AddressBookModel.cpp b/src/model/AddressBookModel.cpp index 7d5e138..fb9c8b5 100644 --- a/src/model/AddressBookModel.cpp +++ b/src/model/AddressBookModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2014-2023 The Monero Project #include "AddressBookModel.h" #include "AddressBook.h" diff --git a/src/model/AddressBookModel.h b/src/model/AddressBookModel.h index 06dc2a4..16ddd6d 100644 --- a/src/model/AddressBookModel.h +++ b/src/model/AddressBookModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef ADDRESSBOOKMODEL_H #define ADDRESSBOOKMODEL_H diff --git a/src/model/AddressBookProxyModel.cpp b/src/model/AddressBookProxyModel.cpp index 2e90678..ae881d6 100644 --- a/src/model/AddressBookProxyModel.cpp +++ b/src/model/AddressBookProxyModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "AddressBookProxyModel.h" #include "AddressBookModel.h" diff --git a/src/model/AddressBookProxyModel.h b/src/model/AddressBookProxyModel.h index 4649250..588f8a6 100644 --- a/src/model/AddressBookProxyModel.h +++ b/src/model/AddressBookProxyModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_ADDRESSBOOKPROXYMODEL_H #define FEATHER_ADDRESSBOOKPROXYMODEL_H diff --git a/src/model/BountiesModel.cpp b/src/model/BountiesModel.cpp index 8f999bf..f0cb5ae 100644 --- a/src/model/BountiesModel.cpp +++ b/src/model/BountiesModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2020-2021, The Monero Project. +// Copyright (c) 2020-2023, The Monero Project. #include "BountiesModel.h" diff --git a/src/model/BountiesModel.h b/src/model/BountiesModel.h index 21aecb7..cde0d23 100644 --- a/src/model/BountiesModel.h +++ b/src/model/BountiesModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2020-2021, The Monero Project. +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_BOUNTIESMODEL_H #define FEATHER_BOUNTIESMODEL_H diff --git a/src/model/CCSModel.cpp b/src/model/CCSModel.cpp index c969995..769f9ea 100644 --- a/src/model/CCSModel.cpp +++ b/src/model/CCSModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CCSModel.h" diff --git a/src/model/CCSModel.h b/src/model/CCSModel.h index e31eb66..2ff4be0 100644 --- a/src/model/CCSModel.h +++ b/src/model/CCSModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CCSMODEL_H #define FEATHER_CCSMODEL_H diff --git a/src/model/CoinsModel.cpp b/src/model/CoinsModel.cpp index 45c2949..45d098f 100644 --- a/src/model/CoinsModel.cpp +++ b/src/model/CoinsModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CoinsModel.h" #include "CoinsInfo.h" diff --git a/src/model/CoinsModel.h b/src/model/CoinsModel.h index 2e17e8a..f9e224a 100644 --- a/src/model/CoinsModel.h +++ b/src/model/CoinsModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COINSMODEL_H #define FEATHER_COINSMODEL_H diff --git a/src/model/CoinsProxyModel.cpp b/src/model/CoinsProxyModel.cpp index d40ab85..16e3a9d 100644 --- a/src/model/CoinsProxyModel.cpp +++ b/src/model/CoinsProxyModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CoinsProxyModel.h" #include "CoinsModel.h" diff --git a/src/model/CoinsProxyModel.h b/src/model/CoinsProxyModel.h index 87429f5..c336cfd 100644 --- a/src/model/CoinsProxyModel.h +++ b/src/model/CoinsProxyModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COINSPROXYMODEL_H #define FEATHER_COINSPROXYMODEL_H diff --git a/src/model/HistoryView.cpp b/src/model/HistoryView.cpp index 86202f7..4caefed 100644 --- a/src/model/HistoryView.cpp +++ b/src/model/HistoryView.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "HistoryView.h" diff --git a/src/model/HistoryView.h b/src/model/HistoryView.h index 58b7be7..5eea566 100644 --- a/src/model/HistoryView.h +++ b/src/model/HistoryView.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_HISTORYVIEW_H #define FEATHER_HISTORYVIEW_H diff --git a/src/model/LocalMoneroModel.cpp b/src/model/LocalMoneroModel.cpp index 7a8e95f..f946b3e 100644 --- a/src/model/LocalMoneroModel.cpp +++ b/src/model/LocalMoneroModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "LocalMoneroModel.h" #include diff --git a/src/model/LocalMoneroModel.h b/src/model/LocalMoneroModel.h index 1885c3d..0bcdee3 100644 --- a/src/model/LocalMoneroModel.h +++ b/src/model/LocalMoneroModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_LOCALMONEROMODEL_H #define FEATHER_LOCALMONEROMODEL_H diff --git a/src/model/ModelUtils.cpp b/src/model/ModelUtils.cpp index 34dd4cc..45bd02f 100644 --- a/src/model/ModelUtils.cpp +++ b/src/model/ModelUtils.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ModelUtils.h" diff --git a/src/model/ModelUtils.h b/src/model/ModelUtils.h index 4b78785..dfea37e 100644 --- a/src/model/ModelUtils.h +++ b/src/model/ModelUtils.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_MODELUTILS_H #define FEATHER_MODELUTILS_H diff --git a/src/model/NodeModel.cpp b/src/model/NodeModel.cpp index 63d8c23..6428cac 100644 --- a/src/model/NodeModel.cpp +++ b/src/model/NodeModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "NodeModel.h" #include "utils/nodes.h" diff --git a/src/model/NodeModel.h b/src/model/NodeModel.h index d57aea4..c767a20 100644 --- a/src/model/NodeModel.h +++ b/src/model/NodeModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_NODEMODEL_H #define FEATHER_NODEMODEL_H diff --git a/src/model/RedditModel.cpp b/src/model/RedditModel.cpp index e0ba26b..5326c56 100644 --- a/src/model/RedditModel.cpp +++ b/src/model/RedditModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "RedditModel.h" diff --git a/src/model/RedditModel.h b/src/model/RedditModel.h index 1d333c6..a4b1c94 100644 --- a/src/model/RedditModel.h +++ b/src/model/RedditModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_REDDITMODEL_H #define FEATHER_REDDITMODEL_H diff --git a/src/model/SubaddressAccountModel.cpp b/src/model/SubaddressAccountModel.cpp index a3737d4..06b2b5f 100644 --- a/src/model/SubaddressAccountModel.cpp +++ b/src/model/SubaddressAccountModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SubaddressAccountModel.h" #include "SubaddressAccount.h" diff --git a/src/model/SubaddressAccountModel.h b/src/model/SubaddressAccountModel.h index 9296bdc..7ce0bbc 100644 --- a/src/model/SubaddressAccountModel.h +++ b/src/model/SubaddressAccountModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef SUBADDRESSACCOUNTMODEL_H #define SUBADDRESSACCOUNTMODEL_H diff --git a/src/model/SubaddressModel.cpp b/src/model/SubaddressModel.cpp index 9dc9ca9..40d0f0f 100644 --- a/src/model/SubaddressModel.cpp +++ b/src/model/SubaddressModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SubaddressModel.h" #include "Subaddress.h" diff --git a/src/model/SubaddressModel.h b/src/model/SubaddressModel.h index a7b10f5..233ac78 100644 --- a/src/model/SubaddressModel.h +++ b/src/model/SubaddressModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef SUBADDRESSMODEL_H #define SUBADDRESSMODEL_H diff --git a/src/model/SubaddressProxyModel.cpp b/src/model/SubaddressProxyModel.cpp index 1462b40..7276fe8 100644 --- a/src/model/SubaddressProxyModel.cpp +++ b/src/model/SubaddressProxyModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SubaddressProxyModel.h" diff --git a/src/model/SubaddressProxyModel.h b/src/model/SubaddressProxyModel.h index 65a8964..87de1f6 100644 --- a/src/model/SubaddressProxyModel.h +++ b/src/model/SubaddressProxyModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SUBADDRESSPROXYMODEL_H #define FEATHER_SUBADDRESSPROXYMODEL_H diff --git a/src/model/SubaddressView.cpp b/src/model/SubaddressView.cpp index bdcb128..a270eb1 100644 --- a/src/model/SubaddressView.cpp +++ b/src/model/SubaddressView.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "SubaddressView.h" diff --git a/src/model/SubaddressView.h b/src/model/SubaddressView.h index c791aff..d0206c7 100644 --- a/src/model/SubaddressView.h +++ b/src/model/SubaddressView.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SUBADDRESSVIEW_H #define FEATHER_SUBADDRESSVIEW_H diff --git a/src/model/TransactionHistoryModel.cpp b/src/model/TransactionHistoryModel.cpp index cd2399a..397ec5d 100644 --- a/src/model/TransactionHistoryModel.cpp +++ b/src/model/TransactionHistoryModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TransactionHistoryModel.h" #include "TransactionHistory.h" diff --git a/src/model/TransactionHistoryModel.h b/src/model/TransactionHistoryModel.h index 1eb5fbe..582c57c 100644 --- a/src/model/TransactionHistoryModel.h +++ b/src/model/TransactionHistoryModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef TRANSACTIONHISTORYMODEL_H #define TRANSACTIONHISTORYMODEL_H diff --git a/src/model/TransactionHistoryProxyModel.cpp b/src/model/TransactionHistoryProxyModel.cpp index 8167543..5e090cc 100644 --- a/src/model/TransactionHistoryProxyModel.cpp +++ b/src/model/TransactionHistoryProxyModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TransactionHistoryProxyModel.h" #include "TransactionHistoryModel.h" diff --git a/src/model/TransactionHistoryProxyModel.h b/src/model/TransactionHistoryProxyModel.h index 6ee38c3..8a46582 100644 --- a/src/model/TransactionHistoryProxyModel.h +++ b/src/model/TransactionHistoryProxyModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TRANSACTIONHISTORYPROXYMODEL_H #define FEATHER_TRANSACTIONHISTORYPROXYMODEL_H diff --git a/src/model/WalletKeysFilesModel.cpp b/src/model/WalletKeysFilesModel.cpp index fd2f80b..024e455 100644 --- a/src/model/WalletKeysFilesModel.cpp +++ b/src/model/WalletKeysFilesModel.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletKeysFilesModel.h" diff --git a/src/model/WalletKeysFilesModel.h b/src/model/WalletKeysFilesModel.h index 2517e7c..568f02c 100644 --- a/src/model/WalletKeysFilesModel.h +++ b/src/model/WalletKeysFilesModel.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2014-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WALLETKEYSFILESMODEL_H #define FEATHER_WALLETKEYSFILESMODEL_H diff --git a/contrib/monero-seed/LICENSE.txt b/src/monero_seed/LICENSE.txt similarity index 100% rename from contrib/monero-seed/LICENSE.txt rename to src/monero_seed/LICENSE.txt diff --git a/contrib/monero-seed/README.md b/src/monero_seed/README.md similarity index 63% rename from contrib/monero-seed/README.md rename to src/monero_seed/README.md index d44196e..e40d1ec 100644 --- a/contrib/monero-seed/README.md +++ b/src/monero_seed/README.md @@ -1,11 +1,10 @@ -## Build -``` -git clone https://github.com/tevador/monero-seed.git -cd monero-seed -mkdir build && cd build -cmake .. -make -``` +## Note to package maintainers: + +This library was vendored because it is **deprecated** and **unmaintained**, it is kept for legacy reasons only. +Feather is the only project that will ever use this code, thus it is considered part of Feather source. +Do NOT unvendor this code. + +--- ## Features @@ -14,54 +13,6 @@ make * advanced checksum based on Reed-Solomon linear code, which allows certain types of errors to be detected without false positives and provides limited error correction capability * built-in way to make seeds incompatible between different coins, e.g. a seed for Aeon cannot be accidentally used to restore a Monero wallet -## Usage - -### Create a new seed - -``` -> ./monero-seed --create [--date ] [--coin ] -``` - -Example: -``` -> ./monero-seed --create --date 2100/03/14 --coin monero -Mnemonic phrase: test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern -- coin: monero -- private key: 7b816d8134e29393b0333eed4b6ed6edf97c156ad139055a706a6fb9599dcf8c -- created on or after: 02/Mar/2100 -``` - -### Restore seed -``` -./monero-seed --restore "<14-word seed>" [--coin ] -``` - -Example: - -``` -> ./monero-seed --restore "test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin monero -- coin: monero -- private key: 7b816d8134e29393b0333eed4b6ed6edf97c156ad139055a706a6fb9599dcf8c -- created on or after: 02/Mar/2100 -``` - -Attempting to restore the same seed under a different coin will fail: -``` -> ./monero-seed --restore "test park taste security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin aeon -ERROR: phrase is invalid (checksum mismatch) -``` - -Restore has limited error correction capability, namely it can correct a single erasure (illegible word with a known location). -This can be tested by replacing a word with `xxxx`: - -``` -> ./monero-seed --restore "test park xxxx security oxygen decorate essence ridge ship fish vehicle dream fluid pattern" --coin monero -Warning: corrected erasure: xxxx -> taste -- coin: monero -- private key: 7b816d8134e29393b0333eed4b6ed6edf97c156ad139055a706a6fb9599dcf8c -- created on or after: 02/Mar/2100 -``` - ## Implementation details The mnemonic phrase contains 154 bits of data, which are used as follows: diff --git a/contrib/monero-seed/src/argon2/argon2.c b/src/monero_seed/argon2/argon2.c similarity index 100% rename from contrib/monero-seed/src/argon2/argon2.c rename to src/monero_seed/argon2/argon2.c diff --git a/contrib/monero-seed/src/argon2/argon2.h b/src/monero_seed/argon2/argon2.h similarity index 100% rename from contrib/monero-seed/src/argon2/argon2.h rename to src/monero_seed/argon2/argon2.h diff --git a/contrib/monero-seed/src/argon2/blake2/blake2-impl.h b/src/monero_seed/argon2/blake2/blake2-impl.h similarity index 100% rename from contrib/monero-seed/src/argon2/blake2/blake2-impl.h rename to src/monero_seed/argon2/blake2/blake2-impl.h diff --git a/contrib/monero-seed/src/argon2/blake2/blake2.h b/src/monero_seed/argon2/blake2/blake2.h similarity index 100% rename from contrib/monero-seed/src/argon2/blake2/blake2.h rename to src/monero_seed/argon2/blake2/blake2.h diff --git a/contrib/monero-seed/src/argon2/blake2/blake2b.c b/src/monero_seed/argon2/blake2/blake2b.c similarity index 100% rename from contrib/monero-seed/src/argon2/blake2/blake2b.c rename to src/monero_seed/argon2/blake2/blake2b.c diff --git a/contrib/monero-seed/src/argon2/blake2/blamka-round-ref.h b/src/monero_seed/argon2/blake2/blamka-round-ref.h similarity index 100% rename from contrib/monero-seed/src/argon2/blake2/blamka-round-ref.h rename to src/monero_seed/argon2/blake2/blamka-round-ref.h diff --git a/contrib/monero-seed/src/argon2/core.c b/src/monero_seed/argon2/core.c similarity index 100% rename from contrib/monero-seed/src/argon2/core.c rename to src/monero_seed/argon2/core.c diff --git a/contrib/monero-seed/src/argon2/core.h b/src/monero_seed/argon2/core.h similarity index 100% rename from contrib/monero-seed/src/argon2/core.h rename to src/monero_seed/argon2/core.h diff --git a/contrib/monero-seed/src/argon2/ref.c b/src/monero_seed/argon2/ref.c similarity index 100% rename from contrib/monero-seed/src/argon2/ref.c rename to src/monero_seed/argon2/ref.c diff --git a/contrib/monero-seed/src/galois_field.cpp b/src/monero_seed/galois_field.cpp similarity index 100% rename from contrib/monero-seed/src/galois_field.cpp rename to src/monero_seed/galois_field.cpp diff --git a/contrib/monero-seed/include/monero_seed/galois_field.hpp b/src/monero_seed/galois_field.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/galois_field.hpp rename to src/monero_seed/galois_field.hpp diff --git a/contrib/monero-seed/src/gf_elem.cpp b/src/monero_seed/gf_elem.cpp similarity index 100% rename from contrib/monero-seed/src/gf_elem.cpp rename to src/monero_seed/gf_elem.cpp diff --git a/contrib/monero-seed/include/monero_seed/gf_elem.hpp b/src/monero_seed/gf_elem.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/gf_elem.hpp rename to src/monero_seed/gf_elem.hpp diff --git a/contrib/monero-seed/src/gf_poly.cpp b/src/monero_seed/gf_poly.cpp similarity index 100% rename from contrib/monero-seed/src/gf_poly.cpp rename to src/monero_seed/gf_poly.cpp diff --git a/contrib/monero-seed/include/monero_seed/gf_poly.hpp b/src/monero_seed/gf_poly.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/gf_poly.hpp rename to src/monero_seed/gf_poly.hpp diff --git a/contrib/monero-seed/src/monero_seed.cpp b/src/monero_seed/monero_seed.cpp similarity index 100% rename from contrib/monero-seed/src/monero_seed.cpp rename to src/monero_seed/monero_seed.cpp diff --git a/contrib/monero-seed/include/monero_seed/monero_seed.hpp b/src/monero_seed/monero_seed.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/monero_seed.hpp rename to src/monero_seed/monero_seed.hpp diff --git a/contrib/monero-seed/src/pbkdf2.c b/src/monero_seed/pbkdf2.c similarity index 100% rename from contrib/monero-seed/src/pbkdf2.c rename to src/monero_seed/pbkdf2.c diff --git a/contrib/monero-seed/src/pbkdf2.h b/src/monero_seed/pbkdf2.h similarity index 100% rename from contrib/monero-seed/src/pbkdf2.h rename to src/monero_seed/pbkdf2.h diff --git a/contrib/monero-seed/src/reed_solomon_code.cpp b/src/monero_seed/reed_solomon_code.cpp similarity index 100% rename from contrib/monero-seed/src/reed_solomon_code.cpp rename to src/monero_seed/reed_solomon_code.cpp diff --git a/contrib/monero-seed/include/monero_seed/reed_solomon_code.hpp b/src/monero_seed/reed_solomon_code.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/reed_solomon_code.hpp rename to src/monero_seed/reed_solomon_code.hpp diff --git a/contrib/monero-seed/src/secure_random.cpp b/src/monero_seed/secure_random.cpp similarity index 100% rename from contrib/monero-seed/src/secure_random.cpp rename to src/monero_seed/secure_random.cpp diff --git a/contrib/monero-seed/include/monero_seed/secure_random.hpp b/src/monero_seed/secure_random.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/secure_random.hpp rename to src/monero_seed/secure_random.hpp diff --git a/contrib/monero-seed/src/sha256/hash_impl.h b/src/monero_seed/sha256/hash_impl.h similarity index 100% rename from contrib/monero-seed/src/sha256/hash_impl.h rename to src/monero_seed/sha256/hash_impl.h diff --git a/contrib/monero-seed/src/wordlist.cpp b/src/monero_seed/wordlist.cpp similarity index 100% rename from contrib/monero-seed/src/wordlist.cpp rename to src/monero_seed/wordlist.cpp diff --git a/contrib/monero-seed/include/monero_seed/wordlist.hpp b/src/monero_seed/wordlist.hpp similarity index 100% rename from contrib/monero-seed/include/monero_seed/wordlist.hpp rename to src/monero_seed/wordlist.hpp diff --git a/src/openpgp/hash.h b/src/openpgp/hash.h index fab781b..8991ed0 100644 --- a/src/openpgp/hash.h +++ b/src/openpgp/hash.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/openpgp/mpi.h b/src/openpgp/mpi.h index 487b175..c4f48ff 100644 --- a/src/openpgp/mpi.h +++ b/src/openpgp/mpi.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/openpgp/openpgp.cpp b/src/openpgp/openpgp.cpp index c446300..1dc0993 100644 --- a/src/openpgp/openpgp.cpp +++ b/src/openpgp/openpgp.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "openpgp.h" diff --git a/src/openpgp/openpgp.h b/src/openpgp/openpgp.h index 8b010a1..e24df54 100644 --- a/src/openpgp/openpgp.h +++ b/src/openpgp/openpgp.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/openpgp/packet_stream.h b/src/openpgp/packet_stream.h index 11c918c..c10505e 100644 --- a/src/openpgp/packet_stream.h +++ b/src/openpgp/packet_stream.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/openpgp/s_expression.h b/src/openpgp/s_expression.h index b72d43c..fedb29f 100644 --- a/src/openpgp/s_expression.h +++ b/src/openpgp/s_expression.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/openpgp/serialization.h b/src/openpgp/serialization.h index 36ae50c..3b19a35 100644 --- a/src/openpgp/serialization.h +++ b/src/openpgp/serialization.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/qrcode_scanner/QrCodeScanDialog.cpp b/src/qrcode_scanner/QrCodeScanDialog.cpp index 5dd5374..78388c1 100644 --- a/src/qrcode_scanner/QrCodeScanDialog.cpp +++ b/src/qrcode_scanner/QrCodeScanDialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "QrCodeScanDialog.h" #include "ui_QrCodeScanDialog.h" diff --git a/src/qrcode_scanner/QrCodeScanDialog.h b/src/qrcode_scanner/QrCodeScanDialog.h index dd2387d..47735d6 100644 --- a/src/qrcode_scanner/QrCodeScanDialog.h +++ b/src/qrcode_scanner/QrCodeScanDialog.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_QRCODESCANDIALOG_H #define FEATHER_QRCODESCANDIALOG_H diff --git a/src/qrcode_scanner/QrScanThread.cpp b/src/qrcode_scanner/QrScanThread.cpp index 3b3db0a..54a699b 100644 --- a/src/qrcode_scanner/QrScanThread.cpp +++ b/src/qrcode_scanner/QrScanThread.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "QrScanThread.h" #include diff --git a/src/qrcode_scanner/QrScanThread.h b/src/qrcode_scanner/QrScanThread.h index 16bee3b..849e775 100644 --- a/src/qrcode_scanner/QrScanThread.h +++ b/src/qrcode_scanner/QrScanThread.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef _QRSCANTHREAD_H_ #define _QRSCANTHREAD_H_ diff --git a/src/qrcode_scanner_qt6/CMakeLists.txt b/src/qrcode_scanner_qt6/CMakeLists.txt new file mode 100644 index 0000000..e927cef --- /dev/null +++ b/src/qrcode_scanner_qt6/CMakeLists.txt @@ -0,0 +1,3 @@ +file(GLOB_RECURSE SRC_SOURCES *.cpp) +file(GLOB_RECURSE SRC_HEADERS *.h) + diff --git a/src/qrcode_scanner_qt6/QrCodeScanDialog.cpp b/src/qrcode_scanner_qt6/QrCodeScanDialog.cpp new file mode 100644 index 0000000..d4e32ca --- /dev/null +++ b/src/qrcode_scanner_qt6/QrCodeScanDialog.cpp @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2023 The Monero Project + +#include "QrCodeScanDialog.h" +#include "ui_QrCodeScanDialog.h" + +#include +#include +#include +#include +#include +#include + +QrCodeScanDialog::QrCodeScanDialog(QWidget *parent) + : QDialog(parent) + , ui(new Ui::QrCodeScanDialog) +{ + ui->setupUi(this); + this->setWindowTitle("Scan QR code"); + + QPixmap pixmap = QPixmap(":/assets/images/warning.png"); + ui->icon_warning->setPixmap(pixmap.scaledToWidth(32, Qt::SmoothTransformation)); + + const QList cameras = QMediaDevices::videoInputs(); + for (const auto &camera : cameras) { + ui->combo_camera->addItem(camera.description()); + } + + connect(ui->combo_camera, QOverload::of(&QComboBox::currentIndexChanged), this, &QrCodeScanDialog::onCameraSwitched); + + this->onCameraSwitched(0); + + m_thread = new QrScanThread(this); + m_thread->start(); + + connect(m_thread, &QrScanThread::decoded, this, &QrCodeScanDialog::onDecoded); + connect(m_thread, &QrScanThread::notifyError, this, &QrCodeScanDialog::notifyError); + + connect(&m_imageTimer, &QTimer::timeout, this, &QrCodeScanDialog::takeImage); + m_imageTimer.start(500); +} + +void QrCodeScanDialog::onCameraSwitched(int index) { + const QList cameras = QMediaDevices::videoInputs(); + + if (index >= cameras.size()) { + return; + } + + m_camera.reset(new QCamera(cameras.at(index))); + m_captureSession.setCamera(m_camera.data()); + m_captureSession.setVideoOutput(ui->viewfinder); + + m_imageCapture = new QImageCapture; + m_captureSession.setImageCapture(m_imageCapture); + + connect(m_imageCapture, &QImageCapture::imageCaptured, this, &QrCodeScanDialog::processCapturedImage); + connect(m_camera.data(), &QCamera::errorOccurred, this, &QrCodeScanDialog::displayCameraError); + connect(m_camera.data(), &QCamera::activeChanged, [this](bool active){ + ui->frame_unavailable->setVisible(!active); + }); + + m_camera->start(); +} + +void QrCodeScanDialog::processCapturedImage(int requestId, const QImage& img) { + Q_UNUSED(requestId); + QImage image{img}; + image.convertTo(QImage::Format_RGB32); + m_thread->addImage(image); +} + +void QrCodeScanDialog::takeImage() +{ + if (m_imageCapture->isReadyForCapture()) { + m_imageCapture->capture(); + } +} + +void QrCodeScanDialog::onDecoded(int type, const QString &data) { + decodedString = data; + this->accept(); +} + +void QrCodeScanDialog::displayCameraError() +{ + if (m_camera->error() != QCamera::NoError) { + QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString()); + } +} + +void QrCodeScanDialog::notifyError(const QString &msg) { + qDebug() << "QrScanner error: " << msg; +} + +QrCodeScanDialog::~QrCodeScanDialog() +{ + m_thread->stop(); + m_thread->quit(); + if (!m_thread->wait(5000)) + { + m_thread->terminate(); + m_thread->wait(); + } +} \ No newline at end of file diff --git a/src/qrcode_scanner_qt6/QrCodeScanDialog.h b/src/qrcode_scanner_qt6/QrCodeScanDialog.h new file mode 100644 index 0000000..74b82e3 --- /dev/null +++ b/src/qrcode_scanner_qt6/QrCodeScanDialog.h @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2023 The Monero Project + +#ifndef FEATHER_QRCODESCANDIALOG_H +#define FEATHER_QRCODESCANDIALOG_H + +#include +#include +#include +#include +#include + +#include "QrScanThread.h" + +namespace Ui { + class QrCodeScanDialog; +} + +class QrCodeScanDialog : public QDialog +{ + Q_OBJECT + +public: + explicit QrCodeScanDialog(QWidget *parent); + ~QrCodeScanDialog() override; + + QString decodedString = ""; + +private slots: + void onCameraSwitched(int index); + void onDecoded(int type, const QString &data); + void notifyError(const QString &msg); + +private: + void processCapturedImage(int requestId, const QImage& img); + void displayCameraError(); + void takeImage(); + + QScopedPointer ui; + + QrScanThread *m_thread; + QImageCapture *m_imageCapture; + QTimer m_imageTimer; + QScopedPointer m_camera; + QMediaCaptureSession m_captureSession; +}; + + +#endif //FEATHER_QRCODESCANDIALOG_H diff --git a/src/qrcode_scanner_qt6/QrCodeScanDialog.ui b/src/qrcode_scanner_qt6/QrCodeScanDialog.ui new file mode 100644 index 0000000..9cda999 --- /dev/null +++ b/src/qrcode_scanner_qt6/QrCodeScanDialog.ui @@ -0,0 +1,110 @@ + + + QrCodeScanDialog + + + + 0 + 0 + 490 + 422 + + + + Dialog + + + + + + + 0 + 0 + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + icon + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 55 + 0 + + + + + + + + Lost connection to camera. Please restart scan dialog. + + + true + + + + + + + + + + + + + 0 + 0 + + + + Camera: + + + + + + + + + + + + + QVideoWidget + QWidget +
qvideowidget.h
+ 1 +
+
+ + +
diff --git a/src/qrcode_scanner_qt6/QrScanThread.cpp b/src/qrcode_scanner_qt6/QrScanThread.cpp new file mode 100644 index 0000000..54a699b --- /dev/null +++ b/src/qrcode_scanner_qt6/QrScanThread.cpp @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2023 The Monero Project + +#include "QrScanThread.h" +#include +#include + +QrScanThread::QrScanThread(QObject *parent) + : QThread(parent) + , m_running(true) +{ + m_scanner.set_handler(*this); +} + +void QrScanThread::image_callback(zbar::Image &image) +{ + qDebug() << "image_callback : Found Code ! " ; + for (zbar::Image::SymbolIterator sym = image.symbol_begin(); sym != image.symbol_end(); ++sym) { + if (!sym->get_count()) { + QString data = QString::fromStdString(sym->get_data()); + emit decoded(sym->get_type(), data); + } + } +} + +void QrScanThread::processZImage(zbar::Image &image) +{ + m_scanner.recycle_image(image); + zbar::Image tmp = image.convert(zbar_fourcc('Y', '8', '0', '0')); + m_scanner.scan(tmp); + image.set_symbols(tmp.get_symbols()); +} + +bool QrScanThread::zimageFromQImage(const QImage &qimg, zbar::Image &dst) +{ + switch (qimg.format()) { + case QImage::Format_RGB32 : + case QImage::Format_ARGB32 : + case QImage::Format_ARGB32_Premultiplied : + break; + default : + qDebug() << "Format: " << qimg.format(); + emit notifyError(QString("Invalid QImage Format !")); + return false; + } + unsigned int bpl( qimg.bytesPerLine() ), width( bpl / 4), height( qimg.height()); + dst.set_size(width, height); + dst.set_format("BGR4"); + unsigned long datalen = qimg.sizeInBytes(); + dst.set_data(qimg.bits(), datalen); + if((width * 4 != bpl) || (width * height * 4 > datalen)){ + emit notifyError(QString("QImage to Zbar::Image failed !")); + return false; + } + return true; +} + +void QrScanThread::processQImage(const QImage &qimg) +{ + try { + m_image = QSharedPointer(new zbar::Image()); + if (!zimageFromQImage(qimg, *m_image)) + return; + processZImage(*m_image); + } + catch(std::exception &e) { + qDebug() << "ERROR: " << e.what(); + emit notifyError(e.what()); + } +} + +void QrScanThread::stop() +{ + m_running = false; + m_waitCondition.wakeOne(); +} + +void QrScanThread::addImage(const QImage &img) +{ + QMutexLocker locker(&m_mutex); + m_queue.append(img); + m_waitCondition.wakeOne(); +} + +void QrScanThread::run() +{ + while (m_running) { + QMutexLocker locker(&m_mutex); + while (m_queue.isEmpty() && m_running) { + m_waitCondition.wait(&m_mutex); + } + if (!m_queue.isEmpty()) { + processQImage(m_queue.takeFirst()); + } + } +} \ No newline at end of file diff --git a/src/qrcode_scanner_qt6/QrScanThread.h b/src/qrcode_scanner_qt6/QrScanThread.h new file mode 100644 index 0000000..849e775 --- /dev/null +++ b/src/qrcode_scanner_qt6/QrScanThread.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2023 The Monero Project + +#ifndef _QRSCANTHREAD_H_ +#define _QRSCANTHREAD_H_ + +#include +#include +#include +#include +#include +#include + +class QrScanThread : public QThread, public zbar::Image::Handler +{ + Q_OBJECT + +public: + QrScanThread(QObject *parent = nullptr); + void addImage(const QImage &img); + virtual void stop(); + +signals: + void decoded(int type, const QString &data); + void notifyError(const QString &error, bool warning = false); + +protected: + virtual void run(); + void processQImage(const QImage &); + void processZImage(zbar::Image &image); + virtual void image_callback(zbar::Image &image); + bool zimageFromQImage(const QImage&, zbar::Image &); + +private: + zbar::ImageScanner m_scanner; + QSharedPointer m_image; + bool m_running; + QMutex m_mutex; + QWaitCondition m_waitCondition; + QList m_queue; +}; +#endif \ No newline at end of file diff --git a/src/qrcode_scanner/QrCodeUtils.cpp b/src/qrcode_utils/QrCodeUtils.cpp similarity index 96% rename from src/qrcode_scanner/QrCodeUtils.cpp rename to src/qrcode_utils/QrCodeUtils.cpp index 1efe489..beb8d9f 100644 --- a/src/qrcode_scanner/QrCodeUtils.cpp +++ b/src/qrcode_utils/QrCodeUtils.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "QrCodeUtils.h" #include diff --git a/src/qrcode_scanner/QrCodeUtils.h b/src/qrcode_utils/QrCodeUtils.h similarity index 85% rename from src/qrcode_scanner/QrCodeUtils.h rename to src/qrcode_utils/QrCodeUtils.h index ca256c6..f934838 100644 --- a/src/qrcode_scanner/QrCodeUtils.h +++ b/src/qrcode_utils/QrCodeUtils.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_QRCODEUTILS_H #define FEATHER_QRCODEUTILS_H diff --git a/src/utils/AppData.cpp b/src/utils/AppData.cpp index 7f1ef37..8434e2f 100644 --- a/src/utils/AppData.cpp +++ b/src/utils/AppData.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "AppData.h" #include "config.h" diff --git a/src/utils/AppData.h b/src/utils/AppData.h index 510ac69..6256e9e 100644 --- a/src/utils/AppData.h +++ b/src/utils/AppData.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_APPDATA_H #define FEATHER_APPDATA_H diff --git a/src/utils/ColorScheme.cpp b/src/utils/ColorScheme.cpp index 32e8f64..094a917 100644 --- a/src/utils/ColorScheme.cpp +++ b/src/utils/ColorScheme.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause // SPDX-FileCopyrightText: 2012 thomasv@gitorious -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "ColorScheme.h" #include diff --git a/src/utils/ColorScheme.h b/src/utils/ColorScheme.h index 15d8d82..c02ea63 100644 --- a/src/utils/ColorScheme.h +++ b/src/utils/ColorScheme.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BSD-3-Clause // SPDX-FileCopyrightText: 2012 thomasv@gitorious -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_COLORSCHEME_H #define FEATHER_COLORSCHEME_H diff --git a/src/utils/EventFilter.cpp b/src/utils/EventFilter.cpp index 60b9d3b..53821f2 100644 --- a/src/utils/EventFilter.cpp +++ b/src/utils/EventFilter.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "EventFilter.h" diff --git a/src/utils/EventFilter.h b/src/utils/EventFilter.h index 2b807df..f123a53 100644 --- a/src/utils/EventFilter.h +++ b/src/utils/EventFilter.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_EVENTFILTER_H #define FEATHER_EVENTFILTER_H diff --git a/src/utils/Icons.cpp b/src/utils/Icons.cpp index e1a6303..71beb51 100644 --- a/src/utils/Icons.cpp +++ b/src/utils/Icons.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "Icons.h" diff --git a/src/utils/Icons.h b/src/utils/Icons.h index fae8f3e..9689ded 100644 --- a/src/utils/Icons.h +++ b/src/utils/Icons.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_ICONS_H #define FEATHER_ICONS_H diff --git a/src/utils/NetworkManager.cpp b/src/utils/NetworkManager.cpp index 208e478..1018727 100644 --- a/src/utils/NetworkManager.cpp +++ b/src/utils/NetworkManager.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "NetworkManager.h" diff --git a/src/utils/NetworkManager.h b/src/utils/NetworkManager.h index f6d461c..7bed7fa 100644 --- a/src/utils/NetworkManager.h +++ b/src/utils/NetworkManager.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_NETWORKMANAGER_H #define FEATHER_NETWORKMANAGER_H diff --git a/src/utils/RestoreHeightLookup.h b/src/utils/RestoreHeightLookup.h index 48f448b..73ff873 100644 --- a/src/utils/RestoreHeightLookup.h +++ b/src/utils/RestoreHeightLookup.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_RESTOREHEIGHTLOOKUP_H #define FEATHER_RESTOREHEIGHTLOOKUP_H @@ -7,7 +7,7 @@ #include #include -#include +#include "monero_seed/monero_seed.hpp" #include "networktype.h" #include "utils/Utils.h" diff --git a/src/utils/Seed.cpp b/src/utils/Seed.cpp index 67e3957..e916550 100644 --- a/src/utils/Seed.cpp +++ b/src/utils/Seed.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include "Seed.h" diff --git a/src/utils/Seed.h b/src/utils/Seed.h index 8ece526..f306a27 100644 --- a/src/utils/Seed.h +++ b/src/utils/Seed.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SEED_H #define FEATHER_SEED_H diff --git a/src/utils/SemanticVersion.h b/src/utils/SemanticVersion.h index 8e148fb..2104fa5 100644 --- a/src/utils/SemanticVersion.h +++ b/src/utils/SemanticVersion.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_SEMANTICVERSION_H #define FEATHER_SEMANTICVERSION_H diff --git a/src/utils/TorManager.cpp b/src/utils/TorManager.cpp index f92c992..9ebbef5 100644 --- a/src/utils/TorManager.cpp +++ b/src/utils/TorManager.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "utils/TorManager.h" diff --git a/src/utils/TorManager.h b/src/utils/TorManager.h index aef48cb..038ba9f 100644 --- a/src/utils/TorManager.h +++ b/src/utils/TorManager.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TOR_H #define FEATHER_TOR_H diff --git a/src/utils/TxFiatHistory.cpp b/src/utils/TxFiatHistory.cpp index 6736de0..e75acbf 100644 --- a/src/utils/TxFiatHistory.cpp +++ b/src/utils/TxFiatHistory.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TxFiatHistory.h" #include "utils/Utils.h" diff --git a/src/utils/TxFiatHistory.h b/src/utils/TxFiatHistory.h index 3596426..5ab51d2 100644 --- a/src/utils/TxFiatHistory.h +++ b/src/utils/TxFiatHistory.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TXFIATHISTORY_H #define FEATHER_TXFIATHISTORY_H diff --git a/src/utils/Updater.cpp b/src/utils/Updater.cpp index 138d27d..da2e9be 100644 --- a/src/utils/Updater.cpp +++ b/src/utils/Updater.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "Updater.h" diff --git a/src/utils/Updater.h b/src/utils/Updater.h index 518ccad..8a42b88 100644 --- a/src/utils/Updater.h +++ b/src/utils/Updater.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #pragma once diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index b0ebbb8..9d50c8c 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include diff --git a/src/utils/Utils.h b/src/utils/Utils.h index badd618..0739bf4 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_UTILS_H #define FEATHER_UTILS_H diff --git a/src/utils/WebsocketClient.cpp b/src/utils/WebsocketClient.cpp index 2b795a7..af1a559 100644 --- a/src/utils/WebsocketClient.cpp +++ b/src/utils/WebsocketClient.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WebsocketClient.h" diff --git a/src/utils/WebsocketClient.h b/src/utils/WebsocketClient.h index 1563f44..3e5d5f8 100644 --- a/src/utils/WebsocketClient.h +++ b/src/utils/WebsocketClient.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WEBSOCKETCLIENT_H #define FEATHER_WEBSOCKETCLIENT_H diff --git a/src/utils/WebsocketNotifier.cpp b/src/utils/WebsocketNotifier.cpp index 6414a70..750fc76 100644 --- a/src/utils/WebsocketNotifier.cpp +++ b/src/utils/WebsocketNotifier.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WebsocketNotifier.h" #include "Utils.h" diff --git a/src/utils/WebsocketNotifier.h b/src/utils/WebsocketNotifier.h index deeef78..a1d6937 100644 --- a/src/utils/WebsocketNotifier.h +++ b/src/utils/WebsocketNotifier.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WEBSOCKETNOTIFIER_H #define FEATHER_WEBSOCKETNOTIFIER_H diff --git a/src/utils/brute.cpp b/src/utils/brute.cpp deleted file mode 100644 index d884c19..0000000 --- a/src/utils/brute.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project - -#include "brute.h" - -brute::brute(const std::string &chars) { - this->chars = chars; - this->len = chars.length(); -} - -std::string brute::next() { - std::string out; - int c = count; - int i; - while (c >= 0){ - i = (c % len); - out = chars[i] + out; - c = (c / len) - 1; - } - count += 1; - return out; -} - -bruteword::bruteword(const std::string &chars) { - this->m_chars = chars; - this->m_currentStrategy = strategy::ReplaceSingle; -} - -void bruteword::setWord(const std::string &word) { - this->m_currentStrategy = strategy::ReplaceSingle; - m_word = word; - resetIndex(); -} - -void bruteword::nextStrategy() { - m_currentStrategy = static_cast(static_cast(m_currentStrategy) + 1); - resetIndex(); -} - -void bruteword::resetIndex() { - iword = 0; - ichar = 0; -} - -std::string bruteword::next() { - std::string out = m_word; - - switch(m_currentStrategy) { - case strategy::ReplaceSingle: { - if (iword >= m_word.length()) { - this->nextStrategy(); - return next(); - } - out[iword] = m_chars[ichar]; - ichar++; - if (ichar == m_chars.length()){ - ichar = 0; - iword++; - } - return out; - } - - case strategy::AppendSingle: { - if (ichar >= m_chars.length()) { - this->nextStrategy(); - return next(); - } - out += m_chars[ichar]; - ichar++; - return out; - } - - case strategy::PrependSingle: { - if (ichar >= m_chars.length()) { - this->nextStrategy(); - return next(); - } - out = m_chars[ichar] + out; - ichar++; - return out; - } - - case strategy::SwitchLetters: { - if (iword+1 >= out.length()) { - this->nextStrategy(); - return next(); - } - char l = out[iword]; - out[iword] = out[iword+1]; - out[iword+1] = l; - iword++; - return out; - } - - case strategy::DeleteSingle: { - if (iword >= out.length()) { - this->nextStrategy(); - return next(); - } - out = out.substr(0, iword) + out.substr(iword+1); - iword++; - return out; - } - - case strategy::AddSingle: { - if (iword+1 >= out.length()) { - this->nextStrategy(); - return next(); - } - out = out.substr(0, iword+1) + m_chars[ichar] + out.substr(iword+1); - ichar++; - if (ichar == m_chars.length()) { - ichar = 0; - iword++; - } - return out; - } - - case strategy::END: { - return ""; - } - } - - return ""; -} \ No newline at end of file diff --git a/src/utils/brute.h b/src/utils/brute.h deleted file mode 100644 index 223c966..0000000 --- a/src/utils/brute.h +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project - -#ifndef FEATHER_BRUTE_H -#define FEATHER_BRUTE_H - -#include - -class brute { -public: - explicit brute(const std::string &chars); - - std::string next(); - - std::string chars; - std::string current; - int len; - int count = 0; -}; - -class bruteword { -public: - enum strategy { - ReplaceSingle = 0, - AppendSingle, - PrependSingle, - SwitchLetters, - DeleteSingle, - AddSingle, - END - }; - - explicit bruteword(const std::string &chars); - void nextStrategy(); - void setWord(const std::string &word); - - std::string next(); - -private: - void resetIndex(); - - std::string m_chars; - std::string m_word; - strategy m_currentStrategy; - - size_t iword = 0; - size_t ichar = 0; -}; - -#endif //FEATHER_BRUTE_H diff --git a/src/utils/childproc.cpp b/src/utils/childproc.cpp index a569060..786c190 100644 --- a/src/utils/childproc.cpp +++ b/src/utils/childproc.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "utils/childproc.h" diff --git a/src/utils/childproc.h b/src/utils/childproc.h index 6b87e1a..c6f5f80 100644 --- a/src/utils/childproc.h +++ b/src/utils/childproc.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_FPROCESS_H #define FEATHER_FPROCESS_H diff --git a/src/utils/config.cpp b/src/utils/config.cpp index ed44c82..4b5950a 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // SPDX-FileCopyrightText: 2011 Felix Geyer // SPDX-FileCopyrightText: 2020 KeePassXC Team -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "config.h" #include "utils/Utils.h" diff --git a/src/utils/config.h b/src/utils/config.h index e85cf5f..cf60eb9 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // SPDX-FileCopyrightText: 2011 Felix Geyer // SPDX-FileCopyrightText: 2020 KeePassXC Team -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CONFIG_H #define FEATHER_CONFIG_H diff --git a/src/utils/daemonrpc.cpp b/src/utils/daemonrpc.cpp index 4eece5f..b80aed9 100644 --- a/src/utils/daemonrpc.cpp +++ b/src/utils/daemonrpc.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "daemonrpc.h" diff --git a/src/utils/daemonrpc.h b/src/utils/daemonrpc.h index c9bc860..01f1a62 100644 --- a/src/utils/daemonrpc.h +++ b/src/utils/daemonrpc.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_DAEMON_RPC_H #define FEATHER_DAEMON_RPC_H diff --git a/src/utils/networking.cpp b/src/utils/networking.cpp index f1893ad..e2a5cda 100644 --- a/src/utils/networking.cpp +++ b/src/utils/networking.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include diff --git a/src/utils/networking.h b/src/utils/networking.h index 9aab733..c140cd0 100644 --- a/src/utils/networking.h +++ b/src/utils/networking.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_NETWORKING_H #define FEATHER_NETWORKING_H diff --git a/src/utils/nodes.cpp b/src/utils/nodes.cpp index c1bfea0..e53c871 100644 --- a/src/utils/nodes.cpp +++ b/src/utils/nodes.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include diff --git a/src/utils/nodes.h b/src/utils/nodes.h index 939c46f..ebad101 100644 --- a/src/utils/nodes.h +++ b/src/utils/nodes.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_NODES_H #define FEATHER_NODES_H diff --git a/src/utils/os/tails.cpp b/src/utils/os/tails.cpp index d53d79b..52f3d3c 100644 --- a/src/utils/os/tails.cpp +++ b/src/utils/os/tails.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include diff --git a/src/utils/os/tails.h b/src/utils/os/tails.h index 9dddd4a..1948685 100644 --- a/src/utils/os/tails.h +++ b/src/utils/os/tails.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef TAILSOS_H #define TAILSOS_H diff --git a/src/utils/os/whonix.cpp b/src/utils/os/whonix.cpp index 8b662da..8d9a682 100644 --- a/src/utils/os/whonix.cpp +++ b/src/utils/os/whonix.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "whonix.h" diff --git a/src/utils/os/whonix.h b/src/utils/os/whonix.h index 8f72e53..e8d8fe1 100644 --- a/src/utils/os/whonix.h +++ b/src/utils/os/whonix.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WHONIX_H #define FEATHER_WHONIX_H diff --git a/src/utils/prices.cpp b/src/utils/prices.cpp index e614268..d66a1f4 100644 --- a/src/utils/prices.cpp +++ b/src/utils/prices.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "utils/prices.h" diff --git a/src/utils/prices.h b/src/utils/prices.h index f249878..55457d1 100644 --- a/src/utils/prices.h +++ b/src/utils/prices.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PRICES_H #define FEATHER_PRICES_H diff --git a/src/utils/xmrig.cpp b/src/utils/xmrig.cpp index 534a524..d960626 100644 --- a/src/utils/xmrig.cpp +++ b/src/utils/xmrig.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include diff --git a/src/utils/xmrig.h b/src/utils/xmrig.h index c914084..fd55eee 100644 --- a/src/utils/xmrig.h +++ b/src/utils/xmrig.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_XMRIG_H #define FEATHER_XMRIG_H diff --git a/src/widgets/BountiesWidget.cpp b/src/widgets/BountiesWidget.cpp index 152afd0..7562285 100644 --- a/src/widgets/BountiesWidget.cpp +++ b/src/widgets/BountiesWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2020-2021, The Monero Project. +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "BountiesWidget.h" #include "ui_BountiesWidget.h" diff --git a/src/widgets/BountiesWidget.h b/src/widgets/BountiesWidget.h index 548e1c2..47f070b 100644 --- a/src/widgets/BountiesWidget.h +++ b/src/widgets/BountiesWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) 2020-2021, The Monero Project. +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_BOUNTIESWIDGET_H #define FEATHER_BOUNTIESWIDGET_H diff --git a/src/widgets/CCSEntry.h b/src/widgets/CCSEntry.h index a60e040..bf1dfdc 100644 --- a/src/widgets/CCSEntry.h +++ b/src/widgets/CCSEntry.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CCSENTRY_H #define FEATHER_CCSENTRY_H diff --git a/src/widgets/CCSProgressDelegate.cpp b/src/widgets/CCSProgressDelegate.cpp index 2f3541e..0dc9889 100644 --- a/src/widgets/CCSProgressDelegate.cpp +++ b/src/widgets/CCSProgressDelegate.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CCSProgressDelegate.h" diff --git a/src/widgets/CCSProgressDelegate.h b/src/widgets/CCSProgressDelegate.h index 42f0bde..0e2319c 100644 --- a/src/widgets/CCSProgressDelegate.h +++ b/src/widgets/CCSProgressDelegate.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CSSPROGRESSDELEGATE_H #define FEATHER_CSSPROGRESSDELEGATE_H diff --git a/src/widgets/CCSWidget.cpp b/src/widgets/CCSWidget.cpp index 0447fd4..da27e54 100644 --- a/src/widgets/CCSWidget.cpp +++ b/src/widgets/CCSWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "CCSWidget.h" #include "ui_CCSWidget.h" diff --git a/src/widgets/CCSWidget.h b/src/widgets/CCSWidget.h index 193660f..3590d4f 100644 --- a/src/widgets/CCSWidget.h +++ b/src/widgets/CCSWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CSSWIDGET_H #define FEATHER_CSSWIDGET_H diff --git a/src/widgets/LocalMoneroWidget.cpp b/src/widgets/LocalMoneroWidget.cpp index ae3b92d..d593879 100644 --- a/src/widgets/LocalMoneroWidget.cpp +++ b/src/widgets/LocalMoneroWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "LocalMoneroWidget.h" #include "ui_LocalMoneroWidget.h" diff --git a/src/widgets/LocalMoneroWidget.h b/src/widgets/LocalMoneroWidget.h index 3c9ad15..c62409e 100644 --- a/src/widgets/LocalMoneroWidget.h +++ b/src/widgets/LocalMoneroWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_LOCALMONEROWIDGET_H #define FEATHER_LOCALMONEROWIDGET_H diff --git a/src/widgets/NodeWidget.cpp b/src/widgets/NodeWidget.cpp index 3b99b7a..374353c 100644 --- a/src/widgets/NodeWidget.cpp +++ b/src/widgets/NodeWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "NodeWidget.h" #include "ui_NodeWidget.h" diff --git a/src/widgets/NodeWidget.h b/src/widgets/NodeWidget.h index b667cc2..a35efa3 100644 --- a/src/widgets/NodeWidget.h +++ b/src/widgets/NodeWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_NODEWIDGET_H #define FEATHER_NODEWIDGET_H diff --git a/src/widgets/PayToEdit.cpp b/src/widgets/PayToEdit.cpp index 2c46674..a38b393 100644 --- a/src/widgets/PayToEdit.cpp +++ b/src/widgets/PayToEdit.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project // SPDX-FileCopyrightText: 2012 thomasv@gitorious #include "PayToEdit.h" @@ -12,7 +12,7 @@ #include "libwalletqt/WalletManager.h" #include "model/ModelUtils.h" -#include "qrcode_scanner/QrCodeUtils.h" +#include "qrcode_utils/QrCodeUtils.h" PayToEdit::PayToEdit(QWidget *parent) : QPlainTextEdit(parent) { diff --git a/src/widgets/PayToEdit.h b/src/widgets/PayToEdit.h index 37bb848..cf08228 100644 --- a/src/widgets/PayToEdit.h +++ b/src/widgets/PayToEdit.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project // SPDX-FileCopyrightText: 2012 thomasv@gitorious #ifndef FEATHER_PAYTOEDIT_H diff --git a/src/widgets/QrCodeWidget.cpp b/src/widgets/QrCodeWidget.cpp index 4fa6fe9..44e0a81 100644 --- a/src/widgets/QrCodeWidget.cpp +++ b/src/widgets/QrCodeWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "QrCodeWidget.h" diff --git a/src/widgets/QrCodeWidget.h b/src/widgets/QrCodeWidget.h index b391168..17b5977 100644 --- a/src/widgets/QrCodeWidget.h +++ b/src/widgets/QrCodeWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_QRCODEWIDGET_H #define FEATHER_QRCODEWIDGET_H diff --git a/src/widgets/RedditPost.h b/src/widgets/RedditPost.h index a5b40d4..14aa3cf 100644 --- a/src/widgets/RedditPost.h +++ b/src/widgets/RedditPost.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_REDDITPOST_H #define FEATHER_REDDITPOST_H diff --git a/src/widgets/RedditWidget.cpp b/src/widgets/RedditWidget.cpp index e07c613..c5089b8 100644 --- a/src/widgets/RedditWidget.cpp +++ b/src/widgets/RedditWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "RedditWidget.h" #include "ui_RedditWidget.h" diff --git a/src/widgets/RedditWidget.h b/src/widgets/RedditWidget.h index 0ea2310..a88cf4f 100644 --- a/src/widgets/RedditWidget.h +++ b/src/widgets/RedditWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_REDDITWIDGET_H #define FEATHER_REDDITWIDGET_H diff --git a/src/widgets/RestoreHeightWidget.cpp b/src/widgets/RestoreHeightWidget.cpp index 1b4c225..4cf2baf 100644 --- a/src/widgets/RestoreHeightWidget.cpp +++ b/src/widgets/RestoreHeightWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "RestoreHeightWidget.h" #include "ui_RestoreHeightWidget.h" diff --git a/src/widgets/RestoreHeightWidget.h b/src/widgets/RestoreHeightWidget.h index e355ec8..ddd8c0c 100644 --- a/src/widgets/RestoreHeightWidget.h +++ b/src/widgets/RestoreHeightWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_RESTOREHEIGHTWIDGET_H #define FEATHER_RESTOREHEIGHTWIDGET_H diff --git a/src/widgets/RevuoItem.h b/src/widgets/RevuoItem.h index c6410fe..8079ba6 100644 --- a/src/widgets/RevuoItem.h +++ b/src/widgets/RevuoItem.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_REVUOITEM_H #define FEATHER_REVUOITEM_H diff --git a/src/widgets/RevuoWidget.cpp b/src/widgets/RevuoWidget.cpp index c6d6621..3a41eda 100644 --- a/src/widgets/RevuoWidget.cpp +++ b/src/widgets/RevuoWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "RevuoWidget.h" #include "ui_RevuoWidget.h" diff --git a/src/widgets/RevuoWidget.h b/src/widgets/RevuoWidget.h index 546148f..07bc424 100644 --- a/src/widgets/RevuoWidget.h +++ b/src/widgets/RevuoWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_REVUOWIDGET_H #define FEATHER_REVUOWIDGET_H diff --git a/src/widgets/TickerWidget.cpp b/src/widgets/TickerWidget.cpp index 63a2137..0a17e7b 100644 --- a/src/widgets/TickerWidget.cpp +++ b/src/widgets/TickerWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "TickerWidget.h" #include "ui_TickerWidget.h" diff --git a/src/widgets/TickerWidget.h b/src/widgets/TickerWidget.h index 752b9ba..7684586 100644 --- a/src/widgets/TickerWidget.h +++ b/src/widgets/TickerWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_TICKERWIDGET_H #define FEATHER_TICKERWIDGET_H diff --git a/src/widgets/XMRigWidget.cpp b/src/widgets/XMRigWidget.cpp index 22d9ef1..444b685 100644 --- a/src/widgets/XMRigWidget.cpp +++ b/src/widgets/XMRigWidget.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "XMRigWidget.h" #include "ui_XMRigWidget.h" diff --git a/src/widgets/XMRigWidget.h b/src/widgets/XMRigWidget.h index aa69d9d..f80ee28 100644 --- a/src/widgets/XMRigWidget.h +++ b/src/widgets/XMRigWidget.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_XMRIGWIDGET_H #define FEATHER_XMRIGWIDGET_H diff --git a/src/wizard/PageHardwareDevice.cpp b/src/wizard/PageHardwareDevice.cpp index 43ec9d2..a9f282e 100644 --- a/src/wizard/PageHardwareDevice.cpp +++ b/src/wizard/PageHardwareDevice.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageHardwareDevice.h" #include "ui_PageHardwareDevice.h" diff --git a/src/wizard/PageHardwareDevice.h b/src/wizard/PageHardwareDevice.h index 3d42970..d92df80 100644 --- a/src/wizard/PageHardwareDevice.h +++ b/src/wizard/PageHardwareDevice.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PAGEHARDWAREDEVICE_H #define FEATHER_PAGEHARDWAREDEVICE_H diff --git a/src/wizard/PageMenu.cpp b/src/wizard/PageMenu.cpp index 850478d..61bde47 100644 --- a/src/wizard/PageMenu.cpp +++ b/src/wizard/PageMenu.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletWizard.h" #include "PageMenu.h" diff --git a/src/wizard/PageMenu.h b/src/wizard/PageMenu.h index 6fe29e1..ba81f34 100644 --- a/src/wizard/PageMenu.h +++ b/src/wizard/PageMenu.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WIZARDMENU_H #define FEATHER_WIZARDMENU_H diff --git a/src/wizard/PageNetwork.cpp b/src/wizard/PageNetwork.cpp index 95bdae4..701ada8 100644 --- a/src/wizard/PageNetwork.cpp +++ b/src/wizard/PageNetwork.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageNetwork.h" #include "ui_PageNetwork.h" diff --git a/src/wizard/PageNetwork.h b/src/wizard/PageNetwork.h index eef597d..f07306c 100644 --- a/src/wizard/PageNetwork.h +++ b/src/wizard/PageNetwork.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WIZARDNETWORK_H #define FEATHER_WIZARDNETWORK_H diff --git a/src/wizard/PageNetworkTor.cpp b/src/wizard/PageNetworkTor.cpp index 31f06b8..cdf014e 100644 --- a/src/wizard/PageNetworkTor.cpp +++ b/src/wizard/PageNetworkTor.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageNetworkTor.h" #include "ui_PageNetworkTor.h" diff --git a/src/wizard/PageNetworkTor.h b/src/wizard/PageNetworkTor.h index 97132d2..63a486a 100644 --- a/src/wizard/PageNetworkTor.h +++ b/src/wizard/PageNetworkTor.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PAGENETWORKTOR_H #define FEATHER_PAGENETWORKTOR_H diff --git a/src/wizard/PageNetworkWebsocket.cpp b/src/wizard/PageNetworkWebsocket.cpp index f2b8a8b..6e2af53 100644 --- a/src/wizard/PageNetworkWebsocket.cpp +++ b/src/wizard/PageNetworkWebsocket.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageNetworkWebsocket.h" #include "ui_PageNetworkWebsocket.h" diff --git a/src/wizard/PageNetworkWebsocket.h b/src/wizard/PageNetworkWebsocket.h index 8428354..443e161 100644 --- a/src/wizard/PageNetworkWebsocket.h +++ b/src/wizard/PageNetworkWebsocket.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PAGENETWORKWEBSOCKET_H #define FEATHER_PAGENETWORKWEBSOCKET_H diff --git a/src/wizard/PageOpenWallet.cpp b/src/wizard/PageOpenWallet.cpp index d4b9a36..dbb82fb 100644 --- a/src/wizard/PageOpenWallet.cpp +++ b/src/wizard/PageOpenWallet.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageOpenWallet.h" #include "ui_PageOpenWallet.h" diff --git a/src/wizard/PageOpenWallet.h b/src/wizard/PageOpenWallet.h index e5da7ff..a39ec55 100644 --- a/src/wizard/PageOpenWallet.h +++ b/src/wizard/PageOpenWallet.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_OPENWALLET_H #define FEATHER_OPENWALLET_H diff --git a/src/wizard/PageSetPassword.cpp b/src/wizard/PageSetPassword.cpp index 7cd4500..28c9e3a 100644 --- a/src/wizard/PageSetPassword.cpp +++ b/src/wizard/PageSetPassword.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageSetPassword.h" #include "ui_PageSetPassword.h" diff --git a/src/wizard/PageSetPassword.h b/src/wizard/PageSetPassword.h index 9eaa710..12f2d06 100644 --- a/src/wizard/PageSetPassword.h +++ b/src/wizard/PageSetPassword.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PASSWORD_H #define FEATHER_PASSWORD_H diff --git a/src/wizard/PageSetRestoreHeight.cpp b/src/wizard/PageSetRestoreHeight.cpp index b5f44ca..db399d2 100644 --- a/src/wizard/PageSetRestoreHeight.cpp +++ b/src/wizard/PageSetRestoreHeight.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include #include "PageSetRestoreHeight.h" diff --git a/src/wizard/PageSetRestoreHeight.h b/src/wizard/PageSetRestoreHeight.h index 78dc03a..e7f0ff1 100644 --- a/src/wizard/PageSetRestoreHeight.h +++ b/src/wizard/PageSetRestoreHeight.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PAGESETRESTOREHEIGHT_H #define FEATHER_PAGESETRESTOREHEIGHT_H diff --git a/src/wizard/PageSetSeedPassphrase.cpp b/src/wizard/PageSetSeedPassphrase.cpp index 1d166be..5b08f5c 100644 --- a/src/wizard/PageSetSeedPassphrase.cpp +++ b/src/wizard/PageSetSeedPassphrase.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageSetSeedPassphrase.h" #include "ui_PageSetSeedPassphrase.h" diff --git a/src/wizard/PageSetSeedPassphrase.h b/src/wizard/PageSetSeedPassphrase.h index 919ed6b..bed1b92 100644 --- a/src/wizard/PageSetSeedPassphrase.h +++ b/src/wizard/PageSetSeedPassphrase.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_PAGESETSEEDPASSPHRASE_H #define FEATHER_PAGESETSEEDPASSPHRASE_H diff --git a/src/wizard/PageWalletFile.cpp b/src/wizard/PageWalletFile.cpp index 2edaecf..5bd4329 100644 --- a/src/wizard/PageWalletFile.cpp +++ b/src/wizard/PageWalletFile.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletWizard.h" #include "PageWalletFile.h" diff --git a/src/wizard/PageWalletFile.h b/src/wizard/PageWalletFile.h index d20be11..82e32bd 100644 --- a/src/wizard/PageWalletFile.h +++ b/src/wizard/PageWalletFile.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CREATEWALLET_H #define FEATHER_CREATEWALLET_H diff --git a/src/wizard/PageWalletRestoreKeys.cpp b/src/wizard/PageWalletRestoreKeys.cpp index b41abe3..df1c839 100644 --- a/src/wizard/PageWalletRestoreKeys.cpp +++ b/src/wizard/PageWalletRestoreKeys.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "PageWalletRestoreKeys.h" #include "ui_PageWalletRestoreKeys.h" diff --git a/src/wizard/PageWalletRestoreKeys.h b/src/wizard/PageWalletRestoreKeys.h index b3a5e2a..19ac3c0 100644 --- a/src/wizard/PageWalletRestoreKeys.h +++ b/src/wizard/PageWalletRestoreKeys.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WIZARDVIEWONLY_H #define FEATHER_WIZARDVIEWONLY_H diff --git a/src/wizard/PageWalletRestoreSeed.cpp b/src/wizard/PageWalletRestoreSeed.cpp index 6188389..5ff08bf 100644 --- a/src/wizard/PageWalletRestoreSeed.cpp +++ b/src/wizard/PageWalletRestoreSeed.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletWizard.h" #include "PageWalletRestoreSeed.h" diff --git a/src/wizard/PageWalletRestoreSeed.h b/src/wizard/PageWalletRestoreSeed.h index 0f448b8..fac2229 100644 --- a/src/wizard/PageWalletRestoreSeed.h +++ b/src/wizard/PageWalletRestoreSeed.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WIZARDRESTORE_H #define FEATHER_WIZARDRESTORE_H diff --git a/src/wizard/PageWalletSeed.cpp b/src/wizard/PageWalletSeed.cpp index 146b08e..0044ed0 100644 --- a/src/wizard/PageWalletSeed.cpp +++ b/src/wizard/PageWalletSeed.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "WalletWizard.h" #include "PageWalletSeed.h" diff --git a/src/wizard/PageWalletSeed.h b/src/wizard/PageWalletSeed.h index 926fdc6..8979478 100644 --- a/src/wizard/PageWalletSeed.h +++ b/src/wizard/PageWalletSeed.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_CREATEWALLETSEED_H #define FEATHER_CREATEWALLETSEED_H diff --git a/src/wizard/WalletWizard.cpp b/src/wizard/WalletWizard.cpp index 5abcb84..1c9dd0f 100644 --- a/src/wizard/WalletWizard.cpp +++ b/src/wizard/WalletWizard.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #include "utils/Utils.h" diff --git a/src/wizard/WalletWizard.h b/src/wizard/WalletWizard.h index c6da79e..e730053 100644 --- a/src/wizard/WalletWizard.h +++ b/src/wizard/WalletWizard.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2022 The Monero Project +// SPDX-FileCopyrightText: 2020-2023 The Monero Project #ifndef FEATHER_WALLETWIZARD_H #define FEATHER_WALLETWIZARD_H diff --git a/utils/build_macos.sh b/utils/build_macos.sh deleted file mode 100644 index 41399c3..0000000 --- a/utils/build_macos.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# Used for macos buildbot -HASH="$1" -echo "[+] hash: $HASH" - -echo "[+] Building" - -rm ~/feather.zip 2>&1 >/dev/null -cd ~/feather -git fetch --all -git reset --hard "$HASH" -git submodule update --init --depth 120 monero -git submodule update --init --depth 120 --recursive monero - -cp "/Users/administrator/tor/libevent-2.1.7.dylib" "/Users/administrator/feather/src/assets/exec/libevent-2.1.7.dylib" -CMAKE_PREFIX_PATH="~/Qt/5.15.1/clang_64" TOR_BIN="/Users/administrator/tor/tor" make -j3 mac-release - -if [[ $? -eq 0 ]]; then - echo "[+] Feather built OK" - cd ~/feather/build/bin - zip -qr ~/feather.zip feather.app -else - echo "[+] Error!" - exit 1; -fi