Skip to content

Commit

Permalink
SapMachine #1823: Import async-profiler: Codesign binaries on macOS a…
Browse files Browse the repository at this point in the history
…nd cleanups (#1830)

Co-authored-by: Christoph Langer <[email protected]>
  • Loading branch information
MBaesken and RealCLanger authored Sep 26, 2024
1 parent 06f965b commit 8bc00ab
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 45 deletions.
68 changes: 26 additions & 42 deletions make/Images.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -247,55 +247,39 @@ ifeq ($(GCOV_ENABLED), true)

endif

# SapMachine 2024-09-13: import async profiler binaries
################################################################################
# Async profiler import
# we can reference into the workspace where we download the async profiler;
# this has to be set via configure
ifeq ($(ASYNC_PROFILER_IMPORT_ENABLED), true)
ifeq ($(call isTargetOs, linux macosx), true)

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_BIN_TO_JDK, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH)/bin, \
DEST := $(JDK_IMAGE_DIR)/bin, \
FILES := asprof, \
))

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_BIN_TO_JRE, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH)/bin, \
DEST := $(JRE_IMAGE_DIR)/bin, \
FILES := asprof, \
))
# SapMachine 2024-09-13: Async profiler import

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_LIB_TO_JDK, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH)/lib, \
DEST := $(JDK_IMAGE_DIR)/lib, \
FILES := async-profiler.jar converter.jar libasyncProfiler$(SHARED_LIBRARY_SUFFIX), \
))
ifeq ($(call isTargetOs, linux macosx)+$(ASYNC_PROFILER_IMPORT_ENABLED), true+true)

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_LIB_TO_JRE, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH)/lib, \
DEST := $(JRE_IMAGE_DIR)/lib, \
FILES := async-profiler.jar converter.jar libasyncProfiler$(SHARED_LIBRARY_SUFFIX), \
))

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_LEGAL_TO_JDK, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH), \
DEST := $(JDK_IMAGE_DIR)/legal/async, \
FILES := CHANGELOG.md LICENSE README.md, \
))
$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_BIN_TO_JDK, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH), \
DEST := $(JDK_IMAGE_DIR), \
FILES := bin/asprof lib/libasyncProfiler$(SHARED_LIBRARY_SUFFIX), \
MACRO := install-file-and-sign, \
))

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_LEGAL_TO_JRE, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH), \
DEST := $(JRE_IMAGE_DIR)/legal/async, \
FILES := CHANGELOG.md LICENSE README.md, \
))
$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_BIN_TO_JRE, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH), \
DEST := $(JRE_IMAGE_DIR), \
FILES := bin/asprof lib/libasyncProfiler$(SHARED_LIBRARY_SUFFIX), \
MACRO := install-file-and-sign, \
))

$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_TO_JDK, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH), \
DEST := $(JDK_IMAGE_DIR), \
FILES := lib/async-profiler.jar lib/converter.jar legal/async/CHANGELOG.md legal/async/LICENSE legal/async/README.md, \
))

JDK_TARGETS += $(COPY_ASYNC_PROFILER_BIN_TO_JDK) $(COPY_ASYNC_PROFILER_LIB_TO_JDK) $(COPY_ASYNC_PROFILER_LEGAL_TO_JDK)
JRE_TARGETS += $(COPY_ASYNC_PROFILER_BIN_TO_JRE) $(COPY_ASYNC_PROFILER_LIB_TO_JRE) $(COPY_ASYNC_PROFILER_LEGAL_TO_JRE)
$(eval $(call SetupCopyFiles, COPY_ASYNC_PROFILER_TO_JRE, \
SRC := $(ASYNC_PROFILER_IMPORT_PATH), \
DEST := $(JRE_IMAGE_DIR), \
FILES := lib/async-profiler.jar lib/converter.jar legal/async/CHANGELOG.md legal/async/LICENSE legal/async/README.md, \
))

endif
JDK_TARGETS += $(COPY_ASYNC_PROFILER_BIN_TO_JDK) $(COPY_ASYNC_PROFILER_TO_JDK)
JRE_TARGETS += $(COPY_ASYNC_PROFILER_BIN_TO_JRE) $(COPY_ASYNC_PROFILER_TO_JRE)
endif

################################################################################
Expand Down
6 changes: 3 additions & 3 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
[Set import path for downloaded async profiler binaries])])
if test "x$with_async_profiler_import_path" != x; then
ASYNC_PROFILER_IMPORT_PATH="$with_async_profiler_import_path"
if test -f "$ASYNC_PROFILER_IMPORT_PATH/LICENSE"; then
if test -f "$ASYNC_PROFILER_IMPORT_PATH/bin/asprof"; then
ASYNC_PROFILER_IMPORT_ENABLED=true
AC_MSG_NOTICE([LICENSE file exists, enabling async-profiler import])
AC_MSG_NOTICE([asprof exists, enabling async-profiler import])
else
AC_MSG_ERROR([Async profiler import path was set, but LICENSE file not found there])
AC_MSG_ERROR([async-profiler import path was set, but asprof was not found])
fi
fi
AC_SUBST(ASYNC_PROFILER_IMPORT_PATH)
Expand Down
24 changes: 24 additions & 0 deletions make/common/FileUtils.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,35 @@ ifeq ($(call isTargetOs, macosx), true)
$(XATTR) -cs '$(call DecodeSpace, $@)'; \
fi
endef

# SapMachine 2024-09-13: import async profiler binaries
ifeq ($(MACOSX_CODESIGN_MODE), disabled)
define install-file-and-sign
$(install-file)
$(ECHO) No Async profiler codesigning, codesign mode is $(MACOSX_CODESIGN_MODE)
endef
else
ifeq ($(MACOSX_CODESIGN_MODE), hardened)
CODESIGN_APOPTS="$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime
else ifeq ($(MACOSX_CODESIGN_MODE), debug)
CODESIGN_APOPTS=-
PLIST_APOPT=-debug
endif
define install-file-and-sign
$(install-file)
$(CODESIGN) --remove-signature '$(call DecodeSpace, $@)'
$(CODESIGN) -f -s $(CODESIGN_APOPTS) --entitlements $(TOPDIR)/make/data/macosxsigning/default$(PLIST_APOPT).plist '$(call DecodeSpace, $@)'
endef
endif
else
define install-file
$(call MakeTargetDir)
$(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
endef
# SapMachine 2024-09-13: import async profiler binaries
define install-file-and-sign
$(install-file)
endef
endif

# Variant of install file that does not preserve symlinks
Expand Down

0 comments on commit 8bc00ab

Please sign in to comment.