This commit is contained in:
Ali 2020-03-25 21:52:35 +04:00
parent ab5ffaf673
commit 113df0b53d
4 changed files with 70 additions and 92 deletions

View File

@ -1,36 +0,0 @@
def string_value(ctx, define_name):
"""Looks up a define on ctx for a string value.
Will also report an error if the value is not defined.
Args:
ctx: A skylark context.
define_name: The name of the define to look up.
Returns:
The value of the define.
"""
value = ctx.var.get(define_name, None)
if value != None:
return value
fail("Expected value for --define={} was not found".format(
define_name,
))
def _file_from_define(ctx):
output = ctx.outputs.out
ctx.actions.write(
output = output,
content = "profile_data",
)
file_from_define = rule(
implementation = _file_from_define,
attrs = {
"define_name": attr.string(mandatory = True),
"extension": attr.string(mandatory = True),
},
outputs = {
"out": "%{name}.%{extension}"
},
)

View File

@ -1,6 +1,3 @@
load("//build-system/bazel-utils:defines.bzl",
"string_value",
)
def _plist_fragment(ctx): def _plist_fragment(ctx):
output = ctx.outputs.out output = ctx.outputs.out

View File

@ -0,0 +1 @@
2.2.0

View File

@ -1,18 +1,43 @@
import sys import sys
import os import os
import json
import re import re
import shutil import shutil
def get_file_list(dir): ignore_patterns_when_copying = [
result_files = [] "^\\.git$",
result_dirs = [] "^.*/\\.git$",
]
def mkdir_p(path):
if not os.path.isdir(path):
os.makedirs(path)
def clean_copy_files(dir, destination_dir):
for root, dirs, files in os.walk(dir, topdown=False): for root, dirs, files in os.walk(dir, topdown=False):
for name in files: for name in files:
result_files.append(os.path.relpath(os.path.join(root, name), dir)) skip_file = False
for pattern in ignore_patterns_when_copying:
if re.match(pattern, name):
skip_file = True
break
if skip_file:
continue
file_path = os.path.relpath(os.path.join(root, name), dir)
dir_path = os.path.dirname(file_path)
mkdir_p(destination_dir + "/" + dir_path)
shutil.copy(dir + "/" + file_path, destination_dir + "/" + file_path)
for name in dirs: for name in dirs:
result_dirs.append(os.path.relpath(os.path.join(root, name), dir)) skip_file = False
return set(result_dirs), set(result_files) for pattern in ignore_patterns_when_copying:
if re.match(pattern, name):
skip_file = True
break
if skip_file:
continue
dir_path = os.path.relpath(os.path.join(root, name), dir)
if os.path.islink(dir + "/" + dir_path):
continue
mkdir_p(destination_dir + "/" + dir_path)
def clean_files(base_dir, dirs, files): def clean_files(base_dir, dirs, files):
for file in files: for file in files:
@ -36,56 +61,47 @@ if len(sys.argv) != 2:
destination = sys.argv[1] destination = sys.argv[1]
initial_dirs, initial_files = get_file_list(destination) deps_data = os.popen("""bazel query 'kind("source file", deps(//Wallet:Wallet))'""").read().splitlines()
for file in initial_files: buildfile_deps_data = os.popen("""bazel query 'buildfiles(deps(//Wallet:Wallet))'""").read().splitlines()
if re.match('^\\.git/.*$', file):
directories = set()
for line in deps_data + buildfile_deps_data:
if len(line) == 0:
continue continue
os.remove(destination + '/' + file) if line[:1] == "@":
for dir in initial_dirs:
if dir == '.git' or re.match('^\\.git/.*$', dir):
continue continue
shutil.rmtree(destination + '/' + dir, ignore_errors=True) if line[:2] != "//":
deps_data = os.popen('make -f Wallet.makefile --silent wallet_deps').read()
deps = json.loads(deps_data)
paths = []
for dep in deps:
dep_type = deps[dep]['buck.type']
if dep_type == 'genrule':
continue continue
match = re.search('//(.+?):', dep) file_path = line[2:].replace(":", "/")
if match: if file_path.startswith("build-input"):
dep_path = match.group(1) continue
if dep_path not in paths: if file_path.startswith("external"):
paths.append(dep_path) continue
file_name = os.path.basename(file_path)
file_dir = os.path.dirname(file_path)
for dep_path in paths: mkdir_p(destination + "/" + file_dir)
shutil.copytree(dep_path, destination + '/' + dep_path) shutil.copy(file_path, destination + '/' + file_path)
dep_dirs, dep_files = get_file_list(destination + '/' + dep_path)
clean_dep_files(destination + '/' + dep_path, dep_dirs, dep_files)
result_dirs, result_files = get_file_list(destination) additional_paths = [
clean_files(destination, result_dirs, result_files) ".gitignore",
"WORKSPACE",
with open(destination + '/BUCK', 'w+b') as file: "build-system/xcode_version",
pass "build-system/bazel_version",
"build-system/bazel-rules",
shutil.copytree('Config', destination + '/' + 'Config') "build-system/tulsi",
shutil.copytree('tools/buck-build', destination + '/' + 'tools/buck-build') "build-system/prepare-build.sh",
"build-system/generate-xcode-project.sh",
shutil.copy('Wallet/README.md', destination + '/' + 'README.md') "build-system/copy-provisioning-profiles-Wallet.sh",
os.remove(destination + '/Wallet/' + 'README.md') "build-system/prepare-build-variables-Wallet.sh",
".bazelrc",
copy_files = [ "Utils.makefile",
'.buckconfig', "Wallet.makefile",
'.gitignore',
'Utils.makefile',
'Wallet.makefile',
'check_env.sh',
'package_app.sh',
] ]
for file in copy_files: for file_path in additional_paths:
shutil.copy(file, destination + '/' + file) if os.path.isdir(file_path):
clean_copy_files(file_path, destination + '/' + file_path)
else:
shutil.copy(file_path, destination + '/' + file_path)