Hi All,
under opencv/3rdparty/openjpeg/ converting openjp2 to bazel
In the process when i'm trying to build using belong content in build file:
cc_library(
name = ""libopenjp2,
srcs = ["*.c"],
hdrs = glob(["*.h"],
),
)
Getting below error:
Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -MD -MF bazel-out/k8-fastbuild/bin/openjp2/_objs/cio/cio.pic.d ... (remaining 15 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
In file included from openjp2/cio.c:40:
openjp2/opj_includes.h:40:10: fatal error: opj_config_private.h: No such file or directory
40 | #include "opj_config_private.h"
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Target //openjp2:cio failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.288s, Critical Path: 0.05s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
So tried creating the missing header file by creating a rule to create file(generate_file.bzl):
# -*- python -*-
def _generate_file_impl(ctx):
out = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(out, ctx.attr.content, ctx.attr.is_executable)
return [DefaultInfo(
files = depset([out]),
data_runfiles = ctx.runfiles(files = [out]),
)]
generate_file = rule(
attrs = {
"content": attr.string(mandatory = True),
"is_executable": attr.bool(default = False),
},
output_to_genfiles = True,
implementation = _generate_file_impl,
)
"""Generate a file with specified content.
This creates a rule to generate a file with specified content (which is either
static or has been previously computed).
Args:
content (:obj:`str`): Desired content of the generated file.
"""
#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:# using the rule file is creating in bazel-bin location, but i want to create it in source code location same as cmake
File location in cmake after build:
opencv/build/3rdparty/openjpeg/openjp2/opj_config_private.h
File location in bazel after build
opencv/3rdparty/openjpeg/openjp2/bazel-bin$ ls
liblibopenjp2.a-2.params _objs opj_config_private.h
How to generate file in source location same as how cmake does