| # 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/host.gni") |
| import("//build/package.gni") |
| import("//build/test.gni") |
| import("//build/test/test_package.gni") |
| import("//third_party/quickjs/compiled_js.gni") |
| |
| config("qjs-config") { |
| version_lines = read_file("VERSION", "list lines") |
| defines = [ |
| "_GNU_SOURCE", |
| "CONFIG_VERSION=\"" + version_lines[0] + "\"", |
| "CONFIG_BIGNUM", |
| ] |
| cflags = [ |
| "-Wno-implicit-int-float-conversion", |
| "-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", |
| ] |
| |
| if (is_fuchsia) { |
| deps = [ |
| "//sdk/lib/fdio", |
| ] |
| |
| # TODO(47041): UBSan has found an instance of undefined behavior in this target. |
| # Disable UBSan for this target temporarily until it is migrated into CI/CQ. |
| configs += [ "//build/config:temporarily_disable_ubsan_do_not_use" ] |
| } |
| public_configs = [ ":qjs-config" ] |
| } |
| |
| executable("qjsc") { |
| sources = [ |
| "qjsc.c", |
| ] |
| deps = [ |
| ":qjs-lib", |
| ] |
| } |
| |
| compiled_js("repl") { |
| source = "repl.js" |
| module = true |
| } |
| |
| compiled_js("qjscalc") { |
| source = "qjscalc.js" |
| module = true |
| } |
| |
| executable("qjs") { |
| # based on QJS_OBJS |
| sources = [ |
| "qjs.c", |
| ] |
| |
| deps = [ |
| ":qjs-lib", |
| ":repl", |
| ":qjscalc", |
| ] |
| |
| if (is_fuchsia) { |
| libs = [ "zircon" ] |
| } |
| } |
| |
| package("quickjs") { |
| deps = [ |
| ":qjs", |
| ] |
| binaries = [ |
| { |
| name = "qjs" |
| shell = true |
| }, |
| ] |
| } |
| |
| test("qjs_test") { |
| sources = [ |
| "basic_test.cc", |
| ] |
| |
| deps = [ |
| ":qjs-lib", |
| "//src/lib/fxl/test:gtest_main", |
| "//third_party/googletest:gtest", |
| ] |
| |
| if (is_fuchsia) { |
| libs = [ "zircon" ] |
| } |
| } |
| |
| unittest_package("qjs_tests") { |
| deps = [ |
| ":qjs_test", |
| ] |
| tests = [ |
| { |
| name = "qjs_test" |
| environments = basic_envs |
| }, |
| ] |
| } |
| |
| install_host_tools("quickjs_host") { |
| deps = [ |
| ":qjs", |
| ] |
| outputs = [ |
| "qjs", |
| ] |
| } |