Skip to content

Commit 4100dc9

Browse files
fthevenetjerboaa
authored andcommitted
8350801: Add a code signing hook to the JDK build system
Reviewed-by: ihse, erikj
1 parent 8a40498 commit 4100dc9

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

make/autoconf/configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE
260260
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH
261261
JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT
262262
JDKOPT_SETUP_MACOSX_SIGNING
263+
JDKOPT_SETUP_SIGNING_HOOK
263264

264265
################################################################################
265266
#

make/autoconf/jdk-options.m4

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,29 @@ AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING],
965965
AC_SUBST(MACOSX_CODESIGN_MODE)
966966
])
967967

968+
################################################################################
969+
#
970+
# Setup a hook to invoke a script that runs for file produced by the native
971+
# compilation steps, after linking.
972+
# Parameter is the path to the script to be called.
973+
#
974+
AC_DEFUN([JDKOPT_SETUP_SIGNING_HOOK],
975+
[
976+
UTIL_ARG_WITH(NAME: signing-hook, TYPE: executable,
977+
OPTIONAL: true, DEFAULT: "",
978+
DESC: [specify path to script used to code sign native binaries]
979+
)
980+
981+
AC_MSG_CHECKING([for signing hook])
982+
if test "x$SIGNING_HOOK" != x; then
983+
UTIL_FIXUP_EXECUTABLE(SIGNING_HOOK)
984+
AC_MSG_RESULT([$SIGNING_HOOK])
985+
else
986+
AC_MSG_RESULT([none])
987+
fi
988+
AC_SUBST(SIGNING_HOOK)
989+
])
990+
968991
################################################################################
969992
#
970993
# fallback linker

make/autoconf/spec.gmk.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ MACOSX_VERSION_MAX := @MACOSX_VERSION_MAX@
479479
MACOSX_CODESIGN_MODE := @MACOSX_CODESIGN_MODE@
480480
MACOSX_CODESIGN_IDENTITY := @MACOSX_CODESIGN_IDENTITY@
481481

482+
# The code signing hook configuration
483+
SIGNING_HOOK := @SIGNING_HOOK@
484+
482485
# Toolchain type: gcc, clang, microsoft...
483486
TOOLCHAIN_TYPE := @TOOLCHAIN_TYPE@
484487
TOOLCHAIN_VERSION := @TOOLCHAIN_VERSION@

make/autoconf/util.m4

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,14 @@ AC_DEFUN([UTIL_CHECK_TYPE_file],
566566
fi
567567
])
568568

569+
AC_DEFUN([UTIL_CHECK_TYPE_executable],
570+
[
571+
# Check that the argument is an existing file that the user has execute access to.
572+
if (test ! -x "$1") || (test ! -f "$1") ; then
573+
FAILURE="File $1 does not exist or is not executable"
574+
fi
575+
])
576+
569577
AC_DEFUN([UTIL_CHECK_TYPE_directory],
570578
[
571579
# Check that the argument is an existing directory
@@ -648,7 +656,7 @@ AC_DEFUN([UTIL_CHECK_TYPE_features],
648656
# Arguments:
649657
# NAME: The base name of this option (i.e. what follows --with-). Required.
650658
# TYPE: The type of the value. Can be one of "string", "integer", "file",
651-
# "directory", "literal", "multivalue" or "features". Required.
659+
# "executable", "directory", "literal", "multivalue" or "features". Required.
652660
# DEFAULT: The default value for this option. Can be any valid string.
653661
# Required.
654662
# OPTIONAL: If this feature can be disabled. Defaults to false. If true,
@@ -758,7 +766,7 @@ UTIL_DEFUN_NAMED([UTIL_ARG_WITH],
758766
# Need to assign since we can't expand ARG TYPE inside the m4 quoted if statement
759767
TEST_TYPE="ARG_TYPE"
760768
# Additional [] needed to keep m4 from mangling shell constructs.
761-
[ if [[ ! "$TEST_TYPE" =~ ^(string|integer|file|directory|literal|multivalue|features)$ ]] ; then ]
769+
[ if [[ ! "$TEST_TYPE" =~ ^(string|integer|file|executable|directory|literal|multivalue|features)$ ]] ; then ]
762770
AC_MSG_ERROR([Internal error: Argument TYPE to [UTIL_ARG_WITH] must be a valid type, was: 'ARG_TYPE'])
763771
fi
764772

make/common/native/Link.gmk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ define CreateDynamicLibraryOrExecutable
203203
$(CODESIGN) -f -s $$($1_CODESIGN_OPTS) --entitlements \
204204
$$(call GetEntitlementsFile, $$@) $$@)
205205
endif
206+
ifneq ($(SIGNING_HOOK), )
207+
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_call_signing_hook, \
208+
$(SIGNING_HOOK) $$($1_TARGET))
209+
endif
206210

207211
# This is for IDE integration purposes only, and is not normally generated
208212
$1_LDFLAGS_FILE := $$(MAKESUPPORT_OUTPUTDIR)/compile-commands/$$($1_UNIQUE_NAME)-ldflags.txt

make/common/native/LinkMicrosoft.gmk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ define CreateDynamicLibraryOrExecutableMicrosoft
117117
-identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" \
118118
-outputresource:$$@;#1
119119
endif
120+
ifneq ($(SIGNING_HOOK), )
121+
$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_call_signing_hook, \
122+
$(SIGNING_HOOK) $$($1_TARGET))
123+
endif
120124
endef
121125

122126
################################################################################

0 commit comments

Comments
 (0)