Does `bazel fetch` support exclusion of targets? - bazel

Does bazel fetch support the exclusion of some targets, e. g.
bazel fetch -- //... -//some/target/...
...?
Unfortunately, it seems not to work:
ERROR: syntax error at '- //some/target/...'
For bazel build the exclusion of target using the "minus operator" (-) seems to work.

Related

How to inspect #local_config_platform//:host?

I'm running into some toolchain issues, with errors like:
INFO: ToolchainResolution: Type #io_bazel_rules_go//go:toolchain: target platform #local_config_platform//:host: Rejected toolchain #go_sdk//:go_linux_amd64-impl; mismatching values: linux, x86_64
INFO: ToolchainResolution: Type #io_bazel_rules_go//go:toolchain: target platform #local_config_platform//:host: No toolchains found.
but I believe I am running on x86_64 and Linux, but that would be made clear by inspecting the generated constraints.
This was mentioned earlier, but I was unable to find said-generated file.
And in case it ever helps anyone else, I'm running popos.
Thanks!
Use query --output=build to dump the rule:
$ bazel query --output=build #local_config_platform//:host
# /home/user/.cache/_bazel_cache/bf5544946d234767647dbf413a7bc3c9/external/local_config_platform/BUILD.bazel:4:9
platform(
name = "host",
constraint_values = ["#platforms//cpu:x86_64", "#platforms//os:linux"],
)
The comment line even tells you were to find the original generated BUILD file.

Bazel rule is missing dependency for clang's sanitize-blacklist

I'm trying to add ASAN sanitize to our project which uses Bazel and stuck with the following problem. I've added blacklist for sanitize in our bazel.rc
build:asan --copt -fsanitize=address
build:asan --linkopt -fsanitize=address
build:asan --copt -fsanitize-blacklist=blacklist.txt
but when I build a target I get missing dependency error
ERROR: memory/main/BUILD:1:1: undeclared inclusion(s) in rule '//main:memory_leak':
this rule is missing dependency declarations for the following files included by 'main/memory_leak.cpp':
'memory/blacklist.txt'
Target //main:memory_leak failed to build
It seems that blacklist.txt should be added to the build rule in BUILD file, but we cannot really do that for all gazillion rules we already have. Is there a way to add a global dependency for all rules or something like this?
Normally the C++ toolchain should have the dependency but it is auto-generated.
You can always create a macros to overwrite the default cc_library:
In tools/build_rules/prelude_bazel:
load('#//tools/build_rules:cc.bzl', 'cc_library')
in tools/build_rules/cc.bzl:
def cc_library(data=[], **kwargs):
native.cc_library(data = data + ['//memory:blacklist.txt'], **kwargs)
in memory/BUILD:
exports_files(['blacklist.txt'])
Also add an empty file tools/build_rules/BUILD.
The first file is importing the cc_library in the begining of all your file, the second file is defining a new cc_library that adds the missing dependency and the third file just expose the 'blacklist.txt' to all the other rules. The last empty file is just to define a package for Bazel that is needed to load the cc.bzl file.

Marmalade iOS multiple architectures support

The instruction for building marmalade extension static lib-wrappers from the official site shows how to build only single architecture (armv6) extension. I tried to include many architectures into the project:
if {{defined I3D_OS_IPHONE}}
{
includepath incoming
files
{
["MyTracker Library armv7"]
(incoming/armv7)
"*.o"
["MyTracker Library armv7s"]
(incoming/armv7s)
"*.o"
["MyTracker Library armv64"]
(incoming/armv64)
"*.o"
["source"]
(use_first_found, source/iphone, source/generic)
MyTracker_platform.mm
#Add any iphone-specific files here
}
}
But I got many error messages after trying to build it:
Executing: '/usr/local/bin/scons -Q compiler=clang'
scons: warning: Support for pre-2.7.0 Python version (2.6.8) is deprecated.
If this will cause hardship, contact dev#scons.tigris.org.
File "/usr/local/bin/scons", line 192, in <module>
Librarian [ar] /Users/misha/Documents/MyTracker/lib/iphone/libMyTracker.a
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: archive member: /Users/misha/Documents/MyTracker/lib/iphone/libMyTracker.a(MyDispatcher.o) cputype (7) does not match previous archive members cputype (12) (all members must match)
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: archive member: /Users/misha/Documents/MyTracker/lib/iphone/libMyTracker.a(MyTracker.o) cputype (16777223) does not match previous archive members cputype (12) (all members must match)
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib: archive member: /Users/misha/Documents/MyTracker/lib/iphone/libMyTracker.a(MyNetwork.o) cputype (16777228) does not match previous archive members cputype (12) (all members must match)
....
malformed object (unknown load command 1)
ar: internal ranlib command failed
scons: *** [/Users/misha/Documents/MyTracker/lib/iphone/libMyTracker.a] Error 1
Executing 'scons -Q' failed. (return code 2). Retry
error: Executing 'scons -Q' failed. (return code 2)
FAILED (error code=3)
How to build an extension with multiple architectures support?
This is typically not the advised way to handle this. You look like you're trying to bring in symbols from those libs, something that the EDK does not support. Your best option is to include these libs (or most probably, just the arm6/7 lib, depending on how low you want to take it) at deploy time along with the compiled extension and instead, compile the extension using a header file (either supplied by the developer of any SDK you're using, or one you've written to compile those .o libs).
Building for multiple targets is something that is being refactored. My understanding is that at some stage both the documentation and the underlying code has got stale. I believe the approach will be quite different from what you are trying to do - I'm not sure why you are pulling in .o files but generally that does work too well in marmalade.

Configuring Lager - I get this error: undefined parse transform 'lager_transform'

I'm testing this https://github.com/saleyn/erws_example on R16B03 (both on windows & Ubuntu)
==> erws_example (compile)
src/erws_handler.erl:none: undefined parse transform 'lager_transform'
ERROR: compile failed while processing /home/charles/erws_example: rebar_abort
I've seen this suggestion http://philipcristiano.com/2013/05/27/ordering-of-rebar-dependencies.html
So far, i'm unable to get any headway.
Thanks.
It seems rebar can not compile parse transforms before compiling everything else (https://github.com/basho/rebar/issues/270). The solution is to compile module with parse transform manually or use file-level parse_transform compiler directive instead of project level.
Try to put lager to first position in rebar dependency list. it will fix it. rebar ordering compile dependencies according to this list, not dependency tree))

Nmake: Placeholder/Wildcards in Targets

I already have a Makefile to build my software on Linux. But now i need a .mak file to build on Windows.
However, it's not possible to use Placeholders in Nmake like this way:
build: mytarget_foo
#target build
mytarget_%:
#target mytarget_% to match mytarget_foo
How to use placeholders in Nmake?
Thanks in advance.
EDIT: console output:
'MAKE : fatal error U1073: don't know how to make 'mytarget_foo
Stop.
Use the asterisk. Here's the doc.
mytarget_*:
# target mytarget_* to match mytarget_foo

Resources