Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
perf subcmd: Create subcmd library
Browse files Browse the repository at this point in the history
Move the subcommand-related files from perf to a new library named
libsubcmd.a.

Since we're moving files anyway, go ahead and rename 'exec_cmd.*' to
'exec-cmd.*' to be consistent with the naming of all the other files.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/c0a838d4c878ab17fee50998811612b2281355c1.1450193761.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
jpoimboe authored and acmel committed Dec 17, 2015
1 parent 2f4ce5e commit 4b6ab94
Show file tree
Hide file tree
Showing 66 changed files with 129 additions and 68 deletions.
7 changes: 7 additions & 0 deletions tools/lib/subcmd/Build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
libsubcmd-y += exec-cmd.o
libsubcmd-y += help.o
libsubcmd-y += pager.o
libsubcmd-y += parse-options.o
libsubcmd-y += run-command.o
libsubcmd-y += sigchain.o
libsubcmd-y += subcmd-config.o
48 changes: 48 additions & 0 deletions tools/lib/subcmd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include ../../scripts/Makefile.include
include ../../perf/config/utilities.mak # QUIET_CLEAN

ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(shell pwd)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif

CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
RM = rm -f

MAKEFLAGS += --no-print-directory

LIBFILE = $(OUTPUT)libsubcmd.a

CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE

CFLAGS += -I$(srctree)/tools/include/
CFLAGS += -I$(srctree)/include/uapi
CFLAGS += -I$(srctree)/include

SUBCMD_IN := $(OUTPUT)libsubcmd-in.o

all:

export srctree OUTPUT CC LD CFLAGS V
include $(srctree)/tools/build/Makefile.include

all: fixdep $(LIBFILE)

$(SUBCMD_IN): FORCE
@$(MAKE) $(build)=libsubcmd

$(LIBFILE): $(SUBCMD_IN)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN)

clean:
$(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)

FORCE:

.PHONY: clean FORCE
2 changes: 1 addition & 1 deletion tools/perf/util/exec_cmd.c → tools/lib/subcmd/exec-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "subcmd-util.h"
#include "exec_cmd.h"
#include "exec-cmd.h"
#include "subcmd-config.h"

#define MAX_ARGS 32
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/perf/util/help.c → tools/lib/subcmd/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <dirent.h>
#include "subcmd-util.h"
#include "help.h"
#include "exec_cmd.h"
#include "exec-cmd.h"

void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <sys/wait.h>
#include "subcmd-util.h"
#include "run-command.h"
#include "exec_cmd.h"
#include "exec-cmd.h"

#define STRERR_BUFSIZE 128

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tools/perf/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tools/lib/traceevent
tools/lib/bpf
tools/lib/api
tools/lib/bpf
tools/lib/subcmd
tools/lib/hweight.c
tools/lib/rbtree.c
tools/lib/string.c
Expand Down
20 changes: 16 additions & 4 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ BISON = bison
STRIP = strip
AWK = awk

LIB_DIR = $(srctree)/tools/lib/api/
LIB_DIR = $(srctree)/tools/lib/api/
TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
BPF_DIR = $(srctree)/tools/lib/bpf/
BPF_DIR = $(srctree)/tools/lib/bpf/
SUBCMD_DIR = $(srctree)/tools/lib/subcmd/

# include config/Makefile by default and rule out
# non-config cases
Expand Down Expand Up @@ -184,6 +185,7 @@ strip-libs = $(filter-out -l%,$(1))
ifneq ($(OUTPUT),)
TE_PATH=$(OUTPUT)
BPF_PATH=$(OUTPUT)
SUBCMD_PATH=$(OUTPUT)
ifneq ($(subdir),)
API_PATH=$(OUTPUT)/../lib/api/
else
Expand All @@ -193,6 +195,7 @@ else
TE_PATH=$(TRACE_EVENT_DIR)
API_PATH=$(LIB_DIR)
BPF_PATH=$(BPF_DIR)
SUBCMD_PATH=$(SUBCMD_DIR)
endif

LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
Expand All @@ -206,6 +209,8 @@ export LIBAPI

LIBBPF = $(BPF_PATH)libbpf.a

LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a

# python extension build directories
PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
Expand Down Expand Up @@ -257,7 +262,7 @@ export PERL_PATH

LIB_FILE=$(OUTPUT)libperf.a

PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT)
PERFLIBS = $(LIB_FILE) $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD)
ifndef NO_LIBBPF
PERFLIBS += $(LIBBPF)
endif
Expand Down Expand Up @@ -437,6 +442,13 @@ $(LIBBPF)-clean:
$(call QUIET_CLEAN, libbpf)
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null

$(LIBSUBCMD): fixdep FORCE
$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a

$(LIBSUBCMD)-clean:
$(call QUIET_CLEAN, libsubcmd)
$(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean

help:
@echo 'Perf make targets:'
@echo ' doc - make *all* documentation (see below)'
Expand Down Expand Up @@ -584,7 +596,7 @@ config-clean:
$(call QUIET_CLEAN, config)
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null

clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean config-clean
clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detected
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/util/intel-pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "../../util/evlist.h"
#include "../../util/evsel.h"
#include "../../util/cpumap.h"
#include "../../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../../util/parse-events.h"
#include "../../util/pmu.h"
#include "../../util/debug.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/futex-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../perf.h"
#include "../util/util.h"
#include "../util/stat.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "bench.h"
#include "futex.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/futex-lock-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "../perf.h"
#include "../util/util.h"
#include "../util/stat.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "bench.h"
#include "futex.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/futex-requeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../perf.h"
#include "../util/util.h"
#include "../util/stat.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "bench.h"
#include "futex.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/futex-wake-parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "../perf.h"
#include "../util/util.h"
#include "../util/stat.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "bench.h"
#include "futex.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/futex-wake.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "../perf.h"
#include "../util/util.h"
#include "../util/stat.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "bench.h"
#include "futex.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/mem-functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "../perf.h"
#include "../util/util.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "../util/cloexec.h"
#include "bench.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "../perf.h"
#include "../builtin.h"
#include "../util/util.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../util/cloexec.h"

#include "bench.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/sched-messaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "../perf.h"
#include "../util/util.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../builtin.h"
#include "bench.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/bench/sched-pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#include "../perf.h"
#include "../util/util.h"
#include "../util/parse-options.h"
#include <subcmd/parse-options.h>
#include "../builtin.h"
#include "bench.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "util/evsel.h"
#include "util/annotate.h"
#include "util/event.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/parse-events.h"
#include "util/thread.h"
#include "util/sort.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
#include "perf.h"
#include "util/util.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "builtin.h"
#include "bench/bench.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-buildid-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "util/cache.h"
#include "util/debug.h"
#include "util/header.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/strlist.h"
#include "util/build-id.h"
#include "util/session.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-buildid-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "util/build-id.h"
#include "util/cache.h"
#include "util/debug.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/session.h"
#include "util/symbol.h"
#include "util/data.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "perf.h"

#include "util/cache.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/util.h"
#include "util/debug.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "builtin.h"
#include "perf.h"
#include "debug.h"
#include "parse-options.h"
#include <subcmd/parse-options.h>
#include "data-convert-bt.h"

typedef int (*data_cmd_fn_t)(int argc, const char **argv, const char *prefix);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "util/evlist.h"
#include "util/evsel.h"
#include "util/parse-events.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/session.h"
#include "util/data.h"
#include "util/debug.h"
Expand Down
8 changes: 4 additions & 4 deletions tools/perf/builtin-help.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include "perf.h"
#include "util/cache.h"
#include "builtin.h"
#include "util/exec_cmd.h"
#include <subcmd/exec-cmd.h>
#include "common-cmds.h"
#include "util/parse-options.h"
#include "util/run-command.h"
#include "util/help.h"
#include <subcmd/parse-options.h>
#include <subcmd/run-command.h>
#include <subcmd/help.h>
#include "util/debug.h"

static struct man_viewer_list {
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "util/data.h"
#include "util/auxtrace.h"

#include "util/parse-options.h"
#include <subcmd/parse-options.h>

#include <linux/list.h>

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "util/tool.h"
#include "util/callchain.h"

#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/trace-event.h"
#include "util/data.h"
#include "util/cpumap.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "util/header.h"
#include "util/session.h"
#include "util/intlist.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/trace-event.h"
#include "util/debug.h"
#include "util/tool.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "util/parse-events.h"
#include "util/cache.h"
#include "util/pmu.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>

int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "util/thread.h"
#include "util/header.h"

#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/trace-event.h"

#include "util/debug.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-mem.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "builtin.h"
#include "perf.h"

#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/trace-event.h"
#include "util/tool.h"
#include "util/session.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "util/strfilter.h"
#include "util/symbol.h"
#include "util/debug.h"
#include "util/parse-options.h"
#include <subcmd/parse-options.h>
#include "util/probe-finder.h"
#include "util/probe-event.h"
#include "util/probe-file.h"
Expand Down
Loading

0 comments on commit 4b6ab94

Please sign in to comment.