-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup plugin options and tidy up BUCK configuration
Summary: - Tidy up BUCK configuration. Invert the shaded target so that it depends on the unshaded one instead of the other way around - Add plugin configs. Currently, we just have `ENABLED` which is false by default, so that the plugin is basically dormant for now - Update existing dummy extension & test accordingly Reviewed By: zielinskimz Differential Revision: D64464563 fbshipit-source-id: 650766d438a3fe6078b0c57da6bef382a5792753
- Loading branch information
1 parent
f17c3dc
commit 89cace8
Showing
8 changed files
with
82 additions
and
24 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
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
46 changes: 46 additions & 0 deletions
46
...compiler-plugin/compiler/src/main/kotlin/com/facebook/litho/common/LithoCompilerConfig.kt
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,46 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* 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.facebook.litho.common | ||
|
||
import org.jetbrains.kotlin.compiler.plugin.CliOption | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
import org.jetbrains.kotlin.config.CompilerConfigurationKey | ||
|
||
class LithoCompilerConfig<T> private constructor(val cliOption: CliOption, val default: T?) { | ||
init { | ||
if (default == null) require(cliOption.required) | ||
} | ||
|
||
val configKey: CompilerConfigurationKey<T> = CompilerConfigurationKey.create(cliOption.optionName) | ||
|
||
companion object { | ||
val ENABLED: LithoCompilerConfig<Boolean> = | ||
LithoCompilerConfig( | ||
CliOption("enabled", "<true | false>", "whether plugin is enabled", false), | ||
default = false) | ||
|
||
val options: List<CliOption> | ||
get() = listOf(ENABLED.cliOption) | ||
} | ||
} | ||
|
||
operator fun <T> CompilerConfiguration.get(property: LithoCompilerConfig<T>): T { | ||
return when (property.default) { | ||
null -> getNotNull(property.configKey) | ||
else -> get(property.configKey, property.default) | ||
} | ||
} |
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