Skip to content

Commit

Permalink
Fix build on Linux and fix logging function on Python 3 (#352).
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed Apr 19, 2017
1 parent 824d7ce commit eeae125
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/client_handler/client_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <stdint.h>
#endif

#include "common/cefpython_public_api.h"

#include "context_menu_handler.h"
#include "dialog_handler.h"
#include "display_handler.h"
Expand Down
15 changes: 9 additions & 6 deletions src/common/cefpython_public_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@
#ifndef CEFPYTHON_PUBLIC_API_H
#define CEFPYTHON_PUBLIC_API_H

// Includes required by "cefpython_fixed.h".
#include "include/cef_client.h"
#include "include/cef_urlrequest.h"
#include "include/cef_command_line.h"
#include "util.h"

#if defined(OS_WIN)
#pragma warning(disable:4190) // cefpython API extern C-linkage warnings
#endif

// Python.h must be included first otherwise error on Linux:
// >> error: "_POSIX_C_SOURCE" redefined
#include "Python.h"


// Includes required by "cefpython_fixed.h".
#include "include/cef_client.h"
#include "include/cef_urlrequest.h"
#include "include/cef_command_line.h"
#include "util.h"

// cefpython_fixed.h declares public functions using DL_IMPORT and these
// macros are not available in Python 3.
#ifndef DL_IMPORT
Expand Down
2 changes: 1 addition & 1 deletion src/compile_time_constants.pxi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file was generated by setup.py
DEF UNAME_SYSNAME = "Linux"
DEF PY_MAJOR_VERSION = 2
DEF PY_MAJOR_VERSION = 3
2 changes: 1 addition & 1 deletion src/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ cpdef object Debug(py_string msg):
# Otherwise the default is LOGSEVERITY_INFO and log_file is
# none.
if g_cef_initialized or g_debug:
cef_log_info(msg)
cef_log_info(PyStringToChar(msg))

cdef void NonCriticalError(py_string msg) except *:
"""Notify about error gently. Does not terminate application."""
Expand Down
19 changes: 15 additions & 4 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
# function then you can't pass shell=True on Linux. If you pass
# then it will execute args[0] and ignore others args.

# NOTE 2: When calling os.system() returned value may be 256 when eg.
# when running unit tests fail. If you pass 256 to sys.exit
# an undefined result will occur. In my case on Linux it caused
# that other script that called it sys.exit(256) was interpreted
# for the script execute successfully. So never pass to sys.exit
# a value returned from os.system. Check the value and call
# sys.exit(1).

# How to debug on Linux (OLD unsupported).
# 1. Install "python-dbg" package
# 2. Install "python-wxgtk2.8-dbg" package
Expand Down Expand Up @@ -753,7 +761,10 @@ def build_cefpython_module():
args.extend(sys.argv[1:])
command = " ".join(args)
ret = subprocess.call(command, shell=True)
sys.exit(ret)
# Always pass fixed value to sys.exit, read note at
# the top of the script about os.system and sys.exit
# issue.
sys.exit(0 if ret == 0 else 1)
else:
print("[build.py] ERROR: failed to build the cefpython module")
sys.exit(1)
Expand Down Expand Up @@ -823,7 +834,7 @@ def install_and_run():
ret = os.system(command)
if ret != 0:
print("[build.py] ERROR while making installer package")
sys.exit(ret)
sys.exit(1)

# Install
print("[build.py] Install the cefpython package")
Expand All @@ -834,7 +845,7 @@ def install_and_run():
ret = os.system(command)
if ret != 0:
print("[build.py] ERROR while installing package")
sys.exit(ret)
sys.exit(1)
os.chdir(BUILD_DIR)

# Delete setup installer directory after the package was installed
Expand All @@ -849,7 +860,7 @@ def install_and_run():
ret = os.system(command)
if ret != 0:
print("[build.py] ERROR while running unit tests")
sys.exit(ret)
sys.exit(1)

# Run examples
if not NO_RUN_EXAMPLES:
Expand Down

0 comments on commit eeae125

Please sign in to comment.