Skip to content

Commit

Permalink
Cocoa: Now in a .app bundle
Browse files Browse the repository at this point in the history
Run 'make app' to get a .app bundle, or just 'make' as ususal if you only want an executable binary file.
  • Loading branch information
ilia3101 committed Jul 31, 2017
1 parent dbfec7f commit d0ee34d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@ What is MLV App? A cross platform RAW conversion software that works **natively*
```
$ git clone https://github.com/ilia3101/MLV-App.git
$ cd MLV-App/platform/cocoa
$ make
$ make app
```
More coming soon (for Qt)
### Where is the code?
Expand Down
17 changes: 16 additions & 1 deletion platform/cocoa/Makefile
Expand Up @@ -24,6 +24,21 @@ main :
rm compile_time_code; \
rm app_window_title.h

# run 'make app' to get a .app bundle
app :
rm $(appname).app; \
$(CC) generate_info_plist.c -o generate_info_plist; \
./generate_info_plist $(appname); \
make main; \
mkdir $(appname).app; \
mkdir $(appname).app/Contents; \
mkdir $(appname).app/Contents/MacOS; \
mkdir $(appname).app/Contents/Resources; \
cp -i $(appname) $(appname).app/Contents/MacOS/; \
cp -i info.plist $(appname).app/Contents/; \
rm generate_info_plist; \
rm info.plist; \

# Actual linking and compiling happens here
build : $(objects)
$(CC) $(mainflags) $(objects) -o $(appname) -framework Cocoa;
Expand Down Expand Up @@ -66,4 +81,4 @@ matrix.o : ../../src/matrix/matrix.c
# Type 'make clean' to remove mess
.PHONY : clean
clean : # Removes the program and object files
rm $(appname) $(objects)
rm -rf $(appname) $(appname).app $(objects)
52 changes: 52 additions & 0 deletions platform/cocoa/generate_info_plist.c
@@ -0,0 +1,52 @@
/* Generates an info.plist file for the app */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* Host name */
#include <unistd.h>

#define TAB " "

#define INFO_PLIST_START \
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" \
"<plist version=\"1.0\">\n" \
"<dict>\n"

#define INFO_PLIST_END \
"</dict>\n" \
"</plist>\n" \

#define INFO_PLIST_PROPERTY(KEY, STRING) \
TAB "<key>" KEY "</key>\n" \
TAB "<string>" STRING "</string>\n"


/* App name should be single commandline argument */
int main(int argc, char * argv[])
{
char * host_name = malloc(1024);
gethostname(host_name, 1023);

FILE * info_plist = fopen("info.plist", "wb");

/* What an amazing plist */
fprintf(info_plist, INFO_PLIST_START);
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundleDisplayName", "%s"), argv[1]);
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundleExecutable", "%s"), argv[1]);
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundleIdentifier", "fm.ilia.%s"), argv[1]);
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundleInfoDictionaryVersion", "6.0"));
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundleName", "%s"), argv[1]);
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundlePackageType", "APPL"));
fprintf(info_plist, INFO_PLIST_PROPERTY("CFBundleVersion", "(%s @%s)"), __DATE__, host_name);
fprintf(info_plist, INFO_PLIST_PROPERTY("LSMinimumSystemVersion", "10.6.0"));
fprintf(info_plist, TAB "<key>LSUIElement</key>\n" TAB "<false/>\n");
fprintf(info_plist, INFO_PLIST_PROPERTY("NSHumanReadableCopyright", "© 2017 Ilia Sibiryakov"));
fprintf(info_plist, INFO_PLIST_END);

fclose(info_plist);

free(host_name);
}
6 changes: 1 addition & 5 deletions platform/cocoa/main.m
Expand Up @@ -225,11 +225,7 @@ int NSApplicationMain(int argc, const char * argv[])

/* ...lets start at 5D2 resolution because that's my camera */

{
int imageSize = 1880 * 1056 * 3;
/* This will be freed and allocated soo many times */
rawImage = malloc( imageSize );
}
rawImage = malloc( 1880 * 1056 * 3 * sizeof(uint8_t) );

/* NSBitmapImageRep lets you display bitmap data n stuff in CrApple things like NSImageView */
rawBitmap = [ [NSBitmapImageRep alloc]
Expand Down

1 comment on commit d0ee34d

@ilia3101
Copy link
Owner Author

@ilia3101 ilia3101 commented on d0ee34d Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied info.plist template from the ancient magic lantern "raw2dng" app of 2013 - I was using it up until 2016 🤣

Please sign in to comment.