Advertisement
tinyevil

Untitled

Dec 27th, 2018
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.41 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/URLStream.js")
  209.     module[EMManifest].add_js_library("emscripten/js/URLStream-lib.js")
  210.     module[EMManifest].add_pre_js("emscripten/js/SharedObject.js")
  211.     module[EMManifest].add_js_library("emscripten/js/SharedObject-lib.js")
  212.     module[EMManifest].add_pre_js("emscripten/js/ExternalInterface.js")
  213.     module[EMManifest].add_js_library("emscripten/js/ExternalInterface-lib.js")
  214.  
  215.     module.add_group(cpp.SourceGroup(
  216.         env,
  217.         "emscripten/source",
  218.         cpp.cpp_files()
  219.     ))
  220.     env.set_pch("emscripten/source/pch.h")
  221.  
  222.  
  223. def em_test(module: cpp.Module, ctx: context.Context):
  224.     module.set_base_path(".")
  225.  
  226.     env = module.get_env().inherit()
  227.     env.std = cpp.Std.Cpp17
  228.     module.add_dependency(cpp.DependencyType.Transitive, ctx.require('em'))
  229.  
  230.     env_pch = env.inherit()
  231.     module.add_group(cpp.SourceGroup(
  232.         env_pch,
  233.         "emscripten/tests",
  234.         cpp.cpp_files(exclude=["main.cpp"])
  235.     ))
  236.     env_pch.set_pch("emscripten/tests/pch.h")
  237.  
  238.     module[EMManifest].add_linker_opt("DEMANGLE_SUPPORT=1")
  239.  
  240.     module.add_group(cpp.SourceGroup(
  241.         env,
  242.         "emscripten/tests",
  243.         cpp.cpp_files(include=["main.cpp"])
  244.     ))
  245.  
  246.  
  247. def native(module: cpp.Module, ctx: context.Context):
  248.     module.set_base_path(".")
  249.     module.add_public_include("include")
  250.     module.add_dependency(cpp.DependencyType.Transitive, ctx.require('fl_native'))
  251.     module.add_dependency(cpp.DependencyType.Private, ctx.require('freetype'))
  252.  
  253.     if EMManifest in module:
  254.         module.add_dependency(cpp.DependencyType.Transitive, ctx.require('em'))
  255.  
  256.     env = module.get_env().inherit()
  257.     env.std = cpp.Std.Cpp17
  258.     env.add_include("include")
  259.  
  260.     excludes = ["win", "glad.c", "CURLRemoteStream.cpp", "LocalFileStream.cpp"]
  261.  
  262.     if EMManifest not in module:
  263.         excludes.append("emscripten")
  264.         excludes.append("EmscriptenStream.cpp")
  265.  
  266.     if NdkManifest not in module:
  267.         excludes.append("android")
  268.  
  269.     if NdkManifest in module:
  270.         excludes.append("glfw")
  271.  
  272.  
  273.     module.add_group(cpp.SourceGroup(
  274.         env,
  275.         "source/flashnative",
  276.         cpp.cpp_files(exclude=excludes)
  277.     ))
  278.     env.set_pch("source/flashnative/pch.h")
  279.  
  280.  
  281. def app(module: cpp.Module, ctx: context.Context):
  282.     module.set_base_path(".")
  283.     module.add_public_include("include")
  284.     module.add_dependency(cpp.DependencyType.Private, ctx.require('native'))
  285.     module.add_dependency(cpp.DependencyType.Private, ctx.require('fl_project'))
  286.  
  287.     if EMManifest in module:
  288.         debug = module.get_env().resolve("debug")
  289.  
  290.         module[EMManifest].add_linker_opt("USE_GLFW=3")
  291.         module[EMManifest].add_linker_opt("NO_FILESYSTEM=1")
  292.  
  293.         if debug == cpp.DebugInfo.Enabled:
  294.             module[EMManifest].add_linker_opt("DEMANGLE_SUPPORT=1")
  295.             module[EMManifest].add_linker_opt("ASSERTIONS=1")
  296.  
  297.         if ctx.config["asmjs"]:
  298.             module[EMManifest].add_linker_opt("WASM=0")
  299.             module[EMManifest].add_linker_opt("TOTAL_MEMORY=256MB")
  300.             module[EMManifest].add_linker_opt("NO_EXIT_RUNTIME=1")
  301.             module[EMManifest].add_linker_opt("EVAL_CTORS=0")
  302.         else:
  303.             module[EMManifest].add_linker_opt("TOTAL_MEMORY=256MB")
  304.             module[EMManifest].add_linker_opt("ALLOW_MEMORY_GROWTH=1")
  305.  
  306.         module[EMManifest].enable_lto = True
  307.         module[EMManifest].enable_closure = True
  308.  
  309.     env = module.get_env().inherit()
  310.     env.std = cpp.Std.Cpp17
  311.     env.add_include("include")
  312.     env.set_pch("source/flashapp/pch.h")
  313.  
  314.     module.add_group(cpp.SourceGroup(
  315.         env,
  316.         "source/flashapp",
  317.         cpp.cpp_files()
  318.     ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement