MCPcopy Create free account
hub / github.com/cztomczak/cefpython / fix_cefpython_api_header_file

Function fix_cefpython_api_header_file

tools/build.py:352–400  ·  view source on GitHub ↗

This function does two things: 1) Disable warnings in cefpython API header file and 2) Make a copy named cefpython_pyXX_fixed.h, this copy will be used by C++ projects and its modification time won't change every time you run build.py script, thus C++ won't rebuild each time.

()

Source from the content-addressed store, hash-verified

350
351
352def fix_cefpython_api_header_file():
353 """This function does two things: 1) Disable warnings in cefpython
354 API header file and 2) Make a copy named cefpython_pyXX_fixed.h,
355 this copy will be used by C++ projects and its modification time
356 won't change every time you run build.py script, thus C++ won't
357 rebuild each time."""
358
359 # Fix cefpython_pyXX.h to disable this warning:
360 # > warning: 'somefunc' has C-linkage specified, but returns
361 # > user-defined type 'sometype' which is incompatible with C
362 # On Mac this warning must be disabled using -Wno-return-type-c-linkage
363 # flag in makefiles.
364
365 print("[build.py] Fix cefpython API header file in the build_cefpython/"
366 " directory")
367 if not os.path.exists(CEFPYTHON_API_HFILE):
368 assert not os.path.exists(CEFPYTHON_API_HFILE_FIXED)
369 print("[build.py] cefpython API header file was not yet generated")
370 return
371
372 # Original contents
373 with open(CEFPYTHON_API_HFILE, "rb") as fo:
374 contents = fo.read().decode("utf-8")
375
376 # Pragma fix on Windows
377 if WINDOWS:
378 pragma = "#pragma warning(disable:4190)"
379 if pragma in contents:
380 print("[build.py] cefpython API header file is already fixed")
381 else:
382 contents = ("%s\n\n" % pragma) + contents
383 with open(CEFPYTHON_API_HFILE, "wb") as fo:
384 fo.write(contents.encode("utf-8"))
385 print("[build.py] Save {filename}"
386 .format(filename=CEFPYTHON_API_HFILE))
387
388 # Make a copy with a "_fixed" postfix
389 if os.path.exists(CEFPYTHON_API_HFILE_FIXED):
390 with open(CEFPYTHON_API_HFILE_FIXED, "rb") as fo:
391 contents_fixed = fo.read().decode("utf-8")
392 else:
393 contents_fixed = ""
394
395 # Resave fixed copy only if contents changed. Other scripts
396 # depend on "modified time" of the "_fixed" file.
397 if contents != contents_fixed:
398 print("[build.py] Save cefpython_fixed.h")
399 with open(CEFPYTHON_API_HFILE_FIXED, "wb") as fo:
400 fo.write(contents.encode("utf-8"))
401
402
403def compile_cpp_projects_with_setuptools():

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected