Skip to content

Commit

Permalink
[Refactoring] Use cmd and build folders by Standard Go Project Layout (
Browse files Browse the repository at this point in the history
…lf-edge#259)

Signed-off-by: Taewan Kim <t25.kim@samsung.com>

- This PR is intended to refactor folder structures by Standard Go Project Layout (Related lf-edge#209).
  • Loading branch information
tiokim authored Feb 10, 2021
1 parent 3a418da commit b5a6cf6
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ src/controller/scoringmgr/mock_internal/myscoring2/libmyscoring2.so*

# Output of build
*.o
GoMain/bin/*
bin/*
src/interfaces/capi/output
src/interfaces/javaapi/output

Expand Down
99 changes: 0 additions & 99 deletions Builder/Dockerfile

This file was deleted.

67 changes: 0 additions & 67 deletions Builder/container.sh

This file was deleted.

6 changes: 3 additions & 3 deletions GoMain/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ ENV MDNS_PORT=5353
ENV MNEDC_PORT=3334
ENV MNEDC_BROADCAST_PORT=3333
ENV ZEROCONF_PORT=42425
ENV APP_MAIN_DIR=GoMain
ENV APP_BIN_DIR=$APP_MAIN_DIR/bin
ENV APP_BIN_DIR=bin
ENV APP_NAME=edge-orchestration
ENV APP_QEMU_DIR=$APP_BIN_DIR/qemu
ENV BUILD_DIR=build

# copy files
COPY $APP_BIN_DIR/$APP_NAME $APP_MAIN_DIR/run.sh $TARGET_DIR/
COPY $APP_BIN_DIR/$APP_NAME $BUILD_DIR/package/run.sh $TARGET_DIR/
COPY $APP_QEMU_DIR/ /usr/bin/
RUN mkdir -p $TARGET_DIR/res/

Expand Down
27 changes: 13 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ GO_LDFLAGS := -ldflags '-extldflags "-static" -X main.version=$(VERSION) -X mai
GO_MOBILE_LDFLAGS := -ldflags '-X main.version=$(VERSION) -X main.commitID=$(GO_COMMIT_ID) -X main.buildTime=$(BUILD_DATE) -X main.buildTags=$(BUILD_TAGS)'

# Target parameters
PKG_NAME := edge-orchestration
OBJ_SRC_DIR := $(BASE_DIR)/src/interfaces/capi
PKG_NAME := edge-orchestration

# GoMain target
GOMAIN_DIR := $(BASE_DIR)/GoMain
GOMAIN_BIN_DIR := $(GOMAIN_DIR)/bin
GOMAIN_SRC_DIR := $(GOMAIN_DIR)/src
EXEC_SRC := $(GOMAIN_DIR)/src/main/main.go
GOMAIN_BIN_FILE := $(PKG_NAME)
# Go Application target
CMD_DIR := $(BASE_DIR)/cmd
CMD_SRC := $(CMD_DIR)/edge-orchestration/main.go
BIN_DIR := $(BASE_DIR)/bin
BIN_FILE := $(PKG_NAME)

# Go Library for C-archive
LIBRARY_NAME := liborchestration
HEADER_FILE := orchestration.h
LIBRARY_FILE := liborchestration.a
CUR_HEADER_FILE := $(LIBRARY_NAME).h
CUR_LIBRARY_FILE := $(LIBRARY_NAME).a
INTERFACE_OUT_DIR := $(BASE_DIR)/src/interfaces/capi/output
OBJ_SRC_DIR := $(CMD_DIR)/edge-orchestration/capi
INTERFACE_OUT_DIR := $(BIN_DIR)/capi/output
ifeq ($(ARCH), arm)
INTERFACE_OUT_INC_DIR := $(INTERFACE_OUT_DIR)/inc/linux_arm
INTERFACE_OUT_BIN_DIR := $(INTERFACE_OUT_DIR)/bin/linux_arm
Expand All @@ -54,8 +53,8 @@ BUILD_VENDOR_DIR := $(BASE_DIR)/vendor
ANDROID_LIBRARY_NAME := liborchestration
ANDROID_LIBRARY_FILE := liborchestration.aar
ANDROID_JAR_FILE := liborchestration-sources.jar
ANDROID_SRC_DIR := $(BASE_DIR)/src/interfaces/javaapi
ANDROID_LIBRARY_OUT_DIR := $(BASE_DIR)/src/interfaces/javaapi/output
ANDROID_SRC_DIR := $(CMD_DIR)/edge-orchestration/javaapi
ANDROID_LIBRARY_OUT_DIR := $(BIN_DIR)/javaapi/output

.DEFAULT_GOAL := help

Expand All @@ -64,8 +63,8 @@ go-vendor:

## edge-orchestration binary build
build-binary:
$(GOBUILD) -a $(GO_LDFLAGS) -o $(GOMAIN_BIN_DIR)/$(GOMAIN_BIN_FILE) $(EXEC_SRC) || exit 1
ls -al $(GOMAIN_BIN_DIR)
$(GOBUILD) -a $(GO_LDFLAGS) -o $(BIN_DIR)/$(BIN_FILE) $(CMD_SRC) || exit 1
ls -al $(BIN_DIR)

## edge-orchestration static archive build
build-object-c:
Expand All @@ -88,7 +87,7 @@ build-object-java:

## edge-orchestration container build
build-container:
$(DOCKER) build --tag $(PKG_NAME):$(CONTAINER_VERSION) --file $(GOMAIN_DIR)/Dockerfile --build-arg PLATFORM=$(CONTAINER_ARCH) .
$(DOCKER) build --tag $(PKG_NAME):$(CONTAINER_VERSION) --file $(BASE_DIR)/Dockerfile --build-arg PLATFORM=$(CONTAINER_ARCH) .

## go test and coverage
test-go:
Expand Down
18 changes: 9 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ function build_binaries() {
function build_binary() {
echo ""
echo "----------------------------------------"
echo " Create Executable binary from GoMain"
echo " Create Executable binary"
echo "----------------------------------------"

export GOPATH=$BASE_DIR/GoMain:$GOPATH
export GOPATH=$BASE_DIR/bin:$GOPATH
make build-binary || exit 1
}

Expand Down Expand Up @@ -224,8 +224,8 @@ function draw_callvis() {
echo " ex) #build_clean_vendor "
echo "**********************************"

export GOPATH=$BASE_DIR/GoMain:$GOPATH
go-callvis -http localhost:7010 -group pkg,type -nostd ./GoMain/src/main/main.go &
export GOPATH=$BASE_DIR/bin:$GOPATH
go-callvis -http localhost:7010 -group pkg,type -nostd ./cmd/edge-orchestration/main.go &
}

function build_objects() {
Expand Down Expand Up @@ -338,7 +338,7 @@ function build_docker_container() {

docker rm -f $DOCKER_IMAGE
docker rmi -f $DOCKER_IMAGE:$CONTAINER_VERSION
mkdir -p $BASE_DIR/GoMain/bin/qemu
mkdir -p $BASE_DIR/bin/qemu
case $1 in
x86)
CONTAINER_ARCH="i386"
Expand All @@ -348,11 +348,11 @@ function build_docker_container() {
;;
arm)
CONTAINER_ARCH="arm32v7"
cp /usr/bin/qemu-arm-static $BASE_DIR/GoMain/bin/qemu
cp /usr/bin/qemu-arm-static $BASE_DIR/bin/qemu
;;
arm64)
CONTAINER_ARCH="arm64v8"
cp /usr/bin/qemu-aarch64-static $BASE_DIR/GoMain/bin/qemu
cp /usr/bin/qemu-aarch64-static $BASE_DIR/bin/qemu
;;
*)
case "$(uname -m)" in
Expand Down Expand Up @@ -425,14 +425,14 @@ case "$1" in
set_secure_option
build_binaries $3
build_docker_container $3
docker save -o $BASE_DIR/GoMain/bin/edge-orchestration.tar edge-orchestration
docker save -o $BASE_DIR/bin/edge-orchestration.tar edge-orchestration
if [ "$3" == "x86_64" ]; then
run_docker_container
fi
else
build_binaries $2
build_docker_container $2
docker save -o $BASE_DIR/GoMain/bin/edge-orchestration.tar edge-orchestration
docker save -o $BASE_DIR/bin/edge-orchestration.tar edge-orchestration
if [ "$2" == "x86_64" ]; then
run_docker_container
fi
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b5a6cf6

Please sign in to comment.