summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2017-04-06 11:30:59 +0900
committerMyungJoo Ham <myungjoo.ham@samsung.com>2017-04-06 11:30:59 +0900
commiteb65c6b1e3e5e9e32ba00f64c74381e7d2c6258b (patch)
tree7f96c347128b677a89ce10a8292e85975954203f
parentc6d65cb0793b213025e66130507b5ac5be2e00e5 (diff)
downloadbuilding-blocks-eb65c6b1e3e5e9e32ba00f64c74381e7d2c6258b.tar.gz
building-blocks-eb65c6b1e3e5e9e32ba00f64c74381e7d2c6258b.tar.bz2
building-blocks-eb65c6b1e3e5e9e32ba00f64c74381e7d2c6258b.zip
RULE: sub3 is allowed. rulecheck updated.
RULE and rule checker updated 1. sub3 is allowed (but warning is emitted) Change-Id: I7668cd19d3dbd7efa591cf6d5138150ac2b86e37 Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
-rw-r--r--RULES18
-rwxr-xr-xrule_checker.py41
2 files changed, 41 insertions, 18 deletions
diff --git a/RULES b/RULES
index 9f3e15c..457923f 100644
--- a/RULES
+++ b/RULES
@@ -6,7 +6,10 @@
1-2. The top-single block name is "building-blocks"
-1-3. Level prefix = "root" | "sub1" | "sub2"
+1-3. Level prefix = "root" | "sub1" | "sub2" | "sub3"
+ However, using deep down to sub3 is not recommended (WARNING)
+
+1-3-A. Using "sub3" is not recommended (WARNING)
1-4. Except for the top-single block, Level prfix follows
the first prefix.
@@ -20,10 +23,10 @@
[first prefix]-[level prefix = "sub1"]-[root name = "ROOTNAME"]-[NAME]
E.g., "building-blocks-sub1-UI-wayland"
-1-7. For "sub2" building blocks, which has a "sub1" building block, "SUB1NAME" as its parent, the naming rule is:
- (SUB1NAME has ROOTNAME as its parent)
- [first prefix]-[level prefix = "sub2"]-[root name = "ROOTNAME"]-[sub1 name = "SUB1NAME"]-[NAME]
- E.g., "building-blocks-sub2-UI-wayland-core"
+1-7. For "sub{N}" (N>1) building blocks, which has a "sub{N-1}" building block, "SUB{M}NAME" as its parent at level M (M < N), the naming rule is:
+ [first prefix]-sub{N}-[root name = "ROOTNAME"]-[sub1 name = "SUB1NAME"]-...-[sub{N-1} name = "SUB{N-1}NAME"]-[NAME]
+ E.g., "building-blocks-sub2-UI-wayland-core",
+ "building-blocks-sub3-UI-wayland-core-extension_super"
1-8. In order to implement "radio-button" UI (choose only one), the block name starts with "chooseonlyone_"
E.g., "building-blocks-root-chooseonlyone_Kernel"
@@ -49,6 +52,9 @@
However, you need to get consents from all related stake-holders.
2-6. There cannot be any other relations defined between blocks.
+ Exception: preset and features blocks may Requires/Suggests
+ other blocks to populate themselves with higher readability.
+ Refer to RULE 5-4.
@@ -98,6 +104,6 @@
5.3. A block must NOT have any files included
5.4. A block that is not preset/feature cannot add "Requires"/"Suggests" on
-another block that is not a direct child of it
+another block that is not a direct child of it (ref. RULE 2.6)
E.g., sub2-* cannot Requires/Suggests another root/sub1/sub2
E.g., sub1-A cannot Requires/Suggests sub2-B-X
diff --git a/rule_checker.py b/rule_checker.py
index 28e1658..e587cfa 100755
--- a/rule_checker.py
+++ b/rule_checker.py
@@ -5,8 +5,8 @@
#############################################################
# Building Block Rule Checker #
#############################################################
-# This does not check all rules of "RULES"
-# This is a prototype with a lot of work in progress
+# This does not check all rules of "RULES".
+# The level of subblocks is limited to 3.
from __future__ import print_function
@@ -120,7 +120,7 @@ def ruleCheckInc(file):
cname = re.sub(r'^\s*((Suggests)|(Requires)):\s*%{name}-', r'', line)
if cname == line:
continue
- c = re.sub(r'^\s*((Suggests)|(Requires)):\s*%{name}-sub[12]-', r'', line)
+ c = re.sub(r'^\s*((Suggests)|(Requires)):\s*%{name}-sub[123]-', r'', line)
c = re.sub(r'\s*', r'', c)
c = re.sub(r'\n', r'', c)
@@ -193,11 +193,17 @@ def ruleCheckInc(file):
# RULE 1-3 / 1-4
if re.search(r'^\s*%package', line) and \
- not re.search(r'^\s*%package\s*((root)|(sub1)|(sub2))', line):
- error +=1
- print("ERROR: RULE 1.3 the send prefix should be root, sub1, or sub2.")
- report(file, lc, line)
- continue
+ not re.search(r'^\s*%package\s*((root)|(sub1)|(sub2))-', line):
+
+ if re.search(r'^\s*%package\s*sub3-', line):
+ warning += 1
+ print("WARNING: RULE 1-3-A. Try not to use sub3 level subblocks")
+ report(file, lc, fline)
+ else:
+ error +=1
+ print("ERROR: RULE 1.3 the send prefix should be root, sub1, sub2, or sub3.")
+ report(file, lc, line)
+ continue
# RULE 1-9 for root block (1-5)
if re.search(r'^\s*%package\s*root', line) and \
@@ -219,14 +225,22 @@ def ruleCheckInc(file):
if re.search(r'^\s*%package\s*sub2', line) and \
not re.search(r'^\s*%package\s*sub2-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+\s*$', line):
error += 1
- print("ERROR: RULE 1.9 not met with sub1 (RULE 1.7)")
+ print("ERROR: RULE 1.9 not met with sub2 (RULE 1.7)")
+ report(file, lc, line)
+ continue
+
+ # RULE 1-9 for sub3 block (1-7)
+ if re.search(r'^\s*%package\s*sub3', line) and \
+ not re.search(r'^\s*%package\s*sub3-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+\s*$', line):
+ error += 1
+ print("ERROR: RULE 1.9 not met with sub3 (RULE 1.7)")
report(file, lc, line)
continue
# Adding a new package. Register to the data structure for context-aware check
- if re.search(r'^\s*%package\s*((root)|(sub1)|(sub2))-', line):
+ if re.search(r'^\s*%package\s*((root)|(sub1)|(sub2)|(sub3))-', line):
# remove tag & prefixes
- n = re.sub(r'^\s*%package\s*((root)|(sub1)|(sub2))-', r'', line)
+ n = re.sub(r'^\s*%package\s*((root)|(sub1)|(sub2)|(sub3))-', r'', line)
# remove tailing whitespaces
n = re.sub(r'\s*', r'', n)
# remove trailing \n
@@ -245,6 +259,9 @@ def ruleCheckInc(file):
elif re.search(r'^\s*%package\s*sub2-', line):
l = 2
p = re.sub(r'^([a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-.*', r'\1', n)
+ elif re.search(r'^\s*%package\s*sub3-', line):
+ l = 3
+ p = re.sub(r'^([a-zA-Z0-9_]+-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-.*', r'\1', n)
p = re.sub(r'\n', r'', p) # remove trailing \n
print("Block: "+n+", level = "+str(l)+", parent = ["+p+"]")
@@ -292,7 +309,7 @@ def ruleCheckInc(file):
# remove tag
n = re.sub(r'^\s*%files\s+', r'', line)
# prefixes
- n = re.sub(r'^((root)|(sub1)|(sub2))-', r'', n)
+ n = re.sub(r'^((root)|(sub1)|(sub2)|(sub3))-', r'', n)
#remove trailing whitespaces / \n
n = re.sub(r'\s*', r'', n)
n = re.sub(r'\n', r'', n)