Skip to content

Commit

Permalink
🏗️ Use options for newlib
Browse files Browse the repository at this point in the history
Using newlib as a compatibility setting is incorrect as the choice of
newlib libc library implementation is a link time choice and does not
affect codegen or ABI.
  • Loading branch information
Khalil Estell authored and kammce committed Dec 13, 2023
1 parent 49df45b commit 3b495d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 33 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ jobs:
- name: 📦 Create Conan Package
run: conan create prebuilt --version=${{ inputs.version }}

- name: 🏗️ Build Demo Package
- name: 🏗️ Build Demos Conan Package
if: ${{ runner.os != 'Windows' }}
working-directory: prebuilt/demo
run: conan build . -o "*:version=${{ inputs.version }}" -pr profile
run: VERBOSE=1 conan build . -pr profile -s compiler.version="${{ inputs.version }}"

- name: 🏗️ Build Demos Conan Package
if: ${{ runner.os == 'Windows' }}
working-directory: prebuilt/demo
run: conan build . -pr profile -s compiler.version="${{ inputs.version }}"

- name: 📡 Sign into JFrog Artifactory
if: ${{ github.ref == 'refs/heads/main' && runner.os != 'Windows' }}
Expand Down
30 changes: 8 additions & 22 deletions prebuilt/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from conan import ConanFile
from conan.tools.files import get, copy
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=2.0.6"
Expand All @@ -25,15 +24,6 @@ class PrebuiltPicolibc(ConanFile):
def package_id(self):
self.info.clear()

def validate(self):
if (
self.settings.compiler == "gcc" and
self.settings.os == "baremetal" and
self.settings.compiler.get_safe("newlib") != "picolibc"
):
raise ConanInvalidConfiguration(
"settings.compiler.newlib must be set to picolibc to use this package!")

def build(self):
get(self,
**self.conan_data["sources"][self.version],
Expand Down Expand Up @@ -67,15 +57,11 @@ def package_info(self):
prefix = os.path.join(self.package_folder, 'arm-none-eabi')
picolibcpp_specs = os.path.join(self.package_folder, specs_path)

newlib = self.settings.compiler.get_safe("newlib")
if newlib == "picolibc":
self.cpp_info.exelinkflags = [
f"-specs={picolibcpp_specs}",
f"--picolibc-prefix={prefix}",
f"-oslib={str(self.options.crt0)}",
]
self.output.info(f"link flags: {self.cpp_info.exelinkflags}")
self.output.info(f"crt0: {str(self.options.crt0)}")
else:
self.output.warning(
f"newlib set to: '{newlib}', compiler flags not used!")
self.cpp_info.exelinkflags = [
f"-specs={picolibcpp_specs}",
f"--picolibc-prefix={prefix}",
f"-oslib={str(self.options.crt0)}",
]

self.output.info(f"link flags: {self.cpp_info.exelinkflags}")
self.output.info(f"crt0: {str(self.options.crt0)}")
12 changes: 4 additions & 8 deletions prebuilt/demo/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
class Demo(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualBuildEnv"
options = {
"version": [
"12.2",
"12.3",
]
}

def build_requirements(self):
self.tool_requires("cmake/3.27.1")
self.tool_requires(f"arm-gnu-toolchain/{self.options.version}")
self.tool_requires(
f"arm-gnu-toolchain/{self.settings.compiler.version}",
options={"custom_libc": True})

def requirements(self):
self.requires(f"prebuilt-picolibc/{self.options.version}")
self.requires(f"prebuilt-picolibc/{self.settings.compiler.version}")

def layout(self):
cmake_layout(self)
Expand Down
1 change: 0 additions & 1 deletion prebuilt/demo/profile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ build_type=MinSizeRel
compiler=gcc
compiler.cppstd=20
compiler.libcxx=libstdc++
compiler.newlib=picolibc
compiler.version=12.2
arch=cortex-m4f
os=baremetal

0 comments on commit 3b495d4

Please sign in to comment.