...

Source file src/github.com/chaos-mesh/chaos-mesh/cmd/generate-makefile/generate_local_binary_makefile.go

Documentation: github.com/chaos-mesh/chaos-mesh/cmd/generate-makefile

     1  // Copyright 2023 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  
    16  package main
    17  
    18  // localBinaryGeneratedMkTemplate is the template for the file local-binary.generated.mk, use binaryGeneratedMkOptions as the context.
    19  const localBinaryGeneratedMkTemplate = `# Generated by ./cmd/generate-makefile. DO NOT EDIT.
    20  
    21  ##@ Generated targets in local-binary.generated.mk
    22  
    23  {{ .Content -}}
    24  
    25  .PHONY: clean-local-binary
    26  clean-local-binary:
    27  {{- range .Recipes }}
    28  	rm -f {{ .OutputPath }}
    29  {{- end }}
    30  `
    31  
    32  // localBinaryRecipeTemplate is the template for one target, use localBinaryRecipeOptions as the context.
    33  const localBinaryRecipeTemplate = `.PHONY: {{ .OutputPath }}
    34  {{ .TargetName }}: {{ StringsJoin .DependencyTargets " " }} ## {{ .Comment }}
    35  {{- if .UseCGO }}
    36  	$(CGO) build -ldflags "$(LDFLAGS)" -tags "${BUILD_TAGS}" -o {{ .OutputPath }} {{ .SourcePath }}
    37  {{- else }}
    38  	$(GO) build -ldflags "$(LDFLAGS)" -tags "${BUILD_TAGS}" -o {{ .OutputPath }} {{ .SourcePath }}
    39  {{- end }}
    40  
    41  `
    42  
    43  // localBinaryRecipes is the list of binaryRecipes to generate, edit here to build new binaries.
    44  var localBinaryRecipes = []binaryRecipeOptions{
    45  	{
    46  		TargetName: "local/chaos-controller-manager",
    47  		SourcePath: "cmd/chaos-controller-manager/main.go",
    48  		OutputPath: "bin/chaos-controller-manager",
    49  		UseCGO:     false,
    50  		Comment:    "Build binary chaos-controller-manager in local environment",
    51  	},
    52  	{
    53  		TargetName: "local/chaos-dashboard",
    54  		SourcePath: "cmd/chaos-dashboard/main.go",
    55  		OutputPath: "bin/chaos-dashboard",
    56  		UseCGO:     true,
    57  		Comment:    "Build binary chaos-dashboard in local environment",
    58  	},
    59  }
    60