-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make a kReleaseMode constant that is public. #27502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (false) { dead(); } isn't tree shaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying that in your example the code is not being removed? (and if so, why isn't it?)
Or are you saying that my use of "tree shaking" is just the incorrect term for removing blocks like that at compile time?
Also, this:
static const Foo foo = Foo(debugName: true ? null : 'Name');would not include the string 'Name' in the compiled output, right?
a6a5de7 to
3e30af5
Compare
3e30af5 to
8def903
Compare
|
We need a way to test that these work properly |
8def903 to
4384fb2
Compare
|
Yeah... Do we currently have a test that builds all the different configurations (all five modes, apk and ios, and simulator/emulator)? I don't know of one. Not sure I want to be the first, but it would be helpful to have even without these variables needing testing. |
|
If we're providing a contract like "guarantee to remove code in x-mode" we need to test it. |
|
Yeah, I agree. Kinda daunting though. |
|
Actually, it wasn't too bad. I have a devicelab test that will run in all five modes. Now I just need to fix the fact that debug and both dynamic modes don't seem to pick up the |
|
Pass or not pass the flag, that is |
|
Good idea @jonahwilliams, but no, that doesn't make any difference, unfortunately. |
a6a398b to
aabe836
Compare
|
OK, I give up on making I'm just going to define Not great, but a little cleaner than it was... |
b3325f1 to
eff0974
Compare
eff0974 to
4e64f08
Compare
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| /// if (!const bool.fromEnvironment('dart.vm.product')) { | ||
| // // Register your service extension here. | ||
| // } | ||
| /// void myRegistrationFunction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we include the foundation/constant.dart import in this example to make clear where the constant is coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this is already in the foundation library (which is where the constant is defined). I added a comment in the example to indicate where it is defined instead, since I'm worried that the sample analyzer will complain if I import it again.
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Before this, we had several places where an isReleaseMode was defined, all with the same definition. This just makes it more broadly visible to allow our users to use it, as well as creating debug and profile versions, and adding a device lab test for it. Since this is a const value, this makes it possible for a developer to easily mark blocks that can be removed at AOT compile time.
Before this, we had several places where an
isReleaseModewas defined, all with the same definition. This just makes it more broadly visible to allow our users to use it, as well as creating debug and profile versions, and adding a device lab test for it.Since this is a const value, this makes it possible for a developer to easily mark blocks that can be removed at AOT compile time.