| 1 | # $Id: testcase-kBuild-define.kmk 2718 2013-12-30 21:30:47Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # kBuild - testcase for the kBuild-define-* directives.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2011-2013 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
|---|
| 8 | #
|
|---|
| 9 | # This file is part of kBuild.
|
|---|
| 10 | #
|
|---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
|---|
| 12 | # it under the terms of the GNU General Public License as published by
|
|---|
| 13 | # the Free Software Foundation; either version 3 of the License, or
|
|---|
| 14 | # (at your option) any later version.
|
|---|
| 15 | #
|
|---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
|---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | # GNU General Public License for more details.
|
|---|
| 20 | #
|
|---|
| 21 | # You should have received a copy of the GNU General Public License
|
|---|
| 22 | # along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 |
|
|---|
| 26 | #DEPTH = ../..
|
|---|
| 27 | #include $(PATH_KBUILD)/header.kmk
|
|---|
| 28 |
|
|---|
| 29 | if 0
|
|---|
| 30 | # object definition syntax:
|
|---|
| 31 | # kobject <type> <name> [extends <object> [by <||>]] [object specific args...]
|
|---|
| 32 | # kendobj [<type> [name]]
|
|---|
| 33 | kobject kb-target MyTarget
|
|---|
| 34 | .TOOL = GCC
|
|---|
| 35 | .SOURCES = file.c
|
|---|
| 36 | kendobj
|
|---|
| 37 | else
|
|---|
| 38 | # Target definition.
|
|---|
| 39 | # kBuild-define-target <name> [extends <target> [by <||>]] [using <template>]
|
|---|
| 40 | # kBuild-endef-target [name]
|
|---|
| 41 | kBuild-define-target MyTarget
|
|---|
| 42 | _TOOL = GCC
|
|---|
| 43 | _SOURCES = file.c
|
|---|
| 44 | kBuild-endef-target
|
|---|
| 45 | endif
|
|---|
| 46 |
|
|---|
| 47 | if 0
|
|---|
| 48 | # accesses an already defined object.
|
|---|
| 49 | # syntax:
|
|---|
| 50 | # kaccess <type> <name>
|
|---|
| 51 | # kendacc [<type> [name]]
|
|---|
| 52 | kaccess kb-target MyTarget
|
|---|
| 53 | .SOURCES += file2.c
|
|---|
| 54 | kendacc
|
|---|
| 55 | else
|
|---|
| 56 | #kBuild-access-target MyTarget
|
|---|
| 57 | #_SOURCES += file2.c
|
|---|
| 58 | #kBuild-endacc-target
|
|---|
| 59 | endif
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | # Referencing an object variable, the object must exist.
|
|---|
| 63 | # syntax: [<type>@<name>].<property>
|
|---|
| 64 | [target@MyTarget]_SOURCES += file3.c
|
|---|
| 65 | $(info [target@MyTarget]_SOURCES is $([target@MyTarget]_SOURCES))
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | # Test #1
|
|---|
| 69 | kBuild-define-target BaseTarget using DUMMY
|
|---|
| 70 | _SOURCES = BaseTargetSource.c
|
|---|
| 71 | kBuild-endef-target BaseTarget
|
|---|
| 72 | $(if-expr "$([target@BaseTarget]_SOURCES)" == "BaseTargetSource.c",,$(error [target@BaseTarget]_SOURCES is '$([target@BaseTarget]_SOURCES)' not 'BaseTargetSource.c'))
|
|---|
| 73 | $(if-expr "$(BaseTarget_SOURCES)" == "BaseTargetSource.c",,$(error BaseTarget's _SOURCES wasn't set correctly in the global space))
|
|---|
| 74 |
|
|---|
| 75 | $(if-expr "$([target@BaseTarget]_TEMPLATE)" == "DUMMY",,$(error [target@BaseTarget]_TEMPLATE is '$([target@BaseTarget]_TEMPLATE)' not 'DUMMY'))
|
|---|
| 76 | $(if-expr "$(BaseTarget_TEMPLATE)" == "DUMMY",,$(error BaseTarget's _TEMPLATE wasn't set correctly in the global space))
|
|---|
| 77 |
|
|---|
| 78 | # Test #2
|
|---|
| 79 | kBuild-define-target TargetWithLocals
|
|---|
| 80 | local _LOCAL_PROP = no global alias
|
|---|
| 81 | kBuild-endef-target
|
|---|
| 82 | $(if-expr "$([target@TargetWithLocals]_LOCAL_PROP)" == "no global alias",,$(error [target@TargetWithLocals]_LOCAL_PROP is '$([target@TargetWithLocals]_LOCAL_PROP)' not 'no global alias'))
|
|---|
| 83 | $(if-expr "$(TargetWithLocals_LOCAL_PROP)" == "",,$(error TargetWithLocals_LOCAL_PROP's local property 'LOCAL_PROP' was exposed globally.))
|
|---|
| 84 |
|
|---|
| 85 | # Test #3
|
|---|
| 86 | kBuild-define-target OutsideMod
|
|---|
| 87 | _SOURCES = file3.c
|
|---|
| 88 | _OTHER = inside-value
|
|---|
| 89 | kBuild-endef-target
|
|---|
| 90 | [target@OutsideMod]_SOURCES += file4.c
|
|---|
| 91 | [target@OutsideMod]_SOURCES <= file2.c
|
|---|
| 92 | [target@OutsideMod]_OTHER = outside-value
|
|---|
| 93 | $(if-expr "$([target@OutsideMod]_SOURCES)" == "file2.c file3.c file4.c",,$(error [target@OutsideMod]_SOURCES is '$([target@OutsideMod]_SOURCES)' not 'file2.c file3.c file4.c'))
|
|---|
| 94 | $(if-expr "$(OutsideMod_SOURCES)" == "file2.c file3.c file4.c",,$(error OutsideMod_SOURCES is '$(OutsideMod_SOURCES)' not 'file2.c file3.c file4.c'))
|
|---|
| 95 |
|
|---|
| 96 | $(if-expr "$([target@OutsideMod]_OTHER)" == "outside-value",,$(error [target@OutsideMod]_OTHER is '$([target@OutsideMod]_OTHER)' not 'outside-value'))
|
|---|
| 97 | $(if-expr "$(OutsideMod_OTHER)" == "outside-value",,$(error OutsideMod_OTHER is '$(OutsideMod_OTHER)' not 'outside-value'))
|
|---|
| 98 |
|
|---|
| 99 | all_recursive:
|
|---|
| 100 | @kmk_echo "kBuild-define-xxxx works fine"
|
|---|
| 101 |
|
|---|