conan error:I need to cross build packages for os:iOS with my Macos, but when the first package was done, it broke my cpt while testing
conan error:I need to cross build packages for os:iOS with my Macos, but when the first package was done, it broke my cpt while testing
我想使用 cpt 与 arch "armv7"、"armv8"、"x86_64" 和 build_type [=31] 交叉构建几个 iOS 包=]、"Release"。但是当第一个包正在测试时,它用“/bin/sh: bin/test_package: Bad CPU type in executable” 破坏了我的建筑。我知道我不能在我的 x86_64 主机架构上 运行 armv7,但我不希望我的构建计划失败。如何在不测试包或不成功测试我的包的情况下继续我的构建。
我已经检查了我的目录 test_package 中的 CMakeLists.txt 和 conanfile.py,但我不知道如何解决这个问题。
这是 test_package
中 conanfile.py 的一部分
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
with tools.environment_append(RunEnvironment(self).vars):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
这是我在 test_package
中的 CMakeLists.txt
project(test_package)
cmake_minimum_required(VERSION 2.8.11)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
这是我的一部分build.py
builder = ConanMultiPackager()
# add builder settings with the arch and type of build
def add_builder_settings(arch, build_type):
requires = {"*": ["darwin-toolchain/1.0.4@theodelrieu/testing"]}
options = {"darwin-toolchain:bitcode": False}
builder.add(settings={"os": "iOS", "arch": arch, "build_type": build_type, "os.version": "10.0", "compiler": "apple-clang"},
build_requires=requires, options=options)
# add build settings for iOS
add_builder_settings("armv7", "Debug")
add_builder_settings("armv7", "Release")
add_builder_settings("armv8", "Debug")
add_builder_settings("armv8", "Release")
add_builder_settings("x86_64", "Debug")
add_builder_settings("x86_64", "Release")
这是我的错误报告
libx264/20171211@username/stable (test package): Running test()
/bin/sh: bin/test_package: Bad CPU type in executable
我想用一个 build.py 构建 6 种类型的包。但是它只构建了一个包就失败了。
为避免test_package交叉构建时执行,强烈推荐Bincrafters思路:
from conans import ConanFile, CMake, tools
import os
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
这里的想法是跳过执行,柯南检测到 arch != build_arch.
您可以在这里查看原始代码:
https://github.com/bincrafters/templates/blob/master/default/test_package/conanfile.py#L15
我想使用 cpt 与 arch "armv7"、"armv8"、"x86_64" 和 build_type [=31] 交叉构建几个 iOS 包=]、"Release"。但是当第一个包正在测试时,它用“/bin/sh: bin/test_package: Bad CPU type in executable” 破坏了我的建筑。我知道我不能在我的 x86_64 主机架构上 运行 armv7,但我不希望我的构建计划失败。如何在不测试包或不成功测试我的包的情况下继续我的构建。
我已经检查了我的目录 test_package 中的 CMakeLists.txt 和 conanfile.py,但我不知道如何解决这个问题。
这是 test_package
中 conanfile.py 的一部分def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
with tools.environment_append(RunEnvironment(self).vars):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
这是我在 test_package
中的 CMakeLists.txtproject(test_package)
cmake_minimum_required(VERSION 2.8.11)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
这是我的一部分build.py
builder = ConanMultiPackager()
# add builder settings with the arch and type of build
def add_builder_settings(arch, build_type):
requires = {"*": ["darwin-toolchain/1.0.4@theodelrieu/testing"]}
options = {"darwin-toolchain:bitcode": False}
builder.add(settings={"os": "iOS", "arch": arch, "build_type": build_type, "os.version": "10.0", "compiler": "apple-clang"},
build_requires=requires, options=options)
# add build settings for iOS
add_builder_settings("armv7", "Debug")
add_builder_settings("armv7", "Release")
add_builder_settings("armv8", "Debug")
add_builder_settings("armv8", "Release")
add_builder_settings("x86_64", "Debug")
add_builder_settings("x86_64", "Release")
这是我的错误报告
libx264/20171211@username/stable (test package): Running test()
/bin/sh: bin/test_package: Bad CPU type in executable
我想用一个 build.py 构建 6 种类型的包。但是它只构建了一个包就失败了。
为避免test_package交叉构建时执行,强烈推荐Bincrafters思路:
from conans import ConanFile, CMake, tools
import os
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
这里的想法是跳过执行,柯南检测到 arch != build_arch.
您可以在这里查看原始代码:
https://github.com/bincrafters/templates/blob/master/default/test_package/conanfile.py#L15