Skip to content

Introducing APP_DIR property #3421

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

Merged
merged 3 commits into from
Jun 29, 2015
Merged

Introducing APP_DIR property #3421

merged 3 commits into from
Jun 29, 2015

Conversation

ffissore
Copy link
Contributor

It allows the IDE to know its installation folder.

Also upgrading appbundler with a patched version: https://bitbucket.org/ffissore/appbundler
It allows to know the current working directory

These two put together, we can now rely on APP_DIR when loading IDE resources while being sure current working directory is properly set, thus being much more friendly when run from CLI

Fixes #1493

/cc @wayoda @haobug @cmaglie @matthijskooijman

We need to make a windows installer as well, to be sure this doesn't break double clicking a .ino file

@ffissore ffissore added the Component: IDE The Arduino IDE label Jun 25, 2015
@ffissore ffissore self-assigned this Jun 25, 2015
@ffissore ffissore added this to the Release 1.6.6 milestone Jun 25, 2015
@ArduinoBot
Copy link
Contributor

Build failed.

@matthijskooijman
Copy link
Collaborator

AFAIU, the OSX bundler app already recognized the $APPROOT variable, but you just modified to not change the current directory, right? Any plans on submitting these changes upstream?

And wouldn't this allow the --curdir handling to be removed?

@matthijskooijman
Copy link
Collaborator

Oh, and kudos for diving into this! Thanks!

@ffissore
Copy link
Contributor Author

The bundler knows about APP_ROOT but doesn't propagate it to the app. I've submitted the changes upstream: https://bitbucket.org/infinitekind/appbundler/pull-request/32/workingdir-set-to-nsfilemanager/diff

Indeed this makes the --curdir hack useless. However, I'd leave it there for backwards compatibility

@ffissore
Copy link
Contributor Author

I've removed the indentation change for a clearer diff

@ArduinoBot
Copy link
Contributor

Build failed.

@ffissore
Copy link
Contributor Author

@ArduinoBot build this please

@ArduinoBot
Copy link
Contributor

Build failed.

@ffissore
Copy link
Contributor Author

Whoops, didn't push .sha file because of a too wide .gitignore. Force pushed

@matthijskooijman
Copy link
Collaborator

The bundler knows about APP_ROOT but doesn't propagate it to the app.

I'm confused - it seems APP_ROOT is already interpolated into (among others) all option values, see this bit of code

The only thing your patch seems to change is, when no "WorkingDirectory" is specified, do noop chdir (to the current directory) instead of to the home directory? (which is fine, just seeing if I understand this correctly)?

Indeed this makes the --curdir hack useless. However, I'd leave it there for backwards compatibility

Compatibility for what exactly? People running java directly passing --curdir (seems unlikely). Or do you want to keep the code around in case we'll need it later? (seems tricky - if it's not needed it will likely bitrot and no longer work when you need it). In any case, I'd remove the --curdir option from the arduino shell script, that only complicates matters and potentially causes inconsistencies between platforms.

Additionally, there seems to be a stray "w$" (and a missing full stop) in your commit message?

@ffissore
Copy link
Contributor Author

No, that bit of code replaces occurrences of the $APP_ROOT placeholder with the actual app root (which is /bla/bla/Arduino.app). I use that feature here

You're right about my patch, expect I fear it's not a noop chdir. I'm not sure, but otherwise I wouldn't be able explain this code: if it was a noop, chdir should have been called only when WorkingDirectory was set, instead it's called anyway.

Compatibility with those users used to the bug and calling the IDE from the CLI setting CWD to an arbitrary value, different from the actual CWD
I just don't want this kind of scripts to fail tomorrow

cd Arduino.app/Contents/
CURDIR=`pwd`
cd MacOS
./Arduino --curdir $CURDIR --verify Java/examples/01.Basics/Blink/Blink.ino --board arduino:avr:uno

I'll include removal of --curdir from the manpage

@ffissore
Copy link
Contributor Author

Turns out --curdir was undocumented. Oh well.
Fixed commit message. Thanks!

@matthijskooijman
Copy link
Collaborator

No, that bit of code replaces occurrences of the $APP_ROOT placeholder with the actual app root (which is /bla/bla/Arduino.app). I use that feature here

That's exactly what I meant when I said "AFAIU, the OSX bundler app already recognized the $APPROOT variable,". I think we agree, in any case.

You're right about my patch, expect I fear it's not a noop chdir. I'm not sure, but otherwise I wouldn't be able explain this code: if it was a noop, chdir should have been called only when WorkingDirectory was set, instead it's called anyway.

It's called in the second case to chdir to $HOME, which is likely not the cwd yet, so it was not a noop previously. Or am I totally misunderstanding you here?

Turns out --curdir was undocumented. Oh well.

Yes, it was only meant as an option for internal use, never meant to be used externally. IMHO, anyone that was using it anyway (if any at all) are on their own, no need to keep messy code around for them...

@ffissore
Copy link
Contributor Author

--curdir dropped, left a blocking error message, in order to force those that have used it to upgrade their scripts

Federico Fissore added 3 commits June 29, 2015 14:28
… folder.

Also upgrading appbundler with a patched version: https://bitbucket.org/ffissore/appbundler It allows to know the current working directory
These two put together, we can now rely on APP_DIR when loading IDE resources while being sure current working directory is properly set, thus being much more friendly when run from CLI
Fixes #1493
ffissore added a commit that referenced this pull request Jun 29, 2015
@ffissore ffissore merged commit 199d069 into arduino:master Jun 29, 2015
@ffissore ffissore deleted the current-working-dir branch June 29, 2015 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants