-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvscode.mak
76 lines (63 loc) · 2.27 KB
/
vscode.mak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
################################################################################
# vscode.mak
# See https://github.com/amb5l/make-fpga
################################################################################
# defaults
VSCODE_DIR?=vscode
ifndef VSCODE_LIB
VSCODE_LIB=work
VSCODE_SRC.work?=$(VSCODE_SRC)
endif
# checks
$(call check_defined,VSCODE_TOP)
$(call check_defined,VSCODE_LIB)
$(foreach l,$(VSCODE_LIB),$(call check_defined,VSCODE_SRC.$l))
################################################################################
# rules and recipes
# workspace directory
$(VSCODE_DIR):
@bash -c "mkdir -p $@"
# library directory(s) containing symbolic link(s) to source(s)
$(foreach l,$(VSCODE_LIB),$(eval $l: $(addprefix $$(VSCODE_DIR)/$l/,$(notdir $(VSCODE_SRC.$l)))))
# symbolic links to library/source files
ifeq ($(OS),Windows_NT)
define rr_srclink
$$(VSCODE_DIR)/$1/$(notdir $2): $2
@bash -c "mkdir -p $$(dir $$@)"
@bash -c "cmd.exe //C \"mklink $$(shell cygpath -w $$@) $$(shell cygpath -w -a $$<)\""
endef
else
define rr_srclink
$$(VSCODE_DIR)/$1/$(notdir $2): $2
@mkdir -p $$(dir $$@)
@ln $$< $$@
endef
endif
$(foreach l,$(VSCODE_LIB),$(foreach s,$(VSCODE_SRC.$l),$(eval $(call rr_srclink,$l,$s))))
# symbolic links to auxilliary text files
ifeq ($(OS),Windows_NT)
define rr_auxlink
$$(VSCODE_DIR)/$(notdir $1): $1
@bash -c "cmd.exe //C \"mklink $$(shell cygpath -w $$@) $$(shell cygpath -w -a $$<)\""
endef
else
define rr_auxlink
$$(VSCODE_DIR)/$(notdir $1): $1
@ln $$< $$@
endef
endif
$(foreach a,$(VSCODE_AUX),$(eval $(call rr_auxlink,$a)))
# V4P configuration file
$(VSCODE_DIR)/config.v4p: vscode_force $(VSCODE_LIB)
@bash -c "echo \"[libraries]\" > $@"
@bash -c "$(foreach l,$(VSCODE_LIB),$(foreach s,$(VSCODE_SRC.$l),echo \"$l/$(notdir $s)=$l\" >> $@;))"
@bash -c "echo \"[settings]\" >> $@"
@bash -c "echo \"V4p.Settings.Basics.TopLevelEntities=$(subst $(space),$(comma),$(VSCODE_TOP))\" >> $@"
################################################################################
# goals
.PHONY: vscode_force edit
vscode_force:
edit: $(VSCODE_DIR)/config.v4p $(addprefix $(VSCODE_DIR)/,$(VSCODE_LIB)) $(foreach x,$(VSCODE_XDC),$(VSCODE_DIR)/$(notdir $(word 1,$(subst =, ,$x)))) $(addprefix $(VSCODE_DIR)/,$(notdir $(VSCODE_AUX)))
@code $(VSCODE_DIR)
clean::
@rm -rf $(VSCODE_DIR)