tools/buildman: Add env-flags section support
RFC PATCH 1/1 tools/buildman: Add env-flags section support
In some cases (such as building little endian MIPS with the ELDK toolchain) you need to set a variable in the environment in order for the build to complete. Add env-flags, similar to make-flags, to allow for this.
---
I have this as RFC since GetEnvSettings is a copy/paste of GetMakeArguments and that tells me there must be a pythonic way of extending / renaming GetMakeArguments to take the dict to work from as an argument. And as per my other email, ${variable-board} doesn't work so the README is actually incorrect.
tools/buildman/README | 24 +++++++++++++++++++++++ tools/buildman/builderthread.py | 6 ++++++ tools/buildman/toolchain.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)
tools/buildman/README +24 -0
@@ -676,6 +676,30 @@ It is expected that any variables added are dealt with in U-Boot's config.mk file and documented in the README. +Providing key/value pairs to the environment +============================================ + +U-Boot's build system supports a few environment variables (such as +CONFIG_USE_PRIVATE_LIBGCC) which affect the build product. These flags can be +specified in the buildman settings file. They can also be useful when building +U-Boot against other open source software. + +[env-flags] +mipsel-flags=CONFIG_USE_PRIVATE_LIBGCC=y +qemu_mipsel=${mipsel-flags} +maltael=${mipsel-flags} +pb1000=${mipsel-flags} +dbau1550_el=${mipsel-flags} + +This will set 'CONFIG_USE_PRIVATE_LIBGCC' to 'y' in the environment for +qemu_mipsel, maltael, pb100 and dbau1550_el. A special variable ${target} is +available to access the target name (qemu_mipsel, maltael, pb1000 and +dbau1550_el in this case). Variables are resolved recursively. + +It is expected that any variables added are dealt with in U-Boot's +config.mk file and documented in the README. + + Quick Sanity Check ==================
tools/buildman/builderthread.py +6 -0
@@ -174,6 +174,12 @@ class BuilderThread(threading.Thread): # Set up the environment and command line env = self.toolchain.MakeEnvironment() + + # Add additional flags + for flag in self.builder.toolchains.GetEnvSettings(brd): + key_val = flag.split('=') + env[key_val[0]] = key_val[1] + Mkdir(out_dir) args = [] cwd = work_dir
tools/buildman/toolchain.py +40 -0
@@ -111,6 +111,7 @@ class Toolchains: else: self.paths.append(value) self._make_flags = dict(bsettings.GetItems('make-flags')) + self._env_flags = dict(bsettings.GetItems('env-flags')) def Add(self, fname, test=True, verbose=False): """Add a toolchain to our list
@@ -245,3 +246,42 @@ class Toolchains: else: i += 1 return args + + def GetEnvSettings(self, board): + """Returns key=value pairs to set in the environment prior to 'make' + + The flags are in a section called 'env-flags'. Flags are named + after the target they represent, for example snapper9260=TESTING=1 + will set TESTING to 1 in the environment prior to invoking make when + building the snapper9260 board. + + References to other boards can be added in the string also. For + example: + + [env-flags] + at91-boards=ENABLE_AT91_TEST=1 + snapper9260=${at91-boards} BUILD_TAG=442 + snapper9g45=${at91-boards} BUILD_TAG=443 + + This will return 'ENABLE_AT91_TEST=1 BUILD_TAG=442' for snapper9260 + and 'ENABLE_AT91_TEST=1 BUILD_TAG=443' for snapper9g45. + + A special 'target' variable is set to the board target. + + Args: + board: Board object for the board to check. + Returns: + key=value parts to set in the environment for that board, or '' + if none + """ + self._env_flags['target'] = board.target + arg_str = self.ResolveReferences(self._env_flags, + self._env_flags.get(board.target, '')) + args = arg_str.split(' ') + i = 0 + while i < len(args): + if not args[i]: + del args[i] + else: + i += 1 + return args
Signature · 1 line
1.7.9.5
RFC PATCH 1/1 tools/buildman: Add env-flags section support
Hi Tom,
Quoted 39 lines · Tom Rini
In some cases (such as building little endian MIPS with the ELDK toolchain) you need to set a variable in the environment in order for the build to complete. Add env-flags, similar to make-flags, to allow for this.
Signed-off-by Tom Rini <[email protected]>---
I have this as RFC since GetEnvSettings is a copy/paste of GetMakeArguments and that tells me there must be a pythonic way of extending / renaming GetMakeArguments to take the dict to work from as an argument. And as per my other email, ${variable-board} doesn't work so the README is actually incorrect.
tools/buildman/README | 24 +++++++++++++++++++++++ tools/buildman/builderthread.py | 6 ++++++ tools/buildman/toolchain.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)tools/buildman/README +12
-0@@ -676,6 +676,30 @@ It is expected that any variables added are dealt with in U-Boot's config.mk file and documented in the README. +Providing key/value pairs to the environment +============================================ + +U-Boot's build system supports a few environment variables (such as +CONFIG_USE_PRIVATE_LIBGCC) which affect the build product. These flags can be +specified in the buildman settings file. They can also be useful when building +U-Boot against other open source software. + +[env-flags] +mipsel-flags=CONFIG_USE_PRIVATE_LIBGCC=y +qemu_mipsel=${mipsel-flags} +maltael=${mipsel-flags}
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's · line 700
Quoted 10 lines
tools/buildman/README +10
-0+pb1000=${mipsel-flags} +dbau1550_el=${mipsel-flags} + +This will set 'CONFIG_USE_PRIVATE_LIBGCC' to 'y' in the environment for +qemu_mipsel, maltael, pb100 and dbau1550_el. A special variable ${target} is +available to access the target name (qemu_mipsel, maltael, pb1000 and +dbau1550_el in this case). Variables are resolved recursively. + +It is expected that any variables added are dealt with in U-Boot's +config.mk file and documented in the README.
This should be equivalent to adding them on the 'make' command line. Is there somethign else?
Quoted 10 lines
tools/buildman/README +2
-0+ + Quick Sanity Check ==================tools/buildman/builderthread.py +0
-0
tools/buildman/builderthread.py class BuilderThread(threading.Thread): · line 182
Quoted 9 lines
tools/buildman/builderthread.py +6
-0@@ -174,6 +174,12 @@ class BuilderThread(threading.Thread): # Set up the environment and command line env = self.toolchain.MakeEnvironment() + + # Add additional flags + for flag in self.builder.toolchains.GetEnvSettings(brd): + key_val = flag.split('=') + env[key_val[0]] = key_val[1] +
I would say move this code into the MakeEnvironment() function mentioned above - that way the toolchain environment is all in one place.
Quoted 48 lines
tools/buildman/builderthread.py +0
-0Mkdir(out_dir) args = [] cwd = work_dirtools/buildman/toolchain.py +30
-0@@ -111,6 +111,7 @@ class Toolchains: else: self.paths.append(value) self._make_flags = dict(bsettings.GetItems('make-flags')) + self._env_flags = dict(bsettings.GetItems('env-flags')) def Add(self, fname, test=True, verbose=False): """Add a toolchain to our list@@ -245,3 +246,42 @@ class Toolchains: else: i += 1 return args + + def GetEnvSettings(self, board): + """Returns key=value pairs to set in the environment prior to 'make' + + The flags are in a section called 'env-flags'. Flags are named + after the target they represent, for example snapper9260=TESTING=1 + will set TESTING to 1 in the environment prior to invoking make when + building the snapper9260 board. + + References to other boards can be added in the string also. For + example: + + [env-flags] + at91-boards=ENABLE_AT91_TEST=1 + snapper9260=${at91-boards} BUILD_TAG=442 + snapper9g45=${at91-boards} BUILD_TAG=443 + + This will return 'ENABLE_AT91_TEST=1 BUILD_TAG=442' for snapper9260 + and 'ENABLE_AT91_TEST=1 BUILD_TAG=443' for snapper9g45. + + A special 'target' variable is set to the board target. + + Args: + board: Board object for the board to check. + Returns: + key=value parts to set in the environment for that board, or '' + if none + """ + self._env_flags['target'] = board.target
tools/buildman/toolchain.py class Toolchains: · line 287
Quoted 10 lines
tools/buildman/toolchain.py +10
-0+ arg_str = self.ResolveReferences(self._env_flags, + self._env_flags.get(board.target, '')) + args = arg_str.split(' ') + i = 0 + while i < len(args): + if not args[i]: + del args[i] + else: + i += 1 + return args
Yes this could go in a common function. You can pass the dictionary to it, and updates within the function will update the dictionary.
BTW I suppose we can replace the last 8 lines with something like:
return [arg for arg in arg_str.split(' ') if arg]
Regards,
Simon
RFC PATCH 1/1 tools/buildman: Add env-flags section support
Quoted 47 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
In some cases (such as building little endian MIPS with the ELDK toolchain) you need to set a variable in the environment in order for the build to complete. Add env-flags, similar to make-flags, to allow for this.
Signed-off-by Tom Rini <[email protected]>---
I have this as RFC since GetEnvSettings is a copy/paste of GetMakeArguments and that tells me there must be a pythonic way of extending / renaming GetMakeArguments to take the dict to work from as an argument. And as per my other email, ${variable-board} doesn't work so the README is actually incorrect.
tools/buildman/README | 24 +++++++++++++++++++++++ tools/buildman/builderthread.py | 6 ++++++ tools/buildman/toolchain.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)tools/buildman/README +17
-0@@ -676,6 +676,30 @@ It is expected that any variables added are dealt with in U-Boot's config.mk file and documented in the README. +Providing key/value pairs to the environment +============================================ + +U-Boot's build system supports a few environment variables (such as +CONFIG_USE_PRIVATE_LIBGCC) which affect the build product. These flags can be +specified in the buildman settings file. They can also be useful when building +U-Boot against other open source software. + +[env-flags] +mipsel-flags=CONFIG_USE_PRIVATE_LIBGCC=y +qemu_mipsel=${mipsel-flags} +maltael=${mipsel-flags} +pb1000=${mipsel-flags} +dbau1550_el=${mipsel-flags} + +This will set 'CONFIG_USE_PRIVATE_LIBGCC' to 'y' in the environment for +qemu_mipsel, maltael, pb100 and dbau1550_el. A special variable ${target} is
Quoted 8 lines
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's · line 700
Quoted 5 lines
tools/buildman/README +5
-0+available to access the target name (qemu_mipsel, maltael, pb1000 and +dbau1550_el in this case). Variables are resolved recursively. + +It is expected that any variables added are dealt with in U-Boot's +config.mk file and documented in the README.This should be equivalent to adding them on the 'make' command line. Is there somethign else?
Well ble-arg. I thought I had tried this already but apparently not. [make-flags]
qemu_mipsel=CONFIG_USE_PRIVATE_LIBGCC=y maltael=CONFIG_USE_PRIVATE_LIBGCC=y pb1000=CONFIG_USE_PRIVATE_LIBGCC=y dbau1550_el=CONFIG_USE_PRIVATE_LIBGCC=y
Gets me building all MIPS boards, so I'm just going to stick with that and we can drop env-flags.
[snip]
Quoted 12 lines
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's
Quoted 11 lines
tools/buildman/README +11
-0+ self._env_flags['target'] = board.target + arg_str = self.ResolveReferences(self._env_flags, + self._env_flags.get(board.target, '')) + args = arg_str.split(' ') + i = 0 + while i < len(args): + if not args[i]: + del args[i] + else: + i += 1 + return args
Quoted 6 lines
Yes this could go in a common function. You can pass the dictionary to it, and updates within the function will update the dictionary.
BTW I suppose we can replace the last 8 lines with something like:
return [arg for arg in
arg_str.split(' ')if arg]
Being a middling at best python person, how common is it to condense things down that far?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140823/b7297ae8/attachment.pgp>
RFC PATCH 1/1 tools/buildman: Add env-flags section support
Hi Tom,
Quoted 83 lines · Tom Rini
Quoted 47 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
In some cases (such as building little endian MIPS with the ELDK toolchain) you need to set a variable in the environment in order for the build to complete. Add env-flags, similar to make-flags, to allow for this.
Signed-off-by Tom Rini <[email protected]>---
I have this as RFC since GetEnvSettings is a copy/paste of GetMakeArguments and that tells me there must be a pythonic way of extending / renaming GetMakeArguments to take the dict to work from as an argument. And as per my other email, ${variable-board} doesn't work so the README is actually incorrect.
tools/buildman/README | 24 +++++++++++++++++++++++ tools/buildman/builderthread.py | 6 ++++++ tools/buildman/toolchain.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)tools/buildman/README +17
-0@@ -676,6 +676,30 @@ It is expected that any variables added are dealt with in U-Boot's config.mk file and documented in the README. +Providing key/value pairs to the environment +============================================ + +U-Boot's build system supports a few environment variables (such as +CONFIG_USE_PRIVATE_LIBGCC) which affect the build product. These flags can be +specified in the buildman settings file. They can also be useful when building +U-Boot against other open source software. + +[env-flags] +mipsel-flags=CONFIG_USE_PRIVATE_LIBGCC=y +qemu_mipsel=${mipsel-flags} +maltael=${mipsel-flags} +pb1000=${mipsel-flags} +dbau1550_el=${mipsel-flags} + +This will set 'CONFIG_USE_PRIVATE_LIBGCC' to 'y' in the environment for +qemu_mipsel, maltael, pb100 and dbau1550_el. A special variable ${target} isQuoted 8 lines
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's · line 700
Quoted 5 lines
tools/buildman/README +5
-0+available to access the target name (qemu_mipsel, maltael, pb1000 and +dbau1550_el in this case). Variables are resolved recursively. + +It is expected that any variables added are dealt with in U-Boot's +config.mk file and documented in the README.This should be equivalent to adding them on the 'make' command line. Is there somethign else?
Well ble-arg. I thought I had tried this already but apparently not. [make-flags]
qemu_mipsel=CONFIG_USE_PRIVATE_LIBGCC=y maltael=CONFIG_USE_PRIVATE_LIBGCC=y pb1000=CONFIG_USE_PRIVATE_LIBGCC=y dbau1550_el=CONFIG_USE_PRIVATE_LIBGCC=yGets me building all MIPS boards, so I'm just going to stick with that and we can drop env-flags.
[snip]
Quoted 15 lines
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's
Quoted 11 lines
tools/buildman/README +11
-0+ self._env_flags['target'] = board.target + arg_str = self.ResolveReferences(self._env_flags, + self._env_flags.get(board.target, '')) + args = arg_str.split(' ') + i = 0 + while i < len(args): + if not args[i]: + del args[i] + else: + i += 1 + return argsYes this could go in a common function. You can pass the dictionary to it, and updates within the function will update the dictionary.
Quoted 6 lines
Quoted 3 lines
BTW I suppose we can replace the last 8 lines with something like:
return [arg for arg in
arg_str.split(' ')if arg]Being a middling at best python person, how common is it to condense things down that far?
List comprehension is fairly common - it's a special idiom that I think Python people are quite proud of. I suppose I wasn't in a very Python mood when I wrote GetMakeArguments() originally.
Regards,
Simon
RFC PATCH 1/1 tools/buildman: Add env-flags section support
Quoted 88 lines · Simon Glass
Hi Tom,
Quoted 85 lines · Tom Rini
Quoted 47 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
In some cases (such as building little endian MIPS with the ELDK toolchain) you need to set a variable in the environment in order for the build to complete. Add env-flags, similar to make-flags, to allow for this.
Signed-off-by Tom Rini <[email protected]>---
I have this as RFC since GetEnvSettings is a copy/paste of GetMakeArguments and that tells me there must be a pythonic way of extending / renaming GetMakeArguments to take the dict to work from as an argument. And as per my other email, ${variable-board} doesn't work so the README is actually incorrect.
tools/buildman/README | 24 +++++++++++++++++++++++ tools/buildman/builderthread.py | 6 ++++++ tools/buildman/toolchain.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)tools/buildman/README +17
-0@@ -676,6 +676,30 @@ It is expected that any variables added are dealt with in U-Boot's config.mk file and documented in the README. +Providing key/value pairs to the environment +============================================ + +U-Boot's build system supports a few environment variables (such as +CONFIG_USE_PRIVATE_LIBGCC) which affect the build product. These flags can be +specified in the buildman settings file. They can also be useful when building +U-Boot against other open source software. + +[env-flags] +mipsel-flags=CONFIG_USE_PRIVATE_LIBGCC=y +qemu_mipsel=${mipsel-flags} +maltael=${mipsel-flags} +pb1000=${mipsel-flags} +dbau1550_el=${mipsel-flags} + +This will set 'CONFIG_USE_PRIVATE_LIBGCC' to 'y' in the environment for +qemu_mipsel, maltael, pb100 and dbau1550_el. A special variable ${target} isQuoted 8 lines
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's · line 700
Quoted 5 lines
tools/buildman/README +5
-0+available to access the target name (qemu_mipsel, maltael, pb1000 and +dbau1550_el in this case). Variables are resolved recursively. + +It is expected that any variables added are dealt with in U-Boot's +config.mk file and documented in the README.This should be equivalent to adding them on the 'make' command line. Is there somethign else?
Well ble-arg. I thought I had tried this already but apparently not. [make-flags]
qemu_mipsel=CONFIG_USE_PRIVATE_LIBGCC=y maltael=CONFIG_USE_PRIVATE_LIBGCC=y pb1000=CONFIG_USE_PRIVATE_LIBGCC=y dbau1550_el=CONFIG_USE_PRIVATE_LIBGCC=yGets me building all MIPS boards, so I'm just going to stick with that and we can drop env-flags.
[snip]
Quoted 17 lines
tools/buildman/README It is expected that any variables added are dealt with in U-Boot's
Quoted 11 lines
tools/buildman/README +11
-0+ self._env_flags['target'] = board.target + arg_str = self.ResolveReferences(self._env_flags, + self._env_flags.get(board.target, '')) + args = arg_str.split(' ') + i = 0 + while i < len(args): + if not args[i]: + del args[i] + else: + i += 1 + return argsYes this could go in a common function. You can pass the dictionary to it, and updates within the function will update the dictionary.
BTW I suppose we can replace the last 8 lines with something like:
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
return [arg for arg in
arg_str.split(' ')if arg]Being a middling at best python person, how common is it to condense things down that far?
List comprehension is fairly common - it's a special idiom that I think Python people are quite proud of. I suppose I wasn't in a very Python mood when I wrote
GetMakeArguments()originally.
Then I'm fine with a clean-up to condense things down. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140823/d79b518a/attachment.pgp>