Skip to content

Commit

Permalink
build system or custom webkit
Browse files Browse the repository at this point in the history
  • Loading branch information
fairwinds committed Oct 13, 2012
1 parent 52b91d7 commit e9502af
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 69 deletions.
2 changes: 2 additions & 0 deletions kroll/SConscript.thirdparty
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ elif build.is_win32():

elif build.is_osx():
excludes = ['.h', '.defs', 'JavaScriptGlue.framework']
if build.tidelite:
excludes.extend(['WebKit.framework', 'WebCore.framework', 'JavaScriptCore.framework'])
targets = []
for framework in Glob(path.join(build.third_party, '*/*.framework')):
t = build.utils.CopyToDir(framework, rtdir, exclude=excludes)
Expand Down
2 changes: 1 addition & 1 deletion kroll/libkroll/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if build.is_linux():
if os.environ.has_key('PKG_CONFIG_PATH'):
env.AppendENVPath('PKG_CONFIG_PATH', os.environ['PKG_CONFIG_PATH'])
env.ParseConfig('pkg-config --cflags --libs libxml-2.0 gtk+-2.0 gdk-2.0 glib-2.0 gthread-2.0')
env.Append(LIBS=['pthread', 'libsoup-2.4', 'libproxy'])
env.Append(LIBS=['pthread', 'libsoup-2.4', 'libproxy', 'libgcrypt', 'libgnutls'])

if build.is_win32():
env.Append(CPPPATH=[path.join(build.third_party, 'icu', 'include')])
Expand Down
32 changes: 24 additions & 8 deletions kroll/libkroll/javascript/SConscript
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
#!/usr/bin/env python

# (c) 2008-2012 Appcelerator Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from os import path
Import('build env module')

env.Append(CPPDEFINES=('KROLL_JAVASCRIPT_API_EXPORT', 1))

build.add_thirdparty(env, 'poco')
build.add_thirdparty(env, 'webkit')

if build.is_win32():
env.Append(LIBS=[
'kernel32', 'shell32',
'user32', 'ole32',
'comctl32', 'shlwapi',
'oleaut32', 'icuuc',
'pthreadVC2', 'kroll'])
env.Append(LINKFLAGS=['/LTCG', '/INCREMENTAL:NO'])
env.Append(LIBS=[
'kernel32', 'shell32',
'user32', 'ole32',
'comctl32', 'shlwapi',
'oleaut32', 'icuuc',
'pthreadVC2', 'kroll'])
env.Append(LINKFLAGS=['/LTCG', '/INCREMENTAL:NO'])

build.mark_build_target(env.SharedLibrary(
path.join(module.dir, 'javascriptmodule'), Glob('*.cpp')))
path.join(module.dir, 'javascriptmodule'), Glob('*.cpp')))

7 changes: 0 additions & 7 deletions kroll/libkroll/javascript/kjs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <Poco/FileStream.h>
#include <Poco/Mutex.h>
#include <JavaScriptCore/JSBasePrivate.h>

namespace kroll
{
Expand Down Expand Up @@ -167,12 +166,6 @@ namespace KJSUtil
{
// this is a KObject that needs to be proxied
jsValue = KObjectToJSValue(value, jsContext);

// Report extra memory costs bound to a KObject.
// This will help avoid memory leaks caused by a lazy GC.
size_t extraMemoryCost = obj->ExtraMemoryCost();
if (extraMemoryCost > 0)
JSReportExtraMemoryCost(jsContext, extraMemoryCost);
}
}
else if (value->IsMethod())
Expand Down
48 changes: 31 additions & 17 deletions kroll/site_scons/kroll.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#!/usr/bin/env python

# (c) 2008-2012 Appcelerator Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import SCons.Variables
import SCons.Environment
from SCons.Script import *
Expand All @@ -22,7 +38,8 @@ class BuildConfig(object):
def __init__(self, **kwargs):
self.debug = False
self.os = None
self.modules = []
self.modules = []
self.tidelite = False
if not hasattr(os, 'uname') or self.matches('CYGWIN'):
self.os = 'win32'
self.arch = 'i386'
Expand Down Expand Up @@ -83,6 +100,10 @@ def add_environ_arg(key, description, default):

self.env.Append(LIBPATH=[self.dir])

if ARGUMENTS.get('lite'):
self.tidelite = True
self.env.Append(CPPDEFINES='TIDE_LITE')

self.init_os_arch()
self.build_targets = [] # targets needed before packaging & distribution can occur
self.staging_targets = [] # staging the module and sdk directories
Expand Down Expand Up @@ -125,28 +146,20 @@ def init_os_arch(self):
self.env.Append(LINKFLAGS=['-m64'])
self.env.Append(CPPDEFINES = ('OS_64', 1))
elif self.is_linux() or self.is_osx():
self.env.Append(CPPFLAGS=['-m32', '-Wall', '-Werror', '-fno-common', '-fvisibility=hidden', '-fno-strict-aliasing'])
if self.is_linux():
self.env.Append(LINKFLAGS=['-m32', '-lgcrypt', '-lgnutls'])
if self.is_osx():
self.env.Append(LINKFLAGS=['-m32'])
self.env.Append(CPPFLAGS=['-m32', '-Wall', '-fno-common', '-fvisibility=hidden', '-fno-strict-aliasing'])
self.env.Append(LINKFLAGS=['-m32'])
self.env.Append(CPPDEFINES = ('OS_32', 1))
else:
self.env.Append(CPPDEFINES = ('OS_32', 1))

if self.is_osx():
if ARGUMENTS.get('osx_10_4', 0):
sdk_dir = '/Developer/SDKs/MacOSX10.4u.sdk'
sdk_minversion = '-mmacosx-version-min=10.4'
self.env['GCC_VERSION'] = '4.0'
self.env['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
else:
sdk_dir = '/Developer/SDKs/MacOSX10.5.sdk'
sdk_minversion = '-mmacosx-version-min=10.5'
self.env['MACOSX_DEPLOYMENT_TARGET'] = '10.5'
sdk_version = '10.6'
sdk_dir = '/Developer/SDKs/MacOSX%s.sdk' % sdk_version
sdk_minversion = '-mmacosx-version-min=%s' % sdk_version
self.env['MACOSX_DEPLOYMENT_TARGET'] = '%s' % sdk_version

self.env['CC'] = ['gcc', '-arch', 'i386']
self.env['CXX'] = ['gcc', '-arch', 'i386']
self.env['CXX'] = ['g++', '-arch', 'i386']
self.env.Append(FRAMEWORKS=['Foundation', 'IOKit'])
self.env.Append(CXXFLAGS=['-isysroot', sdk_dir, sdk_minversion, '-x', 'objective-c++'])
self.env.Append(LINKFLAGS=['-isysroot', sdk_dir, '-syslibroot,' + sdk_dir, '-lstdc++', sdk_minversion])
Expand Down Expand Up @@ -209,7 +222,8 @@ def add_thirdparty(self, env, name):
libs = ['webkittitanium-1.0']

if self.is_osx():
env.Append(FRAMEWORKPATH=[self.tp('webkit')])
if self.tidelite is False:
env.Append(FRAMEWORKPATH=[self.tp('webkit')])
env.Append(FRAMEWORKS=['WebKit', 'JavaScriptCore'])

if cpppath: env.Append(CPPPATH=cpppath)
Expand Down
55 changes: 37 additions & 18 deletions modules/ti.UI/SConscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env python

# (c) 2008-2012 Appcelerator Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from os import path
Import('build env module')

Expand All @@ -10,30 +25,34 @@ build.add_thirdparty(env, 'webkit')
env.Append(LIBS=['tiappmodule'])

sources = Glob('*.cpp') + ['url/url.cpp']

if not build.tidelite:
sources = sources + Glob('lang_binding/*.cpp')

if build.is_linux():
sources = sources + Glob('gtk/*.cpp')
env.Append(LIBS=['Xss', 'libsoup-2.4', 'libsoup-gnome-2.4'])
env.ParseConfig('PKG_CONFIG_PATH=${PKG_CONFIG_PATH} pkg-config --cflags --libs libnotify gtk+-2.0 gdk-2.0 x11 xext')
sources = sources + Glob('gtk/*.cpp')
env.Append(LIBS=['Xss', 'libsoup-2.4', 'libsoup-gnome-2.4'])
env.ParseConfig('PKG_CONFIG_PATH=${PKG_CONFIG_PATH} pkg-config --cflags --libs libnotify gtk+-2.0 gdk-2.0 x11 xext')

elif build.is_win32():
build.add_thirdparty(env, 'cairo')
sources = sources + Glob('win32/*.cpp')
sources += Glob('binding/kjs*.cpp')
env.Append(CPPPATH=[build.tp('icu', 'include')])
env.Append(LIBS=[
'kernel32', 'shell32', 'user32', 'ole32', 'comdlg32', 'comctl32',
'gdi32', 'shlwapi', 'oleaut32', 'icuuc', 'pthreadVC2', 'libcurl_imp',
'comsuppw', 'advapi32'])
env.Append(CCFLAGS=['/MD', '/DUNICODE', '/D_UNICODE'])
env.Append(LINKFLAGS=['/NODEFAULTLIB:LIBCMT.lib', '/LTCG', '/INCREMENTAL:NO', '/OPT:REF'])
build.add_thirdparty(env, 'cairo')
sources = sources + Glob('win32/*.cpp')
sources += Glob('binding/kjs*.cpp')
env.Append(CPPPATH=[build.tp('icu', 'include')])
env.Append(LIBS=[
'kernel32', 'shell32', 'user32', 'ole32', 'comdlg32', 'comctl32',
'gdi32', 'shlwapi', 'oleaut32', 'icuuc', 'pthreadVC2', 'libcurl_imp',
'comsuppw', 'advapi32'])
env.Append(CCFLAGS=['/MD', '/DUNICODE', '/D_UNICODE'])
env.Append(LINKFLAGS=['/NODEFAULTLIB:LIBCMT.lib', '/LTCG', '/INCREMENTAL:NO', '/OPT:REF'])

elif build.is_osx():
env.Append(FRAMEWORKPATH=[build.tp('growl')])
env.Append(FRAMEWORKS=['Cocoa','Carbon', 'IOKit', 'Growl'])
sources = sources + Glob('osx/*.mm') + Glob('osx/*.cpp')
env.Append(CCFLAGS=['-x', 'objective-c++'])
env.Append(FRAMEWORKPATH=[build.tp('growl')])
env.Append(FRAMEWORKS=['Cocoa','Carbon', 'IOKit', 'Growl'])
sources = sources + Glob('osx/*.mm') + Glob('osx/*.cpp')
env.Append(CCFLAGS=['-x', 'objective-c++'])

# Copy the support files the module build directory
build.utils.LightWeightCopy(path.join(build.cwd(), 'support'), module.dir)
build.mark_build_target(env.SharedLibrary(
path.join(module.dir,'tiuimodule'), sources))
path.join(module.dir,'tiuimodule'), sources))
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* see LICENSE in the root folder for details on the license.
* Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
*/
#include "ui_module.h"
#include "../ui_module.h"
#include <algorithm>
#include <cstring>

Expand Down
File renamed without changes.
32 changes: 30 additions & 2 deletions modules/ti.UI/osx/native_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@

#import "../ui_module.h"
#import <Cocoa/Cocoa.h>

#ifndef TIDE_LITE
#import <WebKit/WebInspector.h>
#endif

@class WebViewDelegate;

using namespace ti;

@interface NativeWindow : NSWindow
#ifndef TIDE_LITE
@interface NativeWindow : NSWindow <NSWindowDelegate>
{
BOOL canReceiveFocus;
WebView* webView;
Expand All @@ -38,5 +42,29 @@ using namespace ti;
- (OSXUserWindow*)userWindow;
- (void)showInspector:(BOOL)console;
@end

#else
@interface NativeWindow : NSWindow <NSWindowDelegate>
{
BOOL canReceiveFocus;
WebView* webView;
WebViewDelegate* delegate;
BOOL requiresDisplay;
AutoPtr<OSXUserWindow>* userWindow;
BOOL fullscreen;
BOOL focused;
NSRect savedFrame;
}
- (void)setUserWindow:(AutoPtr<OSXUserWindow>*)inUserWindow;
- (void)setupDecorations:(AutoPtr<WindowConfig>)config;
- (void)setTransparency:(double)transparency;
- (void)setFullscreen:(BOOL)yn;
- (void)close;
- (void)finishClose;
- (void)open;
- (void)frameLoaded;
- (WebView*)webView;
- (OSXUserWindow*)userWindow;
@end
#endif

#endif
8 changes: 8 additions & 0 deletions modules/ti.UI/osx/native_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ - (void)dealloc
[delegate release];
delegate = nil;

#ifndef TIDE_LITE
[inspector release];
#endif

[webView release];
webView = nil;
[super dealloc];
Expand All @@ -102,6 +105,8 @@ - (OSXUserWindow*)userWindow
{
return userWindow->get();
}

#ifndef TIDE_LITE
- (void)showInspector:(BOOL)console
{
if (inspector == nil)
Expand All @@ -119,15 +124,18 @@ - (void)showInspector:(BOOL)console
[inspector show:webView];
}
}
#endif

- (void)windowWillClose:(NSNotification *)notification
{
#ifndef TIDE_LITE
if (inspector)
{
[inspector close:self];
[inspector release];
inspector = nil;
}
#endif
}

- (NSSize)windowWillResize:(NSWindow *) window toSize:(NSSize)newSize
Expand Down
2 changes: 1 addition & 1 deletion modules/ti.UI/osx/osx_ui_binding.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (id)owner;
nativeDockMenu(nil),
activeWindow(0)
{
application = [[TiApplicationDelegate alloc] initWithBinding:this];
TitaniumApplicationDelegate* application = [[TitaniumApplicationDelegate alloc] initWithBinding:this];
[application retain];

NSApplication* nsapp = [NSApplication sharedApplication];
Expand Down
6 changes: 5 additions & 1 deletion modules/ti.UI/osx/osx_user_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,16 @@ static unsigned int toWindowMask(AutoPtr<WindowConfig> config)
callback->Call(ValueList(Value::NewList(results)));
this->Show();
}



void OSXUserWindow::ShowInspector(bool console)
{
#ifndef TIDE_LITE
[nativeWindow showInspector:console];
#endif
}


void OSXUserWindow::SetContentsImpl(const std::string& content, const std::string& baseURL)
{
[[[nativeWindow webView] mainFrame]
Expand Down
8 changes: 3 additions & 5 deletions modules/ti.UI/osx/ti_application_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
#ifndef TI_APP_H
#define TI_APP_H
#import "../ui_module.h"
@interface TiApplicationDelegate : NSObject
@interface TitaniumApplicationDelegate : NSObject <NSApplicationDelegate>
{
ti::OSXUIBinding *binding;
}

-(id)initWithBinding:(ti::OSXUIBinding*)binding;
-(BOOL)application:(NSApplication*)theApplication
openFile:(NSString*)filename;
-(BOOL)application:(NSApplication*)theApplication
openFiles:(NSArray*)filenames;
-(BOOL)application:(NSApplication*)theApplication openFile:(NSString*)filename;
-(BOOL)application:(NSApplication*)theApplication openFiles:(NSArray*)filenames;
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*)sender;
@end

Expand Down
2 changes: 1 addition & 1 deletion modules/ti.UI/osx/ti_application_delegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "osx_ui_binding.h"
#import "osx_menu_item.h"

@implementation TiApplicationDelegate
@implementation TitaniumApplicationDelegate

- (NSMenu *)applicationDockMenu:(NSApplication *)sender
{
Expand Down
Loading

0 comments on commit e9502af

Please sign in to comment.