-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env python | ||
|
||
from argparse import ArgumentParser | ||
import sys | ||
from os import path | ||
from subprocess import CalledProcessError, run | ||
import shutil | ||
import platform | ||
from util import clean_dir, remove_dir | ||
|
||
parser = ArgumentParser() | ||
parser.add_argument("version", nargs="?") | ||
|
||
args = parser.parse_args(sys.argv[1:]) | ||
|
||
libuv_version = args.version.strip("v") | ||
|
||
DEPS_DIR = path.join(path.dirname(__file__), "../deps/") | ||
LIBUV_DIR = path.join(DEPS_DIR, "libuv") | ||
|
||
|
||
def move(item, src, dest): | ||
return shutil.move(path.join(src, item), path.join(dest, item)) | ||
|
||
|
||
def main(args): | ||
libuv_repo = path.join(DEPS_DIR, "libuv_" + libuv_version) | ||
|
||
print("Cloning libuv...") | ||
run( | ||
[ | ||
"git", | ||
"clone", | ||
"--quiet", | ||
"--depth=1", | ||
"https://github.com/libuv/libuv.git", | ||
libuv_repo, | ||
] | ||
) | ||
|
||
print("Getting tags...") | ||
run(["git", "fetch", "--quiet", "--depth=1", "--tags"], cwd=libuv_repo) | ||
|
||
print("Checking out libuv v" + libuv_version + "...") | ||
try: | ||
run( | ||
["git", "checkout", "--quiet", "v" + libuv_version], | ||
cwd=libuv_repo, | ||
check=True, | ||
) | ||
except CalledProcessError: | ||
print("Failed to checkout libuv: v" + libuv_version) | ||
remove_dir(libuv_repo) | ||
exit(1) | ||
|
||
print("Copying header and source files...") | ||
clean_dir(LIBUV_DIR) | ||
move("src", libuv_repo, LIBUV_DIR) | ||
move("include", libuv_repo, LIBUV_DIR) | ||
remove_dir(libuv_repo) | ||
|
||
print("Storing version information...") | ||
with open(path.join(LIBUV_DIR, "version.md"), "w") as writer: | ||
writer.write(libuv_version + " release") | ||
|
||
|
||
main(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import os.path | ||
import platform | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
|
||
def clean_dir(dir): | ||
"""If dir exists, deletes it and recreates it, otherwise creates it.""" | ||
if os.path.isdir(dir): | ||
remove_dir(dir) | ||
|
||
os.makedirs(dir) | ||
|
||
|
||
def ensure_dir(dir): | ||
"""Creates dir if not already there.""" | ||
if os.path.isdir(dir): | ||
return | ||
|
||
os.makedirs(dir) | ||
|
||
|
||
def remove_dir(dir): | ||
"""Recursively removes dir.""" | ||
if platform.system() == "Windows": | ||
# rmtree gives up on readonly files on Windows | ||
# rd doesn't like paths with forward slashes | ||
subprocess.check_call(["cmd", "/c", "rd", "/s", "/q", dir.replace("/", "\\")]) | ||
else: | ||
shutil.rmtree(dir) |