diff --git a/build-it/LV Build/BuildGRPCPackages.vi b/build-it/LV Build/BuildGRPCPackages.vi new file mode 100644 index 00000000..2bc31478 Binary files /dev/null and b/build-it/LV Build/BuildGRPCPackages.vi differ diff --git a/build-it/LV Build/BuildVIPBFile.vi b/build-it/LV Build/BuildVIPBFile.vi new file mode 100644 index 00000000..efe13f2b Binary files /dev/null and b/build-it/LV Build/BuildVIPBFile.vi differ diff --git a/build-it/LV Build/GRPCVIPMBuild.lvproj b/build-it/LV Build/GRPCVIPMBuild.lvproj new file mode 100644 index 00000000..82ae0ef6 --- /dev/null +++ b/build-it/LV Build/GRPCVIPMBuild.lvproj @@ -0,0 +1,96 @@ + + + + true + true + false + 0 + My Computer/VI Server + My Computer/VI Server + true + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + diff --git a/build-it/LV Build/GetClientServerTemplateBuildSpecPath.vi b/build-it/LV Build/GetClientServerTemplateBuildSpecPath.vi new file mode 100644 index 00000000..816a70c9 Binary files /dev/null and b/build-it/LV Build/GetClientServerTemplateBuildSpecPath.vi differ diff --git a/build-it/LV Build/GetInstalledVIPMPackages.vi b/build-it/LV Build/GetInstalledVIPMPackages.vi new file mode 100644 index 00000000..c23f4bc2 Binary files /dev/null and b/build-it/LV Build/GetInstalledVIPMPackages.vi differ diff --git a/build-it/LV Build/GetLVServicerBuildSpecPath.vi b/build-it/LV Build/GetLVServicerBuildSpecPath.vi new file mode 100644 index 00000000..2412e3cb Binary files /dev/null and b/build-it/LV Build/GetLVServicerBuildSpecPath.vi differ diff --git a/build-it/LV Build/GetLVSupportBuildSpecPath.vi b/build-it/LV Build/GetLVSupportBuildSpecPath.vi new file mode 100644 index 00000000..bb58147a Binary files /dev/null and b/build-it/LV Build/GetLVSupportBuildSpecPath.vi differ diff --git a/build-it/LV Build/InstallVIPMPackage.vi b/build-it/LV Build/InstallVIPMPackage.vi new file mode 100644 index 00000000..e51f9c9a Binary files /dev/null and b/build-it/LV Build/InstallVIPMPackage.vi differ diff --git a/build-it/LV Build/UnInstallGRPCPackages.vi b/build-it/LV Build/UnInstallGRPCPackages.vi new file mode 100644 index 00000000..08a1a1fd Binary files /dev/null and b/build-it/LV Build/UnInstallGRPCPackages.vi differ diff --git a/build-it/build.py b/build-it/build.py new file mode 100644 index 00000000..2798f692 --- /dev/null +++ b/build-it/build.py @@ -0,0 +1,90 @@ +import sys +import os +import distutils +import distutils.dir_util +import distutils.file_util +import subprocess + +class LVgRPCBuilder: + def __init__(self): + self.build_script_directory = os.path.abspath(os.path.dirname(__file__)) + self.root_directory = os.path.dirname(self.build_script_directory) + self.server_binary_destination = os.path.join(self.root_directory, "labview source", "gRPC lv Support") + self.generator_binary_destination = os.path.join(self.root_directory, "labview source", "Client Server Support New", "gRPC Scripting Tools", "Proto Parser API") + self.parse_configuration() + + def parse_configuration(self): + self.build_target = None + self.path_to_binaries = None + self.vipb_build_only = True + + for i in range(1, len(sys.argv)): + current_arg = sys.argv[i] + + if current_arg == "--target" or current_arg == "-t": + self.build_target = sys.argv[i+1] + elif current_arg == "--pathToBinaries" or current_arg == "-p": + self.path_to_binaries = sys.argv[i+1] + elif current_arg == "--buildcpp": + self.vipb_build_only = False + + if self.build_target != "Win32" and self.build_target != "Win64" and self.build_target != "All": + raise Exception("Build target should be one off Win32, Win64 or All. Passed build target is " + self.build_target) + + if self.build_target == "All" and self.path_to_binaries == None: + raise Exception("For build target All a path to binaries should be specified using the --pathToBinaries/-p option") + + def get_cmake_args(self): + if self.build_target == "Win32": + return ["-A", "Win32", ".."] + elif self.build_target == "Win64": + return [".."] + + def cpp_build(self): + cpp_build_directory = os.path.join(self.root_directory, "build"); + if os.path.exists(cpp_build_directory): + distutils.dir_util.remove_tree(cpp_build_directory) + os.makedirs(cpp_build_directory) + os.chdir(cpp_build_directory) + + subprocess.run(["cmake"] + self.get_cmake_args()) + subprocess.run(["cmake", "--build", ".", "--config", "Release"]) + + def copy_binaries_all_targets(self): + server_dll_source = os.path.join(self.path_to_binaries, "LabVIEW gRPC Server") + distutils.dir_util.copy_tree(server_dll_source, self.server_binary_destination) + generator_dll_source = os.path.join(self.path_to_binaries, "LabVIEW gRPC Generator") + distutils.dir_util.copy_tree(generator_dll_source, self.generator_binary_destination) + + def copy_binaries_for_target(self): + server_dll_source = os.path.join(self.root_directory, "build", "Release", "labview_grpc_server.dll") + server_dll_destination = os.path.join(self.server_binary_destination, "Libraries", self.build_target) + if not os.path.exists(server_dll_destination): + os.makedirs(server_dll_destination) + distutils.file_util.copy_file(server_dll_source, server_dll_destination) + + generator_dll_source = os.path.join(self.root_directory, "build", "Release", "labview_grpc_generator.dll") + generator_dll_destination = os.path.join(self.generator_binary_destination, "Libraries", self.build_target) + if not os.path.exists(generator_dll_destination): + os.makedirs(generator_dll_destination) + distutils.file_util.copy_file(generator_dll_source, generator_dll_destination) + + def copy_built_binaries(self): + if self.build_target == "All": + self.copy_binaries_all_targets() + else: + self.copy_binaries_for_target() + + + def build(self): + if not self.build_target == "All" and not self.vipb_build_only: + self.cpp_build() + self.copy_built_binaries() + build_vi_path = os.path.join(self.build_script_directory, "LV Build", "BuildGRPCPackages.vi") + subprocess.run(["LabVIEWCLI", "-OperationName", "RunVI", "-VIPath", build_vi_path, os.path.join(self.root_directory, "labview source")]) + +def main(): + gRPCPackageBuilder = LVgRPCBuilder() + gRPCPackageBuilder.build() + +main() \ No newline at end of file diff --git a/docs/Building.md b/docs/Building.md index 5d5dbac3..20397ebb 100644 --- a/docs/Building.md +++ b/docs/Building.md @@ -1,16 +1,18 @@ -# Building the Scripting and Server binaries +# Build Instructions -This document covers building the binaries for various operation systems. +## Building the Scripting and Server binaries + +This section covers building the binaries for various operation systems. You only need to build the binaries if you wish to contribute to the C++ source or if you need binaries for a OS that is not supported by default. -## Build Status +### Build Status ![Linux Build](https://github.com/ni/grpc-labview/workflows/Linux%20Build/badge.svg) ![Windows x64 build](https://github.com/ni/grpc-labview/workflows/Windows%20x64%20build/badge.svg) ![Windows x86 build](https://github.com/ni/grpc-labview/workflows/Windows%20x86%20build/badge.svg) -## Building on Windows +### Building on Windows -### Prerequisites +#### Prerequisites To prepare for cmake + Microsoft Visual C++ compiler build - Install LabVIEW 2019 - Install Visual Studio 2015, 2017, or 2019 (Visual C++ compiler will be used). @@ -18,7 +20,7 @@ To prepare for cmake + Microsoft Visual C++ compiler build - Install [CMake](https://cmake.org/download/). -### Building 64-bit +#### Building 64-bit **Launch "x64 Native Tools Command Prompt for Visual Studio"** @@ -45,7 +47,7 @@ Build Release > cmake .. > cmake --build . --config Release ``` -### Building 32-bit +#### Building 32-bit **Launch "x86 Native Tools Command Prompt for Visual Studio"** @@ -73,7 +75,7 @@ Build Release > cmake --build . --config Release ``` -## Building on Linux +### Building on Linux Download the repo and update submodules, this will pull the gRPC components and all dependencies @@ -101,7 +103,7 @@ Build Release > make ``` -## Building on Linux RT +### Building on Linux RT Install required packages not installed by default @@ -140,3 +142,52 @@ Build Release > make ``` +## Building the VIP files for LV Support, LV Servicer and Client and Server templates + +This section covers building the VIP files from the labview source so that you can install them for a supported version of LabVIEW (2019 or Higher). + +You would need to build the VIP files if you make changes to the LabVIEW pieces of the grpc-labview repository. + +** Building of VIP files using the instructions below is only supported on Windows ** + +### Prerequisites + +- Install LabVIEW 2019 32 bit +- Install LabVIEW CLI +- Install JKI VI Package Manager. You would need Community or Pro edition to build VIP files. +- Install VI Package Manager API for LabVIEW. (Download [location](https://www.ni.com/en-in/support/downloads/tools-network/download.vi-package-manager-api.html#374501)) +- Install Python 3.7 or Higher + +** Apart from these you would need the Prerequisites for building the binaries as well if you use the --buildcpp option described below. ** + +### Building VIP files + +Download the repo. Run the command below to build the VIP files. + +``` +> python build-it\build.py --target [--pathToBinaries ] [--buildcpp] +``` + +The accepted vaues for BUILD_TARGET are: +- Win32 +- Win64 +- All + +If you choose to build for Win32 or Win64 target you can specify the *--buildcpp* option to indicate that you want to build the C++ binaries first and then use them to build VIP files. If you don't specify this option it is assumed that the required binaries are already built accoriding to the steps described above. + +If you choose to build "All" target then you need to specify a folder where we can find the pre built binaries for all the supported targets using the *--pathToBinaries** option. The --buildcpp option would be ignored in this mode even if specified. We expect the folder specified to have the following structure. + +``` +- + - LabVIEW gRPC Server + - Libraries + - Win32 + - Win64 + - Linux + - LinuxRT + - LabVIEW gRPC Generator + - Libraries + - Win32 + - Win64 + - Linux +```