Skip to content

Commit

Permalink
Added: Proper path handling using Python's pathlib.Path.
Browse files Browse the repository at this point in the history
Added: Typeguard support
Updated: PatternRules now using '*' instead of '%'.
  • Loading branch information
drakes00 committed Feb 26, 2024
1 parent 2458580 commit f1407a4
Show file tree
Hide file tree
Showing 14 changed files with 646 additions and 301 deletions.
Binary file added .coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## New Features

- Allow pattern rules with named target ? (ex: %.o -> executable)
- Allow pattern rules with named target ? (ex: *.o -> executable)
- Dependency cycle detection
- Prevent cleaning (NoClean(target))
- Specify cache and output folders
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Rule(targets="output.txt", deps="input.txt", builder=fooBuilder)

# Define a pattern rule to create `.bar` files from `.foo` files using builder
# `fooBuilder`.
PatternRule(target="%.bar", deps="%.foo", builder=fooBuilder)
PatternRule(target="*.bar", deps="*.foo", builder=fooBuilder)

# Declare targets to be built.
AddTarget("output.txt")
Expand Down
2 changes: 1 addition & 1 deletion doc/builders.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ AddTarget("output.txt")
Builders can also handle shell commands. In this case, the action is a shell
command to create a file using the `touch` command.

### 3. Handling Automatic Variables ($^, $@)
### 3. Handling Automatic Variables (\$^, \$@)

```python
builder = Builder(action="cp $^ $@")
Expand Down
12 changes: 6 additions & 6 deletions doc/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class PatternRule:

```python
fooBuilder = Builder(action="Magically creating $@ from $^")
PatternRule(target="%.bar", deps="%.foo", builder=fooBuilder)
PatternRule(target="*.bar", deps="*.foo", builder=fooBuilder)
AddTarget("a.bar")
```

Expand All @@ -140,10 +140,10 @@ this example, the builder action is applied to create `a.bar` from `a.foo`.
fooBuilder = Builder(action="Magically creating $@ from $^")

# Simple pattern rule.
PatternRule(target="%.bar", deps="%.foo", builder=fooBuilder)
PatternRule(target="*.bar", deps="*.foo", builder=fooBuilder)

# Multiple deps pattern rule.
PatternRule(target="%.baz", deps=["%.foo", "%.bar"], builder=fooBuilder)
PatternRule(target="*.baz", deps=["*.foo", "*.bar"], builder=fooBuilder)
```

Pattern rule dependencies can be specified as either a string or a list of
Expand All @@ -156,10 +156,10 @@ strings. Here, the builder action is applied to create `a.baz` from `a.foo` and
fooBuilder = Builder(action="Magically creating $@ from $^")

# Simple pattern rule with exclude.
PatternRule(target="%.bar", deps="%.foo", builder=fooBuilder, exclude=["a.bar"])
PatternRule(target="*.bar", deps="*.foo", builder=fooBuilder, exclude=["a.bar"])

# Multiple deps pattern rule with exclude.
PatternRule(target="%.baz", deps=["%.foo", "%.bar"], builder=fooBuilder, exclude=["a.baz"])
PatternRule(target="*.baz", deps=["*.foo", "*.bar"], builder=fooBuilder, exclude=["a.baz"])
```

Pattern rules can exclude specific targets from matching. Here, `a.bar` and `a.baz` are respectively
Expand All @@ -169,7 +169,7 @@ excluded from the pattern match, so ReMake will not look for their dependencies.

```python
fooBuilder = Builder(action="Magically creating $@ from $<")
rule = PatternRule(target="%.foo", deps="%.bar", builder=fooBuilder)
rule = PatternRule(target="*.foo", deps="*.bar", builder=fooBuilder)
AddTarget(rule.allTargets)
```

Expand Down
2 changes: 1 addition & 1 deletion examples/ReMakeFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from remake.builders import gcc, clang

# Compile any .c file into .o file, then compile all .o into target.
rule = PatternRule(deps="%.c", target="%.o", builder=gcc)
rule = PatternRule(deps="*.c", target="*.o", builder=gcc)
AddTarget(rule.allTargets)

# Compile specific .c file into target.
Expand Down
2 changes: 1 addition & 1 deletion examples/ReMakeFile.latex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from remake.builders import tex2pdf

# Compile any .tex file into .pdf file.
rule = PatternRule(deps="%.tex", target="%.pdf", builder=tex2pdf)
rule = PatternRule(deps="*.tex", target="*.pdf", builder=tex2pdf)
AddTarget(rule.allTargets)

# Compile specific .tex file into .pdf file.
Expand Down
113 changes: 111 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ readme = "README.md"
python = "^3.11"
rich = "^13.4.2"
ward = "^0.67.2b0"
typeguard = "^4.1.5"
ward-coverage = "^0.3.1"


[tool.ward]
hook_module = ["ward_coverage"]

[tool.poetry.group.dev.dependencies]
dunamai = "^1.19.0"
Expand Down
2 changes: 1 addition & 1 deletion remake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

__version__ = "1.0.0"

from remake.main import AddTarget, Builder, Rule, PatternRule, VirtualDep, VirtualTarget, AddVirtualTarget
from remake.main import AddTarget, Builder, Rule, PatternRule, VirtualDep, VirtualTarget, AddVirtualTarget, GlobPattern
from remake.main import findBuildPath, executeReMakeFileFromDirectory, generateDependencyList, buildDeps, cleanDeps
from remake.main import setDryRun, setVerbose, setDevTest, unsetDryRun, unsetVerbose, unsetDevTest
from remake.context import getCurrentContext, getOldContext
Loading

0 comments on commit f1407a4

Please sign in to comment.