Skip to content

Commit

Permalink
Tweak the build to support building on Yocto Thud (Azure#1196)
Browse files Browse the repository at this point in the history
* Add Makefile with `make dist` to generate a source tarball

* Add flag to skip libiothsm build

* Use env::var_os

* Address review comments
  • Loading branch information
myagley authored May 21, 2019
1 parent 67e2745 commit 49ab97e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) Microsoft. All rights reserved.

TARGET=target

_version:=$(shell cat edgelet/version.txt)
VERSION?=${_version}
REVISION?=1

# Converts debian versioning to rpm version
# deb 1.0.1~dev100 ~> rpm 1.0.1-0.1.dev100
RPM_VERSION?=$(word 1,$(subst ~, , $(VERSION)))
_release=$(or $(and $(word 2,$(subst ~, ,$1)),0.${REVISION}.$(word 2,$(subst ~, ,$1))),${REVISION})
RPM_RELEASE?=$(call _release, ${VERSION})

PACKAGE_NAME=iotedge
PACKAGE="$(PACKAGE_NAME)-$(RPM_VERSION)"

GIT=git
GZIP=gzip
MKDIR_P=mkdir -p

$(TARGET):
$(MKDIR_P) $(TARGET)

$(TARGET)/$(PACKAGE).tar.gz: $(TARGET)
@echo Running git archive...
@$(GIT) archive --prefix=$(PACKAGE)/ -o $(TARGET)/$(PACKAGE).tar $(VERSION) 2> /dev/null || (echo 'Warning: $(VERSION) does not exist.' && $(GIT) archive --prefix=$(PACKAGE)/ -o $(TARGET)/$(PACKAGE).tar HEAD)
@echo Running git archive submodules...
p=`pwd` && (echo .; git submodule foreach --recursive) | while read entering path; do \
temp="$${path%\'}"; \
temp="$${temp#\'}"; \
path=$$temp; \
[ "$$path" = "" ] && continue; \
(cd $$path && $(GIT) archive --prefix=$(PACKAGE)/$$path/ HEAD > $$p/$(TARGET)/tmp.tar && tar --concatenate --file=$$p/$(TARGET)/$(PACKAGE).tar $$p/$(TARGET)/tmp.tar && rm $$p/$(TARGET)/tmp.tar); \
done
gzip -f $(TARGET)/$(PACKAGE).tar
rm -f $(TARGET)/$(PACKAGE).tar

# Produces a tarball of the source including all git submodules
dist: $(TARGET)/$(PACKAGE).tar.gz

# Removes the build directory
clean:
rm -rf $(TARGET)

.PHONY: clean dist version

12 changes: 11 additions & 1 deletion edgelet/hsm-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl SetPlatformDefines for Config {
}
}

fn main() {
fn build_libiothsm() {
// Clone Azure C -shared library
let c_shared_repo = "azure-iot-hsm-c/deps/c-shared";
let utpm_repo = "azure-iot-hsm-c/deps/utpm";
Expand Down Expand Up @@ -192,3 +192,13 @@ fn main() {
#[cfg(unix)]
println!("cargo:rustc-link-lib=crypto");
}

fn main() {
if env::var_os("LIBIOTHSM_NOBUILD").is_some() {
// libiothsm-std is expected to be built and installed out of band
println!("cargo:rustc-link-lib=iothsm");
} else {
// build libiothsm-std as part of hsm-sys build
build_libiothsm();
}
}

0 comments on commit 49ab97e

Please sign in to comment.