Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Javascript modular interface build framework
- Loading branch information
Showing
8 changed files
with
258 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Author: Matt Langston | ||
# Created: 2014.09.03 | ||
# | ||
# Try to find JavaScriptCore. Once done this will define: | ||
# | ||
# JavaScriptCore_FOUND - system has JavaScriptCore | ||
# JavaScriptCore_INCLUDE_DIRS - the include directory | ||
# JavaScriptCore_LIBRARY_DIR - the directory containing the library | ||
# JavaScriptCore_LIBRARIES - link these to use JavaScriptCore | ||
|
||
|
||
find_package(PkgConfig) | ||
|
||
pkg_check_modules(PC_JavaScriptCore QUIET JavaScriptCore) | ||
|
||
find_path(JavaScriptCore_INCLUDE_DIRS | ||
NAMES JavaScriptCore/JavaScript.h | ||
HINTS ${PC_JavaScriptCore_INCLUDE_DIRS} ${PC_JavaScriptCore_INCLUDEDIR} | ||
PATHS ENV JavaScriptCore_HOME | ||
PATH_SUFFIXES includes | ||
) | ||
|
||
set(JavaScriptCore_ARCH "x86") | ||
if(CMAKE_GENERATOR MATCHES "^Visual Studio .+ ARM$") | ||
set(JavaScriptCore_ARCH "arm") | ||
endif() | ||
|
||
find_library(JavaScriptCore_LIBRARIES | ||
NAMES JavaScriptCore JavaScriptCore-Debug JavaScriptCore-Release | ||
HINTS ${PC_JavaScriptCore_LIBRARY_DIRS} ${PC_JavaScriptCore_LIBDIR} | ||
PATHS ENV JavaScriptCore_HOME | ||
PATH_SUFFIXES ${JavaScriptCore_ARCH} | ||
) | ||
|
||
if(NOT JavaScriptCore_LIBRARIES MATCHES ".+-NOTFOUND") | ||
get_filename_component(JavaScriptCore_LIBRARY_DIR ${JavaScriptCore_LIBRARIES} DIRECTORY) | ||
|
||
# If we found the JavaScriptCore library and we're using a Visual | ||
# Studio generator and we're targeting either WindowsStore or | ||
# WindowsPhone, then allow Visual Studio to use both the | ||
# JavaScriptCore-Debug.lib and JavaScriptCore-Release.lib if they | ||
# exist. | ||
if(CMAKE_GENERATOR MATCHES "^Visual Studio .+" AND CMAKE_SYSTEM_NAME MATCHES "^Windows(Store|Phone)") | ||
string(REGEX REPLACE "-(Debug|Release)" "-$(Configuration)" JavaScriptCore_LIBRARIES ${JavaScriptCore_LIBRARIES}) | ||
endif() | ||
|
||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(JavaScriptCore DEFAULT_MSG JavaScriptCore_INCLUDE_DIRS JavaScriptCore_LIBRARIES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Locate V8 | ||
# This module defines | ||
# V8_LIBRARY | ||
# V8_FOUND, if false, do not try to link to V8 | ||
# V8_INCLUDE_DIR, where to find the headers | ||
|
||
FIND_PATH(V8_INCLUDE_DIR v8.h | ||
${V8_DIR}/include | ||
$ENV{V8_DIR}/include | ||
$ENV{V8_DIR} | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/include | ||
/usr/include | ||
/sw/include # Fink | ||
/opt/local/include # DarwinPorts | ||
/opt/csw/include # Blastwave | ||
/opt/include | ||
/usr/freeware/include | ||
/devel | ||
) | ||
|
||
# On non-Unix platforms (Mac and Windows specifically based on the forum), | ||
# V8 builds separate shared (or at least linkable) libraries for v8_base and v8_snapshot | ||
IF(NOT UNIX) | ||
FIND_LIBRARY(V8_BASE_LIBRARY | ||
NAMES v8_base v8_base.ia32 v8_base.x64 libv8_base | ||
PATHS | ||
${V8_DIR} | ||
${V8_DIR}/lib | ||
${V8_DIR}/build/Release/lib | ||
$ENV{V8_DIR} | ||
$ENV{V8_DIR}/lib | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/lib | ||
/usr/lib | ||
/sw/lib | ||
/opt/local/lib | ||
/opt/csw/lib | ||
/opt/lib | ||
/usr/freeware/lib64 | ||
) | ||
|
||
FIND_LIBRARY(V8_SNAPSHOT_LIBRARY | ||
NAMES v8_snapshot libv8_snapshot | ||
PATHS | ||
${V8_DIR} | ||
${V8_DIR}/lib | ||
${V8_DIR}/build/Release/lib | ||
$ENV{V8_DIR} | ||
$ENV{V8_DIR}/lib | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/lib | ||
/usr/lib | ||
/sw/lib | ||
/opt/local/lib | ||
/opt/csw/lib | ||
/opt/lib | ||
/usr/freeware/lib64 | ||
) | ||
|
||
FIND_LIBRARY(V8_SNAPSHOT_LIBRARY_DEBUG | ||
NAMES v8_snapshot libv8_snapshot | ||
PATHS | ||
${V8_DIR} | ||
${V8_DIR}/lib | ||
${V8_DIR}/build/Debug/lib | ||
$ENV{V8_DIR} | ||
$ENV{V8_DIR}/lib | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/lib | ||
/usr/lib | ||
/sw/lib | ||
/opt/local/lib | ||
/opt/csw/lib | ||
/opt/lib | ||
/usr/freeware/lib64 | ||
) | ||
|
||
# On Linux, there is just a libv8.so shared library built. | ||
# (well, there are pseudo-static libraries libv8_base.a and libv8_snapshot.a | ||
# but they don't seem to link correctly) | ||
ELSE() | ||
FIND_LIBRARY(V8_LIBRARY | ||
NAMES v8 | ||
PATHS | ||
${V8_DIR} | ||
${V8_DIR}/lib | ||
${V8_DIR}/build/Release/lib | ||
# Having both architectures listed is problematic if both have been | ||
# built (which is the default) | ||
${V8_DIR}/out/ia32.release/lib.target/ | ||
${V8_DIR}/out/x64.release/lib.target/ | ||
$ENV{V8_DIR} | ||
$ENV{V8_DIR}/lib | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local/lib | ||
/usr/lib | ||
/sw/lib | ||
/opt/local/lib | ||
/opt/csw/lib | ||
/opt/lib | ||
/usr/freeware/lib64 | ||
) | ||
ENDIF(NOT UNIX) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
IF(NOT UNIX) | ||
find_package_handle_standard_args(V8 REQUIRED_VARS V8_BASE_LIBRARY V8_SNAPSHOT_LIBRARY V8_INCLUDE_DIR) | ||
ELSE() | ||
find_package_handle_standard_args(V8 REQUIRED_VARS V8_LIBRARY V8_INCLUDE_DIR) | ||
ENDIF() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
IF(${JAVASCRIPT_EXTENSION} MATCHES "JSC") | ||
FIND_PACKAGE(JavaScriptCore REQUIRED) | ||
include_directories(${JavaScriptCore_INCLUDE_DIRS}) | ||
SET(JSE_LDFLAG ${JavaScriptCore_LIBRARIES}) | ||
SET(TARGET_SWIGFLAGS "-jsc") | ||
ELSEIF(${JAVASCRIPT_EXTENSION} MATCHES "V8") | ||
FIND_PACKAGE(V8 REQUIRED) | ||
include_directories(${V8_INCLUDE_DIR}) | ||
SET(JSE_LDFLAG ${V8_LIBRARY}) | ||
SET(TARGET_SWIGFLAGS "-v8") | ||
ELSEIF(${JAVASCRIPT_EXTENSION} MATCHES "NODE") | ||
FIND_PACKAGE(NodeJS REQUIRED) | ||
include_directories(${NodeJS_INCLUDE_DIRS}) | ||
SET(TARGET_SWIGFLAGS "-node") | ||
ELSE() | ||
MESSAGE(FATAL_ERROR "Unkown javascript extension type specified, please choose from: JSC, NODE, V8") | ||
ENDIF() | ||
|
||
include(CommonModularInterface) | ||
|
||
SET(JAVASCRIPT_MODULAR_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) | ||
GENERATE_MODULAR_TARGET(javascript ${CMAKE_CURRENT_SOURCE_DIR} ${JSE_LDFLAG}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <shogun/io/SGIO.h> | ||
#include <stdio.h> | ||
|
||
void sg_global_print_message(FILE* target, const char* str) | ||
{ | ||
fprintf(target, "%s", str); | ||
} | ||
|
||
void sg_global_print_warning(FILE* target, const char* str) | ||
{ | ||
fprintf(target, "%s", str); | ||
} | ||
|
||
void sg_global_print_error(FILE* target, const char* str) | ||
{ | ||
fprintf(target, "%s", str); | ||
} | ||
|
||
void sg_global_cancel_computations(bool &delayed, bool &immediately) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) The Shogun Machine Learning Toolbox | ||
* Written (w) 2016 Viktor Gal | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* The views and conclusions contained in the software and documentation are those | ||
* of the authors and should not be interpreted as representing official policies, | ||
* either expressed or implied, of the Shogun Development Team. | ||
* | ||
*/ | ||
|