Skip to content

Commit

Permalink
fix: Disable python codegen support by default (#6884)
Browse files Browse the repository at this point in the history
* fix: Disable python codegen support by default

* fix: Disable python codegen support by default

* Update EnablePythonCodegenSupport.java
  • Loading branch information
tpasternak authored Oct 11, 2024
1 parent 017e063 commit 7ba94e2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 The Bazel Authors. 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.idea.blaze.base.projectview.section.sections;

import com.google.idea.blaze.base.projectview.section.ScalarSection;
import com.google.idea.blaze.base.projectview.section.SectionKey;
import com.google.idea.blaze.base.projectview.section.SectionParser;

public class EnablePythonCodegenSupport {
public static final SectionKey<Boolean, ScalarSection<Boolean>> KEY =
SectionKey.of("enable_python_codegen_support");
public static final SectionParser PARSER = new BooleanSectionParser(
KEY,
"""
If set to true, enables Python codegen support.
More info <a href=https://github.com/bazelbuild/intellij/blob/master/docs/python/code-generators.md>here</a>
"""
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class Sections {
SyncFlagsSection.PARSER,
TestFlagsSection.PARSER,
ImportTargetOutputSection.PARSER,
EnablePythonCodegenSupport.PARSER,
ExcludeTargetSection.PARSER,
ExcludedSourceSection.PARSER,
RunConfigurationsSection.PARSER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.google.idea.blaze.base.projectview.ProjectViewSet;
import com.google.idea.blaze.base.projectview.section.sections.AutomaticallyDeriveTargetsSection;
import com.google.idea.blaze.base.projectview.section.sections.EnablePythonCodegenSupport;
import com.google.idea.blaze.base.projectview.section.sections.SyncManualTargetsSection;
import com.google.idea.blaze.base.projectview.section.sections.TargetSection;
import com.google.idea.blaze.base.scope.BlazeContext;
Expand Down Expand Up @@ -194,7 +195,7 @@ private static ImmutableList<TargetExpression> deriveTargetsFromDirectories(
.filter(Objects::nonNull)
.collect(Collectors.toSet());

if (!activeLanguageCodeGeneratorTags.isEmpty()) {
if (!activeLanguageCodeGeneratorTags.isEmpty() && projectViewSet.getScalarValue(EnablePythonCodegenSupport.KEY).orElse(false)) {
retainedByCodeGen = TargetTagFilter.filterCodeGen(
project,
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.idea.blaze.base.projectview.section.sections.BuildFlagsSection;
import com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry;
import com.google.idea.blaze.base.projectview.section.sections.DirectorySection;
import com.google.idea.blaze.base.projectview.section.sections.EnablePythonCodegenSupport;
import com.google.idea.blaze.base.projectview.section.sections.ExcludeTargetSection;
import com.google.idea.blaze.base.projectview.section.sections.ExcludedSourceSection;
import com.google.idea.blaze.base.projectview.section.sections.ImportSection;
Expand Down Expand Up @@ -122,6 +123,7 @@ public void testProjectViewSetSerializable() {
.set(new WorkspacePath("test")))
.add(ScalarSection.builder(UseExclusionPatternsSection.KEY).set(false))
.add(ScalarSection.builder(ViewProjectRootSection.KEY).set(false))
.add(ScalarSection.builder(EnablePythonCodegenSupport.KEY).set(false))
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
directories:
.

derive_targets_from_directories: true

additional_languages:
python

enable_python_codegen_support: true

0 comments on commit 7ba94e2

Please sign in to comment.