linux-huawei-cameron: py3 compat and use out-of-source build (MR 1202)
This commit is contained in:
parent
db671ccead
commit
f919b3e05a
2 changed files with 144 additions and 26 deletions
132
device/testing/linux-huawei-cameron/06-py3-compat.patch
Normal file
132
device/testing/linux-huawei-cameron/06-py3-compat.patch
Normal file
|
@ -0,0 +1,132 @@
|
|||
From a537d223a76b9fcccdec94e8d11ade8d1e723d45 Mon Sep 17 00:00:00 2001
|
||||
From: Alexey Min <alexey.min@gmail.com>
|
||||
Date: Sat, 2 May 2020 03:17:39 +0300
|
||||
Subject: [PATCH] port driver generator scripts to py3
|
||||
|
||||
---
|
||||
drivers/hisi/tzdriver/Makefile | 2 +-
|
||||
drivers/hisi/tzdriver/cfc_graph.py | 16 ++++++++++------
|
||||
drivers/hisi/tzdriver/cfc_graphgen.py | 4 ++--
|
||||
drivers/hisi/tzdriver/cfc_rule_parser.py | 4 +++-
|
||||
4 files changed, 16 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/drivers/hisi/tzdriver/Makefile b/drivers/hisi/tzdriver/Makefile
|
||||
index 45521e25..24b3235b 100644
|
||||
--- a/drivers/hisi/tzdriver/Makefile
|
||||
+++ b/drivers/hisi/tzdriver/Makefile
|
||||
@@ -17,7 +17,7 @@ obj-$(CONFIG_TEE_LIBHWSECUREC) += libhwsecurec/
|
||||
obj-$(CONFIG_TEE_CFC) += cfc_data.o cfc_coresight.o
|
||||
$(obj)/cfc_data.o: $(obj)/cfc_data.c
|
||||
$(obj)/cfc_data.c: $(src)/cfc_graphgen.py $(src)/cfc_graph.py $(src)/cfc_codegen.py $(src)/cfc_rule_parser.py $(src)/template $(obj)/rule.out
|
||||
- +python $(srctree)/$(src)/cfc_codegen.py $(obj)/rule.out > $@
|
||||
+ +python3 $(srctree)/$(src)/cfc_codegen.py $(obj)/rule.out > $@
|
||||
$(obj)/rule.out: $(src)/rule.in
|
||||
aarch64-linux-android-cpp $(srctree)/$(src)/rule.in > $@
|
||||
|
||||
diff --git a/drivers/hisi/tzdriver/cfc_graph.py b/drivers/hisi/tzdriver/cfc_graph.py
|
||||
index 9388f44d..b27cad76 100644
|
||||
--- a/drivers/hisi/tzdriver/cfc_graph.py
|
||||
+++ b/drivers/hisi/tzdriver/cfc_graph.py
|
||||
@@ -55,13 +55,13 @@ class NFAState(object):
|
||||
|
||||
# add an out state for a given event
|
||||
def addOutEdge(self, event, state):
|
||||
- if not self.transMap.has_key(event):
|
||||
+ if event not in self.transMap:
|
||||
self.transMap[event] = set()
|
||||
self.transMap[event].add(state)
|
||||
|
||||
# add a set of out states for a given event
|
||||
def addOutEdges(self, event, states):
|
||||
- if not self.transMap.has_key(event):
|
||||
+ if event not in self.transMap:
|
||||
self.transMap[event] = set()
|
||||
self.transMap[event] |= states
|
||||
|
||||
@@ -92,6 +92,10 @@ class DFAState(object):
|
||||
def __eq__(self, other):
|
||||
return self.idx == other.idx or self.NFAStates == other.NFAStates
|
||||
|
||||
+ def __hash__(self):
|
||||
+ # should hash the same values that are compared in __eq__()
|
||||
+ return hash((self.idx, tuple(self.NFAStates)))
|
||||
+
|
||||
# add a NFAState into NFAStateSet, also merge the flags
|
||||
# TODO: need a conflict detection method
|
||||
def addNFAStateSingle(self, nfaState):
|
||||
@@ -115,7 +119,7 @@ class DFAState(object):
|
||||
def genNextDFAState(self, event):
|
||||
nextDFAState = DFAState()
|
||||
for nfaState in self.NFAStates:
|
||||
- if not nfaState.transMap.has_key(event):
|
||||
+ if event not in nfaState.transMap:
|
||||
continue
|
||||
for nextNFAState in nfaState.transMap[event]:
|
||||
nextDFAState.addNFAState(nextNFAState)
|
||||
@@ -159,7 +163,7 @@ class Graph(object):
|
||||
|
||||
# add an event in dict and give it a sequential index
|
||||
def addEvent(self, flags, value):
|
||||
- if not self.events.has_key(value):
|
||||
+ if value not in self.events:
|
||||
if flags & Event.FLAG_WILDCARD:
|
||||
self.events[value] = Event(flags, value, Graph.EVENT_WILDCARD_IDX)
|
||||
else:
|
||||
@@ -196,7 +200,7 @@ class Graph(object):
|
||||
def completeNFAGraph(self):
|
||||
# 1. For GLOBAL events, non-STOP states (without out edge for these events) accepts them as loopback
|
||||
for event in filter(lambda x: x.flags & Event.FLAG_GLOBAL != 0, self.events.values()):
|
||||
- for nfaState in filter(lambda x: x.flags & NFAState.FLAG_STOP == 0 and not x.transMap.has_key(event), self.NFAStates.values()):
|
||||
+ for nfaState in filter(lambda x: x.flags & NFAState.FLAG_STOP == 0 and event not in x.transMap, self.NFAStates.values()):
|
||||
nfaState.addOutEdge(event, nfaState)
|
||||
|
||||
# 2. For RESET events, non-STOP states accept them and go to STATE_STOP_IDX state
|
||||
@@ -206,7 +210,7 @@ class Graph(object):
|
||||
|
||||
# 3. For WILDCARD events, replace it with all non-RESET events (there should be only 1 WILDCARD event)
|
||||
for event in filter(lambda x: x.flags & Event.FLAG_WILDCARD != 0, self.events.values()):
|
||||
- for nfaState in filter(lambda x: x.transMap.has_key(event), self.NFAStates.values()):
|
||||
+ for nfaState in filter(lambda x: event in x.transMap, self.NFAStates.values()):
|
||||
wildcastNextNFAStates = nfaState.transMap.pop(event)
|
||||
for otherEvent in self.events.values():
|
||||
if otherEvent.flags & (Event.FLAG_RESET | Event.FLAG_WILDCARD) == 0:
|
||||
diff --git a/drivers/hisi/tzdriver/cfc_graphgen.py b/drivers/hisi/tzdriver/cfc_graphgen.py
|
||||
index 5d614ea5..9d6d261a 100644
|
||||
--- a/drivers/hisi/tzdriver/cfc_graphgen.py
|
||||
+++ b/drivers/hisi/tzdriver/cfc_graphgen.py
|
||||
@@ -89,7 +89,7 @@ def parseCommandPatternUnit(context, graph, start, end, commandPattern):
|
||||
return
|
||||
|
||||
# check if the var is known
|
||||
- if commandPattern != '.' and not context.markers.has_key(commandPattern):
|
||||
+ if commandPattern != '.' and commandPattern not in context.markers:
|
||||
raise Exception('unrecorgnized var: {}'.format(commandPattern))
|
||||
|
||||
# only ATTRIBUTE_SEND_DATA_START event can reach FLAG_WAIT_DATA state
|
||||
@@ -161,7 +161,7 @@ def genNFAGraph(context):
|
||||
|
||||
start = graph.addNFAState()
|
||||
for commandID, commandPattern in context.commandPatterns:
|
||||
- if not finalStates.has_key(commandID):
|
||||
+ if commandID not in finalStates:
|
||||
finalStates[commandID] = graph.addNFAState().setSucceed().setStop().setCMD(int(commandID))
|
||||
parseCommandPattern(context, graph, start, finalStates[commandID], commandPattern)
|
||||
|
||||
diff --git a/drivers/hisi/tzdriver/cfc_rule_parser.py b/drivers/hisi/tzdriver/cfc_rule_parser.py
|
||||
index bf91a966..03e32c93 100644
|
||||
--- a/drivers/hisi/tzdriver/cfc_rule_parser.py
|
||||
+++ b/drivers/hisi/tzdriver/cfc_rule_parser.py
|
||||
@@ -61,7 +61,9 @@ class CFCRuleTextContent(object):
|
||||
# Var := Symbol[, Attribute]
|
||||
def parseMarker(self, s):
|
||||
s = s.replace(',', ' ')
|
||||
- tokens = filter(bool, s.split())
|
||||
+ # tokens = filter(bool, s.split())
|
||||
+ # same as tokens = [element for element in s.split if bool(element)]
|
||||
+ tokens = list(filter(bool, s.split()))
|
||||
if len(tokens) < 3 or len(tokens) > 4:
|
||||
raise Exception('Line {}: unexpected tokens numbers {}.'.format(self.lineNum, len(tokens)))
|
||||
if tokens[1] != ':=':
|
||||
--
|
||||
2.25.3
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pkgname=linux-huawei-cameron
|
||||
pkgver=4.4.23
|
||||
pkgrel=0
|
||||
pkgrel=1
|
||||
pkgdesc="Huawei Mediapad M5 Pro kernel fork"
|
||||
arch="aarch64"
|
||||
_carch="arm64"
|
||||
|
@ -10,7 +10,7 @@ _flavor="huawei-cameron"
|
|||
url="https://kernel.org"
|
||||
license="GPL2"
|
||||
options="!strip !check !tracedeps pmb:cross-native"
|
||||
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev python dtc"
|
||||
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev python3 dtc"
|
||||
|
||||
# Source
|
||||
_repository="android_kernel_huawei_hi3660"
|
||||
|
@ -23,9 +23,10 @@ source="
|
|||
03_add_compression_methods_to_Kconfig.patch
|
||||
04_make_rdr_hisi_adapter_compileable.patch
|
||||
05-disable-huawei-bfmr.patch
|
||||
06-py3-compat.patch
|
||||
"
|
||||
builddir="$srcdir/$_repository-$_commit"
|
||||
outdir="$srcdir/../out"
|
||||
_outdir="out"
|
||||
|
||||
prepare() {
|
||||
default_prepare
|
||||
|
@ -34,32 +35,16 @@ prepare() {
|
|||
|
||||
build() {
|
||||
unset LDFLAGS
|
||||
mkdir "$outdir"
|
||||
cp "$srcdir/$_config" "$outdir/.config"
|
||||
rm "$builddir/.config"
|
||||
make ARCH="$_carch" O="$outdir" oldconfig
|
||||
mkdir -p "$_outdir"
|
||||
cp "$srcdir/$_config" "$_outdir/.config"
|
||||
rm -f "$builddir/.config"
|
||||
make ARCH="$_carch" O="$_outdir" oldconfig
|
||||
make ARCH="$_carch" CC="${CC:-gcc}" \
|
||||
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" O="$outdir"
|
||||
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" O="$_outdir"
|
||||
}
|
||||
|
||||
package() {
|
||||
# kernel.release
|
||||
install -D "$outdir/include/config/kernel.release" \
|
||||
"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
|
||||
|
||||
# zImage (find the right one)
|
||||
cd "$outdir/arch/$_carch/boot"
|
||||
_target="$pkgdir/boot/vmlinuz-$_flavor"
|
||||
for _zimg in Image.gz zImage-dtb Image.gz-dtb *zImage Image; do
|
||||
[ -e "$_zimg" ] || continue
|
||||
msg "zImage found: $_zimg"
|
||||
install -Dm644 "$_zimg" "$_target"
|
||||
break
|
||||
done
|
||||
if ! [ -e "$_target" ]; then
|
||||
error "Could not find zImage in $PWD!"
|
||||
return 1
|
||||
fi
|
||||
downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
|
||||
}
|
||||
|
||||
sha512sums="1da7c7666f1bf8e3fd3931331b1ebf0ab9520fce47d44749c30abcef55856deaced0ffc74c025b323cc83eb36eb7cf9c514bc65eedbead5d40efd3e16ddc0486 linux-huawei-cameron-18cd8140ad09379365bcd9cb50e45662e8747834.tar.gz
|
||||
|
@ -67,4 +52,5 @@ sha512sums="1da7c7666f1bf8e3fd3931331b1ebf0ab9520fce47d44749c30abcef55856deaced0
|
|||
5473a038ca5703cf4119957ca3af66972c121aa66fe262a3165e5a0e5714037670a96600eedd0488150ff754ead93f43299587554ca6c05022bb55f780d1cd7a 01_use_linux_alpine_crosscompile.patch
|
||||
86afc1337a34524c49e9beaad6506f7038a7413340abc473f8d209a4d3cd6ebbcf8315ae41902427edf97064742c02e2e5bb705a8bcd36d1cae19f76a509e235 03_add_compression_methods_to_Kconfig.patch
|
||||
cdc60b6c829df3b014226b9cb506ed71cf005cf5fec8d4339b54a23f052465501aaa4983ec00f33ef301db2e6a70b24a30439b3f6ce8f7c00348c05d3132ec3f 04_make_rdr_hisi_adapter_compileable.patch
|
||||
6e420722576111a7ba49f265a66de632631c13d1bdb67553916d2156149226526daedc8298d83a38115c0a7189497cdb92b0daa0a263a92e6093f575e855a6e5 05-disable-huawei-bfmr.patch"
|
||||
6e420722576111a7ba49f265a66de632631c13d1bdb67553916d2156149226526daedc8298d83a38115c0a7189497cdb92b0daa0a263a92e6093f575e855a6e5 05-disable-huawei-bfmr.patch
|
||||
e783a5a775797efd229b049dba9a4eacd74b6dd7de2f37dfc0f9ead7c2ca3e617c162d8b28cec2d68fe5c51bff67a7045441b36b055582f07ff531f1dc445809 06-py3-compat.patch"
|
||||
|
|
Loading…
Reference in a new issue