<commit_before># Copyright (c) 2017 Intel Corporation
#
# 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.

TARGET = cc-runtime
DESTDIR :=
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
QEMUBINDIR := $(BINDIR)
SYSCONFDIR := $(PREFIX)/etc
LIBEXECDIR := $(PREFIX)/libexec
LOCALSTATEDIR := $(PREFIX)/var
SHAREDIR := $(PREFIX)/share

CCDIR := clear-containers
PKGDATADIR := $(SHAREDIR)/$(CCDIR)
PKGLIBEXECDIR := $(LIBEXECDIR)/$(CCDIR)

SED = sed

SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
VERSION := ${shell cat ./VERSION}
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})

CONFIG_FILE = configuration.toml
CONFIG = config/$(CONFIG_FILE)
CONFIG_IN = $(CONFIG).in

DESTBINDIR := $(DESTDIR)/$(BINDIR)
DESTTARGET := $(abspath $(DESTBINDIR)/$(TARGET))

DESTCONFDIR := $(DESTDIR)/$(SYSCONFDIR)/$(CCDIR)
DESTCONFIG := $(abspath $(DESTCONFDIR)/$(CONFIG_FILE))

# list of variables the user may wish to override
USER_VARS += BINDIR
USER_VARS += DESTCONFIG
USER_VARS += DESTDIR
USER_VARS += DESTTARGET
USER_VARS += LIBEXECDIR
USER_VARS += LOCALSTATEDIR
USER_VARS += PKGDATADIR
USER_VARS += PKGLIBEXECDIR
USER_VARS += PREFIX
USER_VARS += QEMUBINDIR
USER_VARS += SHAREDIR
USER_VARS += SYSCONFDIR

V            = @
Q            = $(V:1=)
QUIET_BUILD  = $(Q:@=@echo    '     BUILD   '$@;)
QUIET_CHECK  = $(Q:@=@echo    '     CHECK   '$@;)
QUIET_CLEAN  = $(Q:@=@echo    '     CLEAN   '$@;)
QUIET_CONFIG = $(Q:@=@echo    '     CONFIG  '$@;)
QUIET_INST   = $(Q:@=@echo    '     INSTALL '$@;)
QUIET_TEST   = $(Q:@=@echo    '     TEST    '$@;)

default: $(TARGET)
.DEFAULT: default

$(TARGET): $(SOURCES) Makefile show-summary
	$(QUIET_BUILD)go build -i -ldflags "-X main.commit=${COMMIT} -X main.version=${VERSION} -X main.libExecDir=${LIBEXECDIR}" -o $@ .

.PHONY: \
	check \
	check-go-static \
	check-go-test \
	coverage \
	default \
	install \
	show-header \
	show-summary \
	show-variables

$(TARGET).coverage: $(SOURCES) Makefile
	$(QUIET_TEST)go test -o $@ -covermode count

$(CONFIG): $(CONFIG_IN)
	$(QUIET_CONFIG)$(SED) \
		-e "s|@CCDIR@|$(CCDIR)|g" \
		-e "s|@CONFIG_IN@|$(CONFIG_IN)|g" \
		-e "s|@PKGLIBEXECDIR@|$(PKGLIBEXECDIR)|g" \
		-e "s|@PKGDATADIR@|$(PKGDATADIR)|g" \
		-e "s|@QEMUBINDIR@|$(QEMUBINDIR)|g" \
		-e "s|@LOCALSTATEDIR@|$(LOCALSTATEDIR)|g" \
		$< > $@

generate-config: $(CONFIG)

check: check-go-static check-go-test

check-go-test:
	$(QUIET_TEST).ci/go-test.sh

check-go-static:
	$(QUIET_CHECK).ci/go-static-checks.sh $(GO_STATIC_CHECKS_ARGS)
	$(QUIET_CHECK).ci/go-no-os-exit.sh

coverage:
	$(QUIET_TEST).ci/go-test.sh html-coverage

install: $(TARGET) $(CONFIG)
	$(QUIET_INST)install -D $(TARGET) $(DESTTARGET)
	$(QUIET_INST)install -D $(CONFIG) $(DESTCONFIG)

clean:
	$(QUIET_CLEAN)rm -f $(TARGET) $(CONFIG)

show-usage: show-header
	@printf "• Overview:\n"
	@printf "\n"
	@printf "  To build $(TARGET), just run, \"make\".\n"
	@printf "\n"
	@printf "  For a verbose build, run \"make V=1\".\n"<commit_msg>build: Build config file at build time.<commit_after># Copyright (c) 2017 Intel Corporation
#
# 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.

TARGET = cc-runtime
DESTDIR :=
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
QEMUBINDIR := $(BINDIR)
SYSCONFDIR := $(PREFIX)/etc
LIBEXECDIR := $(PREFIX)/libexec
LOCALSTATEDIR := $(PREFIX)/var
SHAREDIR := $(PREFIX)/share

CCDIR := clear-containers
PKGDATADIR := $(SHAREDIR)/$(CCDIR)
PKGLIBEXECDIR := $(LIBEXECDIR)/$(CCDIR)

SED = sed

SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
VERSION := ${shell cat ./VERSION}
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})

CONFIG_FILE = configuration.toml
CONFIG = config/$(CONFIG_FILE)
CONFIG_IN = $(CONFIG).in

DESTBINDIR := $(DESTDIR)/$(BINDIR)
DESTTARGET := $(abspath $(DESTBINDIR)/$(TARGET))

DESTCONFDIR := $(DESTDIR)/$(SYSCONFDIR)/$(CCDIR)
DESTCONFIG := $(abspath $(DESTCONFDIR)/$(CONFIG_FILE))

# list of variables the user may wish to override
USER_VARS += BINDIR
USER_VARS += DESTCONFIG
USER_VARS += DESTDIR
USER_VARS += DESTTARGET
USER_VARS += LIBEXECDIR
USER_VARS += LOCALSTATEDIR
USER_VARS += PKGDATADIR
USER_VARS += PKGLIBEXECDIR
USER_VARS += PREFIX
USER_VARS += QEMUBINDIR
USER_VARS += SHAREDIR
USER_VARS += SYSCONFDIR

V            = @
Q            = $(V:1=)
QUIET_BUILD  = $(Q:@=@echo    '     BUILD   '$@;)
QUIET_CHECK  = $(Q:@=@echo    '     CHECK   '$@;)
QUIET_CLEAN  = $(Q:@=@echo    '     CLEAN   '$@;)
QUIET_CONFIG = $(Q:@=@echo    '     CONFIG  '$@;)
QUIET_INST   = $(Q:@=@echo    '     INSTALL '$@;)
QUIET_TEST   = $(Q:@=@echo    '     TEST    '$@;)

default: $(TARGET) $(CONFIG)
.DEFAULT: default

$(TARGET): $(SOURCES) Makefile | show-summary
	$(QUIET_BUILD)go build -i -ldflags "-X main.commit=${COMMIT} -X main.version=${VERSION} -X main.libExecDir=${LIBEXECDIR}" -o $@ .

.PHONY: \
	check \
	check-go-static \
	check-go-test \
	coverage \
	default \
	install \
	show-header \
	show-summary \
	show-variables

$(TARGET).coverage: $(SOURCES) Makefile
	$(QUIET_TEST)go test -o $@ -covermode count

$(CONFIG): $(CONFIG_IN)
	$(QUIET_CONFIG)$(SED) \
		-e "s|@CCDIR@|$(CCDIR)|g" \
		-e "s|@CONFIG_IN@|$(CONFIG_IN)|g" \
		-e "s|@PKGLIBEXECDIR@|$(PKGLIBEXECDIR)|g" \
		-e "s|@PKGDATADIR@|$(PKGDATADIR)|g" \
		-e "s|@QEMUBINDIR@|$(QEMUBINDIR)|g" \
		-e "s|@LOCALSTATEDIR@|$(LOCALSTATEDIR)|g" \
		$< > $@

generate-config: $(CONFIG)

check: check-go-static check-go-test

check-go-test:
	$(QUIET_TEST).ci/go-test.sh

check-go-static:
	$(QUIET_CHECK).ci/go-static-checks.sh $(GO_STATIC_CHECKS_ARGS)
	$(QUIET_CHECK).ci/go-no-os-exit.sh

coverage:
	$(QUIET_TEST).ci/go-test.sh html-coverage

install: default
	$(QUIET_INST)install -D $(TARGET) $(DESTTARGET)
	$(QUIET_INST)install -D $(CONFIG) $(DESTCONFIG)

clean:
	$(QUIET_CLEAN)rm -f $(TARGET) $(CONFIG)

show-usage: show-header
	@printf "• Overview:\n"
	@printf "\n"
	@printf "  To build $(TARGET), just run, \"make\".\n"
	@printf "\n"
	@printf "  For a verbose build, run \"make V=1\".\n"
{'fraction_non_alphanumeric': 0.17961711711711711, 'fraction_numerical': 0.00365990990990991, 'mean_word_length': 4.100502512562814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3324360', 'n_tokens_mistral': 2807, 'n_tokens_neox': 2786, 'n_words': 627}