// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.packages;
import com.google.devtools.build.lib.packages.Type.ConversionException;
import com.google.devtools.build.lib.syntax.Environment;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.FuncallExpression;
import com.google.devtools.build.lib.syntax.SkylarkBuiltin;
import com.google.devtools.build.lib.syntax.SkylarkBuiltin.Param;
import com.google.devtools.build.lib.syntax.SkylarkFunction;
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.syntax.SkylarkModule;
import java.util.Map;
/**
* A class for the Skylark native module.
*/
@SkylarkModule(name = "native", namespace = true, onlyLoadingPhase = true, doc =
"A built-in module to support native rules and other package helper functions. "
+ "All native rules appear as functions in this module. Note that the native module is only "
+ "available in the loading phase (i.e. for macros, not for rule implementations).
"
+ "Extra helper functions:")
public class SkylarkNativeModule {
@SkylarkBuiltin(name = "glob", objectType = SkylarkNativeModule.class,
doc = "Glob returns a list of every file in the current package that:
include
.exclude
"
+ "(default []
).exclude_directories
argument is enabled (set to 1
), "
+ "files of type directory will be omitted from the results (default 1
).",
mandatoryParams = {
@Param(name = "includes", type = SkylarkList.class, generic1 = String.class,
doc = "The list of glob patterns to include.")},
optionalParams = {
@Param(name = "excludes", type = SkylarkList.class, generic1 = String.class,
doc = "The list of glob patterns to exclude."),
@Param(name = "exclude_directories", type = Integer.class,
doc = "A flag whether to exclude directories or not.")})
private static final SkylarkFunction glob = new SkylarkFunction("glob") {
@Override
public Object call(Mapvisibility
attributes.",
mandatoryParams = {
@Param(name = "name", type = String.class,
doc = "A unique name for this rule.")},
optionalParams = {
@Param(name = "packages", type = SkylarkList.class, generic1 = String.class,
doc = "A complete enumeration of packages in this group."),
@Param(name = "includes", type = SkylarkList.class, generic1 = String.class,
doc = "Other package groups that are included in this one.")})
private static final SkylarkFunction packageGroup = new SkylarkFunction("package_group") {
@Override
public Object call(Map