Merge pull request #29683 from xiangpengzhao/add-make-help
Automatic merge from submit-queue Add "make help" to list all make targets and help info As discussed in [PR#29320comment](https://github.com/kubernetes/kubernetes/pull/29320#issuecomment-234420145), add a `make help` to make the use of `make` easy. Though it works well on my Ubuntu now (see the output as below, not sure if it still works on other systems), I believe the scripts are somewhat ugly, so, any suggestion for optimization is welcome. BTW, I intended to list targets by groups, but it's hard to do that automatically. So I just list them in alphabetical order. I think this may be enough. There are still some TODOs (also mentioned in the Makefile): 1. make EXCLUDE_TARGET auto-generated when there are other files in cmd/ 2. should we exclude the target "cmd/libs" but include "cmd/libs/go2idl/*"? 3. should we let `help` be the first/default target? It will show the help when we just type `make`. 1 and 2 are to exclude the invalid targets generated by `$(notdir $(abspath $(wildcard cmd/*/)))`: - OWNERS is just a file, it can't be a target - libs itself cannot be built /cc @thockin @jfrazelle @MHBauer @dims Output: ``` root@vm:/home/paas/zxp/code/k8s/fork/kubernetes# make help -------------------------------------------------------------------------------- all # Build code. # # Args: # WHAT: Directory names to build. If any of these directories has a 'main' # package, the build will produce executable files under _output/go/bin. # If not specified, "everything" will be built. # GOFLAGS: Extra flags to pass to 'go' when building. # GOLDFLAGS: Extra linking flags passed to 'go' when building. # GOGCFLAGS: Additional go compile flags passed to 'go' when building. # # Example: # make # make all # make all WHAT=cmd/kubelet GOFLAGS=-v # make all GOGCFLAGS="-N -l" # Note: Use the -N -l options to disable compiler optimizations an inlining. # Using these build options allows you to subsequently use source # debugging tools like delve. --------------------------------------------------------------------------------- check # Build and run tests. # # Args: # WHAT: Directory names to test. All *_test.go files under these # directories will be run. If not specified, "everything" will be tested. # TESTS: Same as WHAT. # GOFLAGS: Extra flags to pass to 'go' when building. # GOLDFLAGS: Extra linking flags to pass to 'go' when building. # GOGCFLAGS: Additional go compile flags passed to 'go' when building. # # Example: # make check # make test # make check WHAT=pkg/kubelet GOFLAGS=-v --------------------------------------------------------------------------------- clean # Remove all build artifacts. # # Example: # make clean # # TODO(thockin): call clean_generated when we stop committing generated code. --------------------------------------------------------------------------------- clean_generated # Remove all auto-generated artifacts. # # Example: # make clean_generated --------------------------------------------------------------------------------- clean_meta # Remove make-related metadata files. # # Example: # make clean_meta --------------------------------------------------------------------------------- cross # Cross-compile for all platforms # # Example: # make cross --------------------------------------------------------------------------------- federation-apiserver federation-controller-manager genfeddocs # Add rules for all directories in federation/cmd/ # # Example: # make federation-apiserver federation-controller-manager --------------------------------------------------------------------------------- gendocs genkubedocs genman genswaggertypedocs genutils genyaml hyperkube kube-apiserver kube-controller-manager kubectl kube-dns kubelet kubemark kube-proxy kubernetes-discovery libs linkcheck mungedocs # Add rules for all directories in cmd/ # # Example: # make kubectl kube-proxy --------------------------------------------------------------------------------- generated_files # Produce auto-generated files needed for the build. # # Example: # make generated_files --------------------------------------------------------------------------------- ginkgo # Build ginkgo # # Example: # make ginkgo --------------------------------------------------------------------------------- help # Print make targets and help info # # Example: # make help --------------------------------------------------------------------------------- quick-release # Build a release, but skip tests # # Example: # make release-skip-tests --------------------------------------------------------------------------------- release # Build a release # # Example: # make release --------------------------------------------------------------------------------- release-skip-tests # Build a release, but skip tests # # Example: # make release-skip-tests --------------------------------------------------------------------------------- test # Build and run tests. # # Args: # WHAT: Directory names to test. All *_test.go files under these # directories will be run. If not specified, "everything" will be tested. # TESTS: Same as WHAT. # GOFLAGS: Extra flags to pass to 'go' when building. # GOLDFLAGS: Extra linking flags to pass to 'go' when building. # GOGCFLAGS: Additional go compile flags passed to 'go' when building. # # Example: # make check # make test # make check WHAT=pkg/kubelet GOFLAGS=-v --------------------------------------------------------------------------------- test-cmd # Build and run cmdline tests. # # Example: # make test-cmd --------------------------------------------------------------------------------- test-e2e # Build and run end-to-end tests. # # Example: # make test-e2e --------------------------------------------------------------------------------- test-e2e-node # Build and run node end-to-end tests. # # Args: # FOCUS: Regexp that matches the tests to be run. Defaults to "". # SKIP: Regexp that matches the tests that needs to be skipped. Defaults # to "". # RUN_UNTIL_FAILURE: If true, pass --untilItFails to ginkgo so tests are run # repeatedly until they fail. Defaults to false. # REMOTE: If true, run the tests on a remote host instance on GCE. Defaults # to false. # IMAGES: For REMOTE=true only. Comma delimited list of images for creating # remote hosts to run tests against. Defaults to a recent image. # LIST_IMAGES: If true, don't run tests. Just output the list of available # images for testing. Defaults to false. # HOSTS: For REMOTE=true only. Comma delimited list of running gce hosts to # run tests against. Defaults to "". # DELETE_INSTANCES: For REMOTE=true only. Delete any instances created as # part of this test run. Defaults to false. # ARTIFACTS: For REMOTE=true only. Local directory to scp test artifacts into # from the remote hosts. Defaults to ""/tmp/_artifacts". # REPORT: For REMOTE=false only. Local directory to write juntil xml results # to. Defaults to "/tmp/". # CLEANUP: For REMOTE=true only. If false, do not stop processes or delete # test files on remote hosts. Defaults to true. # IMAGE_PROJECT: For REMOTE=true only. Project containing images provided to # IMAGES. Defaults to "kubernetes-node-e2e-images". # INSTANCE_PREFIX: For REMOTE=true only. Instances created from images will # have the name "-". Defaults to "test". # INSTANCE_METADATA: For REMOTE=true and running on GCE only. # # Example: # make test-e2e-node FOCUS=Kubelet SKIP=container # make test-e2e-node REMOTE=true DELETE_INSTANCES=true # make test-e2e-node TEST_ARGS="--cgroups-per-qos=true" # Build and run tests. --------------------------------------------------------------------------------- test-integration # Build and run integration tests. # # Example: # make test-integration --------------------------------------------------------------------------------- verify # Runs all the presubmission verifications. # # Args: # BRANCH: Branch to be passed to verify-godeps.sh script. # # Example: # make verify # make verify BRANCH=branch_x --------------------------------------------------------------------------------- vet # Run 'go vet'. # # Args: # WHAT: Directory names to vet. All *.go files under these # directories will be vetted. If not specified, "everything" will be # vetted. # # Example: # make vet # make vet WHAT=pkg/kubelet --------------------------------------------------------------------------------- ```
This commit is contained in:
83
hack/make-rules/make-help.sh
Executable file
83
hack/make-rules/make-help.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2016 The Kubernetes Authors.
|
||||
#
|
||||
# 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
red='\E[1;31m'
|
||||
reset='\E[0m'
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
ALL_TARGETS=$(make -C "${KUBE_ROOT}" PRINT_HELP=y -rpn | sed -n -e '/^$/ { n ; /^[^ .#][^ ]*:/ { s/:.*$// ; p ; } ; }' | sort)
|
||||
CMD_TARGETS=$(ls -l "${KUBE_ROOT}/cmd" |awk '/^d/ {print $NF}')
|
||||
PLUGIN_CMD_TARGETS=$(ls -l "${KUBE_ROOT}/plugin/cmd" |awk '/^d/ {print $NF}')
|
||||
FED_CMD_TARGETS=$(ls -l "${KUBE_ROOT}/federation/cmd" |awk '/^d/ {print $NF}')
|
||||
CMD_FLAG=false
|
||||
PLUGIN_CMD_FLAG=false
|
||||
FED_CMD_FLAG=false
|
||||
|
||||
echo "--------------------------------------------------------------------------------"
|
||||
for tar in $ALL_TARGETS; do
|
||||
for cmdtar in $CMD_TARGETS; do
|
||||
if [ $tar = $cmdtar ]; then
|
||||
if [ $CMD_FLAG = true ]; then
|
||||
continue 2;
|
||||
fi
|
||||
|
||||
echo -e "${red}${CMD_TARGETS}${reset}"
|
||||
make -C "${KUBE_ROOT}" $tar PRINT_HELP=y
|
||||
echo "---------------------------------------------------------------------------------"
|
||||
|
||||
CMD_FLAG=true
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
for plugincmdtar in $PLUGIN_CMD_TARGETS; do
|
||||
if [ $tar = $plugincmdtar ]; then
|
||||
if [ $PLUGIN_CMD_FLAG = true ]; then
|
||||
continue 2;
|
||||
fi
|
||||
|
||||
echo -e "${red}${PLUGIN_CMD_TARGETS}${reset}"
|
||||
make -C "${KUBE_ROOT}" $tar PRINT_HELP=y
|
||||
echo "---------------------------------------------------------------------------------"
|
||||
|
||||
PLUGIN_CMD_FLAG=true
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
for fedcmdtar in $FED_CMD_TARGETS; do
|
||||
if [ $tar = $fedcmdtar ]; then
|
||||
if [ $FED_CMD_FLAG = true ]; then
|
||||
continue 2;
|
||||
fi
|
||||
|
||||
echo -e "${red}${FED_CMD_TARGETS}${reset}"
|
||||
make -C "${KUBE_ROOT}" $tar PRINT_HELP=y
|
||||
echo "---------------------------------------------------------------------------------"
|
||||
|
||||
FED_CMD_FLAG=true
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "${red}${tar}${reset}"
|
||||
make -C "${KUBE_ROOT}" $tar PRINT_HELP=y
|
||||
echo "---------------------------------------------------------------------------------"
|
||||
done
|
Reference in New Issue
Block a user