From ad3fb837e44715e5606ebbfba15f624eeb67a48e Mon Sep 17 00:00:00 2001 From: tytan652 Date: Wed, 19 Apr 2023 19:39:15 +0200 Subject: [PATCH 1/2] deps.macos: Add Libqrcodegencpp to macOS deps https://github.com/nayuki/QR-Code-generator C++ implementation tweaked to be shipped as libraries. --- deps.macos/80-qrcodegencpp.zsh | 109 ++++++++++++++++++ .../QR-Code-generator/Readme.markdown | 91 +++++++++++++++ licenses/qrcodegencpp/qrcodegen-cmake/LICENSE | 21 ++++ 3 files changed, 221 insertions(+) create mode 100644 deps.macos/80-qrcodegencpp.zsh create mode 100644 licenses/qrcodegencpp/QR-Code-generator/Readme.markdown create mode 100644 licenses/qrcodegencpp/qrcodegen-cmake/LICENSE diff --git a/deps.macos/80-qrcodegencpp.zsh b/deps.macos/80-qrcodegencpp.zsh new file mode 100644 index 000000000..94ea84af0 --- /dev/null +++ b/deps.macos/80-qrcodegencpp.zsh @@ -0,0 +1,109 @@ +autoload -Uz log_debug log_error log_info log_status log_output + +## Dependency Information +local name='qrcodegencpp' +local version='1.8.0' +local url='https://github.com/nayuki/QR-Code-generator.git' +local hash='720f62bddb7226106071d4728c292cb1df519ceb' +local url_cmake='https://github.com/EasyCoding/qrcodegen-cmake.git' +local hash_cmake='c57623d48a2d422b0f908dcf22d56d603e56c0e4' + +## Build Steps +setup() { + log_info "Setup (%F{3}${target}%f)" + setup_dep ${url} ${hash} + + mkdir -p qrcodegen-cmake-${version} + pushd qrcodegen-cmake-${version} + dep_checkout ${url_cmake} ${hash_cmake} + popd +} + +clean() { + cd ${dir} + + if [[ ${clean_build} -gt 0 && -d build_${arch} ]] { + log_info "Clean build directory (%F{3}${target}%f)" + + rm -rf build_${arch} + } +} + +patch() { + autoload -Uz apply_patch + + log_info "Patch (%F{3}${target}%f)" + + cd ${dir} + + cp -R qrcodegen-cmake-${version}/(cmake|CMakeLists.txt) . +} + +config() { + autoload -Uz mkcd progress + + log_info "Config (%F{3}${target}%f)" + + local _onoff=(OFF ON) + + args=( + ${cmake_flags} + -DBUILD_SHARED_LIBS="${_onoff[(( shared_libs + 1 ))]}" + ) + + cd ${dir} + log_debug "CMake configure options: ${args}" + progress cmake -S . -B build_${arch} -G Ninja ${args} +} + +build() { + autoload -Uz mkcd + + log_info "Build (%F{3}${target}%f)" + + cd ${dir} + cmake --build build_${arch} --config ${config} +} + +install() { + autoload -Uz progress + + log_info "Install (%F{3}${target}%f)" + + args=( + --install "build_${arch}" + --config "${config}" + ) + + cd ${dir} + progress cmake ${args} +} + +fixup() { + cd ${dir} + + log_info "Fixup (%F{3}${target}%f)" + + rm -rf ${target_config[output_dir]}/include/qrcodegen + rm -rf ${target_config[output_dir]}/lib/cmake/qrcodegen + rm -rf ${target_config[output_dir]}/lib/pkgconfig/qrcodegen.pc + rm -rf ${target_config[output_dir]}/lib/libqrcodegen.* + + if (( shared_libs )) { + local -a dylib_files=(${target_config[output_dir]}/lib/libqrcodegencpp*.dylib(.)) + + autoload -Uz fix_rpaths + fix_rpaths ${dylib_files} + + if [[ ${config} == (Release|MinSizeRel) ]] { + dsymutil ${dylib_files} + strip -x ${dylib_files} + } + + for file (${target_config[output_dir]}/lib/cmake/qrcodegencpp/qrcodegencpp-targets-*.cmake) { + sed -i '' 's/libqrcodegencpp.*.dylib/libqrcodegencpp.dylib/' "${file}" + } + } else { + rm -rf -- ${target_config[output_dir]}/lib/libqrcodegencpp*.(dylib|dSYM)(N) + } +} diff --git a/licenses/qrcodegencpp/QR-Code-generator/Readme.markdown b/licenses/qrcodegencpp/QR-Code-generator/Readme.markdown new file mode 100644 index 000000000..66292b4b9 --- /dev/null +++ b/licenses/qrcodegencpp/QR-Code-generator/Readme.markdown @@ -0,0 +1,91 @@ +QR Code generator library +========================= + + +Introduction +------------ + +This project aims to be the best, clearest QR Code generator library in multiple languages. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments. + +Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: [https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library) + + +Features +-------- + +Core features: + +* Available in 6 programming languages, all with nearly equal functionality: Java, TypeScript/JavaScript, Python, Rust, C++, C +* Significantly shorter code but more documentation comments compared to competing libraries +* Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard +* Output format: Raw modules/pixels of the QR symbol +* Detects finder-like penalty patterns more accurately than other implementations +* Encodes numeric and special-alphanumeric text in less space than general text +* Open-source code under the permissive MIT License + +Manual parameters: + +* User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data +* User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one +* User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number +* User can create a list of data segments manually and add ECI segments + +Optional advanced features (Java only): + +* Encodes Japanese Unicode text in kanji mode to save a lot of space compared to UTF-8 bytes +* Computes optimal segment mode switching for text with mixed numeric/alphanumeric/general/kanji parts + +More information about QR Code technology and this library's design can be found on the project home page. + + +Examples +-------- + +The code below is in Java, but the other language ports are designed with essentially the same API naming and behavior. + +```java +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.List; +import javax.imageio.ImageIO; +import io.nayuki.qrcodegen.*; + +// Simple operation +QrCode qr0 = QrCode.encodeText("Hello, world!", QrCode.Ecc.MEDIUM); +BufferedImage img = toImage(qr0, 4, 10); // See QrCodeGeneratorDemo +ImageIO.write(img, "png", new File("qr-code.png")); + +// Manual operation +List segs = QrSegment.makeSegments("3141592653589793238462643383"); +QrCode qr1 = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, 5, 5, 2, false); +for (int y = 0; y < qr1.size; y++) { + for (int x = 0; x < qr1.size; x++) { + (... paint qr1.getModule(x, y) ...) + } +} +``` + + +License +------- + +Copyright © 2022 Project Nayuki. (MIT License) +[https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library) + +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. diff --git a/licenses/qrcodegencpp/qrcodegen-cmake/LICENSE b/licenses/qrcodegencpp/qrcodegen-cmake/LICENSE new file mode 100644 index 000000000..87ce1b09d --- /dev/null +++ b/licenses/qrcodegencpp/qrcodegen-cmake/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2022 EasyCoding Team and contributors + +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. From 8f6f8164d814eb34d1d2684c4526d9b06f7b1210 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Wed, 19 Apr 2023 22:08:10 +0200 Subject: [PATCH 2/2] deps.windows: Add Lidqrcodegencpp to Windows deps https://github.com/nayuki/QR-Code-generator C++ implementation tweaked to be shipped as libraries. --- deps.windows/60-qrcodegencpp.ps1 | 111 +++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 deps.windows/60-qrcodegencpp.ps1 diff --git a/deps.windows/60-qrcodegencpp.ps1 b/deps.windows/60-qrcodegencpp.ps1 new file mode 100644 index 000000000..078949d57 --- /dev/null +++ b/deps.windows/60-qrcodegencpp.ps1 @@ -0,0 +1,111 @@ +param( + [string] $Name = 'qrcodegencpp', + [string] $Version = '1.8.0', + [string] $Uri = 'https://github.com/nayuki/QR-Code-generator.git', + [string] $Hash = '720f62bddb7226106071d4728c292cb1df519ceb', + [string] $UriCMake = 'https://github.com/EasyCoding/qrcodegen-cmake.git', + [string] $HashCMake = 'c57623d48a2d422b0f908dcf22d56d603e56c0e4' +) + +function Setup { + Setup-Dependency -Uri $Uri -Hash $Hash -DestinationPath "$Path/src" + Setup-Dependency -Uri $UriCMake -Hash $HashCMake -DestinationPath "$Path/qrcodegen-cmake" +} + +function Clean { + Set-Location "$Path/src" + + if ( Test-Path "build_${Target}" ) { + Log-Information "Clean build directory (${Target})" + Remove-Item -Path "build_${Target}" -Recurse -Force + } +} + +function Patch { + Log-Information "Patch (${Target})" + Set-Location $Path + + $Items = @( + @{ + Path = "qrcodegen-cmake/CMakeLists.txt" + Destination = "src" + ErrorAction = 'SilentlyContinue' + } + @{ + Path = "qrcodegen-cmake/cmake" + Destination = "src" + Recurse = $true + ErrorAction = 'SilentlyContinue' + } + ) + + $Items | ForEach-Object { + $Item = $_ + Copy-Item @Item + } +} + +function Configure { + Log-Information "Configure (${Target})" + Set-Location "$Path/src" + + $OnOff = @('OFF', 'ON') + $Options = @( + $CmakeOptions + "-DBUILD_SHARED_LIBS:BOOL=$($OnOff[$script:Shared.isPresent])" + ) + + Invoke-External cmake -S . -B "build_${Target}" @Options +} + +function Build { + Log-Information "Build (${Target})" + Set-Location "$Path/src" + + $Options = @( + '--build', "build_${Target}" + '--config', $Configuration + ) + + if ( $VerbosePreference -eq 'Continue' ) { + $Options += '--verbose' + } + + Invoke-External cmake @Options +} + +function Install { + Log-Information "Install (${Target})" + Set-Location "$Path/src" + + $Options = @( + '--install', "build_${Target}" + '--config', $Configuration + ) + + if ( $Configuration -match "(Release|MinSizeRel)" ) { + $Options += '--strip' + } + + Invoke-External cmake @Options +} + +function Fixup { + Log-Information "Fixup (${Target})" + Set-Location $Path + + $Items = @( + @{ FullPath = "$($ConfigData.OutputPath)/include/qrcodegen" } + @{ FullPath = "$($ConfigData.OutputPath)/lib/cmake/qrcodegen" } + @{ FullPath = "$($ConfigData.OutputPath)/lib/pkgconfig/qrcodegen.pc" } + @{ FullPath = "$($ConfigData.OutputPath)/lib/qrcodegen.*" } + @{ FullPath = "$($ConfigData.OutputPath)/bin/qrcodegen.*" } + ) + + $Items | ForEach-Object { + $Item = $_ + if ( Test-Path $Item.FullPath ) { + Remove-Item -Recurse -Force $Item.FullPath + } + } +}