Skip to content

Commit

Permalink
Update to work with latest SDK (linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-mccall committed Aug 22, 2012
1 parent 8b458d1 commit d1fe3fc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
DART_SRC=$HOME/dart/source/dart

# Pick the appropriate architecture (must match Apache, and the Dart you built)
DART_ARCH=x64
DART_ARCH=X64
#DART_ARCH=ia32

# Pick the appropriate build mode (must match the Dart you build)
Expand Down
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ type "$HTTPD" || exit "Couldn't find httpd, edit build.config"

UNAME=`uname`
if [[ "$UNAME" == "Darwin" ]]; then
DART_LIB=$DART_SRC/runtime/xcodebuild/${DART_MODE}_$DART_ARCH
DART_GEN=$DART_SRC/runtime/xcodebuild/DerivedSources/${DART_MODE}_$DART_ARCH
DART_LIB=$DART_SRC/xcodebuild/${DART_MODE}$DART_ARCH
DART_GEN=$DART_SRC/xcodebuild/DerivedSources/${DART_MODE}$DART_ARCH
LIBRARY_GROUP_START= # not needed - mac linker 'just works' with circular dependencies
LIBRARY_GROUP_END=
else
if [[ "$UNAME" != "Linux" ]]; then
echo "Warning: Unrecognized OS $UNAME, this likely won't work"
fi
DART_LIB=$DART_SRC/runtime/out/${DART_MODE}_$DART_ARCH/obj.target/runtime
DART_GEN=$DART_SRC/runtime/out/${DART_MODE}_$DART_ARCH/obj/gen
DART_LIB=$DART_SRC/out/${DART_MODE}$DART_ARCH/obj.target/runtime
DART_GEN=$DART_SRC/out/${DART_MODE}$DART_ARCH/obj/gen
LIBRARY_GROUP_START=,--start-group # dart static libraries have circular references
LIBRARY_GROUP_END=,--end-group
fi
Expand All @@ -34,7 +34,7 @@ fi

rm src/mod_dart_gen.c; python $DART_SRC/runtime/tools/create_string_literal.py --output src/mod_dart_gen.c --include 'none' --input_cc src/mod_dart_gen.c.tmpl --var_name "mod_dart_source" src/mod_dart.dart
$APXS -S CC=g++ -c $COPTS -o mod_dart.so -Wc,-Wall -Wc,-Werror -I $DART_SRC/runtime -lstdc++ -I $DART_GEN \
-Wl,-Wl$LIBRARY_GROUP_START,$DART_LIB/libdart_export.a,$DART_LIB/libdart_builtin.a,$DART_LIB/libdart_lib_withcore.a,$DART_LIB/libdart_builtin.a,$DART_LIB/libdart_vm.a,$DART_LIB/libjscre.a,$DART_LIB/libdouble_conversion.a$LIBRARY_GROUP_END \
-Wl,-Wl$LIBRARY_GROUP_START,$DART_LIB/libdart_export.a,$DART_LIB/libdart_builtin.a,$DART_LIB/libdart_lib_withcore.a,$DART_LIB/libdart_vm.a,$DART_LIB/libjscre.a,$DART_LIB/libdouble_conversion.a,$DART_LIB/../dart/gen/web_gen.o$LIBRARY_GROUP_END \
src/builtin.c src/mod_dart_gen.c src/apache_library.c src/mod_dart.c && \
sudo $APXS -i -a -n dart mod_dart.la && \
sudo apachectl restart
11 changes: 7 additions & 4 deletions src/mod_dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ static bool IsolateCreate(const char* name, const char* main, void* data, char**
Dart_Isolate isolate = Dart_CreateIsolate(name, main, cfg->master_snapshot.buffer, data, error);
if (!isolate) return false;
Dart_EnterScope();
Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
Builtin::SetNativeResolver(Builtin::kIOLibrary);
Builtin::SetupLibrary(Builtin::LoadLibrary(Builtin::kBuiltinLibrary), Builtin::kBuiltinLibrary);
Builtin::SetupLibrary(Builtin::LoadLibrary(Builtin::kIOLibrary), Builtin::kIOLibrary);
return true;
}

static void IsolateShutdown(void* data) {
}

static bool IsolateInterrupt() {
printf("Isolate interrupted!\n");
return true;
Expand Down Expand Up @@ -243,7 +246,7 @@ static dart_snapshot *getScriptSnapshot(request_rec *r) {
static bool initializeState = false;
static void dart_child_init(apr_pool_t *p, server_rec *s) {
// This is allowed to fail, we may have already initialized the VM for snapshot creation
initializeState |= (Dart_SetVMFlags(0, NULL) && Dart_Initialize(IsolateCreate, IsolateInterrupt));
initializeState |= (Dart_SetVMFlags(0, NULL) && Dart_Initialize(IsolateCreate, IsolateInterrupt, IsolateShutdown));
}

static int fatal(request_rec *r, const char *format, Dart_Handle error) {
Expand Down Expand Up @@ -342,7 +345,7 @@ int dart_snapshots(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, serve
// Only create snapshots in the root server
dart_server_config *cfg = (dart_server_config*) ap_get_module_config(server->module_config, &dart_module);
if (cfg->base) return OK;
initializeState = Dart_SetVMFlags(0, NULL) && Dart_Initialize(IsolateCreate, IsolateInterrupt);
initializeState = Dart_SetVMFlags(0, NULL) && Dart_Initialize(IsolateCreate, IsolateInterrupt, IsolateShutdown);

char* error;
if (!create_snapshot(server->process->pool, &(cfg->master_snapshot), "master", NULL, create_master_snapshot, &error)) {
Expand Down
4 changes: 3 additions & 1 deletion src/mod_dart_gen.c.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
const char {{VAR_NAME}}_[] = {
{{DART_SOURCE}}
};
extern "C" const char* {{VAR_NAME}} = {{VAR_NAME}}_;
extern "C" {
const char* {{VAR_NAME}} = {{VAR_NAME}}_;
}

0 comments on commit d1fe3fc

Please sign in to comment.