Skip to content

Commit 7156db4

Browse files
authored
Merge pull request #37 from SwimmingTiger/add_hdc
WIP: add hdc
2 parents 12cba9e + 2dbec63 commit 7156db4

5 files changed

Lines changed: 125 additions & 1 deletion

File tree

build-hnp/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ PKGS=bash \
4343
aria2 \
4444
xz \
4545
gdb \
46-
python
46+
python \
47+
libusb \
48+
hdc
4749
STAMP=$(patsubst %,%/.stamp,$(PKGS))
4850

4951
all: copy
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/src/host/server.cpp b/src/host/server.cpp
2+
index dcae3a6..93ec51f 100644
3+
--- a/src/host/server.cpp
4+
+++ b/src/host/server.cpp
5+
@@ -91,20 +91,20 @@ bool HdcServer::Initial(const char *listenString)
6+
WRITE_LOG(LOG_FATAL, "clsServerForClient Initial failed");
7+
return false;
8+
}
9+
- clsUSBClt->InitLogging(ctxUSB);
10+
+ //clsUSBClt->InitLogging(ctxUSB);
11+
clsTCPClt = new HdcHostTCP(true, this);
12+
- clsUSBClt = new HdcHostUSB(true, this, ctxUSB);
13+
+ /*clsUSBClt = new HdcHostUSB(true, this, ctxUSB);
14+
if (clsUSBClt->Initial() != RET_SUCCESS) {
15+
WRITE_LOG(LOG_FATAL, "clsUSBClt Initial failed");
16+
return false;
17+
- }
18+
- if (!clsServerForClient || !clsTCPClt || !clsUSBClt) {
19+
+ }*/
20+
+ if (!clsServerForClient /*|| !clsTCPClt || !clsUSBClt*/) {
21+
WRITE_LOG(LOG_FATAL, "Class init failed");
22+
return false;
23+
}
24+
25+
#ifdef HDC_SUPPORT_UART
26+
- clsUARTClt = new HdcHostUART(*this);
27+
+ /*clsUARTClt = new HdcHostUART(*this);
28+
if (!clsUARTClt) {
29+
WRITE_LOG(LOG_FATAL, "Class init failed");
30+
return false;
31+
@@ -112,7 +112,7 @@ bool HdcServer::Initial(const char *listenString)
32+
if (clsUARTClt->Initial() != RET_SUCCESS) {
33+
WRITE_LOG(LOG_FATAL, "clsUARTClt Class init failed.");
34+
return false;
35+
- }
36+
+ }*/
37+
#endif
38+
return true;
39+
}

build-hnp/hdc/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
cmake_minimum_required (VERSION 3.10)
2+
3+
project (hdc)
4+
5+
set (CMAKE_CXX_STANDARD 17)
6+
7+
add_definitions(-DHDC_HOST -DHARMONY_PROJECT -DHDC_SUPPORT_UART)
8+
9+
add_custom_command(
10+
OUTPUT ${PROJECT_SOURCE_DIR}/hdc_hash_gen.h
11+
COMMAND python3 ${PROJECT_SOURCE_DIR}/hdc/scripts/hdc_hash_gen.py -f hdc_hash_gen.h -i hdc/ -o ./
12+
DEPENDS ${PROJECT_SOURCE_DIR}/hdc/scripts/hdc_hash_gen.py
13+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
14+
COMMENT "Generating hdc_hash_gen.h using hdc_hash_gen.py"
15+
)
16+
17+
add_custom_target(
18+
generate_hdc_hash_gen_h
19+
DEPENDS ${PROJECT_SOURCE_DIR}/hdc_hash_gen.h
20+
)
21+
22+
include_directories(
23+
${PROJECT_SOURCE_DIR}/../../sysroot/include
24+
${PROJECT_SOURCE_DIR}
25+
${PROJECT_SOURCE_DIR}/securec/include
26+
${PROJECT_SOURCE_DIR}/hdc/src/common
27+
${PROJECT_SOURCE_DIR}/hdc/src/host
28+
)
29+
30+
link_directories(
31+
${PROJECT_SOURCE_DIR}/../../sysroot/lib
32+
)
33+
34+
file(GLOB SRC_FILES
35+
${PROJECT_SOURCE_DIR}/securec/src/*.c
36+
${PROJECT_SOURCE_DIR}/hdc/src/common/*.cpp
37+
${PROJECT_SOURCE_DIR}/hdc/src/host/*.cpp
38+
)
39+
40+
add_executable(hdc ${SRC_FILES})
41+
add_dependencies(hdc generate_hdc_hash_gen_h)
42+
target_link_libraries(hdc libuv.so)
43+
target_link_libraries(hdc libusb-1.0.so)
44+
target_link_libraries(hdc libssl.so)
45+
target_link_libraries(hdc libcrypto.so)
46+
target_link_libraries(hdc liblz4.so)

build-hnp/hdc/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include ../utils/Makefrag
2+
3+
all: download/hdc.zip download/securec.zip CMakeLists.txt
4+
rm -rf temp build
5+
mkdir -p temp build
6+
cd temp && unzip ../download/hdc.zip && mv developtools_hdc-OpenHarmony-v5.0.1-Release hdc
7+
cd temp && unzip ../download/securec.zip && mv third_party_bounds_checking_function-OpenHarmony-5.0.1-Release securec
8+
cp CMakeLists.txt temp
9+
#cd temp/hdc && git init . && git add --all && git commit -m "init" # help to update 0001-ignore-usb-fail.diff with git diff
10+
cd temp/hdc && cat ../../0001-ignore-usb-fail.diff | patch -Np1
11+
cd build && cmake ../temp -DCMAKE_TOOLCHAIN_FILE=${TOOL_HOME}/sdk/default/openharmony/native/build/cmake/ohos.toolchain.cmake -DOHOS_ARCH=arm64-v8a
12+
cd build && make -j$(nproc)
13+
mkdir -p ../sysroot/bin
14+
cp build/hdc ../sysroot/bin/
15+
16+
download/hdc.zip:
17+
mkdir -p download
18+
cd download && wget -O hdc.zip https://gitee.com/openharmony/developtools_hdc/repository/archive/OpenHarmony-v5.0.1-Release.zip
19+
20+
download/securec.zip:
21+
mkdir -p download
22+
cd download && wget -O securec.zip https://gitee.com/openharmony/third_party_bounds_checking_function/repository/archive/OpenHarmony-5.0.1-Release.zip

build-hnp/libusb/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
all: download/libusb-1.0.29.tar.bz2
2+
rm -rf temp build
3+
mkdir -p temp build
4+
cd temp && tar xvf ../download/libusb-1.0.29.tar.bz2
5+
cd temp/libusb-1.0.29 && PKG_CONFIG=/usr/bin/false LIBTOOL=glibtool LIBTOOLIZE=glibtoolize ./configure --host aarch64-unknown-linux-musl --enable-shared --disable-static --disable-udev CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang LD=$(OHOS_SDK_HOME)/native/llvm/bin/ld.lld AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar RANLIB=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ranlib STRIP=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip
6+
cd temp/libusb-1.0.29 && make -j $(shell nproc) && make install DESTDIR=$(shell pwd)/build
7+
mkdir -p ../sysroot
8+
rm -v build/usr/local/lib/*.la
9+
$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip build/usr/local/lib/*.so
10+
ln -s libusb-1.0 build/usr/local/include/libusb # hdc need this
11+
cp -rfv build/usr/local/. ../sysroot | tee file.lst
12+
13+
download/libusb-1.0.29.tar.bz2:
14+
mkdir -p download
15+
cd download && wget https://github.com/libusb/libusb/releases/download/v1.0.29/libusb-1.0.29.tar.bz2

0 commit comments

Comments
 (0)