Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Allow for escaped compiler and link optional parameters #33

Merged
merged 4 commits into from
Apr 13, 2023

Conversation

ScottBailey
Copy link
Contributor

Added transforms that handle the escape (\) character.
Added regression tests to exercise these code paths.

Closes #27

@ScottBailey ScottBailey self-assigned this Apr 12, 2023
@ScottBailey ScottBailey requested a review from mikelik April 12, 2023 01:57
Copy link
Contributor

@mikelik mikelik left a comment

Choose a reason for hiding this comment

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

I have added suggestions, but it works - thanks!

tools/common.hpp Outdated
Comment on lines 10 to 17
std::string escape_transform(std::string input) {
for(auto i=input.begin(); i != input.end(); ++i) {
if(*i == '\\' && i+1 != input.end())
i = input.erase(i);
}
return input;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

How about erase-remove idiom?

Suggested change
std::string escape_transform(std::string input) {
for(auto i=input.begin(); i != input.end(); ++i) {
if(*i == '\\' && i+1 != input.end())
i = input.erase(i);
}
return input;
}
std::string escape_transform(std::string input) {
input.erase(std::remove(input.begin(), input.end(), '\\'), input.end());
return input;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

erase-remove isn't quite the algorithm we want since it would convert the string "\-O2" to "-O2" instead of "-O2".

I added some docs in 52bce66 to address this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think Michal's suggested code does same as original code.
Comment would be useful as I don't quite understand what this function is supposed to do

tools/tests/add_and_update.py Outdated Show resolved Hide resolved
tools/tests/add_and_update.py Outdated Show resolved Hide resolved
tools/tests/add_and_update.py Outdated Show resolved Hide resolved
tools/tests/add_and_update.py Outdated Show resolved Hide resolved
@@ -163,7 +165,7 @@ namespace antler {
dep_subcommand->add_option("-t, tag", tag, "Tag associated with the dependency.");
dep_subcommand->add_option("-r, release", release, "Release version of the depedency.");
dep_subcommand->add_option("--digest, hash", hash, "Hash of the dependency.");

Copy link
Contributor

Choose a reason for hiding this comment

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

general suggestion, please avoid whitespace only changes, it just messing history and makes changes more verbose. Not necessary to fix it for now as it is already there, so just for future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't actually notice I'd done it until AFTER Mikal had reviewed. Auto-updated in my editor. I generally agree, white space changes are to be avoided.

@ScottBailey ScottBailey requested a review from dimas1185 April 13, 2023 15:46
@ScottBailey ScottBailey merged commit 29f3013 into main Apr 13, 2023
@ScottBailey ScottBailey deleted the sbailey/escape_compiler_and_link_options branch April 13, 2023 19:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Cannot add compiler option -O2 to the library / application
3 participants