2020-03-29 01:12:41 +01:00
|
|
|
BASE_PATH := $(realpath -s $(dir $(abspath $(firstword $(MAKEFILE_LIST)))))
|
|
|
|
|
2019-07-28 10:26:05 +02:00
|
|
|
# Documentation
|
2019-07-10 01:54:15 +02:00
|
|
|
OUTLINE_CMD ?= outline
|
2020-03-29 01:12:41 +01:00
|
|
|
DOCUMENTATION_PATH ?= $(BASE_PATH)/_documentation
|
2020-03-28 13:55:53 +01:00
|
|
|
DOCUMENTATION_REFERENCE_PATH ?= $(DOCUMENTATION_PATH)/reference
|
|
|
|
DOCUMENTATION_REFERENCE_TEMPLATE ?= $(DOCUMENTATION_REFERENCE_PATH)/reference.md.tmpl
|
2020-03-29 19:06:41 +02:00
|
|
|
DOCUMENTATION_INLINE_EXAMPLES_PATH ?= starlark/types/testdata/examples
|
2019-07-10 01:54:15 +02:00
|
|
|
|
|
|
|
RUNTIME_MODULES = \
|
2019-08-01 20:43:59 +02:00
|
|
|
github.com/mcuadros/ascode/starlark/module/os \
|
2020-03-22 13:49:24 +01:00
|
|
|
github.com/mcuadros/ascode/starlark/types \
|
2019-08-01 20:43:59 +02:00
|
|
|
github.com/mcuadros/ascode/starlark/module/filepath \
|
2019-07-10 01:54:15 +02:00
|
|
|
github.com/qri-io/starlib/encoding/base64 \
|
|
|
|
github.com/qri-io/starlib/encoding/csv \
|
|
|
|
github.com/qri-io/starlib/encoding/json \
|
2019-07-11 18:45:42 +02:00
|
|
|
github.com/qri-io/starlib/encoding/yaml \
|
2019-07-10 01:54:15 +02:00
|
|
|
github.com/qri-io/starlib/re \
|
2020-03-29 05:25:57 +02:00
|
|
|
github.com/qri-io/starlib/time \
|
|
|
|
github.com/qri-io/starlib/math \
|
2019-07-10 01:54:15 +02:00
|
|
|
github.com/qri-io/starlib/http
|
|
|
|
|
2020-03-29 03:45:15 +02:00
|
|
|
QUERY_GO_MOD_CMD = go run _scripts/query-go-mod.go
|
|
|
|
STARLIB_PKG ?= github.com/qri-io/starlib
|
|
|
|
STARLIB_COMMIT ?= $(shell $(QUERY_GO_MOD_CMD) . $(STARLIB_PKG))
|
|
|
|
STARLIB_PKG_LOCATION = $(GOPATH)/src/$(STARLIB_PKG)
|
|
|
|
|
2020-03-29 19:06:41 +02:00
|
|
|
# Examples
|
|
|
|
EXAMPLE_TO_MD_CMD = go run _scripts/example-to-md.go
|
|
|
|
EXAMPLES = functions.star runtime.star
|
|
|
|
EXAMPLES_PATH = $(BASE_PATH)/_examples
|
|
|
|
DOCUMENTATION_EXAMPLES_PATH = $(DOCUMENTATION_PATH)/example
|
|
|
|
|
2020-03-27 18:33:10 +01:00
|
|
|
# Build Info
|
|
|
|
GO_LDFLAGS_CMD = go run _scripts/goldflags.go
|
|
|
|
GO_LDFLAGS_PACKAGE = cmd
|
|
|
|
GO_LDFLAGS_PACKAGES = \
|
|
|
|
starlarkVersion=go.starlark.net \
|
|
|
|
terraformVersion=github.com/hashicorp/terraform
|
2019-07-28 10:26:05 +02:00
|
|
|
|
2020-03-29 01:12:41 +01:00
|
|
|
# Site
|
|
|
|
HUGO_SITE_PATH ?= $(BASE_PATH)/_site
|
|
|
|
HUGO_SITE_CONTENT_PATH ?= $(HUGO_SITE_PATH)/content
|
|
|
|
HUGO_SITE_TEMPLATE_PATH ?= $(HUGO_SITE_PATH)/themes/hugo-ascode-theme
|
|
|
|
HUGO_THEME_URL ?= https://github.com/mcuadros/hugo-ascode-theme
|
|
|
|
HUGO_PARAMS_VERSION ?= dev
|
|
|
|
export HUGO_PARAMS_VERSION
|
2020-03-29 19:06:41 +02:00
|
|
|
|
|
|
|
|
2019-07-10 01:54:15 +02:00
|
|
|
# Rules
|
2020-03-29 01:12:41 +01:00
|
|
|
.PHONY: documentation clean hugo-server
|
2019-07-10 01:54:15 +02:00
|
|
|
|
|
|
|
documentation: $(RUNTIME_MODULES)
|
2020-03-29 03:45:15 +02:00
|
|
|
$(RUNTIME_MODULES): $(DOCUMENTATION_RUNTIME_PATH) $(STARLIB_PKG_LOCATION)
|
2020-03-28 13:55:53 +01:00
|
|
|
$(OUTLINE_CMD) package \
|
|
|
|
-t $(DOCUMENTATION_REFERENCE_TEMPLATE) \
|
2020-03-29 19:06:41 +02:00
|
|
|
-d $(DOCUMENTATION_INLINE_EXAMPLES_PATH) \
|
2020-03-28 13:55:53 +01:00
|
|
|
$@ \
|
|
|
|
> $(DOCUMENTATION_REFERENCE_PATH)/`basename $@`.md
|
2019-07-10 01:54:15 +02:00
|
|
|
|
2020-03-28 13:55:53 +01:00
|
|
|
$(DOCUMENTATION_REFERENCE_PATH):
|
2019-07-28 10:26:05 +02:00
|
|
|
mkdir -p $@
|
|
|
|
|
2020-03-29 03:45:15 +02:00
|
|
|
$(STARLIB_PKG_LOCATION):
|
|
|
|
git clone https://$(STARLIB_PKG) $@; \
|
|
|
|
cd $@; \
|
|
|
|
git checkout $(STARLIB_COMMIT); \
|
|
|
|
cd $(BASE_PATH);
|
|
|
|
|
2020-03-29 19:06:41 +02:00
|
|
|
examples: $(EXAMPLES)
|
|
|
|
|
|
|
|
$(EXAMPLES):
|
|
|
|
$(EXAMPLE_TO_MD_CMD) \
|
|
|
|
$(EXAMPLES_PATH)/$@ $(shell ls -1 $(DOCUMENTATION_EXAMPLES_PATH) | wc -l) \
|
|
|
|
> $(DOCUMENTATION_EXAMPLES_PATH)/$@.md
|
|
|
|
|
2020-03-27 18:33:10 +01:00
|
|
|
goldflags:
|
2020-03-29 01:12:41 +01:00
|
|
|
@$(GO_LDFLAGS_CMD) $(GO_LDFLAGS_PACKAGE) . $(GO_LDFLAGS_PACKAGES)
|
|
|
|
|
2020-03-29 19:06:41 +02:00
|
|
|
hugo-build: $(HUGO_SITE_PATH) documentation examples
|
2020-03-29 01:12:41 +01:00
|
|
|
hugo --minify --source $(HUGO_SITE_PATH) --config $(DOCUMENTATION_PATH)/config.toml
|
|
|
|
|
2020-03-29 19:06:41 +02:00
|
|
|
hugo-server: $(HUGO_SITE_PATH) documentation examples
|
2020-03-29 01:12:41 +01:00
|
|
|
hugo server --source $(HUGO_SITE_PATH) --config $(DOCUMENTATION_PATH)/config.toml
|
|
|
|
|
|
|
|
$(HUGO_SITE_PATH): $(HUGO_SITE_TEMPLATE_PATH)
|
|
|
|
mkdir -p $@ \
|
|
|
|
mkdir -p $(HUGO_SITE_CONTENT_PATH)
|
|
|
|
mkdir -p $(HUGO_SITE_TEMPLATE_PATH)
|
|
|
|
ln -s $(DOCUMENTATION_PATH) $(HUGO_SITE_CONTENT_PATH)/docs
|
|
|
|
ln -s $(DOCUMENTATION_PATH)/_home.md $(HUGO_SITE_CONTENT_PATH)/_index.md
|
|
|
|
|
2020-03-29 03:45:15 +02:00
|
|
|
|
2020-03-29 01:12:41 +01:00
|
|
|
$(HUGO_SITE_TEMPLATE_PATH):
|
|
|
|
git clone $(HUGO_THEME_URL) $(HUGO_SITE_TEMPLATE_PATH)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(HUGO_SITE_PATH)
|