VirtualBox

Changeset 1109 in kBuild


Ignore:
Timestamp:
Sep 24, 2007 2:27:14 AM (17 years ago)
Author:
bird
Message:

New feature: if1of and ifn1of (CONFIG_WITH_SET_CONDITIONALS).

Location:
trunk/src/kmk
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.am

    r986 r1109  
    110110        -DCONFIG_WITH_XARGS \
    111111        -DCONFIG_WITH_NANOTS \
     112        -DCONFIG_WITH_SET_CONDITIONALS \
    112113        -DCONFIG_PRETTY_COMMAND_PRINTING \
    113114        \
     
    116117        -DBUILD_PLATFORM_CPU=\"$(BUILD_TARGET_CPU)\" \
    117118        \
    118         -DKBUILD_VERSION_MAJOR=0 \
    119         -DKBUILD_VERSION_MINOR=1 \
    120         -DKBUILD_VERSION_PATCH=0 \
     119        -DKBUILD_VERSION_MAJOR=0 \
     120        -DKBUILD_VERSION_MINOR=1 \
     121        -DKBUILD_VERSION_PATCH=0 \
    121122        \
    122123        -DCONFIG_WITH_KMK_BUILTIN \
  • trunk/src/kmk/Makefile.kmk

    r1101 r1109  
    2626        $(PATH_TARGET)/pwd.h \
    2727        $(PATH_TARGET)/inttypes.h
     28TEMPLATE_BIN-KMK_CFLAGS.win.amd64 = $(TEMPLATE_BIN_CFLAGS.win.amd64) -wd4244 -wd4267
    2829TEMPLATE_BIN-KMK_CLEAN.win = $(TEMPLATE_BIN-KMK_DEPS.win)
    2930TEMPLATE_BIN-KMK_INCS = $(PATH_TARGET) . $(TEMPLATE_BIN_INCS)
     
    112113        CONFIG_WITH_XARGS \
    113114        CONFIG_WITH_NANOTS \
     115        CONFIG_WITH_SET_CONDITIONALS \
    114116        CONFIG_PRETTY_COMMAND_PRINTING \
    115117        \
     
    367369        $(MAKE) -f testcase-math.kmk
    368370
    369 
    370 test_all:       test_math test_stack test_shell
    371 
     371test_if1of:
     372        $(MAKE) -f testcase-if1of.kmk
     373
     374test_all:       test_math test_stack test_shell test_if1of
     375
  • trunk/src/kmk/read.c

    r1022 r1109  
    15191519
    15201520/* Interpret conditional commands "ifdef", "ifndef", "ifeq",
    1521    "ifneq", "else" and "endif".
     1521   "ifneq", "if1of", "ifn1of", "else" and "endif".
    15221522   LINE is the input line, with the command as its first word.
    15231523
     
    15341534{
    15351535  char *cmdname;
     1536#ifdef CONFIG_WITH_SET_CONDITIONALS
     1537  enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_if1of, c_ifn1of, c_else, c_endif } cmdtype;
     1538#else
    15361539  enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype;
     1540#endif
    15371541  unsigned int i;
    15381542  unsigned int o;
     
    15471551  else chkword ("ifeq", c_ifeq)
    15481552  else chkword ("ifneq", c_ifneq)
     1553#ifdef CONFIG_WITH_SET_CONDITIONALS
     1554  else chkword ("if1of", c_if1of)
     1555  else chkword ("ifn1of", c_ifn1of)
     1556#endif
    15491557  else chkword ("else", c_else)
    15501558  else chkword ("endif", c_endif)
     
    16871695  else
    16881696    {
     1697#ifdef CONFIG_WITH_SET_CONDITIONALS
     1698      /* "ifeq", "ifneq", "if1of" or "ifn1of". */
     1699#else
    16891700      /* "ifeq" or "ifneq".  */
     1701#endif
    16901702      char *s1, *s2;
    16911703      unsigned int l;
     
    17761788
    17771789      s2 = variable_expand (s2);
     1790#ifdef CONFIG_WITH_SET_CONDITIONALS
     1791      if (cmdtype == c_if1of || cmdtype == c_ifn1of)
     1792        {
     1793          const char *s1_cur;
     1794          unsigned int s1_len;
     1795          const char *s1_iterator = s1;
     1796
     1797          conditionals->ignoring[o] = (cmdtype == c_if1of); /* if not found */
     1798          while ((s1_cur = find_next_token (&s1_iterator, &s1_len)) != 0)
     1799            {
     1800              const char *s2_cur;
     1801              unsigned int s2_len;
     1802              const char *s2_iterator = s2;
     1803              while ((s2_cur = find_next_token (&s2_iterator, &s2_len)) != 0)
     1804                if (s2_len == s1_len
     1805                 && strneq (s2_cur, s1_cur, s1_len) )
     1806                  {
     1807                    conditionals->ignoring[o] = (cmdtype != c_if1of); /* found */
     1808                    break;
     1809                  }
     1810            }
     1811        }
     1812      else
     1813        conditionals->ignoring[o] = (streq (s1, s2) == (cmdtype == c_ifneq));
     1814#else
    17781815      conditionals->ignoring[o] = (streq (s1, s2) == (cmdtype == c_ifneq));
     1816#endif
    17791817    }
    17801818
     
    20692107                cmp timestamp maybe.h || cp -f timestamp maybe.h
    20702108
    2071         This is implemented in remake.c where we don't consider the mtime of 
     2109        This is implemented in remake.c where we don't consider the mtime of
    20722110        the maybe-updated targets. */
    20732111      if (multi_mode != m_no && name[0] == '+'
  • trunk/src/kmk/testcase-if1of.kmk

    r1100 r1109  
    11# $Id: $
    22## @file
     3# kBuild - testcase for the if1of and ifn1of conditionals.
    34#
    4 # kBuild - testcase for the functions.
     5
    56#
    6 # Copyright (c) 2006-2007 knut st. osmundsen <bird-kBuild[email protected]>
     7# Copyright (c) 2007 knut st. osmundsen <bird-src[email protected]>
    78#
     9# This file is part of kBuild.
    810#
    9 # This file is part of kLdr.
    10 #
    11 # kLdr is free software; you can redistribute it and/or modify
     11# kBuild is free software; you can redistribute it and/or modify
    1212# it under the terms of the GNU General Public License as published by
    1313# the Free Software Foundation; either version 2 of the License, or
    1414# (at your option) any later version.
    1515#
    16 # kLdr is distributed in the hope that it will be useful,
     16# kBuild is distributed in the hope that it will be useful,
    1717# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     
    2020#
    2121# You should have received a copy of the GNU General Public License
    22 # along with kLdr; if not, write to the Free Software
    23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     22# along with kBuild; if not, write to the Free Software
     23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    2424#
    2525#
     
    2828include $(PATH_KBUILD)/header.kmk
    2929
    30 ifneq ($(not 1),)
    31  $(error The 'not' function is missing)
     30# the basics.
     31if1of (asdf,asdf)
     32else
     33 $(error busted)
    3234endif
    33 ifneq ($(eq 1,1),1)
    34  $(error The 'eq' function is missing)
     35ifn1of (asdf,asdf)
     36 $(error busted)
    3537endif
    3638
    37 ASSERT1 = $(if $(not $(eq $(STACK1),$(1))),$(error failure: STACK1:='$(STACK1)' expected='$(1)'))
    38 $(call stack-push,STACK1,1)
    39 $(call ASSERT,1)
    40 $(call stack-push,STACK1,2)
    41 $(call ASSERT,1 2)
    42 $(call stack-push,STACK1,3)
    43 $(call ASSERT,1 2 3)
    44 $(call stack-push,STACK1,4)
    45 $(call ASSERT,1 2 3 4)
    46 $(call stack-push,STACK1,5)
    47 $(call ASSERT,1 2 3 4 5)
    48 $(call stack-popv,STACK1)
    49 $(call ASSERT,1 2 3 4)
    50 $(call stack-push,STACK1,5)
    51 $(call ASSERT,1 2 3 4 5)
    52 $(call stack-popv,STACK1)
    53 $(call ASSERT,1 2 3 4)
    54 $(call stack-popv,STACK1)
    55 $(call ASSERT,1 2 3)
    56 $(call stack-push,STACK1,4)
    57 $(call ASSERT,1 2 3 4)
    58 $(call stack-push,STACK1,5)
    59 $(call ASSERT,1 2 3 4 5)
    60 top := $(call stack-top,STACK1)
    61 $(if $(not $(eq $(top),5)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='5'))
    62 $(call ASSERT,1 2 3 4 5)
    63 top := $(call stack-pop,STACK1)
    64 $(if $(not $(eq $(top),5)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='5'))
    65 $(call ASSERT,1 2 3 4)
    66 top := $(call stack-pop,STACK1)
    67 $(if $(not $(eq $(top),4)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='4'))
    68 $(call ASSERT,1 2 3)
    69 top := $(call stack-pop,STACK1)
    70 $(if $(not $(eq $(top),3)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='3'))
    71 $(call ASSERT,1 2)
    72 top := $(call stack-pop,STACK1)
    73 $(if $(not $(eq $(top),2)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='2'))
    74 $(call ASSERT,1)
    75 top := $(call stack-top,STACK1)
    76 $(if $(not $(eq $(top),1)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='1'))
    77 $(call ASSERT,1)
    78 top := $(call stack-pop,STACK1)
    79 $(if $(not $(eq $(top),1)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='1'))
    80 $(call ASSERT,)
    81 top := $(call stack-pop,STACK1)
    82 $(if $(not $(eq $(top),)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected=''))
    83 $(call ASSERT,)
     39# larger sets.
     40if1of (1,2 3 4 5 6 7 8 9 0)
     41 $(error busted)
     42endif
     43if1of (1,12 3 4 5 6 7 8 9 0)
     44 $(error busted)
     45endif
     46if1of (1,2 31 4 5 6 7 8 9 0)
     47 $(error busted)
     48endif
     49ifn1of (1,1 2 3 4 5 6 7 8 9 0)
     50 $(error busted)
     51endif
     52ifn1of (8,1 2 3 4 5 6 7 8 9 0)
     53 $(error busted)
     54endif
     55ifn1of (asdf,asdf)
     56 $(error busted)
     57endif
     58ifn1of (asdf,asdf asdf)
     59 $(error busted)
     60endif
     61
     62# any in set 1 match any in set 2.
     63if1of (1 3 5 7 9, 2 4 6 8)
     64 $(error busted)
     65endif
     66ifn1of (1 2 3 4 5, 2 4 6 8)
     67 $(error busted)
     68endif
     69
     70# real life.
     71ifn1of (win linux, linux)
     72 $(error busted)
     73endif
     74ifn1of (win.x86, win.amd64 linux.x86 darwin.x86 win.x86 os2.x86)
     75 $(error busted)
     76endif
     77
    8478
    8579all_recursive:
    86         $(ECHO) The stack works.$(STACK1)
     80        $(ECHO) "if1of and ifn1of works fine"
  • trunk/src/kmk/variable.c

    r1107 r1109  
    10361036  && defined(CONFIG_WITH_EXPLICIT_MULTITARGET) \
    10371037  && defined(CONFIG_WITH_PREPEND_ASSIGNMENT) \
     1038  && defined(CONFIG_WITH_SET_CONDITIONALS) \
    10381039  && defined(KMK_HELPERS)
    10391040  (void) define_variable ("KMK_FEATURES", 12,
     
    10481049                          " explicit-multitarget"
    10491050                          " prepend-assignment"
     1051                          " set-conditionals"
    10501052                          " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one "
    10511053                          , o_default, 0);
     
    10771079  strcat (buf, " explicit-multitarget");
    10781080#  endif
    1079 #  if defined (CONFIG_WITH_PREPEND_ASSIGNMENT) \
     1081#  if defined (CONFIG_WITH_PREPEND_ASSIGNMENT)
    10801082  strcat (buf, " prepend-assignment");
     1083#  endif
     1084#  if defined (CONFIG_WITH_SET_CONDITIONALS)
     1085  strcat (buf, " set-conditionals");
    10811086#  endif
    10821087#  if defined (KMK_HELPERS)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette