Source rearrangement, OS X app bundle script

This commit is contained in:
Timothy Warren 2012-11-28 13:13:30 -05:00
parent 585542815d
commit f443476435
16 changed files with 179 additions and 9 deletions

4
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "sys/db"]
path = sys/db
[submodule "src/sys/db"]
path = src/sys/db
url = git://github.com/aviat4ion/Query.git

View File

@ -14,7 +14,6 @@
* Wrapper program for embeded php
*/
#include <unistd.h>
#include <sapi/embed/php_embed.h>
int main(int argc, char *argv[])

168
build_osx_bundle.php Normal file
View File

@ -0,0 +1,168 @@
<?php
define('VERSION', '0.1.0');
define('MAJOR_VERSION', '0');
define('MINOR_VERSION', '1');
define('APP_PATH', __DIR__.'/OpenSQLManager.app');
define('CONTENTS', APP_PATH . '/Contents');
define('MAC_OS', CONTENTS . '/MacOS');
define('RESOURCES', CONTENTS . '/Resources');
define('SRC_DIR', __DIR__.'/src');
define('SRC_RESOURCES', __DIR__.'/Resources');
if ( ! function_exists('glob_recursive'))
{
// Does not support flag GLOB_BRACE
/**
* Recursive wrapper for glob
*/
function glob_recursive($pattern, $flags = 0)
{
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir)
{
$files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
}
return $files;
}
}
/**
* Create bundle folder structure
*/
function create_dirs()
{
if ( ! is_dir(APP_PATH))
{
mkdir(APP_PATH);
if ( ! is_dir(CONTENTS))
{
mkdir(CONTENTS);
if ( ! is_dir(RESOURCES))
{
mkdir(RESOURCES);
mkdir(RESOURCES.'/images');
}
if ( ! is_dir(MAC_OS))
{
mkdir(MAC_OS);
mkdir(MAC_OS.'/sys');
mkdir(MAC_OS.'/sys/common');
mkdir(MAC_OS.'/sys/db');
mkdir(MAC_OS.'/sys/widgets');
mkdir(MAC_OS.'/sys/windows');
mkdir(MAC_OS.'/sys/db/classes');
mkdir(MAC_OS.'/sys/db/drivers');
mkdir(MAC_OS.'/sys/db/drivers/mysql');
mkdir(MAC_OS.'/sys/db/drivers/pgsql');
mkdir(MAC_OS.'/sys/db/drivers/sqlite');
mkdir(MAC_OS.'/sys/db/drivers/odbc');
mkdir(MAC_OS.'/sys/db/drivers/firebird');
}
}
}
}
/**
* Copy source files and binary into bundle structure
*/
function copy_src()
{
// Check for binary
if ( ! file_exists('OpenSQLManager'))
{
exit('App bundle not created: binary missing');
}
// Drop to shell because php treats it as text
$src = __DIR__.'/OpenSQLManager';
$dest = MAC_OS;
`cp {$src} {$dest}`;
$raw_src_files = glob_recursive(SRC_DIR.'/*.php');
$src_files = array();
// Filter test files/directories
foreach($raw_src_files as $file)
{
// Skip test files/directories
if (stripos($file, 'test') !== FALSE) continue;
$src_files[] = $file;
}
// Loop through the source files
foreach($src_files as $file)
{
// Figure out the new path
$new_file = str_replace(SRC_DIR, MAC_OS, $file);
// Copy the files
copy($file, $new_file);
}
// Copy resources
$rs = glob_recursive(SRC_RESOURCES.'/*.*');
foreach ($rs as $resource)
{
// Figure out new path
$new_rs = str_replace(SRC_RESOURCES, RESOURCES, $resource);
// Copy the files
copy($resource, $new_rs);
}
}
/**
* Make it an official app
*/
function create_plist()
{
$version = VERSION;
$minor = MINOR_VERSION;
$major = MAJOR_VERSION;
$plist = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>App for managing databases.</string>
<key>CFBundleExecutable</key>
<string>OpenSQLManager</string>
<key>CFBundleIdentifier</key>
<string>com.aviat4ion.OpenSQLManager</string>
<key>CFBundleName</key>
<string>OpenSQLManager</string>
<key>CFBundleIconFile</key>
<string>OSM.icns</string>
<key>CFBundleShortVersionString</key>
<string>{$version}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>IFMajorVersion</key>
<integer>{$major}</integer>
<key>IFMinorVersion</key>
<integer>{$minor}</integer>
</dict>
</plist>
XML;
// Add the plist to the bundle
file_put_contents(CONTENTS.'/Info.plist', $plist);
}
create_dirs();
copy_src();
create_plist();
exit("App bundle created \n");

View File

@ -1,8 +1,11 @@
CC = gcc
CFLAGS = -c `/opt/php-embed/bin/php-config --includes` -Wall -g
LDFLAGS = -L/Library/Frameworks/Firebird.framework/Libraries -L/opt/php-embed/lib -lphp5 `/opt/php-embed/bin/php-config --libs`
all: OpenSQLManager.c
${CC} -O0 -o OpenSQLManager.o OpenSQLManager.c ${CFLAGS}
${CC} -O0 -o OpenSQLManager OpenSQLManager.o ${LDFLAGS}
${CC} -O0 -o OpenSQLManager OpenSQLManager.o ${LDFLAGS}
release: OpenSQLManager.c
${CC} -O2 -o OpenSQLManager.o OpenSQLManager.c ${CFLAGS}
${CC} -O2 -o OpenSQLManager OpenSQLManager.o ${LDFLAGS}

View File

@ -11,10 +11,10 @@
<template name="responsive" />
</transformations>
<files>
<directory>.</directory>
<directory>src</directory>
<directory>tests</directory>
<directory>sys/db/tests</directory>
<directory>src/sys/db/tests</directory>
<ignore>tests/*</ignore>
<ignore>sys/db/tests/*</ignore>
<ignore>src/sys/db/tests/*</ignore>
</files>
</phpdoc>

BIN
resources/OSM.icns Normal file

Binary file not shown.

View File

@ -32,7 +32,7 @@ ini_set('memory_limit', -1);
// Set the current directory as the base for included files
define('OSM_BASE_DIR', __DIR__.'/sys');
define('OSM_RESOURCE_DIR', __DIR__.'/resources');
define('OSM_RESOURCE_DIR', __DIR__.'/../Resources');
define('OSM_SETTINGS_DIR', __DIR__);
define('OSM_PROGRAM_NAME', 'OpenSQLManager');
define('OSM_VERSION', '0.2.0pre');

View File