mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Cleanup
This commit is contained in:
parent
ab5ffaf673
commit
113df0b53d
@ -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}"
|
||||
},
|
||||
)
|
@ -1,6 +1,3 @@
|
||||
load("//build-system/bazel-utils:defines.bzl",
|
||||
"string_value",
|
||||
)
|
||||
|
||||
def _plist_fragment(ctx):
|
||||
output = ctx.outputs.out
|
||||
|
1
build-system/bazel_version
Normal file
1
build-system/bazel_version
Normal file
@ -0,0 +1 @@
|
||||
2.2.0
|
@ -1,18 +1,43 @@
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
|
||||
def get_file_list(dir):
|
||||
result_files = []
|
||||
result_dirs = []
|
||||
ignore_patterns_when_copying = [
|
||||
"^\\.git$",
|
||||
"^.*/\\.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 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:
|
||||
result_dirs.append(os.path.relpath(os.path.join(root, name), dir))
|
||||
return set(result_dirs), set(result_files)
|
||||
skip_file = False
|
||||
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):
|
||||
for file in files:
|
||||
@ -36,56 +61,47 @@ if len(sys.argv) != 2:
|
||||
|
||||
destination = sys.argv[1]
|
||||
|
||||
initial_dirs, initial_files = get_file_list(destination)
|
||||
for file in initial_files:
|
||||
if re.match('^\\.git/.*$', file):
|
||||
deps_data = os.popen("""bazel query 'kind("source file", deps(//Wallet:Wallet))'""").read().splitlines()
|
||||
buildfile_deps_data = os.popen("""bazel query 'buildfiles(deps(//Wallet:Wallet))'""").read().splitlines()
|
||||
|
||||
directories = set()
|
||||
|
||||
for line in deps_data + buildfile_deps_data:
|
||||
if len(line) == 0:
|
||||
continue
|
||||
os.remove(destination + '/' + file)
|
||||
for dir in initial_dirs:
|
||||
if dir == '.git' or re.match('^\\.git/.*$', dir):
|
||||
if line[:1] == "@":
|
||||
continue
|
||||
shutil.rmtree(destination + '/' + dir, ignore_errors=True)
|
||||
|
||||
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':
|
||||
if line[:2] != "//":
|
||||
continue
|
||||
match = re.search('//(.+?):', dep)
|
||||
if match:
|
||||
dep_path = match.group(1)
|
||||
if dep_path not in paths:
|
||||
paths.append(dep_path)
|
||||
file_path = line[2:].replace(":", "/")
|
||||
if file_path.startswith("build-input"):
|
||||
continue
|
||||
if file_path.startswith("external"):
|
||||
continue
|
||||
file_name = os.path.basename(file_path)
|
||||
file_dir = os.path.dirname(file_path)
|
||||
|
||||
for dep_path in paths:
|
||||
shutil.copytree(dep_path, destination + '/' + dep_path)
|
||||
dep_dirs, dep_files = get_file_list(destination + '/' + dep_path)
|
||||
clean_dep_files(destination + '/' + dep_path, dep_dirs, dep_files)
|
||||
mkdir_p(destination + "/" + file_dir)
|
||||
shutil.copy(file_path, destination + '/' + file_path)
|
||||
|
||||
result_dirs, result_files = get_file_list(destination)
|
||||
clean_files(destination, result_dirs, result_files)
|
||||
|
||||
with open(destination + '/BUCK', 'w+b') as file:
|
||||
pass
|
||||
|
||||
shutil.copytree('Config', destination + '/' + 'Config')
|
||||
shutil.copytree('tools/buck-build', destination + '/' + 'tools/buck-build')
|
||||
|
||||
shutil.copy('Wallet/README.md', destination + '/' + 'README.md')
|
||||
os.remove(destination + '/Wallet/' + 'README.md')
|
||||
|
||||
copy_files = [
|
||||
'.buckconfig',
|
||||
'.gitignore',
|
||||
'Utils.makefile',
|
||||
'Wallet.makefile',
|
||||
'check_env.sh',
|
||||
'package_app.sh',
|
||||
additional_paths = [
|
||||
".gitignore",
|
||||
"WORKSPACE",
|
||||
"build-system/xcode_version",
|
||||
"build-system/bazel_version",
|
||||
"build-system/bazel-rules",
|
||||
"build-system/tulsi",
|
||||
"build-system/prepare-build.sh",
|
||||
"build-system/generate-xcode-project.sh",
|
||||
"build-system/copy-provisioning-profiles-Wallet.sh",
|
||||
"build-system/prepare-build-variables-Wallet.sh",
|
||||
".bazelrc",
|
||||
"Utils.makefile",
|
||||
"Wallet.makefile",
|
||||
]
|
||||
|
||||
for file in copy_files:
|
||||
shutil.copy(file, destination + '/' + file)
|
||||
for file_path in additional_paths:
|
||||
if os.path.isdir(file_path):
|
||||
clean_copy_files(file_path, destination + '/' + file_path)
|
||||
else:
|
||||
shutil.copy(file_path, destination + '/' + file_path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user