Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8248610: Clean up handling of Windows RC files
Reviewed-by: erikj
  • Loading branch information
magicus committed Jul 1, 2020
1 parent 32aa661 commit 4b85bd546ee1a2b904f3104241119b0d64a029f3
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 576 deletions.
@@ -52,7 +52,6 @@ TARGETS =
# READMEs and other files.

DEMO_SHARE_SRC := $(TOPDIR)/src/demo/share
GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc

DEMO_MANIFEST := $(SUPPORT_OUTPUTDIR)/demos/java-main-manifest.mf

@@ -64,39 +64,12 @@ AC_DEFUN([FLAGS_SETUP_RCFLAGS],
[
# On Windows, we need to set RC flags.
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
RC_FLAGS="-nologo -l0x409"
JVM_RCFLAGS="-nologo"
RCFLAGS="-nologo"
if test "x$DEBUG_LEVEL" = xrelease; then
RC_FLAGS="$RC_FLAGS -DNDEBUG"
JVM_RCFLAGS="$JVM_RCFLAGS -DNDEBUG"
RCFLAGS="$RCFLAGS -DNDEBUG"
fi
# The version variables used to create RC_FLAGS may be overridden
# in a custom configure script, or possibly the command line.
# Let those variables be expanded at make time in spec.gmk.
# The \$ are escaped to the shell, and the $(...) variables
# are evaluated by make.
RC_FLAGS="$RC_FLAGS \
-D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
-D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
-D\"JDK_FILEDESC=\$(JDK_RC_NAME) binary\" \
-D\"JDK_VER=\$(VERSION_NUMBER)\" \
-D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
-D\"JDK_NAME=\$(JDK_RC_NAME) \$(VERSION_FEATURE)\" \
-D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
JVM_RCFLAGS="$JVM_RCFLAGS \
-D\"HS_VERSION_STRING=\$(VERSION_STRING)\" \
-D\"HS_COMPANY=\$(COMPANY_NAME)\" \
-D\"HS_VER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
-D\"HS_INTERNAL_NAME=jvm\" \
-D\"HS_COPYRIGHT=Copyright $COPYRIGHT_YEAR\" \
-D\"HS_FNAME=jvm.dll\" \
-D\"HS_NAME=\$(PRODUCT_NAME) \$(VERSION_SHORT)\" \
-D\"HS_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
fi
AC_SUBST(RC_FLAGS)
AC_SUBST(JVM_RCFLAGS)
AC_SUBST(RCFLAGS)
])

################################################################################
@@ -494,7 +494,6 @@ JVM_CFLAGS := @JVM_CFLAGS@
JVM_LDFLAGS := @JVM_LDFLAGS@
JVM_ASFLAGS := @JVM_ASFLAGS@
JVM_LIBS := @JVM_LIBS@
JVM_RCFLAGS := @JVM_RCFLAGS@

# These flags might contain variables set by a custom extension that is included later.
EXTRA_CFLAGS = @EXTRA_CFLAGS@
@@ -665,12 +664,7 @@ NEW_JAVADOC = $(INTERIM_LANGTOOLS_ARGS) $(JAVADOC_MAIN_CLASS)

JLINK_KEEP_PACKAGED_MODULES:=@JLINK_KEEP_PACKAGED_MODULES@

# Base flags for RC
# Guarding this against resetting value. Legacy make files include spec multiple
# times.
ifndef RC_FLAGS
RC_FLAGS:=@RC_FLAGS@
endif
RCFLAGS := @RCFLAGS@

# Tools adhering to a minimal and common standard of posix compliance.
AWK:=@AWK@
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -92,6 +92,16 @@ ProcessDir = \
) \
)

GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc

JDK_RCFLAGS=$(RCFLAGS) \
-D"JDK_VERSION_STRING=$(VERSION_STRING)" \
-D"JDK_COMPANY=$(COMPANY_NAME)" \
-D"JDK_VER=$(VERSION_NUMBER_FOUR_POSITIONS)" \
-D"JDK_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \
-D"JDK_NAME=$(JDK_RC_NAME) $(VERSION_SHORT)" \
-D"JDK_FVER=$(subst .,$(COMMA),$(VERSION_NUMBER_FOUR_POSITIONS))"

# Setup make rules for creating a native shared library with suitable defaults
# for the OpenJDK project.
#
@@ -100,14 +110,15 @@ ProcessDir = \
#
# Remaining parameters are named arguments. These are all passed on to
# SetupNativeCompilation, except for
# EXTRA_RC_FLAGS -- additional RC_FLAGS to append.
# EXTRA_RCFLAGS -- additional RCFLAGS to append.
# EXTRA_HEADER_DIRS -- additional directories to look for headers in
# EXTRA_SRC -- additional directories to look for source in
# EXCLUDE_SRC_PATTERNS -- exclude source dirs matching these patterns from
# appearing in SRC.
# HEADERS_FROM_SRC -- if false, does not add source dirs automatically as
# header include dirs. (Defaults to true.)
# SRC -- this is passed on, but preprocessed to accept source dir designations
# RC_FILEDESC -- override the default FILEDESC for Windows version.rc
# such as "java.base:headers".
SetupJdkLibrary = $(NamedParamsMacroTemplate)
define SetupJdkLibraryBody
@@ -137,19 +148,20 @@ define SetupJdkLibraryBody

ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE)
$1_VERSIONINFO_RESOURCE :=
endif

ifeq ($$($1_RC_FLAGS), )
$1_RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=$$($1_NAME).dll" \
-D "JDK_INTERNAL_NAME=$$($1_NAME)" \
-D "JDK_FTYPE=0x2L"
else ifeq ($$($1_RC_FLAGS), DISABLE)
$1_RC_FLAGS :=
ifeq ($$($1_RC_FILEDESC), )
$1_RC_FILEDESC := $(JDK_RC_NAME) binary
endif

$1_RCFLAGS := $(JDK_RCFLAGS) \
-D"JDK_FILEDESC=$$(strip $$($1_RC_FILEDESC))" \
-D"JDK_FNAME=$$($1_NAME).dll" \
-D"JDK_INTERNAL_NAME=$$($1_NAME)" \
-D"JDK_FTYPE=0x2L" \
-I$(TOPDIR)/src/java.base/windows/native/common \
$$($1_EXTRA_RCFLAGS)

ifneq ($$($1_HEADERS_FROM_SRC), false)
$1_SRC_HEADER_FLAGS := $$(addprefix -I, $$(wildcard $$($1_SRC)))
endif
@@ -171,7 +183,6 @@ define SetupJdkLibraryBody
ifeq ($$($1_CFLAGS)$$($1_CXXFLAGS), )
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif
$1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS)

# Since we reuse the rule name ($1), all our arguments will pass through.
# We lose in transparency, but gain in brevity in this call...
@@ -186,7 +197,7 @@ endef
#
# Remaining parameters are named arguments. These are all passed on to
# SetupNativeCompilation, except for
# EXTRA_RC_FLAGS -- additional RC_FLAGS to append.
# EXTRA_RCFLAGS -- additional RCFLAGS to append.
SetupJdkExecutable = $(NamedParamsMacroTemplate)
define SetupJdkExecutableBody
$1_TYPE := EXECUTABLE
@@ -201,20 +212,15 @@ define SetupJdkExecutableBody

ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE)
$1_VERSIONINFO_RESOURCE :=
endif

ifeq ($$($1_RC_FLAGS), )
$1_RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=$$($1_NAME).exe" \
-D "JDK_INTERNAL_NAME=$$($1_NAME)" \
-D "JDK_FTYPE=0x01L"
else ifeq ($$($1_RC_FLAGS), DISABLE)
$1_RC_FLAGS :=
endif

$1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS)
$1_RCFLAGS := $(JDK_RCFLAGS) \
-D"JDK_FILEDESC=$(JDK_RC_NAME) binary" \
-D"JDK_FNAME=$$($1_NAME).exe" \
-D"JDK_INTERNAL_NAME=$$($1_NAME)" \
-D"JDK_FTYPE=0x1L" \
-I$(TOPDIR)/src/java.base/windows/native/common \
$$($1_EXTRA_RCFLAGS)

# Since we reuse the rule name ($1), all our arguments will pass through.
# We lose in transparency, but gain in brevity in this call...
@@ -457,7 +457,7 @@ endef
# EXTRA_OBJECT_FILES List of extra object files to include when linking
# EXTRA_DEPS List of extra dependencies to be added to each compiled file
# VERSIONINFO_RESOURCE Input file for RC. Setting this implies that RC will be run
# RC_FLAGS flags for RC.
# RCFLAGS flags for RC.
# EMBED_MANIFEST if true, embed manifest on Windows.
# MAPFILE mapfile
# USE_MAPFILE_FOR_SYMBOLS if true and this is a STATIC_BUILD, just copy the
@@ -860,23 +860,23 @@ define SetupNativeCompilationBody
-include $$($1_RES_DEPS_FILE)
-include $$($1_RES_DEPS_TARGETS_FILE)

$1_RES_VARDEPS := $$($1_RC) $$($1_RC_FLAGS)
$1_RES_VARDEPS := $$($1_RC) $$($1_RCFLAGS)
$1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \
$$($1_RES).vardeps)

$$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
$$(call LogInfo, Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$($1_BASENAME)))
$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
$$(call ExecuteWithLog, $$@, $$(call MakeCommandRelative, \
$$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
$$($1_RC) $$($1_RCFLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
$$($1_VERSIONINFO_RESOURCE) 2>&1 ))
# Windows RC compiler does not support -showIncludes, so we mis-use CL
# for this. Filter out RC specific arguments that are unknown to CL.
# For some unknown reason, in this case CL actually outputs the show
# includes to stderr so need to redirect it to hide the output from the
# main log.
$$(call ExecuteWithLog, $$($1_RES_DEPS_FILE).obj, \
$$($1_CC) $$(filter-out -l%, $$($1_RC_FLAGS)) \
$$($1_CC) $$(filter-out -l%, $$($1_RCFLAGS)) \
$$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
$(CC_OUT_OPTION)$$($1_RES_DEPS_FILE).obj -P -Fi$$($1_RES_DEPS_FILE).pp \
$$($1_VERSIONINFO_RESOURCE)) 2>&1 \
@@ -48,7 +48,6 @@ LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjli \
-I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libjli \
#
GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc
MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher
JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest

@@ -71,7 +70,7 @@ JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest
# compile time defines exceeding Visual Studio 2013 limitations.
# CFLAGS Additional CFLAGS
# CFLAGS_windows Additional CFLAGS_windows
# EXTRA_RC_FLAGS Additional EXTRA_RC_FLAGS
# EXTRA_RCFLAGS Additional EXTRA_RCFLAGS
# MACOSX_PRIVILEGED On macosx, allow to access other processes
# OPTIMIZATION Override default optimization level (LOW)
# OUTPUT_DIR Override default output directory
@@ -160,7 +159,7 @@ define SetupBuildLauncherBody
$(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib, \
OUTPUT_DIR := $$($1_OUTPUT_DIR), \
VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \
EXTRA_RC_FLAGS := $$($1_EXTRA_RC_FLAGS), \
EXTRA_RCFLAGS := $$($1_EXTRA_RCFLAGS), \
MANIFEST := $(JAVA_MANIFEST), \
MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
))
@@ -27,8 +27,6 @@ include JdkNativeCompilation.gmk

################################################################################

GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc

# Absolute paths to lib files on windows for use in LIBS. Should figure out a more
# elegant solution to this.
WIN_JAVA_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib
@@ -124,13 +124,6 @@ else ifeq ($(call isTargetCpu, x86_64), true)
JVM_EXCLUDE_PATTERNS += x86_32
endif

ifeq ($(call isTargetOs, windows), true)
ifeq ($(call isTargetCpuBits, 64), true)
RC_DESC := 64-Bit$(SPACE)
endif
JVM_RCFLAGS += -D"HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(RC_DESC)$(JVM_VARIANT) VM"
endif

JVM_OPTIMIZATION ?= HIGHEST_JVM

# Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS
@@ -168,8 +161,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
USE_MAPFILE_FOR_SYMBOLS := true, \
STRIPFLAGS := $(JVM_STRIPFLAGS), \
EMBED_MANIFEST := true, \
RC_FLAGS := $(JVM_RCFLAGS), \
VERSIONINFO_RESOURCE := $(TOPDIR)/src/hotspot/os/windows/version.rc, \
RC_FILEDESC := $(HOTSPOT_VM_DISTRO) $(OPENJDK_TARGET_CPU_BITS)-Bit $(JVM_VARIANT) VM, \
PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \
))
@@ -30,22 +30,21 @@ $(eval $(call IncludeCustomExtension, modules/java.base/Launcher.gmk))

JAVA_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/launcher/java.rc

JAVA_RC_FLAGS += -I$(TOPDIR)/src/java.base/windows/native/common
JAVA_RC_FLAGS += -I$(TOPDIR)/src/java.base/windows/native/launcher/icons
JAVA_RCFLAGS ?= -I$(TOPDIR)/src/java.base/windows/native/launcher/icons

################################################################################

$(eval $(call SetupBuildLauncher, java, \
CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \
EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
OPTIMIZATION := HIGH, \
))

ifeq ($(call isTargetOs, windows), true)
$(eval $(call SetupBuildLauncher, javaw, \
CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \
EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
))
endif
@@ -116,7 +116,7 @@ ifeq ($(call isTargetOs, windows), true)
LIBAWT_CFLAGS += -DMLIB_OS64BIT
endif

LIBAWT_RC_FLAGS ?= -I $(TOPDIR)/src/java.base/windows/native/launcher/icons
LIBAWT_RCFLAGS ?= -I$(TOPDIR)/src/java.base/windows/native/launcher/icons
LIBAWT_VERSIONINFO_RESOURCE := $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc
endif

@@ -169,10 +169,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
comdlg32.lib winmm.lib comctl32.lib shlwapi.lib \
delayimp.lib jvm.lib $(WIN_JAVA_LIB) advapi32.lib, \
VERSIONINFO_RESOURCE := $(LIBAWT_VERSIONINFO_RESOURCE), \
RC_FLAGS := $(RC_FLAGS) $(LIBAWT_RC_FLAGS) \
-D "JDK_FNAME=awt.dll" \
-D "JDK_INTERNAL_NAME=awt" \
-D "JDK_FTYPE=0x2L", \
EXTRA_RCFLAGS := $(LIBAWT_RCFLAGS), \
))

$(BUILD_LIBAWT): $(call FindLib, java.base, java)

0 comments on commit 4b85bd5

Please sign in to comment.