1#!/usr/bin/env python 2 3Import("env") 4 5javascript_files = [ 6 "audio_driver_javascript.cpp", 7 "http_client_javascript.cpp", 8 "javascript_eval.cpp", 9 "javascript_main.cpp", 10 "os_javascript.cpp", 11] 12 13build_targets = ["#bin/godot${PROGSUFFIX}.js", "#bin/godot${PROGSUFFIX}.wasm"] 14if env["threads_enabled"]: 15 build_targets.append("#bin/godot${PROGSUFFIX}.worker.js") 16 17build = env.add_program(build_targets, javascript_files) 18 19js_libraries = [ 20 "native/http_request.js", 21] 22for lib in js_libraries: 23 env.Append(LINKFLAGS=["--js-library", env.File(lib).path]) 24env.Depends(build, js_libraries) 25 26js_pre = [ 27 "native/id_handler.js", 28 "native/utils.js", 29] 30for js in js_pre: 31 env.Append(LINKFLAGS=["--pre-js", env.File(js).path]) 32env.Depends(build, js_pre) 33 34engine = [ 35 "engine/preloader.js", 36 "engine/utils.js", 37 "engine/engine.js", 38] 39externs = [env.File("#platform/javascript/engine/externs.js")] 40js_engine = env.CreateEngineFile("#bin/godot${PROGSUFFIX}.engine.js", engine, externs) 41env.Depends(js_engine, externs) 42 43wrap_list = [ 44 build[0], 45 js_engine, 46] 47js_wrapped = env.Textfile("#bin/godot", [env.File(f) for f in wrap_list], TEXTFILESUFFIX="${PROGSUFFIX}.wrapped.js") 48 49zip_dir = env.Dir("#bin/.javascript_zip") 50binary_name = "godot.tools" if env["tools"] else "godot" 51out_files = [ 52 zip_dir.File(binary_name + ".js"), 53 zip_dir.File(binary_name + ".wasm"), 54 zip_dir.File(binary_name + ".html"), 55] 56html_file = "#misc/dist/html/full-size.html" 57in_files = [js_wrapped, build[1], html_file] 58if env["threads_enabled"]: 59 in_files.append(build[2]) 60 out_files.append(zip_dir.File(binary_name + ".worker.js")) 61 62zip_files = env.InstallAs(out_files, in_files) 63env.Zip( 64 "#bin/godot", 65 zip_files, 66 ZIPROOT=zip_dir, 67 ZIPSUFFIX="${PROGSUFFIX}${ZIPSUFFIX}", 68 ZIPCOMSTR="Archving $SOURCES as $TARGET", 69) 70