-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmake_bundle_exe.sh
executable file
·77 lines (63 loc) · 2.5 KB
/
make_bundle_exe.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
### --- SETUP BUNDLE STRUCTURE --- ###
mkdir -p bare_bone.app/Contents/MacOS
mkdir -p bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/{Headers,Resources}
# Create the header file for the dynamic library
cat << 'EOF' > bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/Headers/ClockOpen.h
void openClock();
EOF
# Create the C source file for the dynamic library
cat << 'EOF' > ClockOpen.c
#include <stdlib.h>
void openClock() {
system("open -a Clock");
}
EOF
# Compile the dynamic library
clang -dynamiclib -o bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/ClockOpen ClockOpen.c
# Set the install name for the framework
install_name_tool -id @rpath/ClockOpen.framework/Versions/A/ClockOpen bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/ClockOpen
# Create necessary symbolic links in the framework
ln -s A bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/Current
ln -s Versions/Current/ClockOpen bare_bone.app/Contents/Frameworks/ClockOpen.framework/ClockOpen
ln -s Versions/Current/Headers bare_bone.app/Contents/Frameworks/ClockOpen.framework/Headers
ln -s Versions/Current/Resources bare_bone.app/Contents/Frameworks/ClockOpen.framework/Resources
# Create Info.plist for the Framework
cat << 'EOF' > bare_bone.app/Contents/Frameworks/ClockOpen.framework/Versions/A/Resources/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>ClockOpen</string>
</dict>
</plist>
EOF
# Create the C source file for the main binary
cat << 'EOF' > bare_bone.c
#include <stdio.h>
#include <stdlib.h>
#include "ClockOpen/ClockOpen.h"
int main() {
system("open -a Calculator");
openClock();
return 0;
}
EOF
# Compile the main binary and link it to the framework
clang -o bare_bone.app/Contents/MacOS/bare_bone_exe bare_bone.c -Fbare_bone.app/Contents/Frameworks -framework ClockOpen -Wl,-rpath,@executable_path/../Frameworks
# Clean up C source files
rm bare_bone.c ClockOpen.c
# Creating Info.plist for the App
cat << 'EOF' > bare_bone.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>bare_bone_exe</string>
</dict>
</plist>
EOF
# Sign the application
codesign -f -s - --deep bare_bone.app