a dialect of Python intended for use as a configuration language. Developed for the Bazel build tool and also used in Buck. It has been renamed Starlark.
Questions tagged [skylark]
16 questions
                    
                    10
                    
            votes
                
                3 answers
            
        Bazel: genrule that outputs a directory
I'm just getting started working with Bazel. So, I apologize in advance that I haven't been able to figure this out.
I'm trying to run a command that outputs a bunch of files to a directory and make this directory available for subsequent targets. I…
        
        Skylar Saveland
        
- 11,116
 - 9
 - 75
 - 91
 
                    8
                    
            votes
                
                3 answers
            
        How to create a directory structure in bazel
I want to create the following structure in bazel.
dir1
   |_ file1
   |_ file2
   |_ dir2
         |_file3
Creating a specific structure doesn't seem trivial.
I'm hoping there's a simple and reusable rule.
Something like:
makedir(
  name =…
        
        GGhe
        
- 663
 - 5
 - 17
 
                    4
                    
            votes
                
                1 answer
            
        How to properly load a Starlark script into another?
I'm trying to make a very simple implementation with Starlark:
greeting.bzl
def greet():
    print ("Hello World!")
test.bzl
load (":greeting.bzl", "greet")
greet()
And execute it with:
java -jar Starlark_deploy.jar test.bzl
The result of the…
        
        Humble Student
        
- 3,755
 - 4
 - 20
 - 35
 
                    3
                    
            votes
                
                1 answer
            
        Instantiating a Bazel macro twice with same generated output file
Suppose I have a Bazel macro that is using a generator rule to generate an output file given an input file:
def my_generator(
        name,
        input_file,
        output_file,
        **kwargs):
    args = []
    args.extend(["--arg1",…
        
        roschach
        
- 8,390
 - 14
 - 74
 - 124
 
                    3
                    
            votes
                
                1 answer
            
        Skylark struct with methods
Here's something I tried to do, and it works well. I find it useful, but it feels like a hack, so I'm afraid it will break in the future.
I'm working on converting a large project to Bazel, and we have lots of local wrappers, something…
        
        ugoren
        
- 16,023
 - 3
 - 35
 - 65
 
                    3
                    
            votes
                
                1 answer
            
        How do I include a Skylark configuration parser in my application?
I like the idea of configuring my Java application with restricted Python code. This restrained Python configuration language goes by the name of Skylark. I found a Go library for Skylark support, but I need a Java one.
Which maven artifact from the…
        
        user7610
        
- 25,267
 - 15
 - 124
 - 150
 
                    1
                    
            vote
                
                0 answers
            
        Bazel get full path of bazel-out/workspace in Skylark
I want to integrate checkstyle with bazel following this SO thread: What is the best way to invoke Checkstyle from within Bazel?
which works perfectly as long as I provide the full harcoded path when building the classpath
checkstyle.bzl
for file in…
        
        KeykoYume
        
- 2,497
 - 6
 - 24
 - 48
 
                    1
                    
            vote
                
                2 answers
            
        How do I get workspace status in bazel
I would like to version build artefacts with build number for CI passed to bazel via workspace_status_command. Sometimes I would like to include build number to the name of the artefact.
Is there a way how do I access ctx when writing a macro(as I…
        
        jaksky
        
- 3,305
 - 4
 - 35
 - 68
 
                    1
                    
            vote
                
                1 answer
            
        Toolchain not downloading the tool
Hi I'm trying to set up a toolchain for the Fn project. The approach is to set up a toolchain per binary available in GitHub and then, in theory use it in a rule. 
I have a common package which has the available binaries:
default_version =…
        
        mrk
        
- 75
 - 8
 
                    1
                    
            vote
                
                1 answer
            
        Using bazel macros across repositories with labels
I've got two repositories, Client and Library.
Inside of Client's WORKSPACE file Client imports Library as a http_archive with the name "foo".
Inside of Client, I want to use Library macros that reference targets inside Library. My problem is that…
        
        razeh
        
- 2,725
 - 1
 - 20
 - 27
 
                    0
                    
            votes
                
                0 answers
            
        Python program run using bazel skylark rule is not running properly
I have custom rule to invoke py_binary.
When I do
Bazel Build //Cutom_rule --platform=//platform/stm32f4
the python program invoked is not able to run the subprocesses_run() that runs command(STLink_cli.exe -list) within python program. I think the…
        
        Hema
        
- 1
 - 1
 
                    0
                    
            votes
                
                1 answer
            
        How to get list diff in Skylark?
I'd like to do something like:
    srcs = glob(["*.proto"]) - ["some.proto"],
That particular syntax isn't valid in Skylark. How do I go about accomplishing a list diff in Skylark?
        
        Noel Yap
        
- 18,822
 - 21
 - 92
 - 144
 
                    0
                    
            votes
                
                1 answer
            
        How can I pass an alias value to a bazel function?
I have the following alias defined in a BUILD file:
alias(
    name = "platform",
    actual = select({
        ":macos_x86_64": "macos_x86_64",
        ":linux_x86_64": "linux_x86_64",
        ":linux_aarch64": "linux_aarch64",
    }),
   …
        
        qwerty
        
- 188
 - 4
 
                    0
                    
            votes
                
                1 answer
            
        How to pass test args in Skylark Bazel?
I'm writing some bazel tests where I need to be able to provide the full path to some file.
bazel test //webservice:checkstyle-test --test_arg="path_to_some_file"
My question is how can you parse the input arguments in your bazel test? Is there…
        
        KeykoYume
        
- 2,497
 - 6
 - 24
 - 48
 
                    0
                    
            votes
                
                1 answer
            
        Bazel sorts keys of attr.label_keyed_string_dict implicity
I'm currently running Bazel 0.9.0. I've defined a custom Bazel rule. In one of the fields, I'm using a attr.label_keyed_string_dict. While processing the keys during evaluation phase, the keys are being sorted implicitly. Is there any flag/option to…