Skip to content

Commit eeae125

Browse files
committed
Fix build on Linux and fix logging function on Python 3 (cztomczak#352).
1 parent 824d7ce commit eeae125

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

src/client_handler/client_handler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <stdint.h>
1111
#endif
1212

13-
#include "common/cefpython_public_api.h"
14-
1513
#include "context_menu_handler.h"
1614
#include "dialog_handler.h"
1715
#include "display_handler.h"

src/common/cefpython_public_api.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
#ifndef CEFPYTHON_PUBLIC_API_H
1010
#define CEFPYTHON_PUBLIC_API_H
1111

12-
// Includes required by "cefpython_fixed.h".
13-
#include "include/cef_client.h"
14-
#include "include/cef_urlrequest.h"
15-
#include "include/cef_command_line.h"
16-
#include "util.h"
17-
1812
#if defined(OS_WIN)
1913
#pragma warning(disable:4190) // cefpython API extern C-linkage warnings
2014
#endif
2115

16+
// Python.h must be included first otherwise error on Linux:
17+
// >> error: "_POSIX_C_SOURCE" redefined
2218
#include "Python.h"
2319

20+
21+
// Includes required by "cefpython_fixed.h".
22+
#include "include/cef_client.h"
23+
#include "include/cef_urlrequest.h"
24+
#include "include/cef_command_line.h"
25+
#include "util.h"
26+
2427
// cefpython_fixed.h declares public functions using DL_IMPORT and these
2528
// macros are not available in Python 3.
2629
#ifndef DL_IMPORT

src/compile_time_constants.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file was generated by setup.py
22
DEF UNAME_SYSNAME = "Linux"
3-
DEF PY_MAJOR_VERSION = 2
3+
DEF PY_MAJOR_VERSION = 3

src/utils.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ cpdef object Debug(py_string msg):
5353
# Otherwise the default is LOGSEVERITY_INFO and log_file is
5454
# none.
5555
if g_cef_initialized or g_debug:
56-
cef_log_info(msg)
56+
cef_log_info(PyStringToChar(msg))
5757

5858
cdef void NonCriticalError(py_string msg) except *:
5959
"""Notify about error gently. Does not terminate application."""

tools/build.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
# function then you can't pass shell=True on Linux. If you pass
4242
# then it will execute args[0] and ignore others args.
4343

44+
# NOTE 2: When calling os.system() returned value may be 256 when eg.
45+
# when running unit tests fail. If you pass 256 to sys.exit
46+
# an undefined result will occur. In my case on Linux it caused
47+
# that other script that called it sys.exit(256) was interpreted
48+
# for the script execute successfully. So never pass to sys.exit
49+
# a value returned from os.system. Check the value and call
50+
# sys.exit(1).
51+
4452
# How to debug on Linux (OLD unsupported).
4553
# 1. Install "python-dbg" package
4654
# 2. Install "python-wxgtk2.8-dbg" package
@@ -753,7 +761,10 @@ def build_cefpython_module():
753761
args.extend(sys.argv[1:])
754762
command = " ".join(args)
755763
ret = subprocess.call(command, shell=True)
756-
sys.exit(ret)
764+
# Always pass fixed value to sys.exit, read note at
765+
# the top of the script about os.system and sys.exit
766+
# issue.
767+
sys.exit(0 if ret == 0 else 1)
757768
else:
758769
print("[build.py] ERROR: failed to build the cefpython module")
759770
sys.exit(1)
@@ -823,7 +834,7 @@ def install_and_run():
823834
ret = os.system(command)
824835
if ret != 0:
825836
print("[build.py] ERROR while making installer package")
826-
sys.exit(ret)
837+
sys.exit(1)
827838

828839
# Install
829840
print("[build.py] Install the cefpython package")
@@ -834,7 +845,7 @@ def install_and_run():
834845
ret = os.system(command)
835846
if ret != 0:
836847
print("[build.py] ERROR while installing package")
837-
sys.exit(ret)
848+
sys.exit(1)
838849
os.chdir(BUILD_DIR)
839850

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

854865
# Run examples
855866
if not NO_RUN_EXAMPLES:

0 commit comments

Comments
 (0)