Merge pull request #18 from open-amt-cloud-toolkit/feature_linux_vcpkg
Feature Linux vcpkg, CentOS support.
This commit is contained in:
		
							
								
								
									
										39
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							| @@ -12,6 +12,7 @@ env: | ||||
|   BUILD_TYPE: Release | ||||
|  | ||||
| jobs: | ||||
|  | ||||
|   build-windows: | ||||
|     runs-on: windows-2019 | ||||
|     steps: | ||||
| @@ -19,7 +20,7 @@ jobs: | ||||
|     - name: Create Build Dir | ||||
|       run: mkdir build | ||||
|     - name: Clone | ||||
|       run: git clone --branch 2020.01 https://github.com/microsoft/vcpkg.git | ||||
|       run: git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git | ||||
|     - name: Build VCPKG | ||||
|       run: cd vcpkg && bootstrap-vcpkg.bat | ||||
|       shell: cmd | ||||
| @@ -27,11 +28,8 @@ jobs: | ||||
|       run: ls | ||||
|     - name: dir | ||||
|       run: cd vcpkg && ls | ||||
|     - name: Integrate with VS | ||||
|       run:  ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe integrate install | ||||
|       shell: cmd | ||||
|     - name: Install C++ REST SDK | ||||
|       run:  ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe install cpprestsdk:x64-windows-static | ||||
|       run:  ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe install cpprestsdk[websockets]:x64-windows-static | ||||
|       shell: cmd | ||||
|     - name: dir | ||||
|       run: ls && cd vcpkg && ls | ||||
| @@ -54,16 +52,31 @@ jobs: | ||||
|     steps: | ||||
|     - uses: actions/checkout@v2 | ||||
|     - name: Install Dependencies | ||||
|       run: | | ||||
|         sudo apt install libboost-system-dev libboost-thread-dev libboost-random-dev libboost-regex-dev  libboost-filesystem-dev libssl-dev zlib1g-dev -y | ||||
|         mkdir build  | ||||
|         cd build | ||||
|         cmake -DCMAKE_BUILD_TYPE=Debug .. | ||||
|         cmake --build . | ||||
|          | ||||
|       run: sudo apt install git cmake build-essential curl zip unzip tar pkg-config | ||||
|     - name: Create Build Dir | ||||
|       run: mkdir build | ||||
|     - name: Clone | ||||
|       run: git clone --branch 2020.11-1 https://github.com/microsoft/vcpkg.git | ||||
|     - name: Build VCPKG | ||||
|       run: cd vcpkg && ./bootstrap-vcpkg.sh | ||||
|       shell: bash | ||||
|     - name: dir | ||||
|       run: ls | ||||
|     - name: dir | ||||
|       run: cd vcpkg && ls | ||||
|     - name: Install C++ REST SDK | ||||
|       run:  ${{ runner.workspace }}/rpc/vcpkg/vcpkg install cpprestsdk[websockets] | ||||
|       shell: bash | ||||
|     - name: dir | ||||
|       run: ls && cd vcpkg && ls | ||||
|       shell: bash | ||||
|     - name: Prepare for build | ||||
|       run:  cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake | ||||
|     - name: Build RPC | ||||
|       run: cd build && cmake --build . --config Debug | ||||
|     - name: GitHub Upload Release Artifacts | ||||
|       uses: actions/upload-artifact@v2 | ||||
|       with: | ||||
|         name: RPC_Linux_${{ matrix.os }} | ||||
|         path: | | ||||
|             build/rpc | ||||
|             build/rpc | ||||
|   | ||||
							
								
								
									
										101
									
								
								Build.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								Build.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,101 @@ | ||||
| # Remote Provisioning Client (RPC) | ||||
|  | ||||
| RPC is an application which enables remote capabilities for AMT, such as as device activation. To accomplish this, RPC communicates with the RPS (Remote Provisioning Server). | ||||
|  | ||||
| The steps below assume the following directory structure where **rpc** is the clone of this repository, **vcpkg** is a clone of the VCPKG tool source and **build** is the RPC build directory. Both vcpkg and build directories will be created in later steps. | ||||
|  | ||||
| ``` | ||||
| \rpc | ||||
|   |__vcpkg | ||||
|   |__build | ||||
| ``` | ||||
|  | ||||
| # Linux | ||||
|  | ||||
| Steps below are for Ubuntu 18.04 and 20.04. | ||||
|  | ||||
| ## Dependencies | ||||
|  | ||||
| ``` | ||||
| sudo apt install git cmake build-essential curl zip unzip tar pkg-config | ||||
| ``` | ||||
|  | ||||
| ## Build C++ REST SDK | ||||
|  | ||||
| Open a Terminal window. | ||||
|  | ||||
| ``` | ||||
| git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git | ||||
| cd vcpkg | ||||
| ./bootstrap-vcpkg.sh | ||||
| ./vcpkg install cpprestsdk[websockets] | ||||
| ``` | ||||
|  | ||||
| ## Build RPC | ||||
|  | ||||
| Open a Terminal window. | ||||
|  | ||||
| ``` | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release .. | ||||
| cmake --build . | ||||
| ``` | ||||
|  | ||||
| To build debug: | ||||
| ``` | ||||
| cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug .. | ||||
| cmake --build . | ||||
| ``` | ||||
|  | ||||
| ## Run RPC | ||||
|  | ||||
| Open a Terminal window. | ||||
|  | ||||
| ``` | ||||
| cd build | ||||
| sudo ./rpc --url wss://localhost:8080 --cmd "-t activate --profile profile1" | ||||
| ``` | ||||
|  | ||||
| Use --help for more options. | ||||
|  | ||||
| # Windows | ||||
|  | ||||
| Steps below are for Windows 10 and Visual Studio 2019 Professional. | ||||
|  | ||||
| ## Build C++ REST SDK | ||||
|  | ||||
| Open an x64 Native Tools Command Prompt for Visual Studio 2019. | ||||
|  | ||||
| ``` | ||||
| git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git | ||||
| cd vcpkg | ||||
| bootstrap-vcpkg.bat | ||||
| vcpkg install cpprestsdk[websockets]:x64-windows-static | ||||
| ``` | ||||
|  | ||||
| ## Build RPC | ||||
| Open an x64 Native Tools Command Prompt for Visual Studio 2019. | ||||
| ``` | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake .. | ||||
| cmake --build . --config Release | ||||
| ``` | ||||
|  | ||||
| To build debug: | ||||
| ``` | ||||
| cmake --build . --config Debug | ||||
| ``` | ||||
|  | ||||
| ## Run RPC | ||||
|  | ||||
| Open a Command Prompt as Administrator. | ||||
|  | ||||
| ``` | ||||
| cd build\Release | ||||
| rpc.exe --url wss://localhost:8080 --cmd "-t activate --profile profile1" | ||||
| ``` | ||||
|  | ||||
| Use --help for more options. | ||||
|  | ||||
| @@ -5,14 +5,10 @@ project (rpc VERSION 1.0.0) | ||||
| set (CMAKE_CXX_STANDARD 11) | ||||
|  | ||||
| # RPC version info | ||||
| configure_file(version.h.in | ||||
|                version.h) | ||||
| configure_file(version.h.in version.h) | ||||
| include_directories(${PROJECT_BINARY_DIR}) | ||||
|  | ||||
| # TODO: figure out how to read the LMS version from repo like the main lms CMakeLists.txt | ||||
| set (LMS_VERSION_STRING 1932.0.0.0) | ||||
|  | ||||
| # Compiler settings [Obtained from CmakeLists.txt for lms] | ||||
| # Common compiler settings | ||||
| string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DDEBUG -D_DEBUG") | ||||
| string(APPEND CMAKE_C_FLAGS_DEBUG " -DDEBUG -D_DEBUG") | ||||
|  | ||||
| @@ -31,7 +27,6 @@ if (UNIX) | ||||
| else (UNIX) | ||||
|   add_definitions (/GS /sdl) | ||||
|   set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NXCompat /DynamicBase") | ||||
|   #add_definitions (/D UNICODE /D _UNICODE) | ||||
|   add_definitions (/D UNICODE /D _UNICODE  /D_NO_ASYNCRTIMP /D_ASYNCRT_EXPORT /D_NO_PPLXIMP /DWIN32 /DMBCS /D_USRDLL /DCPPREST_EXCLUDE_COMPRESSION /D_WINSOCK_DEPRECATED_NO_WARNINGS) | ||||
|   add_compile_options ($<$<CONFIG:Release>:/O2>) | ||||
|   add_compile_options (/MT$<$<CONFIG:Debug>:d>) | ||||
| @@ -42,49 +37,10 @@ endif (UNIX) | ||||
| # Add  MicroLMS directly to our build. This adds | ||||
| # the following targets: MicroLMS | ||||
| add_subdirectory(MicroLMS) | ||||
| #add_dependencies(rpc MicroLMS) | ||||
|  | ||||
| if (UNIX) | ||||
|  | ||||
| # Find threads [unix it pthreads] | ||||
| set(CMAKE_THREAD_PREFER_PTHREAD TRUE) | ||||
| set(THREADS_PREFER_PTHREAD_FLAG TRUE) | ||||
| find_package(Threads REQUIRED) | ||||
|  | ||||
| # Find Boost | ||||
| set(Boost_USE_STATIC_LIBS ON) | ||||
| find_package(Boost COMPONENTS system REQUIRED) | ||||
|  | ||||
| # Find OpenSSL | ||||
| find_package(OpenSSL) | ||||
|  | ||||
| # Find ZLIB | ||||
| find_package(ZLIB) | ||||
|  | ||||
| # Download and build CppRestSDK, If GIT_TAG is changed then need to delete cpprestsdk-prefix because UPDATE_COMMAND is set to "" | ||||
| include(ExternalProject) | ||||
| ExternalProject_Add(cpprestsdk | ||||
|   GIT_REPOSITORY    https://github.com/Microsoft/cpprestsdk.git  | ||||
|   GIT_TAG           v2.10.16 | ||||
|   CMAKE_ARGS        -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=<SOURCE_DIR>/../../install | ||||
|   TEST_COMMAND      "" | ||||
|   UPDATE_COMMAND    "" | ||||
| ) | ||||
| ExternalProject_Get_Property(cpprestsdk SOURCE_DIR) | ||||
| set(CPPRESTSDK_LIBARIES ${SOURCE_DIR}/../../install/lib/) | ||||
| set(CPPRESTSDK_INCLUDE_DIR ${SOURCE_DIR}/../../install/include/) | ||||
|  | ||||
| add_library(cpprest INTERFACE) | ||||
| target_link_libraries(cpprest INTERFACE ${CPPRESTSDK_LIBARIES}/libcpprest.a  OpenSSL::SSL OpenSSL::Crypto ${Boost_LIBRARIES} Threads::Threads ZLIB::ZLIB) | ||||
| target_include_directories(cpprest INTERFACE ${CPPRESTSDK_INCLUDE_DIR}) | ||||
|  | ||||
| else (UNIX) | ||||
|  | ||||
| # CppRestSDK | ||||
| find_package(cpprestsdk CONFIG REQUIRED) | ||||
|  | ||||
| endif (UNIX) | ||||
|  | ||||
| # ccu-poc | ||||
| add_executable (rpc | ||||
|   info.h | ||||
| @@ -111,19 +67,20 @@ target_include_directories(rpc PUBLIC | ||||
|   "MicroLMS/heci" | ||||
| ) | ||||
|  | ||||
| if (UNIX) | ||||
| add_dependencies(rpc MicroLMS) | ||||
|  | ||||
| add_dependencies(rpc cpprestsdk) | ||||
| if (UNIX) | ||||
|  | ||||
| target_link_libraries (rpc PRIVATE  | ||||
|   MicroLMS | ||||
|   cpprest | ||||
|   cpprestsdk::cpprest  | ||||
|   cpprestsdk::cpprestsdk_zlib_internal  | ||||
|   cpprestsdk::cpprestsdk_boost_internal  | ||||
|   cpprestsdk::cpprestsdk_openssl_internal | ||||
| ) | ||||
|  | ||||
| else (UNIX) | ||||
|  | ||||
| add_dependencies(rpc MicroLMS ) | ||||
|  | ||||
| target_link_libraries (rpc PRIVATE  | ||||
|   MicroLMS | ||||
|   cpprestsdk::cpprest | ||||
|   | ||||
							
								
								
									
										85
									
								
								CentOS7.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								CentOS7.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | ||||
| # Remote Provisioning Client (RPC) | ||||
|  | ||||
| RPC is an application which enables remote capabilities for AMT, such as as device activation. To accomplish this, RPC communicates with the RPS (Remote Provisioning Server). | ||||
|  | ||||
| The steps below assume the following directory structure where **rpc** is the clone of this repository, **vcpkg** is a clone of the VCPKG tool source and **build** is the RPC build directory. Both vcpkg and build directories will be created in later steps. | ||||
|  | ||||
| ``` | ||||
| \rpc | ||||
|   |__vcpkg | ||||
|   |__build | ||||
| ``` | ||||
|  | ||||
| # Linux | ||||
|  | ||||
| Steps below are for CentOS7. | ||||
|  | ||||
| **The "export PATH=..." (for CMake and Git), and "scl enable devtoolset-7 bash" (for GCC) must be executed in in the Terminal you are building from; i.e. these are temporary changes which only affect the current Terminal session.** | ||||
|  | ||||
| ## Dependencies | ||||
|  | ||||
| ### CMake | ||||
| Download cmake-3.10.2-Linux-x86_64.sh from https://github.com/Kitware/CMake/releases/tag/v3.10.2. | ||||
|      | ||||
| ``` | ||||
| ./cmake-3.10.2-Linux-x86_64.sh | ||||
| export PATH=/home/user/Downloads/cmake-3.10.2-Linux-x86_64/bin:$PATH | ||||
| ``` | ||||
|  | ||||
| ### GCC | ||||
| Update GCC toolchain. | ||||
|  | ||||
| ``` | ||||
| sudo yum install centos-release-scl | ||||
| sudo yum install devtoolset-7 | ||||
| scl enable devtoolset-7 bash | ||||
| ``` | ||||
|  | ||||
| ### Git | ||||
| Build Git source control system. | ||||
| ``` | ||||
| sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-CPAN perl-devel | ||||
| git clone https://github.com/git/git.git | ||||
| make configure | ||||
| make | ||||
| export PATH=/home/user/Downloads/git:$PATH | ||||
| ``` | ||||
|  | ||||
| ## Build C++ REST SDK | ||||
|  | ||||
| Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. | ||||
|  | ||||
| ``` | ||||
| git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git | ||||
| cd vcpkg | ||||
| ./bootstrap-vcpkg.sh | ||||
| ./vcpkg install cpprestsdk[websockets] | ||||
| ``` | ||||
|  | ||||
| ## Build RPC | ||||
|  | ||||
| Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. | ||||
|  | ||||
| ``` | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DNO_SELECT=ON .. | ||||
| cmake --build . | ||||
| ``` | ||||
|  | ||||
| To build debug: | ||||
| ``` | ||||
| cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -DNO_SELECT=ON .. | ||||
| cmake --build . | ||||
| ``` | ||||
|  | ||||
| ## Run RPC | ||||
|  | ||||
| Open a Terminal window. | ||||
|  | ||||
| ``` | ||||
| cd build | ||||
| sudo ./rpc --url wss://localhost:8080 --cmd "-t activate --profile profile1" | ||||
| ``` | ||||
|  | ||||
| Use --help for more options. | ||||
							
								
								
									
										63
									
								
								CentOS8.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								CentOS8.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | ||||
| # Remote Provisioning Client (RPC) | ||||
|  | ||||
| RPC is an application which enables remote capabilities for AMT, such as as device activation. To accomplish this, RPC communicates with the RPS (Remote Provisioning Server). | ||||
|  | ||||
| The steps below assume the following directory structure where **rpc** is the clone of this repository, **vcpkg** is a clone of the VCPKG tool source and **build** is the RPC build directory. Both vcpkg and build directories will be created in later steps. | ||||
|  | ||||
| ``` | ||||
| \rpc | ||||
|   |__vcpkg | ||||
|   |__build | ||||
| ``` | ||||
|  | ||||
| # Linux | ||||
|  | ||||
| Steps below are for CentOS8. | ||||
|  | ||||
| ## Dependencies | ||||
|  | ||||
| ### CMake | ||||
| Install CMake. | ||||
|      | ||||
| ``` | ||||
| sudo yum install cmake | ||||
| ``` | ||||
|  | ||||
| ## Build C++ REST SDK | ||||
|  | ||||
| Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. | ||||
|  | ||||
| ``` | ||||
| git clone -b 2020.11-1 https://github.com/microsoft/vcpkg.git | ||||
| cd vcpkg | ||||
| ./bootstrap-vcpkg.sh | ||||
| ./vcpkg install cpprestsdk[websockets] | ||||
| ``` | ||||
|  | ||||
| ## Build RPC | ||||
|  | ||||
| Using a Terminal window with the PATH and devtoolset enabled per the Dependencies. | ||||
|  | ||||
| ``` | ||||
| mkdir build | ||||
| cd build | ||||
| cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release .. | ||||
| cmake --build . | ||||
| ``` | ||||
|  | ||||
| To build debug: | ||||
| ``` | ||||
| cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug .. | ||||
| cmake --build . | ||||
| ``` | ||||
|  | ||||
| ## Run RPC | ||||
|  | ||||
| Open a Terminal window. | ||||
|  | ||||
| ``` | ||||
| cd build | ||||
| sudo ./rpc --url wss://localhost:8080 --cmd "-t activate --profile profile1" | ||||
| ``` | ||||
|  | ||||
| Use --help for more options. | ||||
| @@ -37,6 +37,10 @@ if (${BUILD_LIBRARY}) | ||||
| add_definitions(-D BUILD_LIBRARY) | ||||
| endif (${BUILD_LIBRARY}) | ||||
|  | ||||
| if (${NO_SELECT}) | ||||
| add_definitions(-D NO_SELECT) | ||||
| endif (${NO_SELECT}) | ||||
|  | ||||
| add_definitions( -D_POSIX ) | ||||
|  | ||||
| else (UNIX) | ||||
| @@ -183,16 +187,5 @@ target_link_libraries ( | ||||
|  | ||||
| endif (BUILD_LIBRARY) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| endif (UNIX) | ||||
|  | ||||
|   | ||||
| @@ -105,13 +105,17 @@ static ssize_t mei_recv_msg(struct mei *me, unsigned char *buffer, ssize_t len, | ||||
|  | ||||
| static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t len, unsigned long timeout) | ||||
| { | ||||
| #ifndef NO_SELECT | ||||
| 	struct timeval tv; | ||||
| #endif | ||||
| 	ssize_t written; | ||||
| 	ssize_t rc; | ||||
| 	fd_set set; | ||||
|  | ||||
| #ifndef NO_SELECT | ||||
| 	tv.tv_sec = timeout / 1000; | ||||
| 	tv.tv_usec = (timeout % 1000) * 1000000; | ||||
| #endif | ||||
|  | ||||
| 	mei_msg(me, "call write length = %zd, cmd=%d\n", len, (int)buffer[0]); | ||||
|  | ||||
| @@ -123,7 +127,7 @@ static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t | ||||
| 		mei_err(me, "write failed with status %zd %s\n", written, strerror(errno)); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | ||||
| #ifndef NO_SELECT | ||||
| 	FD_ZERO(&set); | ||||
| 	FD_SET(me->fd, &set); | ||||
| 	rc = select(me->fd + 1 , NULL, &set, NULL, &tv); | ||||
| @@ -136,7 +140,7 @@ static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t | ||||
| 		mei_err(me, "write failed on select with status %zd\n", rc); | ||||
| 		goto out; | ||||
| 	} | ||||
|  | ||||
| #endif | ||||
| 	rc = written; | ||||
| out: | ||||
| 	sem_post(&(me->Lock)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user