Skip to content

Commit

Permalink
Flip flag --incompatible_new_actions_api
Browse files Browse the repository at this point in the history
#5825

RELNOTES: Flag --incompatible_new_actions_api is enabled by dewfault (#5825)
PiperOrigin-RevId: 250171963
  • Loading branch information
laurentlb authored and copybara-github committed May 27, 2019
1 parent 2a10729 commit 5e51c88
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl

@Option(
name = "incompatible_new_actions_api",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static Builder builderWithDefaults() {
.incompatibleDisallowRuleExecutionPlatformConstraintsAllowed(false)
.incompatibleDisallowStructProviderSyntax(false)
.incompatibleExpandDirectories(true)
.incompatibleNewActionsApi(false)
.incompatibleNewActionsApi(true)
.incompatibleNoAttrLicense(true)
.incompatibleNoKwargsInBuildFiles(false)
.incompatibleNoOutputAttrDefault(true)
Expand Down
77 changes: 40 additions & 37 deletions src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,21 @@
/**
* Main entry point for the Skydoc binary.
*
* <p>Skydoc generates human-readable documentation for relevant details of skylark files by
* running a skylark interpreter with a fake implementation of the build API.</p>
* <p>Skydoc generates human-readable documentation for relevant details of skylark files by running
* a skylark interpreter with a fake implementation of the build API.
*
* <p>Currently, Skydoc generates documentation for skylark rule definitions (discovered by
* invocations of the build API function {@code rule()}.</p>
* invocations of the build API function {@code rule()}.
*
* <p>Usage:
*
* <p>Usage:</p>
* <pre>
* skydoc {target_skylark_file_label} {output_file} [symbol_name]...
* </pre>
* <p>
* Generates documentation for all exported symbols of the target skylark file that are
* specified in the list of symbol names. If no symbol names are supplied, outputs documentation
* for all exported symbols in the target skylark file.
* </p>
*
* <p>Generates documentation for all exported symbols of the target skylark file that are specified
* in the list of symbol names. If no symbol names are supplied, outputs documentation for all
* exported symbols in the target skylark file.
*/
public class SkydocMain {

Expand Down Expand Up @@ -170,6 +170,7 @@ public static void main(String[] args)
StarlarkSemanticsOptions semanticsOptions = parser.getOptions(StarlarkSemanticsOptions.class);
semanticsOptions.incompatibleDepsetUnion = false;
semanticsOptions.incompatibleDisableDeprecatedAttrParams = false;
semanticsOptions.incompatibleNewActionsApi = false;
SkydocOptions skydocOptions = parser.getOptions(SkydocOptions.class);

String targetFileLabelString;
Expand Down Expand Up @@ -198,8 +199,7 @@ public static void main(String[] args)
depRoots = ImmutableList.copyOf(skydocOptions.depRoots);
}

Label targetFileLabel =
Label.parseAbsolute(targetFileLabelString, ImmutableMap.of());
Label targetFileLabel = Label.parseAbsolute(targetFileLabelString, ImmutableMap.of());

ImmutableMap.Builder<String, RuleInfo> ruleInfoMap = ImmutableMap.builder();
ImmutableMap.Builder<String, ProviderInfo> providerInfoMap = ImmutableMap.builder();
Expand Down Expand Up @@ -271,9 +271,8 @@ private static void printRuleInfos(
}

private static void printProviderInfos(
PrintWriter printWriter,
MarkdownRenderer renderer,
Map<String, ProviderInfo> providerInfos) throws IOException {
PrintWriter printWriter, MarkdownRenderer renderer, Map<String, ProviderInfo> providerInfos)
throws IOException {
for (Entry<String, ProviderInfo> entry : providerInfos.entrySet()) {
printProviderInfo(printWriter, renderer, entry.getKey(), entry.getValue());
printWriter.println();
Expand All @@ -299,14 +298,17 @@ private static void printUserDefinedFunctions(
}

private static void printRuleInfo(
PrintWriter printWriter, MarkdownRenderer renderer,
String exportedName, RuleInfo ruleInfo) throws IOException {
PrintWriter printWriter, MarkdownRenderer renderer, String exportedName, RuleInfo ruleInfo)
throws IOException {
printWriter.println(renderer.render(exportedName, ruleInfo));
}

private static void printProviderInfo(
PrintWriter printWriter, MarkdownRenderer renderer,
String exportedName, ProviderInfo providerInfo) throws IOException {
PrintWriter printWriter,
MarkdownRenderer renderer,
String exportedName,
ProviderInfo providerInfo)
throws IOException {
printWriter.println(renderer.render(exportedName, providerInfo));
}

Expand Down Expand Up @@ -347,14 +349,12 @@ public Environment eval(
List<ProviderInfo> providerInfoList = new ArrayList<>();
Environment env = recursiveEval(semantics, label, ruleInfoList, providerInfoList);

Map<BaseFunction, RuleInfo> ruleFunctions = ruleInfoList.stream()
.collect(Collectors.toMap(
RuleInfo::getIdentifierFunction,
Functions.identity()));
Map<BaseFunction, ProviderInfo> providerInfos = providerInfoList.stream()
.collect(Collectors.toMap(
ProviderInfo::getIdentifier,
Functions.identity()));
Map<BaseFunction, RuleInfo> ruleFunctions =
ruleInfoList.stream()
.collect(Collectors.toMap(RuleInfo::getIdentifierFunction, Functions.identity()));
Map<BaseFunction, ProviderInfo> providerInfos =
providerInfoList.stream()
.collect(Collectors.toMap(ProviderInfo::getIdentifier, Functions.identity()));

// Sort the bindings so their ordering is deterministic.
TreeMap<String, Object> sortedBindings = new TreeMap<>(env.getGlobals().getExportedBindings());
Expand Down Expand Up @@ -492,10 +492,11 @@ private Environment evalSkylarkBody(
* @param providerInfoList the list of {@link ProviderInfo} objects, to which provider()
* invocation information will be added
*/
private static GlobalFrame globalFrame(List<RuleInfo> ruleInfoList,
List<ProviderInfo> providerInfoList) {
private static GlobalFrame globalFrame(
List<RuleInfo> ruleInfoList, List<ProviderInfo> providerInfoList) {
TopLevelBootstrap topLevelBootstrap =
new TopLevelBootstrap(new FakeBuildApiGlobals(),
new TopLevelBootstrap(
new FakeBuildApiGlobals(),
new FakeSkylarkAttrApi(),
new FakeSkylarkCommandLineApi(),
new FakeSkylarkNativeModuleApi(),
Expand All @@ -504,16 +505,18 @@ private static GlobalFrame globalFrame(List<RuleInfo> ruleInfoList,
new FakeOutputGroupInfoProvider(),
new FakeActionsInfoProvider(),
new FakeDefaultInfoProvider());
AndroidBootstrap androidBootstrap = new AndroidBootstrap(new FakeAndroidSkylarkCommon(),
new FakeApkInfoProvider(),
new FakeAndroidInstrumentationInfoProvider(),
new FakeAndroidDeviceBrokerInfoProvider(),
new FakeAndroidResourcesInfoProvider(),
new FakeAndroidNativeLibsInfoProvider());
AndroidBootstrap androidBootstrap =
new AndroidBootstrap(
new FakeAndroidSkylarkCommon(),
new FakeApkInfoProvider(),
new FakeAndroidInstrumentationInfoProvider(),
new FakeAndroidDeviceBrokerInfoProvider(),
new FakeAndroidResourcesInfoProvider(),
new FakeAndroidNativeLibsInfoProvider());
AppleBootstrap appleBootstrap = new AppleBootstrap(new FakeAppleCommon());
ConfigBootstrap configBootstrap =
new ConfigBootstrap(new FakeConfigSkylarkCommon(), new FakeConfigApi(),
new FakeConfigGlobalLibrary());
new ConfigBootstrap(
new FakeConfigSkylarkCommon(), new FakeConfigApi(), new FakeConfigGlobalLibrary());
CcBootstrap ccBootstrap = new CcBootstrap(new FakeCcModule());
JavaBootstrap javaBootstrap =
new JavaBootstrap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public void testOutputFilterWithDebug() throws Exception {
"java/b/rules.bzl",
"def _impl(ctx):",
" print('debug in b')",
" ctx.file_action(",
" ctx.actions.write(",
" output = ctx.outputs.my_output,",
" content = 'foo',",
" )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public void testCppActionTemplate_includesActionTemplateMnemonic() throws Except
"test/a.bzl",
"def _impl(ctx):",
" directory = ctx.actions.declare_directory(ctx.attr.name + \"_artifact.cc\")",
" ctx.action(",
" ctx.actions.run_shell(",
" inputs = ctx.files.srcs,",
" outputs = [directory],",
" mnemonic = 'MoveTreeArtifact',",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public final void setUpMocks() throws Exception {

@Before
public final void setupSkylarkRule() throws Exception {
setSkylarkSemanticsOptions("--incompatible_new_actions_api=false");

File[] files = Runfiles.location(RULE_DIRECTORY).listFiles();
for (File file : files) {
scratch.file(RULE_DIRECTORY + "/" + file.getName(), Files.readAllBytes(file.toPath()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,6 @@ public void testCreateSpawnActionUnknownParam() throws Exception {
"ruleContext.actions.run(outputs=[], bad_param = 'some text', executable = f)");
}

@Test
public void testCreateSpawnActionNoExecutable() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
checkErrorContains(
ruleContext,
"You must specify either 'command' or 'executable' argument",
"ruleContext.action(outputs=[])");
}

private Object createTestSpawnAction(SkylarkRuleContext ruleContext) throws Exception {
return evalRuleContextCode(
ruleContext,
Expand Down
12 changes: 6 additions & 6 deletions src/test/shell/bazel/external_path_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ cat $1 | tr 'a-z' 'A-Z' > $2
EOF
cat > rule/to_upper.bzl <<'EOF'
def _to_upper_impl(ctx):
output = ctx.new_file(ctx.label.name + ".txt")
ctx.action(
output = ctx.actions.declare_file(ctx.label.name + ".txt")
ctx.actions.run_shell(
inputs = ctx.files.src + ctx.files._toupper_sh,
outputs = [output],
command = ["/bin/sh"] + [f.path for f in ctx.files._toupper_sh] \
Expand Down Expand Up @@ -489,8 +489,8 @@ genrule(
EOF
cat > rule/to_html.bzl <<'EOF'
def _to_html_impl(ctx):
output = ctx.new_file(ctx.label.name + ".html")
ctx.action(
output = ctx.actions.declare_file(ctx.label.name + ".html")
ctx.actions.run_shell(
inputs = ctx.files.src + ctx.files._to_html + ctx.files._preamb + ctx.files._postamb,
outputs = [output],
command = ["/bin/sh"] + [f.path for f in ctx.files._to_html] \
Expand Down Expand Up @@ -642,8 +642,8 @@ genrule(
EOF
cat > rule/add_preamb.bzl <<'EOF'
def _add_preamb_impl(ctx):
output = ctx.new_file(ctx.label.name + ".txt")
ctx.action(
output = ctx.actions.declare_file(ctx.label.name + ".txt")
ctx.actions.run_shell(
inputs = ctx.files.src + ctx.files._add_preamb + ctx.files._preamb,
outputs = [output],
command = ["/bin/sh"] + [f.path for f in ctx.files._add_preamb] \
Expand Down
4 changes: 2 additions & 2 deletions src/test/shell/integration/aquery_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bar_aspect = aspect(implementation = _aspect_impl,
)
def _bar_impl(ctx):
ctx.file_action(content = "hello world", output = ctx.outputs.out)
ctx.actions.write(content = "hello world", output = ctx.outputs.out)
return struct(files = depset(transitive = [dep[DummyProvider].dummies for dep in ctx.attr.deps]))
bar_rule = rule(
Expand Down Expand Up @@ -798,7 +798,7 @@ function test_aquery_cpp_action_template_treeartifact_output() {
cat > "$pkg/a.bzl" <<'EOF'
def _impl(ctx):
directory = ctx.actions.declare_directory(ctx.attr.name + "_artifact.cc")
ctx.action(
ctx.actions.run_shell(
inputs = ctx.files.srcs,
outputs = [directory],
mnemonic = 'MoveTreeArtifact',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ test_custom_message() {
touch WORKSPACE
cat > rule.bzl <<'EOF'
def _rule_impl(ctx):
out = ctx.new_file(ctx.label.name + ".txt")
ctx.action(
out = ctx.actions.declare_file(ctx.label.name + ".txt")
ctx.actions.run_shell(
inputs = ctx.files._data,
outputs = [out],
command = ["cp"] + [f.path for f in ctx.files._data] + [out.path],
Expand Down

0 comments on commit 5e51c88

Please sign in to comment.