Skip to content

Commit

Permalink
Get v3.5.1 to build in docker image.
Browse files Browse the repository at this point in the history
Seems like the root cause is that when mbedtls moved to use
GnuInstallDirs, the install directory for the library changed. Which
makes sense. I couldn't figure out how to get mbedtls to install do lib,
so I just check if lib64 exists, and if so move to lib.

Doesn't feel good, but there it is.
  • Loading branch information
Cody Piersall committed Jan 10, 2024
1 parent 568b66d commit 2a391cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rev=v1.6.0

[build_mbedtls]
repo=https://github.com/ARMmbed/mbedtls.git
rev=v3.1.0
rev=v3.5.1

[build_ext]
inplace = 1
16 changes: 13 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ def run(self):
os.mkdir(self.build_dir)

cmake_cmd = [*self.cmake_cmd, *self.cmake_extra_args, ".."]
print(f"building {self.git_dir} with:", cmake_cmd)
print(f"building {self.git_dir} with:", cmake_cmd, flush=True)
check_call(cmake_cmd, cwd=self.build_dir)

self.finalize_build()


class BuildNng(BuilderBase):
description = "build the nng library"
git_dir = "nng"
build_dir = "nng/build"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.git_dir = "nng"
self.cmake_extra_args = [
"-DNNG_ENABLE_TLS=ON",
"-DNNG_TESTS=OFF",
Expand All @@ -96,11 +96,11 @@ def finalize_build(self):

class BuildMbedTls(BuilderBase):
description = "build the mbedtls library"
git_dir = "mbedtls"
build_dir = "mbedtls/build"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.git_dir = "mbedtls"
self.cmake_extra_args = [
"-DENABLE_PROGRAMS=OFF",
"-DCMAKE_BUILD_TYPE=Release",
Expand All @@ -122,6 +122,16 @@ def finalize_build(self):
maybe_copy(src + "mbedtls.lib", dst + "mbedtls.lib")
maybe_copy(src + "mbedx509.lib", dst + "mbedx509.lib")
maybe_copy(src + "mbedcrypto.lib", dst + "mbedcrypto.lib")
else:
# kinda hacky...
# In CI, mbedtls installs its libraries into mbedtls/prefix/lib64.
# Not totally sure when this happened, but something in mbedtls changed,
# likely commit 0f2e87bdf534a967937882e7381e067d9b1cb135, when they started
# using GnuInstallDirs. Couldn't build to verify but likely enough.
src = f"{THIS_DIR}/mbedtls/prefix/lib64"
dst = f"{THIS_DIR}/mbedtls/prefix/lib"
if os.path.exists(src):
shutil.move(src, dst)


class BuildBuild(build_ext):
Expand Down

0 comments on commit 2a391cb

Please sign in to comment.