Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VxWorks to os in default settings.yml. (#10313) #10315

Merged
merged 3 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

_t_default_settings_yml = Template(textwrap.dedent("""
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX]
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX, VxWorks]
arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]

# Only for building cross compilation tools, 'os_target/arch_target' is the system for
Expand Down Expand Up @@ -64,6 +64,8 @@
Neutrino:
version: ["6.4", "6.5", "6.6", "7.0", "7.1"]
baremetal:
VxWorks:
version: ["7"]
arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106]
compiler:
sun-cc:
Expand Down
4 changes: 3 additions & 1 deletion conans/client/migrations_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,7 @@

settings_1_45_0 = """
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX]
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX, VxWorks]
arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7]

# Only for building cross compilation tools, 'os_target/arch_target' is the system for
Expand Down Expand Up @@ -3019,6 +3019,8 @@
Neutrino:
version: ["6.4", "6.5", "6.6", "7.0", "7.1"]
baremetal:
VxWorks:
version: ["7"]
arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106]
compiler:
sun-cc:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import platform
import textwrap

import pytest

from conans.test.assets.cmake import gen_cmakelists
from conans.test.assets.sources import gen_function_cpp
from conans.test.utils.tools import TestClient
from conans.util.files import save


@pytest.fixture
def client():
c = TestClient()
save(c.cache.new_config_path, "tools.env.virtualenv:auto_use=True")
clang_profile = textwrap.dedent("""
[settings]
arch=armv7
build_type=RelWithDebInfo
compiler=clang
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is clang the compiler used to cross-compile to vxworks?

For cross compiling, it is typically necessary to provide a CC=full/path/to/cross/compiler env-var

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang and ldarm are available in the path in my docker container.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good, I was mostly wondering if clang is the compiler actually used to compile to vxworks, and no other compiler should go here.

compiler.libcxx=libstdc++11
compiler.version=12
os=VxWorks
os.version=7

[buildenv]
CC=clang
CXX=clang++
""")
conanfile = textwrap.dedent("""
import os
from conans import ConanFile
from conan.tools.cmake import CMake
from conan.tools.layout import cmake_layout
class Pkg(ConanFile):
settings = "os", "compiler", "build_type", "arch"
exports_sources = "*"
generators = "CMakeToolchain"

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmd = os.path.join(self.cpp.build.bindirs[0], "my_app")
self.run(cmd, env=["conanrunenv"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This self.run() should fail if the binary was actually cross-built for vxwork os. It should be replaced for some check of the binary.

""")
c.save({"conanfile.py": conanfile,
"clang": clang_profile,
"CMakeLists.txt": gen_cmakelists(appname="my_app", appsources=["src/main.cpp"]),
"src/main.cpp": gen_function_cpp(name="main")})
return c


@pytest.mark.tool_cmake
@pytest.mark.tool_clang(version="12")
def test_clang_cmake_ninja(client):
client.run("create . pkg/0.1@ -pr=clang -c tools.cmake.cmaketoolchain:generator=Ninja")
assert 'cmake -G "Ninja"' in client.out
assert "main __clang_major__12" in client.out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory the binary created will not run in the current platform, is not executable, this shouldn't be possible.

Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,11 @@ def test_aix(self):
build_os, build_arch, _, _ = get_cross_building_settings(conanfile)
self.assertEqual("AIX", build_os)
self.assertEqual("x86_64", build_arch)

def test_vxworks(self):
with mock.patch("platform.system", mock.MagicMock(return_value='VxWorks')), \
mock.patch("platform.machine", mock.MagicMock(return_value="armv7")):
conanfile = MockConanfile(MockSettings({}))
build_os, build_arch, _, _ = get_cross_building_settings(conanfile)
self.assertEqual("VxWorks", build_os)
self.assertEqual("armv7", build_arch)
3 changes: 2 additions & 1 deletion conans/test/unittests/model/other_settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ class SayConan(ConanFile):
client.run("install . -s os=ChromeOS --build missing", assert_error=True)
self.assertIn(bad_value_msg("settings.os", "ChromeOS",
['AIX', 'Android', 'Arduino', 'Emscripten', 'FreeBSD', 'Linux', 'Macos', 'Neutrino',
'SunOS', 'Windows', 'WindowsCE', 'WindowsStore', 'baremetal', 'iOS', 'tvOS', 'watchOS']),
'SunOS', 'VxWorks', 'Windows', 'WindowsCE', 'WindowsStore', 'baremetal', 'iOS', 'tvOS',
'watchOS']),
client.out)

# Now add new settings to config and try again
Expand Down
4 changes: 2 additions & 2 deletions conans/test/unittests/model/transitive_reqs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,8 +1736,8 @@ def check(conanfile, options, settings):
self.build_graph(content, options="arch_independent=True", settings="os=Linux")
self.assertIn(bad_value_msg("settings.os", "Linux",
['AIX', 'Android', 'Arduino', 'Emscripten', 'FreeBSD', 'Macos',
'Neutrino', 'SunOS', 'Windows', 'WindowsCE', 'WindowsStore',
'baremetal', 'iOS', 'tvOS', 'watchOS']),
'Neutrino', 'SunOS', 'VxWorks', 'Windows', 'WindowsCE',
'WindowsStore', 'baremetal', 'iOS', 'tvOS', 'watchOS']),
str(cm.exception))

def test_config_remove2(self):
Expand Down