Parcourir la source

Merge branch 'Windows' of leo-iot/vendor into develop

增加Windows,ldflags等
myxuan475 il y a 3 mois
Parent
commit
abdcdb1f17
8 fichiers modifiés avec 128 ajouts et 27 suppressions
  1. 33 0
      C2/build.py
  2. 33 0
      C4/build.py
  3. 3 2
      Linux/CMakeLists.txt
  4. 39 0
      Linux/build.py
  5. 7 5
      Linux/vendor.json
  6. 3 4
      Windows/CMakeLists.txt
  7. BIN
      Windows/npcap-sdk-1.13.zip
  8. 10 16
      Windows/vendor.json

+ 33 - 0
C2/build.py

@@ -0,0 +1,33 @@
+import os
+import sys
+import subprocess
+import shutil
+import re
+import getpass
+import glob
+
+def has_build(module_name):
+    build_module = ['openssl']
+    if module_name in build_module:
+        return True
+    else:
+        return False
+
+def build(module_name, build_utils, src_dir, bin_dir, install_dir, job_n):
+    # 设置环境变量
+    os.environ['ARCH'] = 'arm'
+    root_dir = os.environ["PRODUCT_ROOT_DIR"]
+    cross_compile = f'{root_dir}/buildtools/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-'
+    os.environ['CROSS_COMPILE'] = cross_compile
+    if module_name == 'openssl':
+        build_utils.copy_files_ignoring_hidden(src_dir, bin_dir)
+        build_utils.exec_command(['./config', 'no-asm', f'--prefix={install_dir}', f'--cross-compile-prefix={cross_compile}', f'--openssldir={install_dir}'], "config", bin_dir, exit=False)
+        build_utils.exec_command(['sed', '-i', 's/-m64//g', f'{bin_dir}/Makefile'], "sed", bin_dir, exit=True)
+        return build_utils.exec_command(['make', f'--directory={bin_dir}', f'--jobs={job_n}'], "make", bin_dir, exit=False)
+    # subprocess.check_call(['make', f'--directory={root_dir}/system/quectel-cm', f'--jobs={job_n}'])
+
+
+def build_install(module_name, build_utils, bin_dir, install_dir, job_n):
+    if module_name == 'openssl':
+        build_utils.exec_command(['make', 'install', f'--directory={bin_dir}', f'--jobs={job_n}'], "make", bin_dir, exit=False)
+        return True

+ 33 - 0
C4/build.py

@@ -0,0 +1,33 @@
+import os
+import sys
+import subprocess
+import shutil
+import re
+import getpass
+import glob
+
+def has_build(module_name):
+    build_module = ['openssl']
+    if module_name in build_module:
+        return True
+    else:
+        return False
+
+def build(module_name, build_utils, src_dir, bin_dir, install_dir, job_n):
+    # 设置环境变量
+    os.environ['ARCH'] = 'arm'
+    root_dir = os.environ["PRODUCT_ROOT_DIR"]
+    cross_compile = f'{root_dir}/buildtools/toolchains/gcc-gt675x-10.4.0-2023.06.27-x86_64_aarch64-htnice-linux-gnu/bin/aarch64-htnice-linux-gnu-'
+    os.environ['CROSS_COMPILE'] = cross_compile
+    if module_name == 'openssl':
+        build_utils.copy_files_ignoring_hidden(src_dir, bin_dir)
+        build_utils.exec_command(['./config', 'no-asm', f'--prefix={install_dir}', f'--cross-compile-prefix={cross_compile}', f'--openssldir={install_dir}'], "config", bin_dir, exit=False)
+        build_utils.exec_command(['sed', '-i', 's/-m64//g', f'{bin_dir}/Makefile'], "sed", bin_dir, exit=True)
+        return build_utils.exec_command(['make', f'--directory={bin_dir}', f'--jobs={job_n}'], "make", bin_dir, exit=False)
+    # subprocess.check_call(['make', f'--directory={root_dir}/system/quectel-cm', f'--jobs={job_n}'])
+
+
+def build_install(module_name, build_utils, bin_dir, install_dir, job_n):
+    if module_name == 'openssl':
+        build_utils.exec_command(['make', 'install', f'--directory={bin_dir}', f'--jobs={job_n}'], "make", bin_dir, exit=False)
+        return True

+ 3 - 2
Linux/CMakeLists.txt

@@ -60,7 +60,8 @@ build_subdirectory(utils)
 build_subdirectory(foundation/communications)
 build_subdirectory(foundation/leoyun)
 build_subdirectory(foundation/webconfig)
-build_subdirectory(foundation/protocol)
+# build_subdirectory(foundation/protocol)
 build_subdirectory(foundation/data-acq)
 build_subdirectory(foundation/iot_acq)
-build_subdirectory(foundation/downlink)
+build_subdirectory(foundation/downlink)
+build_subdirectory(Lora/chirpstack-handler)

+ 39 - 0
Linux/build.py

@@ -0,0 +1,39 @@
+import os
+import sys
+import subprocess
+import shutil
+import re
+import getpass
+import glob
+
+def has_build(module_name):
+    build_module = ['lua', 'openssl']
+    if module_name in build_module:
+        return True
+    else:
+        return False
+
+def build(module_name, build_utils, src_dir, bin_dir, install_dir, job_n):
+    os.environ['CXXFLAGS']="-fPIC -std=gnu++14 -Wno-error=implicit-function-declaration -Wno-error=int-conversion"
+    os.environ['CFLAGS'] = "-O3 -fPIC -Wunused-result -Wno-error=implicit-function-declaration -Wno-error=int-conversion"
+    if module_name == "lua":
+        print(f'copy files , {src_dir}->{bin_dir}')
+        build_utils.copy_files_ignoring_hidden(src_dir, bin_dir)
+        return build_utils.exec_command(['make', f'--jobs={job_n}'], "make", bin_dir, exit=False)
+    # subprocess.check_call(['make', f'--directory={root_dir}/system/quectel-cm', f'--jobs={job_n}'])
+    elif module_name == 'openssl':
+        build_utils.copy_files_ignoring_hidden(src_dir, bin_dir)
+        build_utils.exec_command(['./config', f'--prefix={install_dir}', f'--openssldir={install_dir}'], "config", bin_dir, exit=False)
+        return build_utils.exec_command(['make', f'--directory={bin_dir}', f'--jobs={job_n}'], "make", bin_dir, exit=False)
+
+
+def build_install(module_name, build_utils, bin_dir, install_dir, job_n):
+    if module_name == "lua":
+        os.makedirs(install_dir, exist_ok=True)
+        os.makedirs(f'{install_dir}/lib', exist_ok=True)
+        os.makedirs(f'{install_dir}/include', exist_ok=True)
+        build_utils.move_matching_files(f'{bin_dir}/*.h', f'{install_dir}/include')
+        build_utils.move_matching_files(f'{bin_dir}/*.a', f'{install_dir}/lib')
+        # build_utils.exec_command(["make", "install", f'--directory={bin_dir}'], "make install", bin_dir, exit=False)
+    elif module_name == "openssl":
+        build_utils.exec_command(['make', 'install', f'--directory={bin_dir}', f'--jobs={job_n}'], "make", bin_dir, exit=False)

+ 7 - 5
Linux/vendor.json

@@ -3,8 +3,9 @@
     "version": "2.0.0",
     "toolchain":"",
     "build-mode": "Debug",
-    "cxxflags" : "-fPIC -std=gnu++14 -Wno-error=implicit-function-declaration -Wno-error=int-conversion",
+    "cxxflags" : "-fPIC -std=gnu++17 -Wno-error=implicit-function-declaration -Wno-error=int-conversion",
     "cflags":"-O3 -fPIC -Wunused-result -Wno-error=implicit-function-declaration -Wno-error=int-conversion",
+    "ldflags":"",
     "modules":[
         {
             "name": "jsoncpp",
@@ -66,22 +67,23 @@
         {
             "name":"grpc",
             "options":[
-                "gRPC_USE_PROTO_LITE=ON",
+                "gRPC_USE_PROTO_LITE=OFF",
                 "gRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_PHP_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_RUBY_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_NODE_PLUGIN=OFF",
-                "gRPC_BUILD_GRPC_CPP_PLUGIN=OFF",
-                "gRPC_BUILD_CODEGEN=OFF",
+                "gRPC_BUILD_GRPC_CPP_PLUGIN=ON",
+                "gRPC_BUILD_CODEGEN=ON",
                 "gRPC_BUILD_TESTS=OFF",
                 "ABSL_RUN_TESTS=OFF",
                 "gRPC_ZLIB_PROVIDER=package",
                 "gRPC_ABSL_PROVIDER=package",
                 "gRPC_PROTOBUF_PROVIDER=package",
                 "gRPC_SSL_PROVIDER=package"
-            ]
+            ],
+            "exports":["GRPC_PROGROM_DIR=$PRODUCT_INSTALL_DIR/grpc/bin"]
         }
     ]
 }

+ 3 - 4
Windows/CMakeLists.txt

@@ -29,10 +29,8 @@ include_directories(${PRODUCT_ROOT_DIR}/thirdparty)
 include_directories(${PRODUCT_ROOT_DIR}/vendor/${PRODUCT_NAME})
 include_directories(${PRODUCT_BUILD_DIR}/thirdparty)
 
-find_library(OPENSSL_SSL_LIBRARY ssl ${OPENSSL_ROOT_DIR}/ssl NO_DEFAULT_PATH)
-find_library(OPENSSL_CRYPTO_LIBRARY crypto ${OPENSSL_ROOT_DIR}/crypto/ NO_DEFAULT_PATH)
-set(OPENSSL_INCLUDE_DIR "${PRODUCT_BUILD_DIR}/thirdparty/openssl/include")
-
+find_library(OPENSSL_SSL_LIBRARY ssl ${OPENSSL_ROOT_DIR}/lib64 NO_DEFAULT_PATH)
+find_library(OPENSSL_CRYPTO_LIBRARY crypto ${OPENSSL_ROOT_DIR}/lib64 NO_DEFAULT_PATH)
 message("OPENSSL: ${OPENSSL_ROOT_DIR}/ssl, OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}, OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}, OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
 
 set(LIBXML2_WITH_PYTHON OFF)
@@ -48,3 +46,4 @@ target_link_directories(vendor PUBLIC ${LIBUV_LIBS_DIR})
 target_link_libraries(vendor uv)
 build_subdirectory(utils)
 # build_subdirectory(foundation/hmi)
+build_subdirectory(Lora/chirpstack-handler)

BIN
Windows/npcap-sdk-1.13.zip


+ 10 - 16
Windows/vendor.json

@@ -15,9 +15,7 @@
         {
             "name": "openssl",
             "exports":[
-                "OPENSSL_ROOT_DIR=$PRODUCT_INSTALL_DIR/openssl",
-                "OPENSSL_CRYPTO_LIBRARY=$PRODUCT_INSTALL_DIR/openssl/lib64/",
-                "OPENSSL_SSL_LIBRARY=$PRODUCT_INSTALL_DIR/openssl/lib64/"
+                "OPENSSL_ROOT_DIR=$PRODUCT_INSTALL_DIR/openssl"
             ]
         },
         {
@@ -46,14 +44,6 @@
             "ldflags":"-L$PRODUCT_VENDOR_DIR/npcap-sdk-1.13/Lib/x64",
             "defines":["_Post_invalid_=\"\""]
         },
-        {
-            "name": "protobuf",
-            "options":["protobuf_BUILD_TESTS=OFF"],
-            "exports":[
-                "PROTOC_DIR=$PRODUCT_BUILD_DIR/thirdparty/protobuf",
-                "PROTOBUF_INCLUDE_DIR=$PRODUCT_ROOT_DIR/thirdparty/protobuf/src;$PRODUCT_ROOT_DIR/thirdparty/protobuf/third_party/abseil-cpp"
-            ]
-        },
         {
             "name":"libevent",
             "options":["EVENT_LIBRARY_SHARED=OFF", "LIBEVENT_STATIC_LINK=ON", "EVENT__DISABLE_TESTS=ON", "EVENT__DISABLE_SAMPLES=ON", "EVENT__DISABLE_BENCHMARK=ON"]
@@ -61,6 +51,9 @@
         {
             "name":"grpc",
             "options":[
+                "BUILD_SHARED_LIBS=ON",
+                "_gRPC_PROTOBUF_PROTOC_EXECUTABLE=$PRODUCT_ROOT_DIR/out/Linux/install/protobuf/bin/protoc",
+                "_gRPC_CPP_PLUGIN=$PRODUCT_ROOT_DIR/out/Linux/install/grpc/bin/grpc_cpp_plugin",
                 "CMAKE_MODULE_PATH=$PRODUCT_ROOT_DIR/thirdparty/xfrpc/cmake/Modules",
                 "gRPC_USE_PROTO_LITE=OFF",
                 "gRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF",
@@ -69,15 +62,16 @@
                 "gRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_RUBY_PLUGIN=OFF",
                 "gRPC_BUILD_GRPC_NODE_PLUGIN=OFF",
-                "gRPC_BUILD_GRPC_CPP_PLUGIN=OFF",
-                "gRPC_BUILD_CODEGEN=OFF",
+                "gRPC_BUILD_GRPC_CPP_PLUGIN=ON",
+                "gRPC_BUILD_CODEGEN=ON",
                 "gRPC_BUILD_TESTS=OFF",
                 "ABSL_RUN_TESTS=OFF",
                 "gRPC_ZLIB_PROVIDER=package",
-                "gRPC_ABSL_PROVIDER=package",
-                "gRPC_PROTOBUF_PROVIDER=package",
+                "gRPC_ABSL_PROVIDER=module",
+                "gRPC_PROTOBUF_PROVIDER=module",
                 "gRPC_SSL_PROVIDER=package"
-            ]
+            ],
+            "exports":["GRPC_PROGROM_DIR=$PRODUCT_ROOT_DIR/out/Linux/install/grpc/bin"]
         }
     ]
 }