blob: 033260541b8e7842705ce629398037a898939006 [file] [log] [blame]
# 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",
# Use a switch rather than a manually created dispatch table. Using the
# host-asan_ubsan variant causes the interpreter to crash with an internal
# stack overflow error if this table is used. The compiler should already
# decide which is the best way to lower a switch statement anyway.
"DIRECT_DISPATCH=0",
]
# Suppress warnings in upstream code that are triggered by Fuchsia compilation flags.
cflags = [
"-Wno-conversion",
"-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" ]
}
public_configs = [ ":qjs-config" ]
}
executable("qjsc") {
sources = [ "qjsc.c" ]
deps = [ ":qjs-lib" ]
configs += [ ":qjs-config" ]
}
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",
":qjscalc",
":repl",
]
if (is_fuchsia) {
deps += [ "//src/zircon/lib/zircon" ]
}
}
package("quickjs") {
deps = [ ":qjs" ]
binaries = [
{
name = "qjs"
shell = true
},
]
}
test("qjs_test") {
sources = [ "basic_test.cc" ]
deps = [
":qjs-lib",
"//sdk/lib/syslog/cpp:backend_legacy",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gtest",
]
if (is_fuchsia) {
deps += [ "//src/zircon/lib/zircon" ]
}
}
unittest_package("qjs_tests") {
deps = [ ":qjs_test" ]
tests = [
{
name = "qjs_test"
environments = basic_envs
},
]
}
install_host_tools("quickjs_host") {
deps = [ ":qjs" ]
outputs = [ "qjs" ]
}