Skip to content

Commit

Permalink
Merge pull request #203 from garrettmoon/master
Browse files Browse the repository at this point in the history
Upgrade to python3 / fix build on 12.3
  • Loading branch information
garrettmoon authored Apr 7, 2022
2 parents 5b03215 + 2071382 commit 2096f5c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
5.1.0
26 changes: 13 additions & 13 deletions BazelExtensions/acknowledgement_merger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import sys
import plistlib
from sets import Set

if len(sys.argv) < 3:
print("Usage <merge|finalize> output_file [inputs]")
Expand All @@ -12,21 +11,22 @@
action = sys.argv[1]

merged_fragments = []
seen_licenses = Set()
seen_licenses = set()
for idx, arg in enumerate(sys.argv):
if idx <= 2:
continue
input_plist = plistlib.readPlist(arg)
if not input_plist:
continue
fragments = input_plist if isinstance(input_plist, list) else [input_plist]
for fragment in fragments:
# We only want to insert a given software license 1 time
title = fragment.get("Title")
if title in seen_licenses:
with open(arg, 'rb') as f:
input_plist = plistlib.load(f, fmt=plistlib.FMT_XML)
if not input_plist:
continue
seen_licenses.add(title)
merged_fragments.append(fragment)
fragments = input_plist if isinstance(input_plist, list) else [input_plist]
for fragment in fragments:
# We only want to insert a given software license 1 time
title = fragment.get("Title")
if title in seen_licenses:
continue
seen_licenses.add(title)
merged_fragments.append(fragment)

if action == "--finalize":
out_plist = {
Expand Down
2 changes: 1 addition & 1 deletion BazelExtensions/headermap_builder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function

import json
Expand Down
6 changes: 5 additions & 1 deletion BazelExtensions/headermap_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# This file is part of The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
Expand Down Expand Up @@ -31,6 +31,8 @@ class HeaderMap(object):
def frompath(path):
with open(path, 'rb') as f:
magic = f.read(4)
if isinstance(magic, bytes):
magic = magic.decode("utf-8")
if magic == k_header_magic_LE:
endian_code = '<'
elif magic == k_header_magic_BE:
Expand Down Expand Up @@ -84,6 +86,8 @@ def frompath(path):
raise SystemExit("error: %s: unable to read zero-sized string table"%(
path,))
strtable = f.read(strtable_size)
if isinstance(strtable, bytes):
strtable = strtable.decode("utf-8")

if len(strtable) != strtable_size:
raise SystemExit("error: %s: unable to read complete string table"%(
Expand Down
2 changes: 1 addition & 1 deletion Examples/BasiciOS/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
5.1.0
11 changes: 2 additions & 9 deletions Examples/BasiciOS/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ load("@rules_pods//BazelExtensions:workspace.bzl", "new_pod_repository")

http_archive(
name = "build_bazel_rules_apple",
sha256 = "a41a75c291c69676b9974458ceee09aea60cee0e1ee282e27cdc90b679dfd30f",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.21.2/rules_apple.0.21.2.tar.gz",
sha256 = "77e8bf6fda706f420a55874ae6ee4df0c9d95da6c7838228b26910fc82eea5a2",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.32.0/rules_apple.0.32.0.tar.gz",
)

load(
Expand All @@ -34,13 +34,6 @@ load(

swift_rules_dependencies()

load(
"@com_google_protobuf//:protobuf_deps.bzl",
"protobuf_deps",
)

protobuf_deps()

new_pod_repository(
name = "SlackTextViewController",
url = "https://github.com/slackhq/SlackTextViewController/archive/v1.9.6.zip",
Expand Down
2 changes: 1 addition & 1 deletion Examples/React/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
5.1.0
11 changes: 2 additions & 9 deletions Examples/React/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ http_archive(

http_archive(
name = "build_bazel_rules_apple",
sha256 = "a41a75c291c69676b9974458ceee09aea60cee0e1ee282e27cdc90b679dfd30f",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.21.2/rules_apple.0.21.2.tar.gz",
sha256 = "77e8bf6fda706f420a55874ae6ee4df0c9d95da6c7838228b26910fc82eea5a2",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.32.0/rules_apple.0.32.0.tar.gz",
)

load(
Expand All @@ -31,10 +31,3 @@ load(
)

swift_rules_dependencies()

load(
"@com_google_protobuf//:protobuf_deps.bzl",
"protobuf_deps",
)

protobuf_deps()
6 changes: 3 additions & 3 deletions bin/update_pods.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
# update_pods.py Installs pods specified in Pods.WORKSPACE to $SRC_ROOT/Vendor/

from subprocess import Popen, PIPE
Expand Down Expand Up @@ -129,7 +129,7 @@ def GetTrace(self):
return self.trace

def HashFile(path):
f = open(path, "r")
f = open(path, "rb")
f_hash = str(hash(f.read()))
f.close()
return str(f_hash)
Expand Down Expand Up @@ -203,7 +203,7 @@ def _needs_update(invocation_info):
pod_root_dir = repository_ctx.GetPodRootDir()
_exec(repository_ctx, ["/bin/bash", "-c", "mkdir -p " + pod_root_dir])
_exec(repository_ctx, ["/bin/bash", "-c", "touch .pod-version"], pod_root_dir)
cached_version = _exec(repository_ctx, ["/bin/bash", "-c", "cat .pod-version"], pod_root_dir).split("\n")[0]
cached_version = _exec(repository_ctx, ["/bin/bash", "-c", "cat .pod-version"], pod_root_dir).split(b'\n')[0]
return GetVersion(invocation_info) != cached_version

def _load_repo_if_needed(repository_ctx, repo_tool_bin_path):
Expand Down

0 comments on commit 2096f5c

Please sign in to comment.