Skip to content

add {COPYFILEIFNEWER} token#2617

Merged
nickclark2016 merged 1 commit intopremake:masterfrom
alchemyyy:master
Feb 26, 2026
Merged

add {COPYFILEIFNEWER} token#2617
nickclark2016 merged 1 commit intopremake:masterfrom
alchemyyy:master

Conversation

@alchemyyy
Copy link
Contributor

What does this PR do?**

Adds a {COPYIFNEWER} command token that copies a file only if the source is newer than the destination, or the destination doesn't exist.

How does this PR change Premake's behavior?

No breaking changes. Existing behavior is untouched. This just adds a new {COPYIFNEWER} token alongside the existing {COPY}, {COPYFILE}, etc.

Anything else we should know?

Nothing.

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

Copy link
Member

@nickclark2016 nickclark2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, just that comment on the Tokens table and we'll be good to merge this.

|------------|---------------------------------------------|-----------------------|-------|
| {CHDIR} | chdir {args} | cd {args} | |
| {COPYFILE} | copy /B /Y {args} | cp -f {args} | |
| {COPYFILEIFNEWER} | xcopy /D /Y {args}* | cp -u {args} | 5.0-beta9 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response. You don't need the "Since" field, since this will just be present in 5.0 stable (next release).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@nickclark2016
Copy link
Member

Tests fail. Please fix.

@alchemyyy alchemyyy force-pushed the master branch 2 times, most recently from 12df880 to a0a2623 Compare February 25, 2026 01:38
@alchemyyy
Copy link
Contributor Author

alchemyyy commented Feb 25, 2026

Tests fail. Please fix.

fixed.
https://github.com/alchemyyy/premake-core/actions/runs/22378235375
https://github.com/alchemyyy/premake-core/actions/runs/22378235351

checks out okay here. Thanks for the review!

end

function suite.translateCommand_windowsCopyFileIfNewerWithPaths()
test.isequal('xcopy /D /Y src\\dir\\file.txt dst\\dir\\file.txt*', os.translateCommands('{COPYFILEIFNEWER} src/dir/file.txt dst/dir/file.txt', "windows"))
Copy link
Contributor

@Jarod42 Jarod42 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paths should be enclosed by %[..] i.e 'xcopy /D /Y %[src\\dir\\file.txt dst\\dir\\file.txt*]'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here. I would agree this should be fixed.

end

function suite.translateCommand_windowsCopyFileIfNewerWithPaths()
test.isequal('xcopy /D /Y src\\dir\\file.txt dst\\dir\\file.txt*', os.translateCommands('{COPYFILEIFNEWER} src/dir/file.txt dst/dir/file.txt', "windows"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch here. I would agree this should be fixed.

@nickclark2016 nickclark2016 merged commit b3b39d4 into premake:master Feb 26, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants