From 9c282d6a0eea8404653edb5d61adfe429b05ec18 Mon Sep 17 00:00:00 2001 From: Christian Moritz Date: Thu, 12 Sep 2019 21:07:21 +0200 Subject: [PATCH] Move GN root into //core/libdeno (#2943) --- .gitattributes | 6 +++--- .gitmodules | 2 +- BUILD.gn | 6 ------ build_overrides | 1 - buildtools | 1 - core/build.rs | 7 ++----- .gn => core/libdeno/.gn | 0 core/libdeno/BUILD.gn | 14 +++++++------- core/libdeno/api.cc | 6 +++--- core/libdeno/binding.cc | 4 ++-- core/libdeno/buffer.h | 4 ++-- build => core/libdeno/build | 0 core/libdeno/build_overrides | 1 + core/libdeno/buildtools | 1 + core/libdeno/exceptions.h | 2 +- core/libdeno/internal.h | 4 ++-- core/libdeno/testing | 1 + core/libdeno/third_party | 1 + core/libdeno/tools | 1 + core/libdeno/v8 | 1 + js/stat_test.ts | 24 ++++++++++++------------ testing | 1 - third_party | 2 +- tools/cargo_package.py | 2 +- tools/clang | 1 - tools/format.py | 8 ++++---- tools/lint.py | 7 +++---- tools/setup.py | 20 ++++++++++++-------- tools/third_party.py | 24 ++++++++++++++---------- tools/util.py | 1 + website/manual.md | 8 ++++---- 31 files changed, 81 insertions(+), 80 deletions(-) delete mode 100644 BUILD.gn delete mode 120000 build_overrides delete mode 120000 buildtools rename .gn => core/libdeno/.gn (100%) rename build => core/libdeno/build (100%) create mode 120000 core/libdeno/build_overrides create mode 120000 core/libdeno/buildtools create mode 120000 core/libdeno/testing create mode 120000 core/libdeno/third_party create mode 120000 core/libdeno/tools create mode 120000 core/libdeno/v8 delete mode 120000 testing delete mode 120000 tools/clang diff --git a/.gitattributes b/.gitattributes index 356dc788c8..15deed7bce 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,7 +4,7 @@ # Tell git which symlinks point to files, and which ones point to directories. # This is relevant for Windows only, and requires git >= 2.19.2 to work. -/* symlink=dir -/website/* symlink=dir -/tools/clang symlink=dir +/core/libdeno/* symlink=dir +/node_modules symlink=dir /tools/memory symlink=dir +/website/* symlink=dir diff --git a/.gitmodules b/.gitmodules index 10e1215d73..248beb8eb7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,7 +2,7 @@ path = third_party url = https://github.com/denoland/deno_third_party.git [submodule "build"] - path = build + path = core/libdeno/build url = https://github.com/denoland/chromium_build.git [submodule "js/deps/https/deno.land/x/std"] path = js/deps/https/deno.land/std diff --git a/BUILD.gn b/BUILD.gn deleted file mode 100644 index b8e196655d..0000000000 --- a/BUILD.gn +++ /dev/null @@ -1,6 +0,0 @@ -group("default") { - testonly = true - deps = [ - "core/libdeno:default", - ] -} diff --git a/build_overrides b/build_overrides deleted file mode 120000 index 3e199c0e10..0000000000 --- a/build_overrides +++ /dev/null @@ -1 +0,0 @@ -third_party/v8/build_overrides \ No newline at end of file diff --git a/buildtools b/buildtools deleted file mode 120000 index 25713c88ac..0000000000 --- a/buildtools +++ /dev/null @@ -1 +0,0 @@ -third_party/v8/buildtools \ No newline at end of file diff --git a/core/build.rs b/core/build.rs index 83569eeeea..ead65476ad 100644 --- a/core/build.rs +++ b/core/build.rs @@ -4,12 +4,9 @@ fn main() { let build = gn::Build::setup(); - println!( - "cargo:rustc-link-search=native={}/obj/core/libdeno", - build.gn_out_dir - ); + println!("cargo:rustc-link-search=native={}/obj", build.gn_out_dir); - build.run("core/libdeno:default"); + build.run("default"); } mod gn { diff --git a/.gn b/core/libdeno/.gn similarity index 100% rename from .gn rename to core/libdeno/.gn diff --git a/core/libdeno/BUILD.gn b/core/libdeno/BUILD.gn index 2eb0b71280..d2322c678d 100644 --- a/core/libdeno/BUILD.gn +++ b/core/libdeno/BUILD.gn @@ -1,5 +1,5 @@ # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import("//third_party/v8/gni/v8.gni") +import("//v8/gni/v8.gni") group("default") { testonly = true @@ -11,8 +11,8 @@ group("default") { } config("deno_config") { - include_dirs = [ "//third_party/v8" ] # This allows us to v8/src/base/ libraries. - configs = [ "//third_party/v8:external_config" ] + include_dirs = [ "//v8" ] # This allows us to v8/src/base/ libraries. + configs = [ "//v8:external_config" ] cflags = [] if (is_debug) { @@ -39,10 +39,10 @@ config("deno_config") { v8_source_set("v8") { deps = [ - "//third_party/v8:v8", - "//third_party/v8:v8_libbase", - "//third_party/v8:v8_libplatform", - "//third_party/v8:v8_libsampler", + "//v8:v8", + "//v8:v8_libbase", + "//v8:v8_libplatform", + "//v8:v8_libsampler", ] configs = [ ":deno_config" ] } diff --git a/core/libdeno/api.cc b/core/libdeno/api.cc index 2e926f7933..54501f543e 100644 --- a/core/libdeno/api.cc +++ b/core/libdeno/api.cc @@ -5,9 +5,9 @@ #include #include -#include "third_party/v8/include/libplatform/libplatform.h" -#include "third_party/v8/include/v8.h" -#include "third_party/v8/src/base/logging.h" +#include "v8/include/libplatform/libplatform.h" +#include "v8/include/v8.h" +#include "v8/src/base/logging.h" #include "deno.h" #include "exceptions.h" diff --git a/core/libdeno/binding.cc b/core/libdeno/binding.cc index 7827cd5228..911c614994 100644 --- a/core/libdeno/binding.cc +++ b/core/libdeno/binding.cc @@ -14,8 +14,8 @@ #include #endif // _WIN32 -#include "third_party/v8/include/v8.h" -#include "third_party/v8/src/base/logging.h" +#include "v8/include/v8.h" +#include "v8/src/base/logging.h" #include "deno.h" #include "exceptions.h" diff --git a/core/libdeno/buffer.h b/core/libdeno/buffer.h index 636c241b0a..9a6e3acf7d 100644 --- a/core/libdeno/buffer.h +++ b/core/libdeno/buffer.h @@ -10,8 +10,8 @@ #include #include -#include "third_party/v8/include/v8.h" -#include "third_party/v8/src/base/logging.h" +#include "v8/include/v8.h" +#include "v8/src/base/logging.h" namespace deno { diff --git a/build b/core/libdeno/build similarity index 100% rename from build rename to core/libdeno/build diff --git a/core/libdeno/build_overrides b/core/libdeno/build_overrides new file mode 120000 index 0000000000..f1aca1a07d --- /dev/null +++ b/core/libdeno/build_overrides @@ -0,0 +1 @@ +v8/build_overrides \ No newline at end of file diff --git a/core/libdeno/buildtools b/core/libdeno/buildtools new file mode 120000 index 0000000000..c5b1c451c8 --- /dev/null +++ b/core/libdeno/buildtools @@ -0,0 +1 @@ +v8/buildtools \ No newline at end of file diff --git a/core/libdeno/exceptions.h b/core/libdeno/exceptions.h index 2c0947be29..d8852f544e 100644 --- a/core/libdeno/exceptions.h +++ b/core/libdeno/exceptions.h @@ -3,7 +3,7 @@ #define EXCEPTIONS_H_ #include -#include "third_party/v8/include/v8.h" +#include "v8/include/v8.h" namespace deno { diff --git a/core/libdeno/internal.h b/core/libdeno/internal.h index f3789fcc3e..89c746d048 100644 --- a/core/libdeno/internal.h +++ b/core/libdeno/internal.h @@ -9,8 +9,8 @@ #include "buffer.h" #include "deno.h" -#include "third_party/v8/include/v8.h" -#include "third_party/v8/src/base/logging.h" +#include "v8/include/v8.h" +#include "v8/src/base/logging.h" namespace deno { diff --git a/core/libdeno/testing b/core/libdeno/testing new file mode 120000 index 0000000000..ed34f4824a --- /dev/null +++ b/core/libdeno/testing @@ -0,0 +1 @@ +v8/testing \ No newline at end of file diff --git a/core/libdeno/third_party b/core/libdeno/third_party new file mode 120000 index 0000000000..48370cbe73 --- /dev/null +++ b/core/libdeno/third_party @@ -0,0 +1 @@ +v8/third_party \ No newline at end of file diff --git a/core/libdeno/tools b/core/libdeno/tools new file mode 120000 index 0000000000..7b6c53ae95 --- /dev/null +++ b/core/libdeno/tools @@ -0,0 +1 @@ +v8/tools \ No newline at end of file diff --git a/core/libdeno/v8 b/core/libdeno/v8 new file mode 120000 index 0000000000..efdcb44da2 --- /dev/null +++ b/core/libdeno/v8 @@ -0,0 +1 @@ +../../third_party/v8 \ No newline at end of file diff --git a/js/stat_test.ts b/js/stat_test.ts index 50ee6c9d36..1de98f984d 100644 --- a/js/stat_test.ts +++ b/js/stat_test.ts @@ -8,9 +8,9 @@ testPerm({ read: true }, async function statSyncSuccess(): Promise { assert(packageInfo.isFile()); assert(!packageInfo.isSymlink()); - const testingInfo = Deno.statSync("testing"); - assert(testingInfo.isDirectory()); - assert(!testingInfo.isSymlink()); + const modulesInfo = Deno.statSync("node_modules"); + assert(modulesInfo.isDirectory()); + assert(!modulesInfo.isSymlink()); const testsInfo = Deno.statSync("tests"); assert(testsInfo.isDirectory()); @@ -50,9 +50,9 @@ testPerm({ read: true }, async function lstatSyncSuccess(): Promise { assert(packageInfo.isFile()); assert(!packageInfo.isSymlink()); - const testingInfo = Deno.lstatSync("testing"); - assert(!testingInfo.isDirectory()); - assert(testingInfo.isSymlink()); + const modulesInfo = Deno.lstatSync("node_modules"); + assert(!modulesInfo.isDirectory()); + assert(modulesInfo.isSymlink()); const testsInfo = Deno.lstatSync("tests"); assert(testsInfo.isDirectory()); @@ -92,9 +92,9 @@ testPerm({ read: true }, async function statSuccess(): Promise { assert(packageInfo.isFile()); assert(!packageInfo.isSymlink()); - const testingInfo = await Deno.stat("testing"); - assert(testingInfo.isDirectory()); - assert(!testingInfo.isSymlink()); + const modulesInfo = await Deno.stat("node_modules"); + assert(modulesInfo.isDirectory()); + assert(!modulesInfo.isSymlink()); const testsInfo = await Deno.stat("tests"); assert(testsInfo.isDirectory()); @@ -134,9 +134,9 @@ testPerm({ read: true }, async function lstatSuccess(): Promise { assert(packageInfo.isFile()); assert(!packageInfo.isSymlink()); - const testingInfo = await Deno.lstat("testing"); - assert(!testingInfo.isDirectory()); - assert(testingInfo.isSymlink()); + const modulesInfo = await Deno.lstat("node_modules"); + assert(!modulesInfo.isDirectory()); + assert(modulesInfo.isSymlink()); const testsInfo = await Deno.lstat("tests"); assert(testsInfo.isDirectory()); diff --git a/testing b/testing deleted file mode 120000 index ee58868150..0000000000 --- a/testing +++ /dev/null @@ -1 +0,0 @@ -third_party/v8/testing \ No newline at end of file diff --git a/third_party b/third_party index 4b36ce22a2..5f9af82470 160000 --- a/third_party +++ b/third_party @@ -1 +1 @@ -Subproject commit 4b36ce22a2ef7310f815acb6a2de0d26766a24b6 +Subproject commit 5f9af82470e8770a1c0170bbcf30502509332dac diff --git a/tools/cargo_package.py b/tools/cargo_package.py index 152685d6bb..7696681e79 100755 --- a/tools/cargo_package.py +++ b/tools/cargo_package.py @@ -30,7 +30,7 @@ elif sys.platform == "win32": else: assert (False) -lib_name = os.path.join(root_path, "target/release/obj/core/libdeno", +lib_name = os.path.join(root_path, "target", "release", "obj", "libdeno" + static_lib_suffix) diff --git a/tools/clang b/tools/clang deleted file mode 120000 index e3fc678576..0000000000 --- a/tools/clang +++ /dev/null @@ -1 +0,0 @@ -../third_party/v8/tools/clang \ No newline at end of file diff --git a/tools/format.py b/tools/format.py index 2628928f1e..ac60358048 100755 --- a/tools/format.py +++ b/tools/format.py @@ -3,7 +3,7 @@ import os import sys import argparse -from third_party import google_env, python_env +from third_party import get_buildtools_tool_path, google_env, python_env from util import git_ls_files, third_party_path, root_path, run @@ -44,8 +44,8 @@ def main(): def clang_format(): - print "clang_format" - exe = os.path.join(third_party_path, "depot_tools", "clang-format") + print "clang-format" + exe = get_buildtools_tool_path("clang-format") source_files = git_ls_files(root_path, ["*.cc", "*.h"]) run([exe, "-i", "-style", "Google", "--"] + source_files, env=google_env(), @@ -54,7 +54,7 @@ def clang_format(): def gn_format(): print "gn format" - exe = os.path.join(third_party_path, "depot_tools", "gn") + exe = get_buildtools_tool_path("gn") source_files = git_ls_files(root_path, ["*.gn", "*.gni"]) run([exe, "format", "--"] + source_files, env=google_env(), quiet=True) diff --git a/tools/lint.py b/tools/lint.py index 29ed86fa99..61c6c59cea 100755 --- a/tools/lint.py +++ b/tools/lint.py @@ -4,7 +4,7 @@ import os import sys -from util import enable_ansi_colors, git_ls_files, root_path, run +from util import enable_ansi_colors, git_ls_files, libdeno_path, root_path, run from util import third_party_path from third_party import python_env @@ -20,14 +20,13 @@ def main(): def cpplint(): print "cpplint" script = os.path.join(third_party_path, "cpplint", "cpplint.py") - libdeno_dir = os.path.join(root_path, "core", "libdeno") - source_files = git_ls_files(libdeno_dir, ["*.cc", "*.h"]) + source_files = git_ls_files(libdeno_path, ["*.cc", "*.h"]) run([ sys.executable, script, "--quiet", "--filter=-build/include_subdir", - "--repository=" + libdeno_dir, + "--repository=" + libdeno_path, "--", ] + source_files, env=python_env(), diff --git a/tools/setup.py b/tools/setup.py index b8b9da3244..aef65924de 100755 --- a/tools/setup.py +++ b/tools/setup.py @@ -6,8 +6,8 @@ import sys from distutils.spawn import find_executable import argparse import third_party -from util import build_mode, build_path, enable_ansi_colors, run, shell_quote -from util import root_path, third_party_path +from util import build_mode, build_path, enable_ansi_colors, libdeno_path +from util import shell_quote, root_path, run, third_party_path parser = argparse.ArgumentParser() parser.add_argument( @@ -49,15 +49,17 @@ def write_if_not_exists(filename, contents): def write_lastchange(): + lastchange_file = os.path.join(libdeno_path, "build", "util", "LASTCHANGE") + committime_file = lastchange_file + ".committime" write_if_not_exists( - "build/util/LASTCHANGE", + lastchange_file, "LASTCHANGE=c42e4ddbb7973bfb0c57a49ab6bf6dc432baad7e-\n") - write_if_not_exists("build/util/LASTCHANGE.committime", "1535518087") + write_if_not_exists(committime_file, "1535518087") # TODO Properly we should call the following script, but it seems to cause # a rebuild on every commit. # run([ - # sys.executable, "build/util/lastchange.py", "-o", - # "build/util/LASTCHANGE", "--source-dir", root_path, "--filter=" + # sys.executable, "build/util/lastchange.py", "-o", lastchange_file, + # "--source-dir", root_path, "--filter=" # ]) @@ -146,7 +148,7 @@ def gn_exe(): if "DENO_GN_PATH" in os.environ: return os.environ["DENO_GN_PATH"] else: - return os.path.join(third_party_path, "depot_tools", "gn") + return third_party.get_buildtools_tool_path("gn") # gn gen. @@ -175,7 +177,9 @@ def gn_gen(mode): for line in gn_args: print " " + line - run([gn_exe(), "gen", build_path()], env=third_party.google_env()) + run([gn_exe(), "gen", build_path()], + cwd=libdeno_path, + env=third_party.google_env()) if __name__ == '__main__': diff --git a/tools/third_party.py b/tools/third_party.py index bcac9a5b45..bdb5662af5 100644 --- a/tools/third_party.py +++ b/tools/third_party.py @@ -7,10 +7,9 @@ import re import site import sys from tempfile import mkdtemp -from util import add_env_path, executable_suffix, make_env, rmtree, root_path -from util import run, third_party_path +from util import add_env_path, executable_suffix, libdeno_path, make_env, rmtree +from util import root_path, run, third_party_path -chromium_build_path = os.path.join(root_path, "build") depot_tools_path = os.path.join(third_party_path, "depot_tools") prebuilt_path = os.path.join(root_path, "prebuilt") python_packages_path = os.path.join(third_party_path, "python_packages") @@ -32,7 +31,8 @@ def python_env(env=None, merge_env=None): python_site_env = {} temp = os.environ["PATH"], sys.path os.environ["PATH"], sys.path = "", [] - site.addsitedir(chromium_build_path) # Modifies PATH and sys.path. + site.addsitedir(os.path.join(libdeno_path, + "build")) # Modifies PATH and sys.path. site.addsitedir(python_packages_path) # Modifies PATH and sys.path. python_site_env = {"PATH": os.environ["PATH"], "PYTHONPATH": sys.path} os.environ["PATH"], sys.path = temp @@ -181,6 +181,11 @@ def get_prebuilt_tool_path(tool): tool + executable_suffix) +def get_buildtools_tool_path(tool): + return os.path.join(libdeno_path, "buildtools", get_platform_dir_name(), + tool + executable_suffix) + + # Download the given item from Google storage. def download_from_google_storage(item, bucket, base_dir): download_script = os.path.join(depot_tools_path, @@ -202,7 +207,7 @@ def download_from_google_storage(item, bucket, base_dir): # Download the given item from Chrome Infrastructure Package Deployment. def download_from_cipd(item, version): cipd_exe = os.path.join(depot_tools_path, "cipd") - download_dir = os.path.join(third_party_path, "v8", "buildtools", + download_dir = os.path.join(libdeno_path, "buildtools", get_platform_dir_name()) if sys.platform == "win32": @@ -239,9 +244,8 @@ def download_gn(): # Download clang-format from Google storage. def download_clang_format(): - download_from_google_storage( - "clang-format", "chromium-clang-format", - os.path.join(third_party_path, "v8", "buildtools")) + download_from_google_storage("clang-format", "chromium-clang-format", + os.path.join(libdeno_path, "buildtools")) def download_sccache(): @@ -254,13 +258,13 @@ def download_hyperfine(): # Download clang by calling the clang update script. def download_clang(): - update_script = os.path.join(third_party_path, "v8", "tools", "clang", + update_script = os.path.join(libdeno_path, "v8", "tools", "clang", "scripts", "update.py") run([sys.executable, update_script], env=google_env()) def maybe_download_sysroot(): if sys.platform.startswith("linux"): - install_script = os.path.join(chromium_build_path, "linux", + install_script = os.path.join(libdeno_path, "build", "linux", "sysroot_scripts", "install-sysroot.py") run([sys.executable, install_script, "--arch=amd64"], env=google_env()) diff --git a/tools/util.py b/tools/util.py index 82465f8650..93502b06d5 100644 --- a/tools/util.py +++ b/tools/util.py @@ -20,6 +20,7 @@ else: executable_suffix = ".exe" if os.name == "nt" else "" root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +libdeno_path = os.path.join(root_path, "core", "libdeno") tests_path = os.path.join(root_path, "tests") third_party_path = os.path.join(root_path, "third_party") diff --git a/website/manual.md b/website/manual.md index a3315eeec4..1016aea65a 100644 --- a/website/manual.md +++ b/website/manual.md @@ -204,16 +204,16 @@ ninja -C target/debug cargo build --release # List executable targets. -gn ls target/debug //:* --as=output --type=executable +gn --root=core/libdeno ls target/debug "//:*" --as=output --type=executable # List build configuration. -gn args target/debug/ --list +gn --root=core/libdeno args target/debug/ --list # Edit build configuration. -gn args target/debug/ +gn --root=core/libdeno args target/debug/ # Describe a target. -gn desc target/debug/ :deno +gn --root=core/libdeno desc target/debug/ :deno gn help # Update third_party modules