Skip to content

Commit d49e44a

Browse files
committed
Add '--platform' option
1 parent 102c4c8 commit d49e44a

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build/*
22
.idea/*
3-
.gradle/*
3+
.gradle/*
4+
install

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This currently supports
1212
- Mac OS X 10.4 or higher
1313
- Linux (32- and 64-bit)
1414

15-
ARM/Android is not currently supported.
15+
ARM is not currently supported.
1616

1717
## Command line arguments
1818

@@ -26,6 +26,16 @@ Short name | Long name | Description | Argument
2626
-n | --natives | Flags the C++ native libraries for install
2727
| | --all | Installs all OpenCV artifacts
2828
| | --no-overwrite | Do not overwrite already installed files
29+
| | --platform | Download artifacts for a specific platform. They will be located in `./install` | The platform to download artifacts for
30+
31+
#### Options for `platform`
32+
```
33+
win32
34+
win64
35+
osx
36+
linux32
37+
linux64
38+
```
2939

3040
## Usage
3141
```

src/main/java/edu/wpi/first/wpilib/opencv/installer/Installer.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public class Installer {
4040
}
4141
}
4242

43-
private static final Platform platform = PlatformDetector.getPlatform();
43+
private static Platform platform = PlatformDetector.getPlatform();
44+
private static boolean overridePlatform = false;
4445
private static final String groupId = "org.opencv";
4546
private static final String javaJarName = "opencv-java";
4647
private static final String jniName = "opencv-jni";
@@ -68,6 +69,7 @@ public static void main(String... args) throws ParseException {
6869
addOption("a", "all", false, "Installs all artifacts");
6970
addOption("v", "version", true, "Set the version of OpenCV to install");
7071
addOption(null, "no-overwrite", false, "Don't overwrite existing files when installing");
72+
addOption(null, "platform", true, "Install artifacts for a specific platform");
7173
}};
7274
CommandLine parsedArgs = p.parse(options, args);
7375
if (parsedArgs.hasOption("help")) {
@@ -78,6 +80,10 @@ public static void main(String... args) throws ParseException {
7880
if (!parsedArgs.hasOption("version")) {
7981
throw new MissingOptionException("-v <version>");
8082
}
83+
if (parsedArgs.hasOption("platform")) {
84+
overridePlatform = true;
85+
platform = Platform.valueOf(parsedArgs.getOptionValue("platform"));
86+
}
8187
openCvVersion = parsedArgs.getOptionValue("version");
8288
version = platform + "-" + openCvVersion;
8389
overwrite = !parsedArgs.hasOption("no-overwrite");
@@ -124,24 +130,27 @@ private static void install(ArtifactType type) {
124130
try {
125131
String artifactId;
126132
String v = version;
127-
String installLocation;
133+
String installLocation = "";
134+
if (overridePlatform) {
135+
installLocation = "install";
136+
}
128137
switch (type) {
129138
case JAVA:
130139
artifactId = javaJarName;
131140
v = openCvVersion;
132-
installLocation = platform.getJavaInstallLocation();
141+
installLocation += platform.getJavaInstallLocation();
133142
break;
134143
case JNI:
135144
artifactId = jniName;
136-
installLocation = platform.getJniInstallLocation();
145+
installLocation += platform.getJniInstallLocation();
137146
break;
138147
case HEADERS:
139148
artifactId = headersName;
140-
installLocation = platform.getHeadersInstallLocation();
149+
installLocation += platform.getHeadersInstallLocation();
141150
break;
142151
case NATIVES:
143152
artifactId = nativesName;
144-
installLocation = platform.getNativesInstallLocation();
153+
installLocation += platform.getNativesInstallLocation();
145154
break;
146155
default:
147156
throw new UnsupportedOperationException("Unknown artifact type: " + type);

0 commit comments

Comments
 (0)