1# 2# Build a rust-project.json for use by rust-analyzer 3# 4# Builds a rust-project.json in the current builddir using the contents of 5# RUST_ANALYZER_CONTENTS as the body. RUST_ANALYZER_CONTENTS must be a valid 6# concatenated list of json objects. 7# 8# Inputs: 9# BUILDDIR 10# RUST_ANALYZER_CONTENTS 11 12RUST_PROJECT_JSON := $(BUILDDIR)/rust-project.json 13define RUST_PROJECT_JSON_CONTENTS := 14{ 15 "crates": [ 16$(call STRIP_TRAILING_COMMA,$(RUST_ANALYZER_CONTENTS)) 17 ] 18} 19endef 20RUST_PROJECT_JSON_CONTENTS := $(subst $(NEWLINE),\n,$(RUST_PROJECT_JSON_CONTENTS)) 21RUST_PROJECT_JSON_CONTENTS := $(subst %,%%,$(RUST_PROJECT_JSON_CONTENTS)) 22.PHONY: $(RUST_PROJECT_JSON) 23$(RUST_PROJECT_JSON): CONTENTS := $(RUST_PROJECT_JSON_CONTENTS) 24$(RUST_PROJECT_JSON): 25 @$(MKDIR) 26 @echo Creating rust-project.json for rust-analyzer 27 $(NOECHO)printf '$(CONTENTS)' > $@ 28 29EXTRA_BUILDDEPS += $(RUST_PROJECT_JSON) 30 31RUST_ANALYZER_CONTENTS := 32RUST_PROJECT_JSON := 33RUST_PROJECT_JSON_CONTENTS := 34