| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/compiled_action.gni") |
| import("//build/host.gni") |
| |
| if (current_toolchain == host_toolchain) { |
| config("qjs-config") { |
| version_lines = read_file("VERSION", "list lines") |
| defines = [ |
| "_GNU_SOURCE", |
| "CONFIG_VERSION=\"" + version_lines[0] + "\"", |
| ] |
| cflags = [ |
| "-Wno-sign-compare", |
| "-Wno-unused-variable", |
| "-funsigned-char", |
| ] |
| } |
| |
| source_set("qjs-lib") { |
| # based on QJS_LIB_OBJS |
| sources = [ |
| "cutils.c", |
| "libbf.c", |
| "libbf.h", |
| "libregexp.c", |
| "libunicode.c", |
| "quickjs-libc.c", |
| "quickjs.c", |
| ] |
| |
| public_configs = [ ":qjs-config" ] |
| } |
| |
| executable("qjsc") { |
| sources = [ |
| "qjsc.c", |
| ] |
| deps = [ |
| ":qjs-lib", |
| ] |
| } |
| |
| template("compiled_js") { |
| generate_target = "${target_name}_gen" |
| generated_file = "${target_gen_dir}/${target_name}.c" |
| |
| compiled_action(generate_target) { |
| tool = ":qjsc" |
| inputs = [ |
| invoker.source, |
| ] |
| outputs = [ |
| generated_file, |
| ] |
| args = [ |
| "-c", |
| "-o", |
| rebase_path(generated_file), |
| ] |
| if (defined(invoker.module) && invoker.module) { |
| args += [ "-m" ] |
| } |
| |
| args += [ rebase_path(invoker.source) ] |
| } |
| |
| source_set(target_name) { |
| sources = [ |
| generated_file, |
| ] |
| deps = [ |
| ":${generate_target}", |
| ] |
| } |
| } |
| |
| compiled_js("repl") { |
| source = "repl.js" |
| module = true |
| } |
| |
| executable("qjs") { |
| # based on QJS_OBJS |
| sources = [ |
| "qjs.c", |
| ] |
| |
| deps = [ |
| ":qjs-lib", |
| ":repl", |
| ] |
| } |
| |
| group("quickjs") { |
| deps = [ |
| ":qjs", |
| ] |
| } |
| } |
| |
| install_host_tools("quickjs_host") { |
| deps = [ |
| ":qjs", |
| ] |
| outputs = [ |
| "qjs", |
| ] |
| } |