summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2019-05-28 16:34:35 -0400
committerJoey Grover <joeygrover@gmail.com>2019-05-28 16:34:35 -0400
commit25174f98ec62395a0a6812dc8786eb0d9bf79759 (patch)
tree3e2b6f2cef15c80c3b20429fe13c0d8bf10e1d06
parenta1c9407c775b61ae9a0d7f1d921ea379b71e7504 (diff)
downloadsdl_android-25174f98ec62395a0a6812dc8786eb0d9bf79759.tar.gz
Add windows symlink script
Also add destination folder to gitignore
-rw-r--r--.gitignore1
-rw-r--r--android/sdl_android/build.gradle17
-rw-r--r--baseAndroid/README.md7
-rw-r--r--baseAndroid/make_symbolic_links.py69
-rw-r--r--baseAndroid/make_symlinks.lnkbin0 -> 2143 bytes
-rw-r--r--baseAndroid/run_as_admin_symlink_script.bat4
6 files changed, 96 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index a87913e43..13eed80b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ javaSE/local.properties
javaEE/out/
javaEE/build/
javaEE/local.properties
+baseAndroid/windows/
##############################
diff --git a/android/sdl_android/build.gradle b/android/sdl_android/build.gradle
index 21ff200cb..88c2617ec 100644
--- a/android/sdl_android/build.gradle
+++ b/android/sdl_android/build.gradle
@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
+import org.apache.tools.ant.taskdefs.condition.Os
+
android {
compileSdkVersion 28
@@ -34,10 +36,23 @@ android {
}
sourceSets {
- main.java.srcDirs += '../../baseAndroid/src/main/java'
+ if(Os.isFamily(Os.FAMILY_WINDOWS)){
+ //The buildWindowsSymLinks task must be run first if this is
+ //being compiled on a Windows machine
+ main.java.srcDirs += '../../baseAndroid/windows/src/main/java'
+ }else{
+ main.java.srcDirs += '../../baseAndroid/src/main/java'
+ }
}
}
+task buildWindowSymLinks(type:Exec){
+
+ workingDir '../../baseAndroid'
+
+ commandLine 'cmd', '/c', 'make_symlinks.lnk'
+}
+
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api 'com.smartdevicelink:bson_java_port:1.2.0'
diff --git a/baseAndroid/README.md b/baseAndroid/README.md
index 6ad99fef3..e851b814f 100644
--- a/baseAndroid/README.md
+++ b/baseAndroid/README.md
@@ -2,5 +2,10 @@
The Base Android folder symbolically links files used by the Android project that are in the Base folder.
-This folder does not need to be imported. Please refer to the installation instructions in the Android, JavaSE, or JavaEE readme's.
+This folder does not need to be imported. Please refer to the installation instructions in the Android, JavaSE, or JavaEE README's.
+### Windows
+
+The original links were created for a unix based operating system. The Windows versions of those same symbolic links follow the same path structure as this root folder, but under the `Windows` folder. The `build.gradle` file contains the necessary conditional that will pick the correct set of links to use.
+
+If you are not building the project with the supplied gradle files, you will need to point to the correct path based on the operating system in which you are building the project. \ No newline at end of file
diff --git a/baseAndroid/make_symbolic_links.py b/baseAndroid/make_symbolic_links.py
new file mode 100644
index 000000000..4be7cdeea
--- /dev/null
+++ b/baseAndroid/make_symbolic_links.py
@@ -0,0 +1,69 @@
+import os
+import pathlib
+from pathlib import Path
+import re
+
+
+def has_admin():
+ if os.name == 'nt':
+ try:
+ # only windows users with admin privileges can read the C:\windows\temp
+ temp = os.listdir(os.sep.join([os.environ.get('SystemRoot', 'C:\\windows'), 'temp']))
+ except:
+ return os.environ['USERNAME'],False
+ else:
+ return os.environ['USERNAME'],True
+ else:
+ if 'SUDO_USER' in os.environ and os.geteuid() == 0:
+ return os.environ['SUDO_USER'],True
+ else:
+ return os.environ['USERNAME'],False
+
+
+print('Script Start')
+
+isAdmin = has_admin()
+print('Running As Admin - ', isAdmin[1])
+if not isAdmin[1]:
+ print('Can\'t run without admin privileges')
+ exit()
+
+pathlist = Path('src/').glob('**/*')
+# Delete the old directory
+os.system('echo y | rmdir windows /s')
+
+for path in pathlist:
+ path_in_str = str(path)
+ if os.path.isfile(path):
+ # check if it's a link to a file or folder
+ source_link_str = path_in_str
+ source_link_str = '..\\base\\' + source_link_str
+ # Remove the root folder for the actual link
+ print(source_link_str)
+
+ testDest = 'windows\\' + path_in_str
+
+ directory = pathlib.Path(testDest).parent
+ print(str(directory))
+ prefixDir = (re.sub(r"\\+[^\\]*", r"\\..", str(directory))+'\\..\\')[8:] # 8 to remove windows/
+ # Change all the directory paths into .. so that it will properly move up a folder.
+
+ os.system('mkdir %s' % directory)
+ os.system('icacls %s /grant Everyone:(f)' % directory)
+
+ # Now we need to go through each destination directory and understand that's how many ../ we have to add
+ if path_in_str.endswith('.java'):
+ print('Java file link found')
+
+ command = 'mklink "%s" "%s%s"' % (testDest, prefixDir, source_link_str)
+ print('Performing command %s' % command)
+ os.system(command)
+ else:
+ print('Directory link found')
+ command = 'mklink /D "%s" "%s%s"' % (testDest, prefixDir, source_link_str)
+ print('Performing command %s' % command)
+ os.system(command)
+
+print('Script Ends')
+
+
diff --git a/baseAndroid/make_symlinks.lnk b/baseAndroid/make_symlinks.lnk
new file mode 100644
index 000000000..86e9d3e41
--- /dev/null
+++ b/baseAndroid/make_symlinks.lnk
Binary files differ
diff --git a/baseAndroid/run_as_admin_symlink_script.bat b/baseAndroid/run_as_admin_symlink_script.bat
new file mode 100644
index 000000000..439d7709f
--- /dev/null
+++ b/baseAndroid/run_as_admin_symlink_script.bat
@@ -0,0 +1,4 @@
+pushd %~dp0
+python make_symbolic_links.py
+popd
+pause \ No newline at end of file