-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent the bazel plugin from being used for non-Android C++ developm…
…ent in Android Studio. Also ensure that bazel with clion remains usable for all C++ development. PiperOrigin-RevId: 611040268
- Loading branch information
1 parent
3283e9d
commit bd3db6d
Showing
12 changed files
with
197 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
aswb/src/com/google/idea/blaze/android/cppimpl/NdkCppSupportChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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.android.cppimpl; | ||
|
||
import com.android.tools.ndk.AndroidSysroot; | ||
import com.android.tools.ndk.configuration.NdkConfigurationValidatorKt; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.idea.blaze.cpp.CppSupportChecker; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* Uses the Android Studio API to check if a CPP configuration is supported, i.e. is for NDK | ||
* development rather than non-Android CPP. | ||
*/ | ||
public class NdkCppSupportChecker implements CppSupportChecker { | ||
|
||
@Override | ||
public boolean supportsCppConfiguration( | ||
ImmutableList<String> compilerSwitches, Path workspaceRoot) { | ||
return NdkConfigurationValidatorKt.isValidNdkConfiguration( | ||
compilerSwitches, | ||
workspaceRoot, | ||
AndroidSysroot::isValidAndroidSysroot, | ||
AndroidSysroot::isValidAndroidSysrootUsrInclude, | ||
AndroidSysroot::isPotentialNonAndroidSysrootUsrInclude); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.clwb; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.idea.blaze.cpp.CppSupportChecker; | ||
import java.nio.file.Path; | ||
|
||
/** CLwB supports all CPP development. */ | ||
public class ClwbSupportsCpp implements CppSupportChecker { | ||
|
||
@Override | ||
public boolean supportsCppConfiguration( | ||
ImmutableList<String> compilerSwitches, Path workspaceRoot) { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.cpp; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.intellij.openapi.diagnostic.Logger; | ||
import com.intellij.openapi.extensions.ExtensionPointName; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
/** Checks whether or not the IDE supports a given CPP configuration. */ | ||
public interface CppSupportChecker { | ||
|
||
ExtensionPointName<CppSupportChecker> EP_NAME = | ||
new ExtensionPointName<>("com.google.idea.blaze.cpp.CppSupportChecker"); | ||
|
||
Logger logger = Logger.getInstance(CppSupportChecker.class); | ||
|
||
static boolean isSupportedCppConfiguration(List<String> compilerSwitches, Path workspaceRoot) { | ||
for (CppSupportChecker checker : EP_NAME.getExtensionList()) { | ||
if (checker.supportsCppConfiguration(ImmutableList.copyOf(compilerSwitches), workspaceRoot)) { | ||
logger.info("CPP support allowed by " + checker.getClass().getName()); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
boolean supportsCppConfiguration(ImmutableList<String> compilerSwitches, Path workspaceRoot); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters