1 # 2 # Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. Oracle designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Oracle in the LICENSE file that accompanied this code. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 # This must be the first rule 27 default: all 28 29 include $(SPEC) 30 include MakeBase.gmk 31 32 ################################################################################ 33 # Return the full path to an indexer-specific file fragment. 34 # 35 # Param 1: Fragment name 36 ################################################################################ 37 GetIndexerFragment = \ 38 $(TOPDIR)/make/ide/vscode/hotspot/indexers/$(VSCODE_INDEXER)-$(1).txt 39 40 ################################################################################ 41 # Show indexer-specific notes if they exist, otherwise do nothing 42 ################################################################################ 43 ifneq (,$(wildcard $(call GetIndexerFragment,notes))) 44 ShowIndexerNotes = $(CAT) $(call GetIndexerFragment,notes) 45 else 46 ShowIndexerNotes = 47 endif 48 49 ################################################################################ 50 # Return the platform-dependent preferred debug engine name. 51 ################################################################################ 52 ifeq ($(call isTargetOs, windows), true) 53 DebugEngineName = cppvsdbg 54 else 55 DebugEngineName = cppdbg 56 endif 57 58 ################################################################################ 59 # Return an additional configuration fragment if the WORKSPACE_ROOT is different 60 # from TOPDIR. 61 ################################################################################ 62 ifneq ($(WORKSPACE_ROOT),$(TOPDIR)) 63 GetExtraWorkspaceRoot = $(TOPDIR)/make/ide/vscode/hotspot/template-workspace-folder.txt 64 else 65 GetExtraWorkspaceRoot = /dev/null 66 endif 67 68 ################################################################################ 69 # Create a project configuration from a given template, replacing a known set 70 # of variables. 71 # 72 # Param 1: Template 73 # Param 2: Output 74 ################################################################################ 75 define CreateFromTemplate 76 $(call LogInfo, Generating $2) 77 $(call MakeDir, $(dir $2)) 78 $(SED) -e '/{{INDEXER_EXTENSIONS}}/r $(call GetIndexerFragment,extensions)' \ 79 -e '/{{INDEXER_SETTINGS}}/r $(call GetIndexerFragment,settings)' \ 80 -e '/{{EXTRA_WORKSPACE_ROOT}}/r $(call GetExtraWorkspaceRoot)' $1 | \ 81 $(SED) -e 's!{{TOPDIR}}!$(call FixPath,$(TOPDIR))!g' \ 82 -e 's!{{TOPDIR_RELATIVE}}!$(call FixPath,$(strip \ 83 $(call RelativePath,$(OUTPUTDIR),$(TOPDIR))))!g' \ 84 -e 's!{{WORKSPACE_ROOT}}!$(call FixPath,$(WORKSPACE_ROOT))!g' \ 85 -e 's!{{OUTPUTDIR}}!$(call FixPath,$(OUTPUTDIR))!g' \ 86 -e 's!{{CONF_NAME}}!$(CONF_NAME)!g' \ 87 -e 's!{{COMPILER}}!$(call FixPath,$(CXX)) $(SYSROOT_CFLAGS)!g' \ 88 -e 's!{{MAKE}}!$(call FixPath,$(MAKE))!g' \ 89 -e 's!{{PATH}}!$(call FixPathList,$(PATH))!g' \ 90 -e 's!{{DEBUGENGINENAME}}!$(call DebugEngineName)!g' \ 91 -e '/{{INDEXER_EXTENSIONS}}/d' \ 92 -e '/{{INDEXER_SETTINGS}}/d' \ 93 -e '/{{EXTRA_WORKSPACE_ROOT}}/d' \ 94 > $2 95 endef 96 97 $(OUTPUTDIR)/jdk.code-workspace: 98 $(call LogWarn, Creating workspace $@) 99 $(call CreateFromTemplate, $(TOPDIR)/make/ide/vscode/hotspot/template-workspace.jsonc, $@) 100 $(call ShowIndexerNotes) 101 102 $(OUTPUTDIR)/.vscode/tasks.json: 103 $(call CreateFromTemplate, $(TOPDIR)/make/ide/vscode/hotspot/template-tasks.jsonc, $@) 104 105 $(OUTPUTDIR)/.vscode/launch.json: 106 $(call CreateFromTemplate, $(TOPDIR)/make/ide/vscode/hotspot/template-launch.jsonc, $@) 107 108 TARGETS := $(OUTPUTDIR)/jdk.code-workspace $(OUTPUTDIR)/.vscode/tasks.json \ 109 $(OUTPUTDIR)/.vscode/launch.json 110 111 all: $(TARGETS) 112 113 .PHONY: all $(TARGETS)