Changeset 725 for trunk/src/gmake


Ignore:
Timestamp:
Dec 15, 2006, 6:18:47 AM (19 years ago)
Author:
bird
Message:

Partial implementation of a _PATH target property for resolving relative paths. It's primarily intended for sub-makefile mode where we apply it to all targets automatically. TODOs: INCS, DEPs (source level) and SUBDIRS*.

Location:
trunk/src/gmake
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/function.c

    r720 r725  
    21192119 return o;
    21202120}
     2121
     2122#ifdef CONFIG_WITH_ABSPATHEX
     2123/* same as abspath except that the current path is given as the 2nd argument. */
     2124static char *
     2125func_abspathex (char *o, char **argv, const char *funcname UNUSED)
     2126{
     2127  /* Expand the argument.  */
     2128  char *p = argv[0];
     2129  PATH_VAR (current_directory);
     2130  char *cwd = argv[1];
     2131  unsigned int cwd_len = ~0U;
     2132  char *path = 0;
     2133  int doneany = 0;
     2134  unsigned int len = 0;
     2135  PATH_VAR (in);
     2136  PATH_VAR (out);
     2137
     2138  while ((path = find_next_token (&p, &len)) != 0)
     2139    {
     2140      if (len < GET_PATH_MAX)
     2141        {
     2142#ifdef HAVE_DOS_PATHS
     2143          if (path[0] != '/' && path[0] != '\\' && (len < 2 || path[1] != ':') && cwd)
     2144#else
     2145          if (path[0] != '/' && cwd)
     2146#endif
     2147            {
     2148              /* relative path, prefix with cwd. */
     2149              if (cwd_len == ~0U)
     2150                cwd_len = strlen (cwd);
     2151              if (cwd_len + len + 1 >= GET_PATH_MAX)
     2152                  continue;
     2153              memcpy (in, cwd, cwd_len)
     2154              in[cwd_len] = '/';
     2155              memcpy (in + cwd_len + 1, path, len);
     2156              in[cwd_len + len + 1] = '\0';
     2157            }
     2158          else
     2159            {
     2160              /* absolute path pass it as-is. */
     2161              memcpy (in, path, len);
     2162              in[len] = '\0';
     2163            }
     2164
     2165          if (abspath (in, out))
     2166            {
     2167              o = variable_buffer_output (o, out, strlen (out));
     2168              o = variable_buffer_output (o, " ", 1);
     2169              doneany = 1;
     2170            }
     2171        }
     2172    }
     2173
     2174  /* Kill last space.  */
     2175  if (doneany)
     2176    --o;
     2177
     2178 return o;
     2179}
     2180#endif
    21212181
    21222182#ifdef CONFIG_WITH_TOUPPER_TOLOWER
     
    23782438  { STRING_SIZE_TUPLE("tolower"),       0,  1,  1,  func_toupper_tolower},
    23792439#endif
     2440#ifdef CONFIG_WITH_ABSPATHEX
     2441  { STRING_SIZE_TUPLE("abspathex"),     0,  2,  1,  func_abspathex},
     2442#endif
    23802443#if defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE)
    23812444  { STRING_SIZE_TUPLE("comp-vars"),     3,  3,  1,  func_comp_vars},
  • trunk/src/gmake/kbuild.c

    r646 r725  
    788788                           struct variable *pType, struct variable *pBldType,
    789789                           struct variable *pBldTrg, struct variable *pBldTrgArch, struct variable *pBldTrgCpu,
     790                           struct variable *pDefPath,
    790791                           const char *pszProp, const char *pszVarName, int iDirection)
    791792{
     
    10021003            paVars[iVar].cchExp = strlen(paVars[iVar].pszExp);
    10031004        }
     1005        if (pDefPath)
     1006        {
     1007            /** @todo */
     1008        }
    10041009        cchTotal += paVars[iVar].cchExp + 1;
    10051010    }
     
    10301035}
    10311036
    1032 /* get a source property. */
     1037/* get a source property. Doesn't respect the default path. */
    10331038char *
    10341039func_kbuild_source_prop(char *o, char **argv, const char *pszFuncName)
     
    10561061    pVar = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType,
    10571062                                      pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu,
     1063                                      NULL,
    10581064                                      argv[0], argv[1], iDirection);
    10591065    if (pVar)
     
    11901196    struct variable *pTarget    = kbuild_get_variable("target");
    11911197    struct variable *pSource    = kbuild_get_variable("source");
     1198    struct variable *pDefPath   = kbuild_get_variable("defpath");
    11921199    struct variable *pType      = kbuild_get_variable("type");
    11931200    struct variable *pBldType   = kbuild_get_variable("bld_type");
     
    12071214    kbuild_get_sdks(&Sdks, pTarget, pSource, pBldType, pBldTrg, pBldTrgArch);
    12081215
    1209     pDefs  = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu,
     1216    if (pDefPath && !pDefPath->value_length)
     1217        pDefPath = NULL;
     1218    pDefs  = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu, NULL,
    12101219                                        "DEFS", "defs", 1/* left-to-right */);
    1211     pIncs  = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu,
     1220    pIncs  = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu, NULL,
    12121221                                        "INCS", "incs", -1/* right-to-left */);
    1213     pFlags = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu,
     1222    pFlags = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu, pDefPath,
    12141223                                        "FLAGS", "flags", 1/* left-to-right */);
    1215     pDeps  = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu,
     1224    pDeps  = kbuild_collect_source_prop(pTarget, pSource, pTool, &Sdks, pType, pBldType, pBldTrg, pBldTrgArch, pBldTrgCpu, pDefPath,
    12161225                                        "DEPS", "deps", 1/* left-to-right */);
    12171226
Note: See TracChangeset for help on using the changeset viewer.