Skip to content

Commit d972e1e

Browse files
author
Colin Robertson
authored
Merge pull request #3435 from MicrosoftDocs/master637692250399017714
Repo sync for protected CLA branch
2 parents a351596 + eb3e4b8 commit d972e1e

12 files changed

+515
-15
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
description: "Learn more about: abspath NMAKE function"
3+
title: "abspath NMAKE function"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["abspath NMAKE function", "NMAKE function, abspath"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `abspath` NMAKE function
9+
10+
Gets the absolute path for each item in a list.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(abspath input)
16+
```
17+
18+
### Parameters
19+
20+
*`input`*\
21+
The [list](using-an-nmake-macro.md#function-list-syntax) of file paths to convert.
22+
23+
## Return value
24+
25+
A [list](using-an-nmake-macro.md#function-list-syntax) with each of the items from *`input`* converted to their absolute form.
26+
27+
## Remarks
28+
29+
`abspath` supports extended-length paths, either by using the `\\?\` prefix, or when long paths are enabled. For more information about long paths, see [Maximum Path Length Limitation](/windows/win32/fileio/maximum-file-path-limitation).
30+
31+
## Example
32+
33+
```makefile
34+
$(abspath relative\path\file.c) # If run from "c:\temp", evaluates to "c:\temp\relative\path\file.c"
35+
$(abspath c:\temp\..\file1.cpp c:\\temp\/dir//) # Evaluates to "c:\file1.cpp c:\temp\dir\". Follows path traversals and normalizes directory separators.
36+
37+
# abspath can be combined with filter to find which items exist within a directory tree
38+
TEMP_SOURCES=$(filteri c:\temp\\%,$(abspath $(SOURCES)))
39+
```
40+
41+
## See also
42+
43+
[Macros and NMAKE](macros-and-nmake.md)\
44+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
description: "Learn more about: basename NMAKE function"
3+
title: "basename NMAKE function"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["basename NMAKE function", "NMAKE function, basename"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `basename` NMAKE function
9+
10+
Gets the base name for each item in a list.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(basename input)
16+
```
17+
18+
### Parameters
19+
20+
*`input`*\
21+
The [list](using-an-nmake-macro.md#function-list-syntax) of file paths to convert.
22+
23+
## Return value
24+
25+
A [list](using-an-nmake-macro.md#function-list-syntax) with each of the items from *`input`* converted to their base name (that is, with their extensions removed).
26+
27+
## Remarks
28+
29+
`basename` doesn't have any maximum path limitations.
30+
31+
The `basename` function is equivalent to using the [`R` modifier in a filename macro](special-nmake-macros.md#filename-macros).
32+
33+
## Example
34+
35+
```makefile
36+
$(basename c:\temp\file.txt) # Evaluates to "c:\temp\file"
37+
$(basename c:\temp\ c:\file) # Evaluates to "c:\temp\ c:\file" - Directories and files without extensions are left as-is
38+
$(basename c:\src\.gitignore) # Evaluates to "c:\src\" - Dot files are considered to be extensions and so are removed
39+
```
40+
41+
## See also
42+
43+
[Macros and NMAKE](macros-and-nmake.md)\
44+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
description: "Learn more about: filter, filteri NMAKE functions"
3+
title: "filter, filteri NMAKE functions"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["filter NMAKE function", "filteri NMAKE function", "NMAKE function, filter", "NMAKE function, filteri"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `filter`, `filteri` NMAKE functions
9+
10+
Evaluates to a list of items that matched at least one pattern.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(filter filters,input)
16+
$(filteri filters,input)
17+
```
18+
19+
### Parameters
20+
21+
*`filters`*\
22+
A [list](using-an-nmake-macro.md#function-list-syntax) of one or more [patterns](using-an-nmake-macro.md#function-pattern-syntax) to filter by.
23+
24+
*`input`*\
25+
The [list](using-an-nmake-macro.md#function-list-syntax) to be filtered.
26+
27+
## Return value
28+
29+
A list of all of the items in *`input`* that match at least one pattern in *`filters`*.
30+
31+
## Remarks
32+
33+
`filteri` is the case-insensitive version of `filter`.
34+
35+
## Example
36+
37+
```makefile
38+
$(filter He%,Hello Hey Hi) # Evaluates to "Hello Hey" - "Hi" doesn't match the filter
39+
$(filter %y %i,Hello Hey Hi) # Evaluates to "Hey Hi" - items are kept if they match any filter, "Hello" is dropped as it doesn't match any
40+
$(filter Not%Found,Hello Hey Hi) # Evaluates to "" - none of the items match any filters
41+
42+
$(filter he%,Hello Hey Hi) # Evaluates to "" - filter is case-sensitive
43+
$(filteri he%,Hello Hey Hi) # Evaluates to "Hello Hey" - filteri is case-insensitive
44+
45+
# filteri is commonly used to filter a list of files by their extensions
46+
CPP_SOURCES=$(filteri %.cpp %.cxx,$(SOURCES))
47+
C_SOURCES=$(filteri %.c,$(SOURCES))
48+
```
49+
50+
## See also
51+
52+
[Macros and NMAKE](macros-and-nmake.md)\
53+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)\
54+
[`filterout`, `filterouti`](nmake-function-filterout.md)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
description: "Learn more about: filterout, filterouti NMAKE functions"
3+
title: "filterout, filterouti NMAKE functions"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["filterout NMAKE function", "filterouti NMAKE function", "NMAKE function, filterout", "NMAKE function, filterouti"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `filterout`, `filterouti` NMAKE functions
9+
10+
Evaluates to a list of items that don't match any patterns.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(filterout filters,input)
16+
$(filterouti filters,input)
17+
```
18+
19+
### Parameters
20+
21+
*`filters`*\
22+
A [list](using-an-nmake-macro.md#function-list-syntax) of one or more [patterns](using-an-nmake-macro.md#function-pattern-syntax) to filter by.
23+
24+
*`input`*\
25+
The [list](using-an-nmake-macro.md#function-list-syntax) to be filtered.
26+
27+
## Return value
28+
29+
A [list](using-an-nmake-macro.md#function-list-syntax) of all of the items in *`input`* that don't match any patterns in *`filters`*.
30+
31+
## Remarks
32+
33+
`filterouti` is the case-insensitive version of `filterout`.
34+
35+
## Example
36+
37+
```makefile
38+
$(filterout He%,Hello Hey Hi) # Evaluates to "Hi" - "Hello" and "Hey" match the filter
39+
$(filterout %y %i,Hello Hey Hi) # Evaluates to "Hello" - items are kept if they don't match any filters, "Hey" and "Hi" each match one filter
40+
$(filterout H%,Hello Hey Hi) # Evaluates to "" - each of the items matched the filter
41+
42+
$(filterout he%,Hello Hey Hi) # Evaluates to "Hello Hey Hi" - filterout is case-sensitive
43+
$(filterouti he%,Hello Hey Hi) # Evaluates to "Hi" - filterouti is case-insensitive
44+
```
45+
46+
## See also
47+
48+
[Macros and NMAKE](macros-and-nmake.md)\
49+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)\
50+
[`filter`, `filteri`](nmake-function-filter.md)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
description: "Learn more about: findstring, findstringi NMAKE functions"
3+
title: "findstring, findstringi NMAKE functions"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["findstring NMAKE function", "findstringi NMAKE function", "NMAKE function, findstring", "NMAKE function, findstringi"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `findstring`, `findstringi` NMAKE functions
9+
10+
Evaluates to the searched-for string if it's found within another string.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(findstring searchFor,input)
16+
$(findstringi searchFor,input)
17+
```
18+
19+
### Parameters
20+
21+
*`searchFor`*\
22+
The string to search for.
23+
24+
*`input`*\
25+
The string to search in.
26+
27+
## Return value
28+
29+
If *`searchFor`* is found within *`input`*, then the function returns *`searchFor`*, otherwise it returns null.
30+
31+
## Remarks
32+
33+
`findstringi` is the case-insensitive version of `findstring`.
34+
35+
## Example
36+
37+
```makefile
38+
$(findstring Hello,Hello World!) # Evaluates to "Hello"
39+
$(findstring Hey,Hello World!) # Evaluates to ""
40+
41+
$(findstring hello,Hello World!) # Evaluates to "" - findstring is case-sensitive
42+
$(findstringi hello,Hello World!) # Evaluates to "hello" - findstringi is case-insensitive
43+
```
44+
45+
## See also
46+
47+
[Macros and NMAKE](macros-and-nmake.md)\
48+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
description: "Learn more about: patsubst, patsubsti NMAKE functions"
3+
title: "patsubst, patsubsti NMAKE functions"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["patsubst NMAKE function", "patsubsti NMAKE function", "NMAKE function, patsubst", "NMAKE function, patsubsti"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `patsubst`, `patsubsti` NMAKE functions
9+
10+
Evaluates to a list of items with each item that matches a pattern replaced by a substitution, and items that don't match kept as-is.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(patsubst pattern,replacement,input)
16+
$(patsubsti pattern,replacement,input)
17+
```
18+
19+
### Parameters
20+
21+
*`pattern`*\
22+
The [pattern](using-an-nmake-macro.md#function-pattern-syntax) to search for.
23+
24+
*`replacement`*\
25+
The [pattern](using-an-nmake-macro.md#function-pattern-syntax) to replace *`pattern`* with. If a wildcard is present in *`replacement`*, then it will be replaced with the text that the wildcard in *`pattern`* matched.
26+
27+
*`input`*\
28+
The [list](using-an-nmake-macro.md#function-list-syntax) of items to be replaced or kept.
29+
30+
## Return value
31+
32+
Returns *`input`*, but each item that matches *`pattern`* is replaced by *`replacement`*. Items that don't match *`pattern`* are kept as-is.
33+
34+
## Remarks
35+
36+
`patsubsti` is the case-insensitive version of `patsubst`.
37+
38+
## Example
39+
40+
```makefile
41+
$(patsubst He%,_%_,Hello Hey Hi) # Evaluates to "_llo_ _y_ Hi"
42+
# "He" matches "Hello" and "Hey", and so "llo" and "y" are matched by the wildcard
43+
# and used to substitute the wildcard in the replacement. "Hi" is not matched and so is kept as-is
44+
45+
$(patsubst Hi,Bye,Hello Hey Hi) # Evaluates to "Hello Hey Bye" - No wildcard is required
46+
$(patsubst %lo,Bye,Hello Hey Hi) # Evaluates to "Bye Hey Hi"
47+
# A wildcard can be used in the pattern without a wildcard in the replacement
48+
49+
$(patsubst he%,_%_,Hello Hey Hi) # Evaluates to "Hello Hey Hi" - patsubst is case-sensitive, so no substitutions performed
50+
$(patsubst he%,_%_,Hello Hey Hi) # Evaluates to "_llo_ _y_ Hi" - patsubsti is case-insensitive
51+
52+
# patsubsti is commonly used to change the file extensions of a list of files
53+
OBJ_FILES=$(patsubst %.c,%.obj,$(C_SOURCES)) $(patsubst %.cpp,%.obj,$(patsubst %.cxx,%.obj,$(CPP_SOURCES)))
54+
```
55+
56+
## See also
57+
58+
[Macros and NMAKE](macros-and-nmake.md)\
59+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
description: "Learn more about: strip NMAKE function"
3+
title: "strip NMAKE function"
4+
ms.date: "9/30/2021"
5+
helpviewer_keywords: ["strip NMAKE function", "NMAKE function, strip"]
6+
monikerRange: '>=msvc-170'
7+
---
8+
# `strip` NMAKE function
9+
10+
Cleans up whitespace in and around a list of items.
11+
12+
## Syntax
13+
14+
```makefile
15+
$(strip input)
16+
```
17+
18+
### Parameters
19+
20+
*`input`*\
21+
The [list](using-an-nmake-macro.md#function-list-syntax) to be cleaned.
22+
23+
## Return value
24+
25+
A [list](using-an-nmake-macro.md#function-list-syntax) of the exact same items as *`input`*.
26+
27+
## Remarks
28+
29+
NMAKE outputs a [list](using-an-nmake-macro.md#function-list-syntax) that has a single space between each item and no leading or trailing whitespace. `strip` doesn't change any item within a list, but it does ensure that the returned list is in this canonical form. The canonical form can be useful for later operations that operate on strings instead of lists.
30+
31+
## Example
32+
33+
```makefile
34+
$(strip a b c d ) # Evaluates to "a b c d"
35+
36+
# strip is useful to get a canonical form of a list, which can then be transformed into a different format
37+
SINGLESPACE=$(subst ',,' ') # Use "subst" since a normal assignment trims trailing whitespace.
38+
INCLUDE_PATH=$(subst $(SINGLESPACE),;,$(strip $(INCLUDES)))
39+
```
40+
41+
## See also
42+
43+
[Macros and NMAKE](macros-and-nmake.md)\
44+
[NMAKE functions by category](using-an-nmake-macro.md#functions-by-category)

0 commit comments

Comments
 (0)