Skip to content

Commit b831cf6

Browse files
author
David Roberts
authored
[ML] Make the ML native code more ".app"-like on macOS (#593)
Successful notarization and acceptance by Gatekeeper on macOS Catalina requires that the ML programs and dynamic libraries be arranged into the directory structure used by macOS apps. This functionality may be required for notarization on macOS Catalina. * Avoid clashing use of .plist files for static analysis output Static analysis files are now named *.xml (after all .plist files really are .xml files) * Add CFBundlePackageType = APPL to Info.plist Also make sure the identifier only uses valid characters * Change macOS directory structure * Switch CPP_CROSS_COMPILE back to macosx * Fix resource dir and include top level Info.plist with XML header * Oops * Fix problem with ordering of static initialization * Now we're shipping an app, use the app name in all Info.plist entries When this PR started out we thought we'd be shipping a number of standalone "command line tools". But that didn't work with notarization, so we had to make a more radical change, to become an app. (I also removed some dead code related to detecting Linux MUSL.)
1 parent 3101f43 commit b831cf6

File tree

28 files changed

+217
-166
lines changed

28 files changed

+217
-166
lines changed

3rd_party/3rd_party.sh

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,19 @@ case `uname` in
5959
STL_PREFIX=libstdc++
6060
STL_EXTENSION=.so.6
6161
ZLIB_LOCATION=
62+
elif [ "$CPP_CROSS_COMPILE" = macosx ] ; then
63+
SYSROOT=/usr/local/sysroot-x86_64-apple-macosx10.11
64+
BOOST_LOCATION=$SYSROOT/usr/local/lib
65+
BOOST_COMPILER=clang
66+
BOOST_EXTENSION=mt-x64-1_71.dylib
67+
BOOST_LIBRARIES='atomic chrono date_time filesystem iostreams log log_setup program_options regex system thread'
68+
XML_LOCATION=
69+
GCC_RT_LOCATION=
70+
STL_LOCATION=
71+
ZLIB_LOCATION=
6272
else
63-
if [ "$CPP_CROSS_COMPILE" = macosx ] ; then
64-
SYSROOT=/usr/local/sysroot-x86_64-apple-macosx10.11
65-
BOOST_LOCATION=$SYSROOT/usr/local/lib
66-
BOOST_COMPILER=clang
67-
BOOST_EXTENSION=mt-x64-1_71.dylib
68-
BOOST_LIBRARIES='atomic chrono date_time filesystem iostreams log log_setup program_options regex system thread'
69-
XML_LOCATION=
70-
GCC_RT_LOCATION=
71-
STL_LOCATION=
72-
ZLIB_LOCATION=
73-
else
74-
echo "Cannot cross compile to $CPP_CROSS_COMPILE"
75-
exit 3
76-
fi
73+
echo "Cannot cross compile to $CPP_CROSS_COMPILE"
74+
exit 3
7775
fi
7876
;;
7977

bin/autoconfig/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=$(OBJS_DIR)/autoconfig$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/bin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
ML_LIBS=$(LIB_ML_CORE) $(LIB_ML_MATHS) $(LIB_ML_MODEL) $(LIB_ML_API) $(LIB_ML_CONFIG)
1313

bin/autodetect/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=$(OBJS_DIR)/autodetect$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/bin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
ML_LIBS=$(LIB_ML_CORE) $(LIB_ML_MATHS) $(LIB_ML_MODEL) $(LIB_ML_API)
1313

bin/categorize/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=$(OBJS_DIR)/categorize$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/bin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
ML_LIBS=$(LIB_ML_CORE) $(LIB_ML_MATHS) $(LIB_ML_MODEL) $(LIB_ML_API)
1313

bin/controller/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=$(OBJS_DIR)/controller$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/bin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
ML_LIBS=$(LIB_ML_CORE)
1313

@@ -16,14 +16,19 @@ USE_BOOST_PROGRAMOPTIONS_LIBS=1
1616

1717
LIBS=$(ML_LIBS)
1818

19-
all: build
19+
all:: build
2020

2121
SRCS= \
2222
Main.cc \
2323
CBlockingCallCancellerThread.cc \
2424
CCmdLineParser.cc \
2525
CCommandProcessor.cc \
2626

27+
ifneq ($(PLIST_FILE),)
28+
all:: $(CPP_SRC_HOME)/gradle.properties $(CPP_SRC_HOME)/mk/make_info_plist.sh
29+
$(MKDIR) $(INSTALL_DIR)
30+
$(CPP_SRC_HOME)/mk/make_info_plist.sh "$(ML_APP_NAME)" true > $(INSTALL_DIR)/../$(notdir $(PLIST_FILE))
31+
endif
2732

2833
include $(CPP_SRC_HOME)/mk/stdapp.mk
2934

bin/data_frame_analyzer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=$(OBJS_DIR)/data_frame_analyzer$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/bin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
ML_LIBS=$(LIB_ML_CORE) $(LIB_ML_MATHS) $(LIB_ML_MODEL) $(LIB_ML_API)
1313

bin/normalize/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=$(OBJS_DIR)/normalize$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/bin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
ML_LIBS=$(LIB_ML_CORE) $(LIB_ML_MATHS) $(LIB_ML_MODEL) $(LIB_ML_API)
1313

dev-tools/strip_binaries.sh

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,47 @@
55
# you may not use this file except in compliance with the Elastic License.
66
#
77

8-
# Strips Ml native code binaries to make them smaller before distribution.
8+
# Strips ML native code binaries to make them smaller before distribution.
9+
10+
ML_APP_NAME=controller
11+
case `uname` in
12+
13+
Darwin)
14+
EXE_DIR="$ML_APP_NAME.app/Contents/MacOS"
15+
DYNAMIC_LIB_DIR="$ML_APP_NAME.app/Contents/lib"
16+
;;
17+
18+
Linux)
19+
if [ -z "$CPP_CROSS_COMPILE" ] ; then
20+
EXE_DIR=bin
21+
DYNAMIC_LIB_DIR=lib
22+
elif [ "$CPP_CROSS_COMPILE" = macosx ] ; then
23+
EXE_DIR="$ML_APP_NAME.app/Contents/MacOS"
24+
DYNAMIC_LIB_DIR="$ML_APP_NAME.app/Contents/lib"
25+
else
26+
echo "Cannot cross compile to $CPP_CROSS_COMPILE"
27+
exit 1
28+
fi
29+
;;
30+
31+
esac
932

1033
# Ensure $CPP_PLATFORM_HOME is set
1134
if [ -z "$CPP_PLATFORM_HOME" ] ; then
1235
echo '$CPP_PLATFORM_HOME is not set'
13-
exit 1
36+
exit 2
1437
fi
1538

16-
# Ensure the bin folder has been created.
17-
if [ ! -d "$CPP_PLATFORM_HOME/bin" ] ; then
18-
echo '$CPP_PLATFORM_HOME/bin does not exist'
19-
exit 2
39+
# Ensure the executable programs folder has been created.
40+
if [ ! -d "$CPP_PLATFORM_HOME/$EXE_DIR" ] ; then
41+
echo "$CPP_PLATFORM_HOME/$EXE_DIR does not exist"
42+
exit 3
2043
fi
2144

2245
# Ensure the lib folder has been created.
23-
if [ ! -d "$CPP_PLATFORM_HOME/lib" ] ; then
24-
echo '$CPP_PLATFORM_HOME/lib does not exist'
25-
exit 3
46+
if [ ! -d "$CPP_PLATFORM_HOME/$DYNAMIC_LIB_DIR" ] ; then
47+
echo "$CPP_PLATFORM_HOME/$DYNAMIC_LIB_DIR does not exist"
48+
exit 4
2649
fi
2750

2851
cd "$CPP_PLATFORM_HOME"
@@ -32,13 +55,13 @@ cd "$CPP_PLATFORM_HOME"
3255
case `uname` in
3356

3457
Darwin)
35-
for PROGRAM in `ls -1d bin/* | grep -v '\.dSYM$'`
58+
for PROGRAM in `ls -1d "$EXE_DIR"/* | grep -v '\.dSYM$'`
3659
do
3760
echo "Stripping $PROGRAM"
3861
dsymutil $PROGRAM
3962
strip -u -r $PROGRAM
4063
done
41-
for LIBRARY in `ls -1d lib/* | grep -v '\.dSYM$'`
64+
for LIBRARY in `ls -1d "$DYNAMIC_LIB_DIR"/* | grep -v '\.dSYM$'`
4265
do
4366
echo "Stripping $LIBRARY"
4467
case $LIBRARY in
@@ -51,42 +74,40 @@ case `uname` in
5174

5275
Linux)
5376
if [ -z "$CPP_CROSS_COMPILE" ] ; then
54-
for PROGRAM in `ls -1 bin/* | egrep -v 'bin/core|-debug$'`
77+
for PROGRAM in `ls -1 "$EXE_DIR"/* | egrep -v "$EXE_DIR"'/core|-debug$'`
5578
do
5679
echo "Stripping $PROGRAM"
5780
objcopy --only-keep-debug "$PROGRAM" "$PROGRAM-debug"
5881
strip --strip-all $PROGRAM
5982
objcopy --add-gnu-debuglink="$PROGRAM-debug" "$PROGRAM"
6083
chmod -x "$PROGRAM-debug"
6184
done
62-
for LIBRARY in `ls -1 lib/* | egrep -v 'lib/core|-debug$'`
85+
for LIBRARY in `ls -1 "$DYNAMIC_LIB_DIR"/* | egrep -v 'lib/core|-debug$'`
6386
do
6487
echo "Stripping $LIBRARY"
6588
objcopy --only-keep-debug "$LIBRARY" "$LIBRARY-debug"
6689
strip --strip-unneeded $LIBRARY
6790
objcopy --add-gnu-debuglink="$LIBRARY-debug" "$LIBRARY"
6891
done
92+
elif [ "$CPP_CROSS_COMPILE" = macosx ] ; then
93+
for PROGRAM in `ls -1d "$EXE_DIR"/* | grep -v '\.dSYM$'`
94+
do
95+
echo "Stripping $PROGRAM"
96+
llvm-dsymutil-3.9 $PROGRAM
97+
/usr/local/bin/x86_64-apple-macosx10.11-strip -u -r $PROGRAM
98+
done
99+
for LIBRARY in `ls -1d "$DYNAMIC_LIB_DIR"/* | grep -v '\.dSYM$'`
100+
do
101+
echo "Stripping $LIBRARY"
102+
case $LIBRARY in
103+
*Ml*)
104+
llvm-dsymutil-3.9 $LIBRARY
105+
esac
106+
/usr/local/bin/x86_64-apple-macosx10.11-strip -x $LIBRARY
107+
done
69108
else
70-
if [ "$CPP_CROSS_COMPILE" = macosx ] ; then
71-
for PROGRAM in `ls -1d bin/* | grep -v '\.dSYM$'`
72-
do
73-
echo "Stripping $PROGRAM"
74-
llvm-dsymutil-3.9 $PROGRAM
75-
/usr/local/bin/x86_64-apple-macosx10.11-strip -u -r $PROGRAM
76-
done
77-
for LIBRARY in `ls -1d lib/* | grep -v '\.dSYM$'`
78-
do
79-
echo "Stripping $LIBRARY"
80-
case $LIBRARY in
81-
*Ml*)
82-
llvm-dsymutil-3.9 $LIBRARY
83-
esac
84-
/usr/local/bin/x86_64-apple-macosx10.11-strip -x $LIBRARY
85-
done
86-
else
87-
echo "Cannot cross compile to $CPP_CROSS_COMPILE"
88-
exit 4
89-
fi
109+
echo "Cannot cross compile to $CPP_CROSS_COMPILE"
110+
exit 5
90111
fi
91112
;;
92113

devbin/analyze_test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(CPP_SRC_HOME)/mk/defines.mk
77

88
TARGET=analyze_test$(EXE_EXT)
99

10-
INSTALL_DIR=$(CPP_PLATFORM_HOME)/devbin
10+
INSTALL_DIR=$(CPP_PLATFORM_HOME)/$(EXE_DIR)
1111

1212
all: build
1313

docs/CHANGELOG.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ find lower loss models faster. (See {ml-pull}686[#686].)
4141
4242
== {es} version 7.4.1
4343
44+
=== Enhancements
45+
46+
* The {ml} native processes are now arranged in a .app directory structure on
47+
macOS, to allow for notarization on macOS Catalina. (See {ml-pull}593[#593].)
48+
4449
=== Bug Fixes
4550
4651
* A reference to a temporary variable was causing forecast model restoration to fail.

0 commit comments

Comments
 (0)