diff --git a/.github/actions/install-openwrt-sdk/action.yml b/.github/actions/install-openwrt-sdk/action.yml index b6c0f7fb..8cbea649 100644 --- a/.github/actions/install-openwrt-sdk/action.yml +++ b/.github/actions/install-openwrt-sdk/action.yml @@ -1,12 +1,15 @@ name: Download OpenWRT SDK -description: Download, extract and prepare OpenWRT SDK for specific target (architecture) +description: Download, extract and prepare OpenWRT SDK for specific target inputs: openwrt-version: required: true description: OpenWRT version - arch: + target: required: true - description: Target name + description: Target-subtarget pair + arch: + required: false + description: Archtecture name eabi: required: false description: EABI @@ -14,12 +17,12 @@ inputs: runs: using: composite steps: - - name: Restore OpenWRT SDK from cache + - name: Restore OpenWRT SDK from cache (${{ inputs.arch }}) id: cache-owrt-sdk-restore uses: actions/cache/restore@v3 with: path: owrtsdk - key: openwrt-sdk-${{ inputs.openwrt-version }}-${{ inputs.arch }} + key: openwrt-sdk-${{ inputs.openwrt-version }}-${{ inputs.target }} - name: Prepare OpenWRT SDK directory id: prepare-owrt-sdk-dir @@ -32,25 +35,25 @@ runs: if: steps.cache-owrt-sdk-restore.outputs.cache-hit != 'true' && inputs.eabi == 'true' shell: bash working-directory: owrtsdk - run: ${{ github.action_path }}/download-owrt-sdk.sh ${{ inputs.arch }} ${{ inputs.openwrt-version }} openwrt-sdk-${{ inputs.openwrt-version }}-${{ inputs.arch }}_gcc-11.2.0_musl_eabi.Linux-x86_64 + run: ${{ github.action_path }}/download-owrt-sdk.sh ${{ inputs.target }} ${{ inputs.openwrt-version }} openwrt-sdk-${{ inputs.openwrt-version }}-${{ inputs.target }}_gcc-11.2.0_musl_eabi.Linux-x86_64 - name: Download OpenWRT SDK id: download-owrt-sdk if: steps.cache-owrt-sdk-restore.outputs.cache-hit != 'true' && inputs.eabi != 'true' shell: bash working-directory: owrtsdk - run: ${{ github.action_path }}/download-owrt-sdk.sh ${{ inputs.arch }} ${{ inputs.openwrt-version }} openwrt-sdk-${{ inputs.openwrt-version }}-${{ inputs.arch }}_gcc-11.2.0_musl.Linux-x86_64 + run: ${{ github.action_path }}/download-owrt-sdk.sh ${{ inputs.target }} ${{ inputs.openwrt-version }} openwrt-sdk-${{ inputs.openwrt-version }}-${{ inputs.target }}_gcc-11.2.0_musl.Linux-x86_64 - name: Prepare OpenWRT SDK id: prepare-owrt-sdk if: steps.cache-owrt-sdk-restore.outputs.cache-hit != 'true' shell: bash - working-directory: owrtsdk/${{ inputs.arch }} + working-directory: owrtsdk/${{ inputs.target }} run: | ./scripts/feeds update -a ./scripts/feeds install -a - - name: Cache OpenWRT SDK + - name: Cache OpenWRT SDK (${{ inputs.arch }}) id: cache-owrt-sdk-save if: steps.cache-owrt-sdk-restore.outputs.cache-hit != 'true' uses: actions/cache/save@v3 diff --git a/.github/actions/install-required-packages/action.yml b/.github/actions/install-required-packages/action.yml index 4957cce4..7b6f919c 100644 --- a/.github/actions/install-required-packages/action.yml +++ b/.github/actions/install-required-packages/action.yml @@ -7,13 +7,9 @@ runs: uses: awalsh128/cache-apt-pkgs-action@latest with: packages: | - git curl wget - bison flex - build-essential pkg-config automake libtool libtool-bin autoconf - libncurses5-dev libssl-dev libxml2-dev libnewt-dev libsqlite3-dev - unixodbc-dev uuid-dev libsystemd-dev - libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev - libspandsp-dev libedit-dev libjansson-dev libspeexdsp-dev libopus-dev libopusfile-dev + git wget + build-essential + libasound2-dev libsqlite3-dev asterisk-dev - name: Git configuration shell: bash diff --git a/.github/workflows/cross-compile.yml b/.github/workflows/cross-compile.yml new file mode 100644 index 00000000..730f2040 --- /dev/null +++ b/.github/workflows/cross-compile.yml @@ -0,0 +1,81 @@ +name: Cross compile + +on: + workflow_dispatch: + push: + branches: + - master + - cross-compile + +env: + BUILD_TYPE: Release + UBUNTU_DISTRO: ubuntu22.04 + +jobs: + build-pkg: + strategy: + matrix: + arch: [armv7, aarch64] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: uraimo/run-on-arch-action@v2 + name: Build package (${{ matrix.arch }}) + with: + arch: ${{ matrix.arch }} + distro: ${{ env.UBUNTU_DISTRO }} + githubToken: ${{ github.token }} + install: | + apt-get update -qq -y + apt-get install -qq -y git cmake \ + build-essential \ + libsqlite3-dev libasound2-dev asterisk-dev + git config --global --add safe.directory /home/runner/work/asterisk-chan-quectel/asterisk-chan-quectel + env: | + DEBIAN_FRONTEND: noninteractive + run: | + cmake -P make-build-dir.cmake + cmake -P make-package.cmake + - uses: ./.github/actions/install-required-packages + - name: Install lintian + env: + DEBIAN_FRONTEND: noninteractive + run: sudo apt-get install -qq -y lintian + - name: Check package + run: lintian --verbose --info package/asterisk-chan-quectel_*.deb + - name: Archive DEB + uses: actions/upload-artifact@v3 + with: + name: pkg-deb-${{ matrix.arch }} + path: | + package/asterisk-chan-quectel_*.deb + package/asterisk-chan-quectel_*.deb.sha256 + retention-days: 1 + if-no-files-found: error + - name: Archive TAR.GZ + uses: actions/upload-artifact@v3 + with: + name: pkg-tar-gz-${{ matrix.arch }} + path: | + package/asterisk-chan-quectel_*.tar.gz + package/asterisk-chan-quectel_*.tar.gz.sha256 + retention-days: 1 + if-no-files-found: error + - uses: uraimo/run-on-arch-action@v2 + name: Try to instal package (${{ matrix.arch }}) + with: + arch: ${{ matrix.arch }} + distro: ${{ env.UBUNTU_DISTRO }} + setup: | + mkdir -p "${PWD}/package" + dockerRunArgs: | + --volume "${PWD}/package:/package" + install: | + apt-get update -qq -y + apt-get install -qq -y gdebi-core + env: | + DEBIAN_FRONTEND: noninteractive + run: | + gdebi --non-interactive package/asterisk-chan-quectel_*.deb || echo "::error::Could not install package ${{ matrix.arch }}" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ecdd3f87..e90d8a5e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ on: env: BUILD_TYPE: Release OWRTVER: 22.03.5 - ASTVER: 18 + UBUNTU_DISTRO: ubuntu22.04 jobs: pre-build: @@ -28,9 +28,6 @@ jobs: sparse-checkout: .github/actions sparse-checkout-cone-mode: false - uses: ./.github/actions/install-required-packages - - uses: ./.github/actions/install-asterisk-headers - with: - asterisk-version: ${{ env.ASTVER }} build-deb-pkg: needs: pre-build @@ -44,19 +41,12 @@ jobs: env: DEBIAN_FRONTEND: noninteractive run: sudo apt-get install -qq lintian - - uses: ./.github/actions/install-asterisk-headers - with: - asterisk-version: ${{ env.ASTVER }} - - name: Configure project run: cmake -P make-build-dir.cmake - - name: Build packages run: cmake -P make-package.cmake - - name: Check package run: lintian --verbose --info package/asterisk-chan-quectel_*.deb - - name: Archive DEB uses: actions/upload-artifact@v3 with: @@ -66,7 +56,6 @@ jobs: package/asterisk-chan-quectel_*.deb.sha256 retention-days: 1 if-no-files-found: error - - name: Archive TAR.GZ uses: actions/upload-artifact@v3 with: @@ -94,24 +83,128 @@ jobs: run: | for p in $(ls *.deb); do echo "::notice::Installing package $p" - sudo gdebi --non-interactive $p + sudo gdebi --non-interactive $p || echo "::error::Could not install package $p" done + build-deb-pkg-arch: + needs: pre-build + strategy: + matrix: + arch: [armv7, aarch64] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: ./.github/actions/install-required-packages + - uses: uraimo/run-on-arch-action@v2 + name: Build package (${{ matrix.arch }}) + with: + arch: ${{ matrix.arch }} + distro: ${{ env.UBUNTU_DISTRO }} + githubToken: ${{ github.token }} + install: | + apt-get update -qq -y + apt-get install -qq -y git cmake \ + build-essential \ + libsqlite3-dev libasound2-dev asterisk-dev + git config --global --add safe.directory /home/runner/work/asterisk-chan-quectel/asterisk-chan-quectel + env: | + DEBIAN_FRONTEND: noninteractive + run: | + cmake -P make-build-dir.cmake + cmake -P make-package.cmake + - name: Install lintian + env: + DEBIAN_FRONTEND: noninteractive + run: sudo apt-get install -qq -y lintian + - name: Check package + run: lintian --verbose --info package/asterisk-chan-quectel_*.deb + - name: Archive DEB + uses: actions/upload-artifact@v3 + with: + name: pkg-deb-${{ matrix.arch }} + path: | + package/asterisk-chan-quectel_*.deb + package/asterisk-chan-quectel_*.deb.sha256 + retention-days: 1 + if-no-files-found: error + - name: Archive TAR.GZ + uses: actions/upload-artifact@v3 + with: + name: pkg-tar-gz-${{ matrix.arch }} + path: | + package/asterisk-chan-quectel_*.tar.gz + package/asterisk-chan-quectel_*.tar.gz.sha256 + retention-days: 1 + if-no-files-found: error + - uses: uraimo/run-on-arch-action@v2 + name: Try to instal package (${{ matrix.arch }}) + with: + arch: ${{ matrix.arch }} + distro: ${{ env.UBUNTU_DISTRO }} + setup: | + mkdir -p "${PWD}/package" + dockerRunArgs: | + --volume "${PWD}/package:/package" + install: | + apt-get update -qq -y + apt-get install -qq -y gdebi-core + env: | + DEBIAN_FRONTEND: noninteractive + run: | + for p in $(ls package/*.deb); do + pn=$(basename $p) + echo "::notice::Installing package $pn" + gdebi --non-interactive $p || echo "::error::Could not install package $pn" + done + build-openwrt-pkg: runs-on: ubuntu-latest needs: pre-build strategy: matrix: - arch: [x86-64, x86-generic, ramips-mt7620, bcm47xx-generic, bcm63xx-generic, sunxi-cortexa7, sunxi-cortexa8, sunxi-cortexa53, armvirt-32, rockchip-armv8, bcm27xx-bcm2708] include: - - arch: sunxi-cortexa7 + - target: x86-64 + arch: x86_64 + - target: x86-generic + arch: i386 + cpu-type: pentium4 + - target: ramips-mt7620 + arch: mipsel + cpu-type: 24kc + - target: bcm47xx-generic + arch: mipsel + cpu-type: mips32 + - target: bcm63xx-generic + arch: mips + cpu-type: mips32 + - target: armvirt-32 + arch: arm + cpu-type: cortex-a15 + cpu-subtype: neon-vfpv4 eabi: true - - arch: sunxi-cortexa8 + - target: rockchip-armv8 + arch: aarch64 + cpu-type: generic + - target: bcm27xx-bcm2708 + arch: arm + cpu-type: arm1176jzf-s + cpu-subtype: vfp eabi: true - - arch: bcm27xx-bcm2708 + - target: sunxi-cortexa7 + arch: arm + cpu-type: cortex-a7 + cpu-subtype: neon-vfpv4 eabi: true - - arch: armvirt-32 + - target: sunxi-cortexa8 + arch: arm + cpu-type: cortex-a8 + cpu-subtype: vfpv3 eabi: true + - target: sunxi-cortexa53 + arch: aarch64 + cpu-type: cortex-a53 steps: - name: Checkout actions uses: actions/checkout@v3 @@ -120,55 +213,46 @@ jobs: .github/actions sparse-checkout-cone-mode: false - uses: ./.github/actions/install-required-packages - - uses: ./.github/actions/install-asterisk-headers - with: - asterisk-version: ${{ env.ASTVER }} - uses: ./.github/actions/install-openwrt-sdk with: openwrt-version: ${{ env.OWRTVER }} + target: ${{ matrix.target }} arch: ${{ matrix.arch }} eabi: ${{ matrix.eabi }} - uses: actions/checkout@v3 with: fetch-depth: 0 path: asterisk-modules/asterisk-chan-quectel - - name: Configure project run: cmake -P asterisk-modules/asterisk-chan-quectel/make-build-dir.cmake - - name: Generate OpenWRT Makefile run: cmake -P asterisk-modules/asterisk-chan-quectel/install-openwrt-makefile.cmake - - - name: Check OpenWRT SDK config file + - name: Check OpenWRT SDK config file existience id: check-owrt-cfg uses: andstor/file-existence-action@v2 with: - files: "owrtsdk/${{ matrix.arch }}/.config" - + files: "owrtsdk/${{ matrix.target }}/.config" - name: Prepare OpenWRT SDK (symlink) run: | owrtsdk=$(cd owrtsdk; pwd) cd asterisk-modules/asterisk-chan-quectel/install/openwrt - ln -sf ${owrtsdk}/${{ matrix.arch }} ${{ matrix.arch }} - + ln -sf ${owrtsdk}/${{ matrix.target }} ${{ matrix.target }} - name: Prepare OpenWRT SDK (files) if: steps.check-owrt-cfg.outputs.files_exists != 'true' working-directory: asterisk-modules/asterisk-chan-quectel/install/openwrt - run: cp feeds-strskx.conf diffconfig build-opk.sh ${{ matrix.arch }} - + run: cp feeds-strskx.conf diffconfig build-opk.sh ${{ matrix.target }} - name: Prepare OpenWRT SDK (feeds) if: steps.check-owrt-cfg.outputs.files_exists == 'true' - working-directory: asterisk-modules/asterisk-chan-quectel/install/openwrt/${{ matrix.arch }} + working-directory: asterisk-modules/asterisk-chan-quectel/install/openwrt/${{ matrix.target }} run: ./scripts/feeds install asterisk-chan-quectel - - name: Build OpenWRT packages - working-directory: asterisk-modules/asterisk-chan-quectel/install/openwrt/${{ matrix.arch }} + working-directory: asterisk-modules/asterisk-chan-quectel/install/openwrt/${{ matrix.target }} run: ./build-opk.sh - name: Archive IPK uses: actions/upload-artifact@v3 with: - name: ipk-${{ matrix.arch }} - path: asterisk-modules/asterisk-chan-quectel/install/openwrt/${{ matrix.arch }}/bin/packages/*/strskx/*.ipk + name: pkg-ipk-${{ format('{0}{1}{2}', matrix.arch, matrix.cpu-type && format('_{0}', matrix.cpu-type) || '', matrix.cpu-subtype && format('_{0}', matrix.cpu-subtype) || '') }} + path: asterisk-modules/asterisk-chan-quectel/install/openwrt/${{ matrix.target }}/bin/packages/*/strskx/*.ipk retention-days: 1 if-no-files-found: error @@ -176,12 +260,10 @@ jobs: runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - needs: [build-openwrt-pkg, deb-pkg-try-install] + needs: [build-openwrt-pkg, deb-pkg-try-install, build-deb-pkg-arch] if: startsWith(github.ref, 'refs/tags/') steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - + - uses: actions/download-artifact@v3 - name: Publish packages uses: softprops/action-gh-release@v1 with: diff --git a/CMakePresets.json b/CMakePresets.json index 55339dad..df2e8ca3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -83,6 +83,36 @@ "environment": { "CMAKE_INSTALL_MODE": "COPY" } + }, + { + "name": "arm", + "inherits": "default", + "toolchainFile": "${sourceDir}/cmake/toolchain/arm-linux-gnueabihf.toolchain.cmake", + "cacheVariables" : { + "CPACK_PACKAGE_ARCHITECTURE": { + "type": "STRING", + "value": "armhf" + }, + "CPACK_DEBIAN_PACKAGE_ARCHITECTURE": { + "type": "STRING", + "value": "armhf" + } + } + }, + { + "name": "arm64", + "inherits": "default", + "toolchainFile": "${sourceDir}/cmake/toolchain/aarch64-linux-gnu.toolchain.cmake", + "cacheVariables" : { + "CPACK_PACKAGE_ARCHITECTURE": { + "type": "STRING", + "value": "arm64" + }, + "CPACK_DEBIAN_PACKAGE_ARCHITECTURE": { + "type": "STRING", + "value": "arm64" + } + } } ], "buildPresets": [ @@ -91,12 +121,36 @@ "configurePreset": "default", "jobs": 0 }, + { + "name": "arm", + "configurePreset": "arm", + "jobs": 0 + }, + { + "name": "arm64", + "configurePreset": "arm64", + "jobs": 0 + }, { "name": "package", "configurePreset": "default", "jobs": 0, "cleanFirst": true, "targets": "package" - } + }, + { + "name": "package-arm", + "configurePreset": "arm", + "jobs": 0, + "cleanFirst": true, + "targets": "package" + }, + { + "name": "package-arm64", + "configurePreset": "arm64", + "jobs": 0, + "cleanFirst": true, + "targets": "package" + } ] } diff --git a/cmake/toolchain/aarch64-linux-gnu.toolchain.cmake b/cmake/toolchain/aarch64-linux-gnu.toolchain.cmake new file mode 100644 index 00000000..b7c8f8b6 --- /dev/null +++ b/cmake/toolchain/aarch64-linux-gnu.toolchain.cmake @@ -0,0 +1,40 @@ +# +# aarch64-linux-gnu.toolchain.cmake +# +# Required packages: +# g++-aarch64-linux-gnu +# binutils-aarch64-linux-gnu +# +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(triple arm-linux-aarch64) + +# Without that flag CMake is not able to pass test compilation check +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_AR aarch64-linux-gnu-ar${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_ASM_COMPILER aarch64-linux-gnu-gcc${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_C_COMPILER_TARGET ${triple}) +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_CXX_COMPILER_TARGET ${triple}) +set(CMAKE_LINKER aarch64-linux-gnu-ld${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_OBJCOPY aarch64-linux-gnu-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_RANLIB aarch64-linux-gnu-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_SIZE aarch64-linux-gnu-size${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_STRIP aarch64-linux-gnu-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_GCOV aarch64-linux-gnu-gcov${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") + +set(CMAKE_C_FLAGS "-march=armv8-a -Wno-psabi" CACHE INTERNAL "") +set(CMAKE_CXX_FLAGS "-march=armv8-a" CACHE INTERNAL "") + +set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "") +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE INTERNAL "") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE INTERNAL "") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE INTERNAL "") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/toolchain/arm-linux-gnueabihf.toolchain.cmake b/cmake/toolchain/arm-linux-gnueabihf.toolchain.cmake new file mode 100644 index 00000000..9aa8282d --- /dev/null +++ b/cmake/toolchain/arm-linux-gnueabihf.toolchain.cmake @@ -0,0 +1,40 @@ +# +# arm-linux-gnueabihf.toolchain.cmake +# +# Required packages: +# g++-arm-linux-gnueabihf +# binutils-arm-linux-gnueabihf +# +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(triple arm-linux-gnueabihf) + +# Without that flag CMake is not able to pass test compilation check +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) + +set(CMAKE_AR arm-linux-gnueabihf-ar${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_ASM_COMPILER arm-linux-gnueabihf-gcc${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_C_COMPILER_TARGET ${triple}) +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_CXX_COMPILER_TARGET ${triple}) +set(CMAKE_LINKER arm-linux-gnueabihf-ld${CMAKE_EXECUTABLE_SUFFIX}) +set(CMAKE_OBJCOPY arm-linux-gnueabihf-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_RANLIB arm-linux-gnueabihf-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_SIZE arm-linux-gnueabihf-size${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_STRIP arm-linux-gnueabihf-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") +set(CMAKE_GCOV arm-linux-gnueabihf-gcov${CMAKE_EXECUTABLE_SUFFIX} CACHE INTERNAL "") + +set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon -Wno-psabi" CACHE INTERNAL "") +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon -Wno-psabi" CACHE INTERNAL "") + +set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "") +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE INTERNAL "") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE INTERNAL "") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE INTERNAL "") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/install-chan-quectel.cmake b/install-chan-quectel.cmake index 19644d48..ec418dc8 100755 --- a/install-chan-quectel.cmake +++ b/install-chan-quectel.cmake @@ -1,10 +1,20 @@ #!/usr/bin/cmake -P +IF(NOT DEFINED CMAKE_ARGV3) + SET(PRESET_NAME "build") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm") + SET(PRESET_NAME "build-arm") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm64") + SET(PRESET_NAME "build-arm64") +ELSE() + MESSAGE(FATAL_ERROR "Unknown architecture: ${CMAKE_ARGV3}") +ENDIF() + CMAKE_PATH(GET CMAKE_SCRIPT_MODE_FILE PARENT_PATH SCRIPT_DIR) SET(ENV{DESTDIR} ${SCRIPT_DIR}/install/chan-quectel) EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} --install build --component chan-quectel --prefix=/usr + COMMAND ${CMAKE_COMMAND} --install ${PRESET_NAME} --component chan-quectel --prefix=/usr WORKING_DIRECTORY ${SCRIPT_DIR} COMMAND_ERROR_IS_FATAL ANY ) diff --git a/install-openwrt-makefile.cmake b/install-openwrt-makefile.cmake index c7d400e8..8e398a73 100755 --- a/install-openwrt-makefile.cmake +++ b/install-openwrt-makefile.cmake @@ -1,10 +1,20 @@ #!/usr/bin/cmake -P +IF(NOT DEFINED CMAKE_ARGV3) + SET(PRESET_NAME "build") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm") + SET(PRESET_NAME "build-arm") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm64") + SET(PRESET_NAME "build-arm64") +ELSE() + MESSAGE(FATAL_ERROR "Unknown architecture: ${CMAKE_ARGV3}") +ENDIF() + CMAKE_PATH(GET CMAKE_SCRIPT_MODE_FILE PARENT_PATH SCRIPT_DIR) SET(ENV{DESTDIR} ${SCRIPT_DIR}/install) EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} --install build --component openwrt --prefix=/ + COMMAND ${CMAKE_COMMAND} --install ${PRESET_NAME} --component openwrt --prefix=/ WORKING_DIRECTORY ${SCRIPT_DIR} COMMAND_ERROR_IS_FATAL ANY ) diff --git a/make-build-dir.cmake b/make-build-dir.cmake index 22cb1ce6..5d839517 100755 --- a/make-build-dir.cmake +++ b/make-build-dir.cmake @@ -1,9 +1,19 @@ #!/usr/bin/cmake -P +IF(NOT DEFINED CMAKE_ARGV3) + SET(PRESET_NAME "default") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm") + SET(PRESET_NAME "arm") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm64") + SET(PRESET_NAME "arm64") +ELSE() + MESSAGE(FATAL_ERROR "Unknown architecture: ${CMAKE_ARGV3}") +ENDIF() + CMAKE_PATH(GET CMAKE_SCRIPT_MODE_FILE PARENT_PATH SCRIPT_DIR) EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} --preset default + COMMAND ${CMAKE_COMMAND} --preset ${PRESET_NAME} WORKING_DIRECTORY ${SCRIPT_DIR} COMMAND_ERROR_IS_FATAL ANY ) diff --git a/make-package.cmake b/make-package.cmake index 281df0dc..e9303a63 100755 --- a/make-package.cmake +++ b/make-package.cmake @@ -1,9 +1,19 @@ #!/usr/bin/cmake -P +IF(NOT DEFINED CMAKE_ARGV3) + SET(PRESET_NAME "package") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm") + SET(PRESET_NAME "package-arm") +ELSEIF(${CMAKE_ARGV3} STREQUAL "arm64") + SET(PRESET_NAME "package-arm64") +ELSE() + MESSAGE(FATAL_ERROR "Unknown architecture: ${CMAKE_ARGV3}") +ENDIF() + CMAKE_PATH(GET CMAKE_SCRIPT_MODE_FILE PARENT_PATH SCRIPT_DIR) EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} --build --preset package + COMMAND ${CMAKE_COMMAND} --build --preset ${PRESET_NAME} WORKING_DIRECTORY ${SCRIPT_DIR} COMMAND_ERROR_IS_FATAL ANY ) diff --git a/src/channel.c b/src/channel.c index 3ca83254..b475145b 100644 --- a/src/channel.c +++ b/src/channel.c @@ -524,7 +524,7 @@ static ssize_t iov_write(struct pvt* pvt, int fd, const struct iovec* const iov, return -err; } else if (w && w != len) { - ast_log(LOG_WARNING, "[%s][TTY] Incomplete frame written: %ld/%ld\n", PVT_ID(pvt), w, len); + ast_log(LOG_WARNING, "[%s][TTY] Incomplete frame written: %ld/%ld\n", PVT_ID(pvt), (long)w, (long)len); } return w;