Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update target/variant/modifier logic in build_examples.py #23054

Merged
merged 69 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2893b27
Starting to add some build target logic and unit tests
andy31415 Oct 5, 2022
77fa84d
Restyle
andy31415 Oct 5, 2022
45650a4
make basic unit tests pass
andy31415 Oct 5, 2022
b5f9c42
More unit tests
andy31415 Oct 5, 2022
b4188d0
Restyle
andy31415 Oct 5, 2022
ec259c2
Update prefix logic: use the builder prefix as well
andy31415 Oct 5, 2022
b1643cc
Prepare to move build targets for linux
andy31415 Oct 5, 2022
13bb846
More conversion tests
andy31415 Oct 5, 2022
3cf6f6a
more conversions
andy31415 Oct 5, 2022
3e03e46
Converted more targets
andy31415 Oct 5, 2022
bbc029a
Converted more targets
andy31415 Oct 5, 2022
0847480
Updted more targets
andy31415 Oct 5, 2022
31b7f4c
Simplify target part
andy31415 Oct 5, 2022
4b967d7
Restyle
andy31415 Oct 5, 2022
ee9bd0a
All applications are converted
andy31415 Oct 5, 2022
9cd533e
Remove old target code - should not be needed anymore
andy31415 Oct 5, 2022
28bb6e5
Restyle
andy31415 Oct 5, 2022
4bc52aa
Building at least chip-tool works. No introspection though
andy31415 Oct 5, 2022
9b05be0
Fix typo in m5 builds
andy31415 Oct 5, 2022
7263085
A bit easier to parse logging
andy31415 Oct 5, 2022
6f39558
More updates
andy31415 Oct 5, 2022
a46d644
Add ability to output all variants of some target
andy31415 Oct 6, 2022
4810c3c
Restyle
andy31415 Oct 6, 2022
d151f1b
Add the ability to print all possible targets
andy31415 Oct 6, 2022
76fef85
Add esp32 qemu support
andy31415 Oct 6, 2022
f3e4c57
Restyle
andy31415 Oct 6, 2022
07fcd35
Fix typo
andy31415 Oct 6, 2022
866921a
Simplify target printout, make nrf tests work
andy31415 Oct 6, 2022
705655f
Restyle
andy31415 Oct 6, 2022
9aa07f6
Remove some usages of target glob
andy31415 Oct 6, 2022
5407ffe
Replace glob in build scripts
andy31415 Oct 6, 2022
1375af3
Restyle
andy31415 Oct 6, 2022
c867517
convert some globs into instructions, fix some target compile bugs
andy31415 Oct 6, 2022
fcdae7c
make unit tests pass
andy31415 Oct 6, 2022
68919c3
more unit tests
andy31415 Oct 6, 2022
3c893d1
Restyle
andy31415 Oct 6, 2022
b829199
Remove the default of "all" in build targets since that does not mean…
andy31415 Oct 6, 2022
30bf993
Rename arm64-clang to arm64 in targets for cloudbuild smoke test
andy31415 Oct 6, 2022
5767939
For arm64, clang is a modifier that is required
andy31415 Oct 6, 2022
241f58d
Remove some whitespace.Tested that targets are ok
andy31415 Oct 6, 2022
a7aae5c
Fix ameba
andy31415 Oct 6, 2022
d7b9ebc
Fix tizen
andy31415 Oct 6, 2022
0537862
Fix infineon
andy31415 Oct 6, 2022
67831d2
Fix qpg
andy31415 Oct 6, 2022
68488b9
Fix infineon, cc13x2x7 and update android a bit
andy31415 Oct 6, 2022
c125fc3
Fix linux standalone
andy31415 Oct 6, 2022
8355edc
Fix efr32
andy31415 Oct 6, 2022
1e75a25
Fix esp32
andy31415 Oct 6, 2022
074a902
Remove glob option from tasks.json
andy31415 Oct 6, 2022
80a0d18
Fix platform naming for targets - fixes darwin target naming
andy31415 Oct 6, 2022
19ffd8b
Fix k32w targets - no more release
andy31415 Oct 6, 2022
9c4669d
Adjust arm64 cross compile target names
andy31415 Oct 6, 2022
3775422
Fix boufallolab app target
andy31415 Oct 6, 2022
f09094b
All-clusters full thread device does not link (insufficient ram/flash…
andy31415 Oct 6, 2022
7d0ea1a
Merge branch 'master' into build_variant_update
andy31415 Oct 6, 2022
1614424
Update k32w example builds: nologs is mandatory for low-power builds
andy31415 Oct 6, 2022
bd21b1c
Fix output dir for boufallolab: output should be all lowercase
andy31415 Oct 6, 2022
743f2db
Add back the test/extra_tests variant to host builds
andy31415 Oct 6, 2022
c57cc9c
Fix qpg size reports
andy31415 Oct 6, 2022
045b5be
Update unit tests for available outpust now that test variant was added
andy31415 Oct 6, 2022
1e64e41
Fix expected paths for cc13x2x7 builds
andy31415 Oct 6, 2022
dc833f5
Fix typo in infineon build
andy31415 Oct 6, 2022
e096252
Fix BL702 path for output - duplicate boufallolab
andy31415 Oct 6, 2022
885efb6
Allow rpc modifier for BL706
andy31415 Oct 6, 2022
c1678f5
Fix unit tests
andy31415 Oct 6, 2022
57fc675
Move nltestrunner to esp32 test runner and include in cloudbuild
andy31415 Oct 7, 2022
05be0b6
Undo duplicate build target addition
andy31415 Oct 7, 2022
ad052dc
Fix typo: esp32 -> efr32
andy31415 Oct 7, 2022
3beceac
Split out fake platform: only tests are really supported there
andy31415 Oct 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ability to output all variants of some target
  • Loading branch information
andy31415 committed Oct 6, 2022
commit a46d6446a84646e9e7cbd191c8b7d821e2396eda
60 changes: 59 additions & 1 deletion scripts/build/build/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
# combination of platform/board/app/modifier(s). This requirement is unenfornced in code
# but easy enough to follow when defining names for things: just don't reuse names between '-'

import itertools
import logging
import os
import re

from typing import Any, Optional
from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any, Optional


@dataclass(init=False)
Expand Down Expand Up @@ -254,6 +256,62 @@ def HumanString(self):

return result

def AllVariants(self) -> Iterable[str]:
"""Returns all possible accepted variants by this target.

For example name-{a,b}-{c,d}[-1][-2] could return (there may be Only/ExceptIfRe rules):

name-a-c
name-a-c-1
name-a-c-2
name-a-c-1-2
name-a-d
name-a-d-1
...
name-b-d-2
name-b-d-1-2

Notice that this DOES increase exponentially and is potentially a very long list
"""

# Output is made out of 2 separate parts:
# - a valid combination of "fixed parts"
# - a combination of modifiers

fixed_indices = [0]*len(self.fixed_targets)

while True:

prefix = "-".join(map(
lambda p: self.fixed_targets[p[0]][p[1]].name, enumerate(fixed_indices)
))

for n in range(len(self.modifiers) + 1):
for c in itertools.combinations(self.modifiers, n):
suffix = ""
for m in c:
suffix += "-" + m.name
option = f"{self.name}-{prefix}{suffix}"

if self.StringIntoTargetParts(option) is not None:
yield option

# Move to the next index in fixed_indices or exit loop if we cannot move
move_idx = len(fixed_indices) - 1
while move_idx >= 0:
if fixed_indices[move_idx] + 1 < len(self.fixed_targets[move_idx]):
fixed_indices[move_idx] += 1
break

# need to move the previous value
fixed_indices[move_idx] = 0
move_idx -= 1

if move_idx < 0:
# done iterating through all
return


def StringIntoTargetParts(self, value: str):
"""Given an input string, process through all the input rules and return
the underlying list of target parts for the input.
Expand Down
42 changes: 42 additions & 0 deletions scripts/build/build/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,48 @@ def test_modifiers(self):
"fake-{foo,bar}-{one,two}[-m1][-m2][-x1][-y1]"
)

self.assertEqual(
set(t.AllVariants()),
{
'fake-foo-one',
'fake-foo-one-m1',
'fake-foo-one-m1-x1',
'fake-foo-one-m1-x1-y1',
'fake-foo-one-m1-y1',
'fake-foo-one-m2',
'fake-foo-one-m2-x1',
'fake-foo-one-m2-x1-y1',
'fake-foo-one-m2-y1',
'fake-foo-one-x1',
'fake-foo-one-x1-y1',
'fake-foo-one-y1',
'fake-foo-two',
'fake-foo-two-m1',
'fake-foo-two-m1-x1',
'fake-foo-two-m1-x1-y1',
'fake-foo-two-m1-y1',
'fake-foo-two-m2',
'fake-foo-two-m2-x1',
'fake-foo-two-m2-x1-y1',
'fake-foo-two-m2-y1',
'fake-foo-two-x1',
'fake-foo-two-x1-y1',
'fake-foo-two-y1',
'fake-bar-one',
'fake-bar-one-m1',
'fake-bar-one-m1-x1',
'fake-bar-one-m2',
'fake-bar-one-m2-x1',
'fake-bar-one-x1',
'fake-bar-two',
'fake-bar-two-m1',
'fake-bar-two-m1-x1',
'fake-bar-two-m2',
'fake-bar-two-m2-x1',
'fake-bar-two-x1',
}
)

self.assertIsNotNone(t.StringIntoTargetParts('fake-foo-one'))
self.assertIsNotNone(t.StringIntoTargetParts('fake-bar-one-m1'))
self.assertIsNotNone(t.StringIntoTargetParts('fake-foo-one-m2'))
Expand Down