Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix(endpoint): Revise endpoint build targets in favor of Bazel
Browse files Browse the repository at this point in the history
It's hard to build endpoint library with mixed build system.
This commit removed the http-parser and the mbedtls submodules
from GNU Make build system and changed them to build from Bazel.

The http_parser changed to use the source from entangled. Add
`@http_parser` into deps if needed.

The mbedtls's version from entangled has not been updated for a long
time. So the mbedtls source is still pull from github. But changed the
build system from GNU Make to Bazel. In order to avoid conflict with
the same library inside entangled. The mbedtls library which pulled
from github add a suffix `2_16_6`. Add `@mbedtls_2_16_6` into deps
if needed.

Close #647
  • Loading branch information
splasky committed May 27, 2020
1 parent 5b9207b commit 2d0acdc
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 41 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@
[submodule "third_party/mosquitto"]
path = third_party/mosquitto
url = https://github.com/eclipse/mosquitto.git
[submodule "third_party/http-parser"]
path = third_party/http-parser
url = https://github.com/nodejs/http-parser.git
[submodule "third_party/mbedtls"]
path = third_party/mbedtls
url = https://github.com/ARMmbed/mbedtls.git
17 changes: 1 addition & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ DCURL_DIR := third_party/dcurl
DCURL_LIB := $(DCURL_DIR)/build/libdcurl.so
MOSQUITTO_DIR := third_party/mosquitto
MOSQUITTO_LIB := $(MOSQUITTO_DIR)/lib/libmosquitto.so.1
MBEDTLS_DIR := third_party/mbedtls
MBEDTLS_LIB := $(MBEDTLS_PATH)/library/libmbedx509.so $(MBEDTLS_PATH)/library/libmbedtls.so $(MBEDTLS_PATH)/library/libmbedcrypto.so
HTTPPARSER_DIR := third_party/http-parser
HTTPPARSER_LIB := $(HTTPPARSER_DIR)/libhttp_parser.so
PEM_DIR = pem
DEPS += $(DCURL_LIB) $(HTTPPARSER_LIB) $(MBEDTLS_LIB)
DEPS += $(DCURL_LIB)
PEM := $(PEM_DIR)/cert.pem

all: $(DEPS) cert
Expand All @@ -27,14 +23,6 @@ $(MOSQUITTO_LIB): $(MOSQUITTO_DIR)
@echo
$(MAKE) -C $^ WITH_DOCS=no

$(HTTPPARSER_LIB): $(HTTPPARSER_DIR)
git submodule update --init $^
$(MAKE) -C $^ library

$(MBEDTLS_LIB): $(MBEDTLS_DIR)
git submodule update --init $^
$(MAKE) -C $^ SHARED=1 lib

cert: check_pem
@xxd -i $(PEM) > $(PEM_DIR)/ca_crt.inc
@sed -E \
Expand All @@ -52,9 +40,6 @@ endif
clean:
$(MAKE) -C $(DCURL_DIR) clean
$(MAKE) -C $(MOSQUITTO_DIR) clean
$(MAKE) -C $(HTTPPARSER_DIR) clean
$(MAKE) -C $(MBEDTLS_DIR) clean


distclean: clean
$(RM) -r $(DCURL_DIR)
Expand Down
7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ git_repository(
tag = "v0.9.0",
)

new_git_repository(
name = "mbedtls_2_16_6",
build_file = "//third_party:mbedtls.BUILD",
remote = "https://github.com/ARMmbed/mbedtls.git",
tag = "mbedtls-2.16.6",
)

load("@rules_iota//:defs.bzl", "iota_deps")
load("@io_bazel_rules_docker//repositories:repositories.bzl", container_repositories = "repositories")

Expand Down
14 changes: 0 additions & 14 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,3 @@ cc_library(
"mosquitto/lib/mqtt_protocol.h",
],
)

cc_library(
name = "http-parser",
srcs = glob(["http-parser/*.so.*"]),
hdrs = ["http-parser/http_parser.h"],
includes = ["http-parser"],
)

cc_library(
name = "mbedtls",
srcs = glob(["mbedtls/library/*.so.*"]),
hdrs = glob(["mbedtls/include/mbedtls/*.h"]) + glob(["mbedtls/include/psa/*.h"]),
includes = ["mbedtls/include"],
)
1 change: 0 additions & 1 deletion third_party/http-parser
Submodule http-parser deleted from 7af127
1 change: 0 additions & 1 deletion third_party/mbedtls
Submodule mbedtls deleted from 5f69cb
8 changes: 8 additions & 0 deletions third_party/mbedtls.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cc_library(
name = "mbedtls_2_16_6",
srcs = glob(["library/*.c"]),
hdrs = glob(["include/mbedtls/*.h"]) + glob(["include/psa/*.h"]),
include_prefix = "mbedtls",
strip_include_prefix = "include/mbedtls",
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cc_library(
hdrs = ["cipher.h"],
deps = [
"//common:ta_errors",
"//third_party:mbedtls",
"@mbedtls_2_16_6",
],
)

Expand Down
4 changes: 2 additions & 2 deletions utils/connectivity/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cc_library(
deps = [
"//common",
"//pem:cert",
"//third_party:http-parser",
"//third_party:mbedtls",
"@http_parser",
"@mbedtls_2_16_6",
],
)

0 comments on commit 2d0acdc

Please sign in to comment.