Restored makefiles.

This commit is contained in:
emery.berger@gmail.com 2022-01-20 21:04:41 -05:00
parent 69f0f9de5a
commit 25530b1b27
7 changed files with 196 additions and 3 deletions

24
Makefile Normal file
View File

@ -0,0 +1,24 @@
ROOT := .
DIRS := libcoz viewer
include $(ROOT)/common.mk
update-gh-pages:: all
@echo $(LOG_PREFIX) Pushing profiler viewer to gh-pages branch $(LOG_SUFFIX)
@git push origin `git subtree split --prefix viewer master 2> /dev/null`:gh-pages
install:: all
@echo $(LOG_PREFIX) Installing coz to prefix $(prefix) $(LOG_SUFFIX)
@sed 's@destdir@"${DESTDIR}${prefix}"@g' coz-profilerConfig.cmake.in > coz-profilerConfig.cmake
@$(INSTALL) -D coz $(DESTDIR)$(bindir)/coz
@$(INSTALL) -D coz-profilerConfig.cmake $(DESTDIR)$(pkglibdir)/coz-profilerConfig.cmake
@$(INSTALL) -D libcoz/libcoz.so $(DESTDIR)$(pkglibdir)/libcoz.so
@$(INSTALL) -D include/coz.h $(DESTDIR)$(incdir)/coz.h
@mkdir -p $(DESTDIR)$(man1dir)
@$(RST2MAN) docs/coz.rst $(DESTDIR)$(man1dir)/coz.1
bench bench_small bench_large::
@$(MAKE) -C benchmarks $@
check::
@$(MAKE) -C benchmarks check

99
common.mk Normal file
View File

@ -0,0 +1,99 @@
DESTDIR ?=
prefix ?= /usr
bindir := $(prefix)/bin
pkglibdir := $(prefix)/lib/coz-profiler
incdir := $(prefix)/include
mandir := $(prefix)/share/man
man1dir := $(mandir)/man1
INSTALL = install
RST2MAN = rst2man
# Build with clang by default
CC ?= clang
CXX ?= clang++
# Set coz and include path for coz
ifeq ($(USE_SYSTEM_COZ),1)
COZ := $(shell which coz)
else
COZ := $(ROOT)/coz
endif
# Default flags
CFLAGS ?= -g -O2
CXXFLAGS ?= $(CFLAGS)
# Default source and object files
SRCS ?= $(wildcard *.cpp) $(wildcard *.c)
OBJS ?= $(addprefix obj/,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRCS))))
# Prevent errors if files named all, clean, distclean, bench, or test exist
.PHONY: all clean distclean bench bench_small bench_large test
# Targets to build recursively into $(DIRS)
RECURSIVE_TARGETS ?= all clean bench bench_large bench_small test install check
# Targets separated by type
SHARED_LIB_TARGETS := $(filter %.so, $(TARGETS))
STATIC_LIB_TARGETS := $(filter %.a, $(TARGETS))
OTHER_TARGETS := $(filter-out %.so, $(filter-out %.a, $(TARGETS)))
# If not set, the build path is just the current directory name
MAKEPATH ?= $(shell basename $(shell pwd))
# Log the build path in gray, following by a log message in bold green
LOG_PREFIX := "$(shell tput setaf 7)[$(MAKEPATH)]$(shell tput sgr0)$(shell tput setaf 2)"
LOG_SUFFIX := "$(shell tput sgr0)"
# Build in parallel
MAKEFLAGS += -j
# Build all targets by default, unless this is a benchmark
all:: $(TARGETS)
# Clean up after a build
clean::
@for t in $(TARGETS); do \
echo $(LOG_PREFIX) Cleaning $$t $(LOG_SUFFIX); \
done
@rm -rf $(TARGETS) obj
# Bring source back to pristine state
distclean:: clean
@$(MAKE) -C benchmarks clean
# Compile a C++ source file (and generate its dependency rules)
obj/%.o: %.cpp $(PREREQS)
@echo $(LOG_PREFIX) Compiling $< $(LOG_SUFFIX)
@mkdir -p obj
@$(CXX) $(CXXFLAGS) -MMD -MP -o $@ -c $<
# Compile a C source file (and generate its dependency rules)
obj/%.o: %.c $(PREREQS)
@echo $(LOG_PREFIX) Compiling $< $(LOG_SUFFIX)
@mkdir -p obj
@$(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
# Link a shared library
$(SHARED_LIB_TARGETS): $(OBJS)
@echo $(LOG_PREFIX) Linking $@ $(LOG_SUFFIX)
@$(CXX) -shared $(LDFLAGS) -o $@ $^ $(LIBS)
$(STATIC_LIB_TARGETS): $(OBJS)
@echo $(LOG_PREFIX) Linking $@ $(LOG_SUFFIX)
@ar rs $@ $^
# Link binary targets
$(OTHER_TARGETS): $(OBJS)
@echo $(LOG_PREFIX) Linking $@ $(LOG_SUFFIX)
@$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
# Include dependency rules for all objects
-include $(OBJS:.o=.d)
# Build any recursive targets in subdirectories
$(RECURSIVE_TARGETS)::
@for dir in $(DIRS); do \
$(MAKE) -C $$dir --no-print-directory $@ MAKEPATH="$(MAKEPATH)/$$dir" || exit 1; \
done

14
libcoz/Makefile Normal file
View File

@ -0,0 +1,14 @@
ROOT := ..
TARGETS := libcoz.so
LIBS := -ldl -lrt -lpthread $(shell pkg-config --libs libelf++ libdwarf++)
CXXFLAGS := -gdwarf-3 --std=c++0x -g -O2 -fPIC -I$(ROOT)/include -I. \
$(shell pkg-config --cflags libelf++ libdwarf++)
include $(ROOT)/common.mk
check:: libcoz.so
printf "int main(int argc, char *argv[])\n{\nreturn (0);\n}\n" > x.c
gcc -g -o x x.c || ( $(RM) x x.c ; exit 1)
../coz run --- ./x
if grep -q time= profile.coz; then echo success: coz profiler ran as it should.; fi
$(RM) -f x.c x profile.coz

9
viewer/Makefile Normal file
View File

@ -0,0 +1,9 @@
ROOT := ..
include $(ROOT)/common.mk
all:: js/ui.js
js/ui.js: $(wildcard ts/*.ts) tsconfig.json
@echo $(LOG_PREFIX) Building profile viewer $(LOG_SUFFIX)
@npm install > /dev/null

View File

@ -514,7 +514,7 @@ var Profile = /** @class */ (function () {
/****** Add or update y-axis title ******/
var ytitle_sel = plot_area_sel.selectAll('text.ytitle').data([0]);
ytitle_sel.enter().append('text').attr('class', 'ytitle');
ytitle_sel.attr('x', -(svg_height - margins.bottom) / 2) // x and y are flipped because of rotation
ytitle_sel.attr('x', -(svg_height - margins.bottom) / 2)
.attr('y', -45) // Approximate width of y-axis
.attr('transform', 'rotate(-90)')
.style('text-anchor', 'middle')

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,55 @@
{
"name": "coz",
"version": "1.0.0",
"lockfileVersion": 1,
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "coz",
"version": "1.0.0",
"license": "BSD-2-Clause",
"devDependencies": {
"@types/bootstrap": "^3.3.32",
"@types/d3": "^3.5.36",
"@types/jquery": "^2.0.33",
"typescript": "^3.5.3"
}
},
"node_modules/@types/bootstrap": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/@types/bootstrap/-/bootstrap-3.4.0.tgz",
"integrity": "sha512-LS05hVAAsX86qbHg7W+ydwBlNHrVCoFw6wEP3/uW4eYmRXl08bWmPeN/+onM+8qZTFfDgUlG/OItJI8SW972oQ==",
"dev": true,
"dependencies": {
"@types/jquery": "*"
}
},
"node_modules/@types/d3": {
"version": "3.5.42",
"resolved": "https://registry.npmjs.org/@types/d3/-/d3-3.5.42.tgz",
"integrity": "sha512-jKnkXluwSAzkvR19zjCHvLYgsWuDqpeE79NrhWrqhKqrx3sgTRqqt4SKaxSy+N7mt1J04Xy4L0/cKdfIgnjzVQ==",
"dev": true
},
"node_modules/@types/jquery": {
"version": "2.0.54",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.54.tgz",
"integrity": "sha512-D/PomKwNkDfSKD13DEVQT/pq2TUjN54c6uB341fEZanIzkjfGe7UaFuuaLZbpEiS5j7Wk2MUHAZqZIoECw29lg==",
"dev": true
},
"node_modules/typescript": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
}
},
"dependencies": {
"@types/bootstrap": {
"version": "3.4.0",