added emscripten support (#846)
This commit is contained in:
parent
a34226ca94
commit
6ed0c9e58b
60
.github/workflows/emscripten.yml
vendored
Normal file
60
.github/workflows/emscripten.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
name: Emscripten
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
name: Emscripten-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: emscripten/emsdk
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
build_type: [Release, Debug]
|
||||||
|
extra: [no-custom-prefix, custom-prefix]
|
||||||
|
lib: [static]
|
||||||
|
std: [98, 11, 14, 17, 20]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
|
||||||
|
cmake \
|
||||||
|
ninja-build
|
||||||
|
|
||||||
|
- name: Setup C++98 Environment
|
||||||
|
if: matrix.std == '98'
|
||||||
|
run: |
|
||||||
|
echo 'CXXFLAGS=-Wno-error=variadic-macros -Wno-error=long-long ${{env.CXXFLAGS}}' >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
env:
|
||||||
|
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -Wno-error=wasm-exception-spec ${{env.CXXFLAGS}}
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build_${{matrix.build_type}} \
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
|
||||||
|
-DCMAKE_AR=$(which emar) \
|
||||||
|
-DCMAKE_C_COMPILER=$(which emcc) \
|
||||||
|
-DCMAKE_CXX_COMPILER=$(which em++) \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
|
||||||
|
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
|
||||||
|
-DCMAKE_RANLIB=$(which emranlib) \
|
||||||
|
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} \
|
||||||
|
-G Ninja \
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}} \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
@ -93,11 +93,11 @@ find_package (Unwind)
|
|||||||
if (Unwind_FOUND)
|
if (Unwind_FOUND)
|
||||||
set (HAVE_LIB_UNWIND 1)
|
set (HAVE_LIB_UNWIND 1)
|
||||||
else (Unwind_FOUND)
|
else (Unwind_FOUND)
|
||||||
check_include_file_cxx (unwind.h HAVE_UNWIND_H)
|
|
||||||
# Check whether linking actually succeeds. ARM toolchains of LLVM unwind
|
# Check whether linking actually succeeds. ARM toolchains of LLVM unwind
|
||||||
# implementation do not necessarily provide the _Unwind_Backtrace function
|
# implementation do not necessarily provide the _Unwind_Backtrace function
|
||||||
# which causes the previous check to succeed but the linking to fail.
|
# which causes the previous check to succeed but the linking to fail.
|
||||||
check_cxx_symbol_exists (_Unwind_Backtrace unwind.h HAVE__UNWIND_BACKTRACE)
|
check_cxx_symbol_exists (_Unwind_Backtrace unwind.h HAVE__UNWIND_BACKTRACE)
|
||||||
|
check_cxx_symbol_exists (_Unwind_GetIP unwind.h HAVE__UNWIND_GETIP)
|
||||||
endif (Unwind_FOUND)
|
endif (Unwind_FOUND)
|
||||||
|
|
||||||
check_include_file_cxx (dlfcn.h HAVE_DLFCN_H)
|
check_include_file_cxx (dlfcn.h HAVE_DLFCN_H)
|
||||||
@ -197,9 +197,10 @@ int main(void)
|
|||||||
}
|
}
|
||||||
" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
|
" HAVE___SYNC_VAL_COMPARE_AND_SWAP)
|
||||||
|
|
||||||
cmake_push_check_state (RESET)
|
if (Threads_FOUND)
|
||||||
set (CMAKE_REQUIRED_LIBRARIES Threads::Threads)
|
cmake_push_check_state (RESET)
|
||||||
check_cxx_source_compiles ("
|
set (CMAKE_REQUIRED_LIBRARIES Threads::Threads)
|
||||||
|
check_cxx_source_compiles ("
|
||||||
#define _XOPEN_SOURCE 500
|
#define _XOPEN_SOURCE 500
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
int main(void)
|
int main(void)
|
||||||
@ -209,8 +210,9 @@ int main(void)
|
|||||||
pthread_rwlock_rdlock(&l);
|
pthread_rwlock_rdlock(&l);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
" HAVE_RWLOCK)
|
" HAVE_RWLOCK)
|
||||||
cmake_pop_check_state ()
|
cmake_pop_check_state ()
|
||||||
|
endif (Threads_FOUND)
|
||||||
|
|
||||||
check_cxx_source_compiles ("
|
check_cxx_source_compiles ("
|
||||||
__declspec(selectany) int a;
|
__declspec(selectany) int a;
|
||||||
|
|||||||
@ -118,12 +118,12 @@
|
|||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
|
#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
|
||||||
|
|
||||||
/* Define if you have the <unwind.h> header file. */
|
|
||||||
#cmakedefine HAVE_UNWIND_H
|
|
||||||
|
|
||||||
/* Define if you linking to _Unwind_Backtrace is possible. */
|
/* Define if you linking to _Unwind_Backtrace is possible. */
|
||||||
#cmakedefine HAVE__UNWIND_BACKTRACE
|
#cmakedefine HAVE__UNWIND_BACKTRACE
|
||||||
|
|
||||||
|
/* Define if you linking to _Unwind_GetIP is possible. */
|
||||||
|
#cmakedefine HAVE__UNWIND_GETIP
|
||||||
|
|
||||||
/* define if the compiler supports using expression for operator */
|
/* define if the compiler supports using expression for operator */
|
||||||
#cmakedefine HAVE_USING_OPERATOR
|
#cmakedefine HAVE_USING_OPERATOR
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
@ac_google_start_namespace@
|
@ac_google_start_namespace@
|
||||||
|
|
||||||
#if @ac_cv_have_uint16_t@ // the C99 format
|
#if @ac_cv_have_stdint_h@ // the C99 format
|
||||||
typedef int32_t int32;
|
typedef int32_t int32;
|
||||||
typedef uint32_t uint32;
|
typedef uint32_t uint32;
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
@ -1822,8 +1822,8 @@ GLOG_EXPORT void SetEmailLogging(LogSeverity min_severity,
|
|||||||
|
|
||||||
// A simple function that sends email. dest is a commma-separated
|
// A simple function that sends email. dest is a commma-separated
|
||||||
// list of addressess. Thread-safe.
|
// list of addressess. Thread-safe.
|
||||||
GLOG_EXPORT bool SendEmail(const char *dest,
|
GLOG_EXPORT bool SendEmail(const char* dest, const char* subject,
|
||||||
const char *subject, const char *body);
|
const char* body);
|
||||||
|
|
||||||
GLOG_EXPORT const std::vector<std::string>& GetLoggingDirectories();
|
GLOG_EXPORT const std::vector<std::string>& GetLoggingDirectories();
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,8 @@
|
|||||||
#define GLOG_OS_NETBSD
|
#define GLOG_OS_NETBSD
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
#define GLOG_OS_OPENBSD
|
#define GLOG_OS_OPENBSD
|
||||||
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
#define GLOG_OS_EMSCRIPTEN
|
||||||
#else
|
#else
|
||||||
// TODO(hamaji): Add other platforms.
|
// TODO(hamaji): Add other platforms.
|
||||||
#error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github.
|
#error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github.
|
||||||
|
|||||||
@ -2188,6 +2188,7 @@ void SetExitOnDFatal(bool value) {
|
|||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
#ifndef GLOG_OS_EMSCRIPTEN
|
||||||
// Shell-escaping as we need to shell out ot /bin/mail.
|
// Shell-escaping as we need to shell out ot /bin/mail.
|
||||||
static const char kDontNeedShellEscapeChars[] =
|
static const char kDontNeedShellEscapeChars[] =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
@ -2222,14 +2223,14 @@ static string ShellEscape(const string& src) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// use_logging controls whether the logging functions LOG/VLOG are used
|
// use_logging controls whether the logging functions LOG/VLOG are used
|
||||||
// to log errors. It should be set to false when the caller holds the
|
// to log errors. It should be set to false when the caller holds the
|
||||||
// log_mutex.
|
// log_mutex.
|
||||||
static bool SendEmailInternal(const char*dest, const char *subject,
|
static bool SendEmailInternal(const char*dest, const char *subject,
|
||||||
const char*body, bool use_logging) {
|
const char*body, bool use_logging) {
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef GLOG_OS_EMSCRIPTEN
|
||||||
if (dest && *dest) {
|
if (dest && *dest) {
|
||||||
if ( use_logging ) {
|
if ( use_logging ) {
|
||||||
VLOG(1) << "Trying to send TITLE:" << subject
|
VLOG(1) << "Trying to send TITLE:" << subject
|
||||||
@ -2275,6 +2276,12 @@ static bool SendEmailInternal(const char*dest, const char *subject,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)dest;
|
||||||
|
(void)subject;
|
||||||
|
(void)body;
|
||||||
|
(void)use_logging;
|
||||||
|
LOG(WARNING) << "Email support not available; not sending message";
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,11 +59,12 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && (!(defined(GLOG_OS_MACOSX)))
|
#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && \
|
||||||
# define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
|
(!(defined(GLOG_OS_MACOSX))) && !defined(GLOG_OS_EMSCRIPTEN)
|
||||||
|
#define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
|
||||||
#else
|
#else
|
||||||
// Not so safe, but what can you do?
|
// Not so safe, but what can you do?
|
||||||
# define safe_write(fd, s, len) write(fd, s, len)
|
#define safe_write(fd, s, len) write(fd, s, len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
|
|||||||
@ -73,7 +73,7 @@ static _Unwind_Reason_Code GetOneFrame(struct _Unwind_Context *uc, void *opq) {
|
|||||||
if (targ->skip_count > 0) {
|
if (targ->skip_count > 0) {
|
||||||
targ->skip_count--;
|
targ->skip_count--;
|
||||||
} else {
|
} else {
|
||||||
targ->result[targ->count++] = (void *) _Unwind_GetIP(uc);
|
targ->result[targ->count++] = reinterpret_cast<void *>(_Unwind_GetIP(uc));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targ->count == targ->max_depth) {
|
if (targ->count == targ->max_depth) {
|
||||||
|
|||||||
@ -834,7 +834,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
|
|||||||
|
|
||||||
_END_GOOGLE_NAMESPACE_
|
_END_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR)
|
#elif (defined(GLOG_OS_MACOSX) || defined(GLOG_OS_EMSCRIPTEN)) && defined(HAVE_DLADDR)
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|||||||
@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
#if defined(HAVE_LIB_UNWIND)
|
#if defined(HAVE_LIB_UNWIND)
|
||||||
# define STACKTRACE_H "stacktrace_libunwind-inl.h"
|
# define STACKTRACE_H "stacktrace_libunwind-inl.h"
|
||||||
#elif defined(HAVE__UNWIND_BACKTRACE)
|
#elif defined(HAVE__UNWIND_BACKTRACE) && defined(HAVE__UNWIND_GETIP)
|
||||||
# define STACKTRACE_H "stacktrace_unwind-inl.h"
|
# define STACKTRACE_H "stacktrace_unwind-inl.h"
|
||||||
#elif !defined(NO_FRAME_POINTER)
|
#elif !defined(NO_FRAME_POINTER)
|
||||||
# if defined(__i386__) && __GNUC__ >= 2
|
# if defined(__i386__) && __GNUC__ >= 2
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user