Advertisement
tinyevil

Untitled

Jan 6th, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.92 KB | None | 0 0
  1. import build.cpp as cpp
  2. import build.context as context
  3. import build.utils as utils
  4. from build.em import EMManifest
  5. from build.ndk import NdkManifest
  6.  
  7.  
  8. def lua(module: cpp.Module, ctx: context.Context):
  9.     module.set_base_path("thirdparty/lua")
  10.     module.add_public_include("src")
  11.  
  12.     env = module.get_env().inherit()
  13.     env.std = cpp.Std.C11
  14.  
  15.     cppenv = module.get_env().inherit()
  16.     cppenv.std = cpp.Std.Cpp17
  17.  
  18.     module.add_group(cpp.SourceGroup(
  19.         env,
  20.         "src",
  21.         cpp.c_files(exclude=[
  22.             "lua.c",
  23.             "luac.c"
  24.         ])
  25.     ))
  26.     module.add_group(cpp.SourceGroup(
  27.         cppenv,
  28.         "src",
  29.         cpp.cpp_files()
  30.     ))
  31.  
  32.  
  33. def zlib(module: cpp.Module, ctx: context.Context):
  34.     if EMManifest in module:
  35.         module.set_base_path("thirdparty/zlib-em")
  36.     else:
  37.         module.set_base_path("thirdparty/zlib")
  38.     module.add_public_include(".")
  39.  
  40.     env = module.get_env().inherit()
  41.     env.std = cpp.Std.C11
  42.  
  43.     module.add_group(cpp.SourceGroup(
  44.         env,
  45.         ".",
  46.         cpp.c_files(shallow=True)
  47.     ))
  48.  
  49.  
  50. def freetype(module: cpp.Module, ctx: context.Context):
  51.     module.set_base_path("thirdparty/freetype-2.9.1")
  52.     module.add_public_include("include")
  53.  
  54.     env = module.get_env().inherit()
  55.     env.std = cpp.Std.C11
  56.     env.add_include("include")
  57.     env.defines["FT2_BUILD_LIBRARY"] = "1"
  58.  
  59.     module.add_dependency(cpp.DependencyType.Private, ctx.require('zlib'))
  60.  
  61.     module.add_group(cpp.SourceGroup(
  62.         env,
  63.         "src",
  64.         utils.files_list([
  65.             "base/ftbase.c",
  66.             "base/ftbbox.c",
  67.             "base/ftdebug.c",
  68.             "base/ftglyph.c",
  69.             "base/ftinit.c",
  70.             "base/ftsystem.c",
  71.             "truetype/truetype.c",
  72.             "sfnt/sfnt.c",
  73.             "psnames/psnames.c",
  74.             "smooth/smooth.c",
  75.             "base/ftbitmap.c",
  76.             "autofit/autofit.c",
  77.             "gzip/ftgzip.c",
  78.         ])
  79.     ))
  80.  
  81.  
  82. def libpng(module: cpp.Module, ctx: context.Context):
  83.     module.set_base_path("thirdparty/libpng")
  84.     module.add_public_include(".")
  85.  
  86.     module.add_dependency(cpp.DependencyType.Private, ctx.require('zlib'))
  87.  
  88.     env = module.get_env().inherit()
  89.     env.std = cpp.Std.C11
  90.     env.defines["PNG_ARM_NEON_OPT"] = "0"
  91.  
  92.     module.add_group(cpp.SourceGroup(
  93.         env,
  94.         ".",
  95.         cpp.c_files(shallow=True, exclude=["example.c", "pngtest.c"])
  96.     ))
  97.  
  98.  
  99. def libjpeg(module: cpp.Module, ctx: context.Context):
  100.     module.set_base_path("thirdparty/libjpeg")
  101.     module.add_public_include(".")
  102.  
  103.     module.add_dependency(cpp.DependencyType.Private, ctx.require('zlib'))
  104.  
  105.     env = module.get_env().inherit()
  106.     env.std = cpp.Std.C11
  107.  
  108.     module.add_group(cpp.SourceGroup(
  109.         env,
  110.         ".",
  111.         cpp.c_files(
  112.             shallow=True,
  113.             exclude=[
  114.                 "jmemdos.c", "jmemmac.c", "jmemname.c",
  115.                 "cjpeg.c", "ckconfig.c", "djpeg.c", "rdjpgcom.c", "wrjpgcom.c",
  116.                 "jpegtran.c", "jmemmac.c", "jmemansi.c"
  117.             ]
  118.         )
  119.     ))
  120.  
  121.  
  122. def fl_native(module: cpp.Module, ctx: context.Context):
  123.     module.set_base_path(".")
  124.     module.add_public_include("include")
  125.     module.add_public_include(".output/builtin/include")
  126.  
  127.     module.add_dependency(cpp.DependencyType.Private, ctx.require('zlib'))
  128.     module.add_dependency(cpp.DependencyType.Private, ctx.require('libjpeg'))
  129.     module.add_dependency(cpp.DependencyType.Private, ctx.require('libpng'))
  130.     module.add_dependency(cpp.DependencyType.Private, ctx.require('lua'))
  131.  
  132.     env = module.get_env().inherit()
  133.     env.std = cpp.Std.Cpp17
  134.     env.warnings["unused-variable"] = False
  135.     env.add_include("include")
  136.     env.add_include(".output/builtin/include")
  137.     env.set_pch("source/fl_native/pch.h")
  138.  
  139.     module.add_group(cpp.SourceGroup(
  140.         env,
  141.         ".output/builtin/source",
  142.         cpp.cpp_files()
  143.     ))
  144.  
  145.     module.add_group(cpp.SourceGroup(
  146.         env,
  147.         "native",
  148.         cpp.cpp_files()
  149.     ))
  150.  
  151.  
  152. def fl_project(module: cpp.Module, ctx: context.Context):
  153.     module.set_base_path(".")
  154.     module.add_public_include("include")
  155.     module.add_public_include(".output/project/include")
  156.     module.add_dependency(cpp.DependencyType.Transitive, ctx.require('native'))
  157.     module.add_dependency(cpp.DependencyType.Transitive, ctx.require('fl_lua'))
  158.  
  159.     env = module.get_env().inherit()
  160.     env.std = cpp.Std.Cpp17
  161.     env.warnings["unused-variable"] = False
  162.     env.add_include("include")
  163.     env.add_include(".output/project/include")
  164.     env.set_pch("source/fl_project/pch.h")
  165.  
  166.     module.add_group(cpp.SourceGroup(
  167.         env,
  168.         ".output/project/source",
  169.         cpp.cpp_files()
  170.     ))
  171.  
  172.  
  173. def fl_lua(module: cpp.Module, ctx: context.Context):
  174.     module.set_base_path(".")
  175.     module.add_public_include("include")
  176.     module.add_public_include(".output/lua/include")
  177.  
  178.     env = module.get_env().inherit()
  179.     env.std = cpp.Std.Cpp17
  180.     env.warnings["unused-variable"] = False
  181.     env.add_include("include")
  182.     env.add_include(".output/lua/include")
  183.     env.set_pch("source/lua-wrapper/pch.h")
  184.  
  185.     module.add_dependency(cpp.DependencyType.Private, ctx.require('lua'))
  186.     module.add_dependency(cpp.DependencyType.Private, ctx.require('fl_native'))
  187.  
  188.     module.add_group(cpp.SourceGroup(
  189.         env,
  190.         ".output/lua/source",
  191.         cpp.cpp_files()
  192.     ))
  193.     module.add_group(cpp.SourceGroup(
  194.         env,
  195.         "source/lua-wrapper",
  196.         cpp.cpp_files()
  197.     ))
  198.  
  199.  
  200. def em(module: cpp.Module, ctx: context.Context):
  201.     module.set_base_path(".")
  202.     module.add_public_include("emscripten/include")
  203.  
  204.     env = module.get_env().inherit()
  205.     env.std = cpp.Std.Cpp17
  206.     env.add_include("emscripten/include")
  207.  
  208.     module[EMManifest].add_pre_js("emscripten/js/support.js")
  209.     module[EMManifest].add_pre_js("emscripten/js/URLStream.js")
  210.     module[EMManifest].add_js_library("emscripten/js/URLStream-lib.js")
  211.     module[EMManifest].add_pre_js("emscripten/js/SharedObject.js")
  212.     module[EMManifest].add_js_library("emscripten/js/SharedObject-lib.js")
  213.     module[EMManifest].add_pre_js("emscripten/js/ExternalInterface.js")
  214.     module[EMManifest].add_js_library("emscripten/js/ExternalInterface-lib.js")
  215.     module[EMManifest].add_pre_js("emscripten/js/StageText.js")
  216.     module[EMManifest].add_js_library("emscripten/js/StageText-lib.js")
  217.     module[EMManifest].add_pre_js("emscripten/js/WebUtils.js")
  218.     module[EMManifest].add_js_library("emscripten/js/WebUtils-lib.js")
  219.  
  220.     module.add_group(cpp.SourceGroup(
  221.         env,
  222.         "emscripten/source",
  223.         cpp.cpp_files()
  224.     ))
  225.     env.set_pch("emscripten/source/pch.h")
  226.  
  227.  
  228. def em_test(module: cpp.Module, ctx: context.Context):
  229.     module.set_base_path(".")
  230.  
  231.     env = module.get_env().inherit()
  232.     env.std = cpp.Std.Cpp17
  233.     module.add_dependency(cpp.DependencyType.Transitive, ctx.require('em'))
  234.  
  235.     env_pch = env.inherit()
  236.     module.add_group(cpp.SourceGroup(
  237.         env_pch,
  238.         "emscripten/tests",
  239.         cpp.cpp_files(exclude=["main.cpp"])
  240.     ))
  241.     env_pch.set_pch("emscripten/tests/pch.h")
  242.  
  243.     module[EMManifest].add_linker_opt("DEMANGLE_SUPPORT=1")
  244.  
  245.     module.add_group(cpp.SourceGroup(
  246.         env,
  247.         "emscripten/tests",
  248.         cpp.cpp_files(include=["main.cpp"])
  249.     ))
  250.  
  251.  
  252. def native(module: cpp.Module, ctx: context.Context):
  253.     module.set_base_path(".")
  254.     module.add_public_include("include")
  255.     module.add_dependency(cpp.DependencyType.Transitive, ctx.require('fl_native'))
  256.     module.add_dependency(cpp.DependencyType.Private, ctx.require('freetype'))
  257.  
  258.     if EMManifest in module:
  259.         module.add_dependency(cpp.DependencyType.Transitive, ctx.require('em'))
  260.  
  261.     env = module.get_env().inherit()
  262.     env.std = cpp.Std.Cpp17
  263.     env.add_include("include")
  264.  
  265.     excludes = ["win", "glad.c", "CURLRemoteStream.cpp", "LocalFileStream.cpp"]
  266.  
  267.     if EMManifest not in module:
  268.         excludes.append("emscripten")
  269.         excludes.append("EmscriptenStream.cpp")
  270.  
  271.     if NdkManifest not in module:
  272.         excludes.append("android")
  273.  
  274.     if NdkManifest in module:
  275.         excludes.append("glfw")
  276.  
  277.     module.add_group(cpp.SourceGroup(
  278.         env,
  279.         "source/flashnative",
  280.         cpp.cpp_files(exclude=excludes)
  281.     ))
  282.     env.set_pch("source/flashnative/pch.h")
  283.  
  284.  
  285. def app(module: cpp.Module, ctx: context.Context):
  286.     module.set_base_path(".")
  287.     module.add_public_include("include")
  288.     module.add_dependency(cpp.DependencyType.Private, ctx.require('native'))
  289.     module.add_dependency(cpp.DependencyType.Private, ctx.require('fl_project'))
  290.  
  291.     if EMManifest in module:
  292.         debug = module.get_env().resolve("debug")
  293.  
  294.         module[EMManifest].add_linker_opt("USE_GLFW=3")
  295.         module[EMManifest].add_linker_opt("NO_FILESYSTEM=1")
  296.  
  297.         if debug == cpp.DebugInfo.Enabled:
  298.             module[EMManifest].add_linker_opt("ASSERTIONS=1")
  299.  
  300.             #opt = module.get_env().resolve("opt")
  301.             #if opt == cpp.Opt.Disabled:
  302.             #   module[EMManifest].add_linker_opt("DEMANGLE_SUPPORT=1")
  303.             #   module[EMManifest].add_linker_opt("SAFE_HEAP=1")
  304.             #   module[EMManifest].add_linker_opt("ALIASING_FUNCTION_POINTERS=0")
  305.  
  306.         if ctx.config["asmjs"]:
  307.             module[EMManifest].add_linker_opt("WASM=0")
  308.             module[EMManifest].add_linker_opt("TOTAL_MEMORY=256MB")
  309.             module[EMManifest].add_linker_opt("NO_EXIT_RUNTIME=1")
  310.             module[EMManifest].add_linker_opt("EVAL_CTORS=0")
  311.         else:
  312.             module[EMManifest].add_linker_opt("TOTAL_MEMORY=256MB")
  313.             module[EMManifest].add_linker_opt("ALLOW_MEMORY_GROWTH=1")
  314.  
  315.         module[EMManifest].enable_lto = True
  316.         module[EMManifest].enable_closure = True
  317.  
  318.     env = module.get_env().inherit()
  319.     env.std = cpp.Std.Cpp17
  320.     env.add_include("include")
  321.     env.set_pch("source/flashapp/pch.h")
  322.  
  323.     module.add_group(cpp.SourceGroup(
  324.         env,
  325.         "source/flashapp",
  326.         cpp.cpp_files()
  327.     ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement