- 1 year ago
generate c++ source files from multiple proto files with import statements from directory structure in windows bat file
To generate C++ source files from multiple proto files with import statements from directory structure in a Windows batch file, you can use the protoc
command with the --proto_path
flag to specify the directory containing the proto files and the --cpp_out
flag to specify the output directory for the generated C++ files.
Here is an example batch file that demonstrates how to use protoc
to generate C++ files from multiple proto files:
vbnet@echo off
set PROTO_DIR=.\proto
set CPP_DIR=.\cpp
rem Generate C++ files from all proto files in the proto directory and its subdirectories
for /r "%PROTO_DIR%" %%f in (*.proto) do (
protoc --proto_path="%PROTO_DIR%" --cpp_out="%CPP_DIR%" "%%f"
)
echo C++ files generated successfully!
This batch file assumes that your proto files are located in the proto
directory and that you want to generate C++ files in the cpp
directory. You can modify the PROTO_DIR
and CPP_DIR
variables to match your directory structure.
The for /r
loop iterates through all proto files in the specified directory and its subdirectories. For each proto file, the protoc
command is called with the --proto_path
flag set to the proto directory and the --cpp_out
flag set to the cpp directory.
After running the batch file, you should see the generated C++ files in the output directory.