Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize Gazelle Behavior? #1197

Open
jflan-dd opened this issue Aug 14, 2024 · 3 comments
Open

Customize Gazelle Behavior? #1197

jflan-dd opened this issue Aug 14, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@jflan-dd
Copy link
Contributor

It it feasible to customize the behavior of gazelle when generating local BUILD files?

In our project we define different "layers" which are reflected in the folder structure on disk. So for example there's a Networking folder, which contains lots of individual packages and our current tooling automatically appends "Networking" to the end of the package name. So for the code in Layers/Networking/Address/Sources will create a package named "AddressNetworking".

Are there any customization points to replicate this logic for the update_build_files command?

@cgrindel
Copy link
Owner

Not at this time. However, I am open to suggestions on how we might be able to support this.

@cgrindel cgrindel added the enhancement New feature or request label Aug 17, 2024
@jflan-dd
Copy link
Contributor Author

jflan-dd commented Aug 23, 2024

Maybe we could take inspiration from Swiftlint's extra_rules setup: https://github.com/jpsim/swiftlint-bazel-example

Add a step in here somewhere that defaults to an empty implementation, but could be overridden similarly to Swiftlint.

func defaultNameAndModuleName(args language.GenerateArgs) (string, string) {
// If the name is specified by a directive, short cirucit and return that:
sc := swiftcfg.GetSwiftConfig(args.Config)
if defaultModuleName, ok := sc.DefaultModuleNames[args.Rel]; ok {
return defaultModuleName, defaultModuleName
}
// Otherwise, derive the name from the:
// 1. Directory name.
// 2. Repository name.
// 3. "DefaultModule"
var defaultName string
if args.Rel == "" {

Related: Could I use this section to accomplish what I need?

	// If the name is specified by a directive, short cirucit and return that:
	sc := swiftcfg.GetSwiftConfig(args.Config)

@cgrindel
Copy link
Owner

cgrindel commented Sep 1, 2024

Could I use this section to accomplish what I need?

I think that it will. I forgot that we had that directive. There are examples of the swift_default_module_name directive in the repo. Here is one:

# gazelle:swift_default_module_name SnapkitExample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants