mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Take into account --curdir for all relative paths
In a lot of places, (potentially) relative paths were passed to File without any processing, making them be resolved without taking into account --curdir. By passing them through Base.absoluteFile instead, these paths are resolved relative to the working directory before starting arduino (at least on Linux, which is currently the only platform supporting --curdir). This applies --curdir to the --preferences-file option and the build.path, settings.path, sketchbook.path preferences. For example, this now works as expected: arduino --pref build.path=build_dir --verify Blink.ino
This commit is contained in:
parent
4f33d0851c
commit
cc773fb1e0
@ -143,7 +143,7 @@ public class Base {
|
||||
if (!portableFolder.exists())
|
||||
portableFolder = null;
|
||||
|
||||
File preferencesFile = null;
|
||||
String preferencesFile = null;
|
||||
|
||||
// Do a first pass over the commandline arguments, the rest of them
|
||||
// will be processed by the Base constructor. Note that this loop
|
||||
@ -153,7 +153,7 @@ public class Base {
|
||||
for (int i = 0; i < args.length - 1; i++) {
|
||||
if (args[i].equals("--preferences-file")) {
|
||||
++i;
|
||||
preferencesFile = new File(args[i]);
|
||||
preferencesFile = args[i];
|
||||
continue;
|
||||
}
|
||||
if (args[i].equals("--curdir")) {
|
||||
@ -164,7 +164,7 @@ public class Base {
|
||||
}
|
||||
|
||||
// run static initialization that grabs all the prefs
|
||||
Preferences.init(preferencesFile);
|
||||
Preferences.init(absoluteFile(preferencesFile));
|
||||
|
||||
try {
|
||||
File versionFile = getContentFile("lib/version.txt");
|
||||
@ -296,6 +296,8 @@ public class Base {
|
||||
// directory when starting the IDE (which is not the same as the
|
||||
// current working directory!).
|
||||
static public File absoluteFile(String path) {
|
||||
if (path == null) return null;
|
||||
|
||||
File file = new File(path);
|
||||
if (!file.isAbsolute()) {
|
||||
file = new File(currentDirectory, path);
|
||||
@ -320,7 +322,7 @@ public class Base {
|
||||
if (portableFolder != null)
|
||||
sketchbookFolder = new File(portableFolder, sketchbookPath);
|
||||
else
|
||||
sketchbookFolder = new File(sketchbookPath);
|
||||
sketchbookFolder = Base.absoluteFile(sketchbookPath);
|
||||
if (!sketchbookFolder.exists()) {
|
||||
Base.showWarning(_("Sketchbook folder disappeared"),
|
||||
_("The sketchbook folder no longer exists.\n" +
|
||||
@ -2047,7 +2049,7 @@ public class Base {
|
||||
|
||||
String preferencesPath = Preferences.get("settings.path");
|
||||
if (preferencesPath != null) {
|
||||
settingsFolder = new File(preferencesPath);
|
||||
settingsFolder = absoluteFile(preferencesPath);
|
||||
|
||||
} else {
|
||||
try {
|
||||
@ -2086,8 +2088,7 @@ public class Base {
|
||||
if (buildFolder == null) {
|
||||
String buildPath = Preferences.get("build.path");
|
||||
if (buildPath != null) {
|
||||
buildFolder = new File(buildPath);
|
||||
|
||||
buildFolder = Base.absoluteFile(buildPath);
|
||||
} else {
|
||||
//File folder = new File(getTempFolder(), "build");
|
||||
//if (!folder.exists()) folder.mkdirs();
|
||||
@ -2248,7 +2249,7 @@ public class Base {
|
||||
static public File getSketchbookFolder() {
|
||||
if (portableFolder != null)
|
||||
return new File(portableFolder, Preferences.get("sketchbook.path"));
|
||||
return new File(Preferences.get("sketchbook.path"));
|
||||
return absoluteFile(Preferences.get("sketchbook.path"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,6 +280,13 @@ HISTORY
|
||||
file, just like *--pref*. The *--verbose* options still only
|
||||
apply to the current run.
|
||||
|
||||
{empty}::
|
||||
A path passed to *--preferences-file*, or set in the
|
||||
*build.path*, *preferences.path* or *settings.path* is now
|
||||
interpreted relative to the current directory instead of the
|
||||
location of the arduino command itself.
|
||||
|
||||
|
||||
RESOURCES
|
||||
---------
|
||||
Web site: <http://arduino.cc/>
|
||||
|
Loading…
Reference in New Issue
Block a user