Skip to content

Commit

Permalink
tools: generate third_party dir and symlinks from the script. (denola…
Browse files Browse the repository at this point in the history
…nd#346)

Everyone needs to run ./tools/build_third_party.py after this commit.
  • Loading branch information
kt3k authored and ry committed Jul 8, 2018
1 parent cf0c066 commit 6c79b47
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 18 deletions.
11 changes: 2 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,5 @@
# npm deps
node_modules

# git deps
/third_party/v8/
/third_party/cpplint/
/third_party/zlib/
/third_party/rust_crates/libc/
/third_party/flatbuffers/

# gclient files
/third_party/.gclient_entries
# third party deps
/third_party/
1 change: 0 additions & 1 deletion third_party/.gclient

This file was deleted.

1 change: 0 additions & 1 deletion third_party/googletest

This file was deleted.

1 change: 0 additions & 1 deletion third_party/jinja2

This file was deleted.

1 change: 0 additions & 1 deletion third_party/llvm-build

This file was deleted.

1 change: 0 additions & 1 deletion third_party/markupsafe

This file was deleted.

1 change: 0 additions & 1 deletion third_party/package.json

This file was deleted.

1 change: 0 additions & 1 deletion third_party/yarn.lock

This file was deleted.

41 changes: 39 additions & 2 deletions tools/build_third_party.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# This script updates the third party dependencies of deno.
# This script generates the third party dependencies of deno.
# - Get Depot Tools and make sure it's in your path.
# http:https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
# - You need yarn installed as well.
Expand All @@ -8,14 +8,26 @@
# Use //js/package.json to modify the npm deps.

import os
from os.path import join
import subprocess

root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
third_party_path = os.path.join(root_path, "third_party")
third_party_path = join(root_path, "third_party")


def main():
try:
os.makedirs(third_party_path)
except:
pass
os.chdir(third_party_path)
remove_and_symlink(join("..", "gclient_config.py"), ".gclient")
remove_and_symlink(join("..", "package.json"), "package.json")
remove_and_symlink(join("..", "yarn.lock"), "yarn.lock")
remove_and_symlink(join("v8", "third_party", "googletest"), "googletest")
remove_and_symlink(join("v8", "third_party", "jinja2"), "jinja2")
remove_and_symlink(join("v8", "third_party", "llvm-build"), "llvm-build")
remove_and_symlink(join("v8", "third_party", "markupsafe"), "markupsafe")
run(["gclient", "sync", "--no-history"])
run(["yarn"])

Expand All @@ -26,5 +38,30 @@ def run(args):
subprocess.check_call(args, env=env)


def remove_and_symlink(target, name):
try:
os.unlink(name)
except:
pass
os.symlink(target, name)


def symlink(target, name, target_is_dir=False):
if os.name == "nt":
import ctypes
CreateSymbolicLinkW = ctypes.windll.kernel32.CreateSymbolicLinkW
CreateSymbolicLinkW.restype = ctypes.c_ubyte
CreateSymbolicLinkW.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p,
ctypes.c_uint32)

flags = 0x02 # SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
if (target_is_dir):
flags |= 0x01 # SYMBOLIC_LINK_FLAG_DIRECTORY
if not CreateSymbolicLinkW(name, target, flags):
raise ctypes.WinError()
else:
os.symlink(target, name)


if '__main__' == __name__:
main()

0 comments on commit 6c79b47

Please sign in to comment.