Protoc generates GRPC .pb.go and grpc.pb.go files in different directories - grpc

I have a GRPC service and associated requests declared in a file called github.com/myuser/myrepo/protos/iam/v1/service.proto. The header for this file looks like this:
syntax = "proto3";
package myrepo.iam.v1;
option go_package = "github.com/myuser/myrepo-go/iam/v1"; // golang
Now, when I attempt to compile this using the following protoc command from the myrepo directory:
find ./protos -type f -name "*.proto" -exec protoc --go_out=./gopb --go-grpc_out=./gopb --go_opt=module=github.com/myuser/myrepo-go {} \;
This command works and produces two files:
gopb /
- iam /
- v1 /
- service.pb.go
- github.com /
- myuser /
- myrepo-go /
- iam /
- v1 /
- service_grpc.pb.go
Of these files, service.pb.go is located correctly but I'm not sure why service_grpc.pb.go is located where it is. How can I ensure that both files are written to gopb/iam/v1/?

You need to duplicate the --go_opt=module= flag for gRPC i.e. --go-grpc_opt=module=github.com/myuser/myrepo-go
protoc \
--go_out=./gopb \
--go_opt=module=github.com/myuser/myrepo-go
--go-grpc_out=./gopb \
--go-grpc_opt=module=github.com/myuser/myrepo-go \
service.proto

Related

Yocto: recipe cannot be made due to missing directories

I am starting to work on Yocto, and trying to put in my first recipe. I already put in the layer for it, called: "meta-layer". This layer was added using the bitbake-layers (create and add) tools, and looks like this:
With the conf/layer.conf in there looking like this:
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-layer"
BBFILE_PATTERN_meta-layer = "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-layer = "6"
LAYERDEPENDS_meta-layer = "core"
LAYERSERIES_COMPAT_meta-layer = "mickledore"
And the bblayers.conf in the build folder looks like this:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBLAYERS ?= " \
/home/ydaelemans/workdir/poky/meta \
/home/ydaelemans/workdir/poky/meta-poky \
/home/ydaelemans/workdir/poky/meta-yocto-bsp \
/home/ydaelemans/workdir/poky/meta-qt5 \
/home/ydaelemans/workdir/poky/meta-hello \
/home/ydaelemans/workdir/poky/build/workspace \
/home/ydaelemans/workdir/poky/build/meta-layer \
"
When I now add a recipe using the devtool add, it adds the recipe .bb file in the wrong place (I think?), namely in
devtool add hello /home/ydaelemans//workdir/poky/meta-layer/recipes-hello
/home/ydaelemans/workdir/poky/build/workspace/recipes/hello/hello.bb
Which is in the build directory instead of the layer in the source directory. When trying to run here it will give errors that it cannot find the source files. So I copy it back into the layer (one level above the source files). From here I make some adjustments for it (since I am running a QT program, and yes the qt meta is already pulled and build on this setup). Now this file will look like this:
SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "CLOSED"
DEPENDS += "qtbase wayland"
SRC_URI = "file://hello.pro \
file://main.cpp \
file://mainwindow.cpp \
file://mainwindow.h \
file://mainwindow.ui \
file://hello.pro.user \
file://hello.pro.user \
file://Makefile"
S = "{WORKDIR}"
do_install:append () {
# install -d ${D}${bindir}
# install -m 0775 qt-app ${D}${bindir}/
}
FILES_${PN} += "${bindir}/qt-app"
inherit qmake5
When I then run it using:
bitbake -b /home/ydaelemans/workdir/poky/meta-layer/recipes-hello/hello.bb
I get these errors:
dir/poky/meta-layer/recipes-hello/hello.bb
WARNING: Buildfile specified, dependencies will not be handled. If this is not what you want, do not use -b / --buildfile.
Loading cache: 100% |########################################################| Time: 0:00:00
Loaded 1786 entries from dependency cache.
Build Configuration:
BB_VERSION = "2.2.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "qemuarm"
DISTRO = "poky"
DISTRO_VERSION = "4.1"
TUNE_FEATURES = "arm vfp cortexa15 neon thumb callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky
meta-yocto-bsp = "master:0ce159991d8e49f8fa97bdf5f088fdfd753a32dc"
meta-qt5 = "master:1d1b19ff577835bf847152eed44d52e8267d9093"
meta-hello
workspace
meta-layer = "master:0ce159991d8e49f8fa97bdf5f088fdfd753a32dc"
Initialising tasks: 100% |###################################################| Time: 0:00:01
Sstate summary: Wanted 0 Local 0 Mirrors 0 Missed 0 Current 0 (0% match, 0% complete)
NOTE: No setscene tasks
NOTE: Executing Tasks
ERROR: hello-1.0-r0 do_configure: ExecutionError('/home/ydaelemans/workdir/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/hello/1.0-r0/temp/run.qmake5_base_postconfigure.22783', 2, None, None)
ERROR: Logfile of failure stored in: /home/ydaelemans/workdir/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/hello/1.0-r0/temp/log.do_configure.22783
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing python function externalsrc_configure_prefunc
| DEBUG: Python function externalsrc_configure_prefunc finished
| DEBUG: Executing shell function qmake5_base_preconfigure
| DEBUG: Shell function qmake5_base_preconfigure finished
| DEBUG: Executing shell function do_configure
| DEBUG: Shell function do_configure finished
| DEBUG: Executing python function do_qa_configure
| DEBUG: Python function do_qa_configure finished
| DEBUG: Executing shell function qmake5_base_postconfigure
| WARNING: exit code 2 from a shell command.
| /home/ydaelemans/workdir/poky/build/tmp/work/cortexa15t2hf-neon-poky-linux-gnueabi/hello/1.0-r0/temp/run.qmake5_base_postconfigure.22783: 152: cannot create /home/ydaelemans/workdir/poky/build/tmp/work-shared/hello/1.0-r0/configure.sstate: Directory nonexistent
ERROR: Task (/home/ydaelemans/workdir/poky/meta-layer/recipes-hello/hello.bb:do_configure) failed with exit code '1'
NOTE: Tasks Summary: Attempted 7 tasks of which 6 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/home/ydaelemans/workdir/poky/meta-layer/recipes-hello/hello.bb:do_configure
Summary: There was 1 WARNING message.
Summary: There was 1 ERROR message, returning a non-zero exit code.
It looks like it is failing on the configuration, which I am not touching. It seems weird that I would need to make that directory by hand no? Or is that indeed what you need to do?
PS: why does devtool add put my recipe .bb file in the build directory instead of at the layers in the source directory?
Regarding the PATH of your recipe after devtool add, it is completely normal.
Devtool uses a “Workspace” layer in which to accomplish builds. This layer is not specific to any single devtool command but is rather a common working area used across the tool.
https://docs.yoctoproject.org/ref-manual/devtool-reference.html
Normally after devtool add the PATH in bblayers.conf should be updated.
Regarding the configuration error, you shouldn't create it by hand. I highly recommand you to avoid using devtool add if you are confused.
Run bitbake -c cleanall hello
Create your layer, and your recipe.
Add the PATH to bblayers.conf
Add in your distro file IMAGE_INSTALL_append = " Hello" (do not forget the space before Hello"
And this it. Launch bitbake.
Please read the documentation

How to find static path in create react app?

I (using windows) have implemented the code given here. For which when I do npm run winBuild where winBuild is "winBuild": "set \"GENERATE_SOURCEMAP=false\" && react-scripts build" I get the below image in my console
and
The post build I have is "postbuild": "purgecss --css build/static/css/*.css --content build/index.html build/static/js/*.js --output build/static/css && find /path/to/build/static -type f \\( -name \\*.js -o -name \\*.css \\) -exec gzip {} \\; -exec mv {}.gz {} \\;"
Taken from above link. But then I realise that it is asking for /path/to/build/static which will vary. How do I find path to static files in create-react-app and if this file name will vary how am I getting File sizes after gzip: as shown in image in my console?
In the Docker container in Linux machine, it's throwing an error as No such file or directory.

how to use bundled program after pyinstaller --add-binary?

I am trying to make an executable with pyinstaller, by issuing something like this:
pyinstaller -F --add-binary="sometool.exe:." myapp.py
The build works fine. But, if I try to do something like:
os.popen('sometool.exe'), the error is that was not found.
So, how can I do that?
For Unix like machine
pyinstaller --noconfirm --log-level=WARN \
--onefile --nowindow \
--add-data="README:." \
--add-data="image1.png:img" \
--add-binary="libfoo.so:lib" \
--hidden-import=secret1 \
--hidden-import=secret2 \
--upx-dir=/usr/local/share/ \
myscript.spec
Or for Windows
pyinstaller --noconfirm --log-level=WARN ^
--onefile --nowindow ^
--add-data="README;." ^
--add-data="image1.png;img" ^
--add-binary="libfoo.so;lib" ^
--hidden-import=secret1 ^
--hidden-import=secret2 ^
--icon=..\MLNMFLCN.ICO ^
myscript.spec
Official Doc: https://pyinstaller.readthedocs.io/en/stable/usage.html
I spent hours to figure out how to use --add-binary and finally got it working. Look at --add-binary="libcrypto.dll:lib", you must add :lib as postfix.
Try using this according to this question:
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
And than in your app:
os.popen(resource_path('sometool.exe'))
This should work. I use this everyday :)
For windows, you should use ; instead of : before the binary file path.
like this :
pyinstaller -F --add-binary="sometool.exe;." myapp.py

Symfony2 Api-Platform bin/schema issue

I've just started Api-Platform framework and while executing:
php bin/schema generate-types src/ app/config/schema.yml
I get this:
C:\wamp\www\sf2-api>php bin/schema generate-types src/ app/config/schema.yml
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../vendor/api-platform/schema-generator/bin" &
& pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m $dir);
fi
fi
dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/schema" "$#"
I am using Symfony 2.7.8 on window7.
I have the same issue on ubunbu 14.04.
Finally, I replace the bin directory with the one in blog-api.
Updated:
The bin-api-platform is the one generated by api-platform.
The bin-blog-api is the one I copy from blog-api. This works fine.
Use :
php vendor/api-platform/schema-generator/bin/schema generate-types src/app/config/schema.yml
instead of :
php bin/schema generate-types src/ app/config/schema.yml
The correct syntax is:
php vendor/api-platform/schema-generator/bin/schema generate-types src/ app/config/schema.yml

Unix find command - Equivalent of .net File.Exists and Directoty.Exists in Unix

In our .net application we have to run file operation commands against Unix system. I am trying to have equivalent of File.Exists and Directory.Exists.
Using ssh in in .net, got to work so far in following way:
Find only files with matching name:
find /folder/subfolder -maxdepth 1 -type f -iname test.mov
Find only directories with matching name:
find /folder/subfolder -maxdepth 1 -type d -iname test
Question - Is it possible to do above operations without splitting full path?
It is not big deal to split the path but existing service in production accepts only command to run and the path.
test -d /path/to/directory_name
[ -d /path/to/directory_name ]
return true or false - i.e. directory.exists
test -f /path/to/filename
[ -f /path/to/filename ]
same for files
You can use these constructs to return ok or not ok
[ -f /path/to/filename ] && exit 0 || exit 1
find does not return an error when it cannot find a named directory or file

Resources