# HG changeset patch # User davidb # Date 1587060639 25200 # Node ID cd2ca4727b7f50ea20e3ad3d87df8cc039082bd9 # Parent 539c3641c5390ba7792d4b91fd111347851d9be7 Builds under Windows. diff -r 539c3641c539 -r cd2ca4727b7f Makefile.win --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.win Thu Apr 16 11:10:39 2020 -0700 @@ -0,0 +1,24 @@ +CXX = cl +CXXFLAGS = /nologo /I"$(JRE_HOME)\include" /I"$(JRE_HOME)\include\win32" \ + /I"$(EXIV2_HOME)\include" /I"$(EXIV2_HOME)\build" /EHsc +NDIR = src\name\blackcap\exifwasher\exiv2 +BDIR = src\name\blackcap\exifwasher\binaries\windows +LD = link +LDFLAGS = /NOLOGO /DLL /LIBPATH:"$(EXIV2_HOME)\lib" /DEFAULTLIB:exiv2 + +.PHONY: all checkenv + +all: checkenv $(BDIR)\jni.dll $(BDIR)\exiv2.dll + +checkenv: + @checkenv JRE_HOME EXIV2_HOME + +$(NDIR)\native.obj: $(NDIR)\native.cpp + $(CXX) $(CXXFLAGS) /c /Fo:"$@" "$?" + +$(BDIR)\jni.dll: $(NDIR)\native.obj + if not exist "$(BDIR)" md "$(BDIR)" + $(LD) $(LDFLAGS) /OUT:"$@" "$?" + +$(BDIR)\exiv2.dll: "$(EXIV2_HOME)\bin\exiv2.dll" + copy/y/b $? $@ diff -r 539c3641c539 -r cd2ca4727b7f build.xml --- a/build.xml Sun Apr 12 18:46:57 2020 -0700 +++ b/build.xml Thu Apr 16 11:10:39 2020 -0700 @@ -18,7 +18,7 @@ - + diff -r 539c3641c539 -r cd2ca4727b7f checkenv.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/checkenv.cmd Thu Apr 16 11:10:39 2020 -0700 @@ -0,0 +1,11 @@ +@echo off +SETLOCAL EnableDelayedExpansion + +for %%i in (%*) do ( + if "!%%i!"=="" ( + echo ERROR: %%i not set + exit/b 1 + ) +) + +exit/b 0 diff -r 539c3641c539 -r cd2ca4727b7f setup.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.cmd Thu Apr 16 11:10:39 2020 -0700 @@ -0,0 +1,42 @@ +@echo off +rem -*- coding: windows-1252 -*- + +rem Basic directory stuff, edit as needed. +set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 +set JRE_HOME=C:\Program Files\Java\jdk1.8.0_241 +set KOTLIN_HOME=C:\Users\David Barts\java\kotlin-compiler-1.3.71\kotlinc +set ANT_HOME=C:\Users\David Barts\java\apache-ant-1.10.7 +set EXIV2_HOME=C:\Users\David Barts\Downloads\exiv2-0.27.2-2017msvc64\exiv2-0.27.2-2017msvc64 + +rem For each directory, fix PATH if needed. +call :fixpath "%JRE_HOME%" +call :fixpath "%KOTLIN_HOME%" +call :fixpath "%ANT_HOME%" +exit/b 0 + +rem The rest of this file probably won't need changing. + +rem Subroutine to fix up path, if needed. So we don't mindlessly grow +rem PATH. +:fixpath +set bindir=%~1\bin +if not exist "%bindir%\" goto amf +set p2=%path% +:loop + for /f "tokens=1* delims=;" %%A in ("%p2%") do ( + set first=%%A + set rest=%%B + ) + if "%first%"=="%bindir%" goto amf + if "%rest%"=="" goto notfound + set p2=%rest% + goto loop +:notfound +echo Adding "%bindir%" to PATH. +set path=%bindir%;%path% +:amf +set bindir= +set p2= +set first= +set rest= +exit/b 0 diff -r 539c3641c539 -r cd2ca4727b7f setup.sh --- a/setup.sh Sun Apr 12 18:46:57 2020 -0700 +++ b/setup.sh Thu Apr 16 11:10:39 2020 -0700 @@ -1,7 +1,7 @@ #!/bin/bash export JRE_HOME="$(/usr/libexec/java_home)" -export KOTLIN_HOME="/usr/local/Cellar/kotlin/1.3.71" +export KOTLIN_HOME="/usr/local/Cellar/kotlin/1.3.71/libexec" export EXIV2_HOME="$HOME/temp/exiv2/exiv2-0.27.2-Source" export ANT_HOME="$HOME/java/apache-ant-1.10.1" diff -r 539c3641c539 -r cd2ca4727b7f src/name/blackcap/exifwasher/Files.kt --- a/src/name/blackcap/exifwasher/Files.kt Sun Apr 12 18:46:57 2020 -0700 +++ b/src/name/blackcap/exifwasher/Files.kt Thu Apr 16 11:10:39 2020 -0700 @@ -42,15 +42,14 @@ private val SHORTNAME = "exifwasher" private val LONGNAME = "name.blackcap." + SHORTNAME private val HOME = System.getenv("HOME") -private val APPDATA = System.getenv("APPDATA") val PF_DIR = when (OS.type) { OS.MAC -> joinPath(HOME, "Library", "Application Support", LONGNAME) - OS.WINDOWS -> joinPath(APPDATA, "Roaming", LONGNAME) + OS.WINDOWS -> joinPath(System.getenv("APPDATA"), LONGNAME) else -> joinPath(HOME, "." + SHORTNAME) } val LF_DIR = when (OS.type) { OS.MAC -> joinPath(HOME, "Library", "Application Support", LONGNAME) - OS.WINDOWS -> joinPath(APPDATA, "Local", LONGNAME) + OS.WINDOWS -> joinPath(System.getenv("LOCALAPPDATA"), LONGNAME) else -> joinPath(HOME, "." + SHORTNAME) } val PROP_FILE = File(PF_DIR, SHORTNAME + ".properties") diff -r 539c3641c539 -r cd2ca4727b7f src/name/blackcap/exifwasher/Misc.kt --- a/src/name/blackcap/exifwasher/Misc.kt Sun Apr 12 18:46:57 2020 -0700 +++ b/src/name/blackcap/exifwasher/Misc.kt Thu Apr 16 11:10:39 2020 -0700 @@ -177,7 +177,7 @@ * Set column width of a table. */ fun JTable.setColWidth(col: Int, width: Int, string: String?) { - val FUZZ = 4 + val FUZZ = 16 columnModel.getColumn(col).preferredWidth = if (string.isNullOrEmpty()) { width } else { diff -r 539c3641c539 -r cd2ca4727b7f src/name/blackcap/exifwasher/exiv2/Initialize.kt --- a/src/name/blackcap/exifwasher/exiv2/Initialize.kt Sun Apr 12 18:46:57 2020 -0700 +++ b/src/name/blackcap/exifwasher/exiv2/Initialize.kt Thu Apr 16 11:10:39 2020 -0700 @@ -26,24 +26,18 @@ } /* use the appropriate binary for the system we're on */ - val subdir = when(OS.type) { - OS.UNIX -> "linux" - OS.MAC -> "mac" - OS.WINDOWS -> "windows" - OS.OTHER -> throw RuntimeException("unsupported OS!") - } - val ext = when(OS.type) { - OS.UNIX -> "so" - OS.MAC -> "dylib" - OS.WINDOWS -> "dll" + val (subdir, pfx, ext) = when(OS.type) { + OS.UNIX -> Triple("linux", "lib", ".so") + OS.MAC -> Triple("mac", "lib", ".dylib") + OS.WINDOWS -> Triple("windows", "", ".dll") OS.OTHER -> throw RuntimeException("unsupported OS!") } /* extract to scratch files, if needed, then load */ val klass = Initialize::class.java var myJar = JarFile(File(klass.getProtectionDomain().getCodeSource().getLocation().toURI())) - for (base in arrayOf("libexiv2", "libjni")) { - val eBase = "${base}.${ext}" + for (base in arrayOf("exiv2", "jni")) { + val eBase = "${pfx}${base}${ext}" val sPath = "name/blackcap/exifwasher/binaries/${subdir}/${eBase}" val source = myJar.getJarEntry(sPath) if (source == null) { diff -r 539c3641c539 -r cd2ca4727b7f src/name/blackcap/exifwasher/exiv2/native.cpp --- a/src/name/blackcap/exifwasher/exiv2/native.cpp Sun Apr 12 18:46:57 2020 -0700 +++ b/src/name/blackcap/exifwasher/exiv2/native.cpp Thu Apr 16 11:10:39 2020 -0700 @@ -100,6 +100,20 @@ /* Header for class name_blackcap_exifwasher_exiv2_ExifData */ /* + * Utility function to parse out a type prefix from a key name. + */ +char *getType(const char *key) { + const char *dot = strchr(key, '.'); + if (dot == NULL) + throw std::invalid_argument(std::string("invalid key: ") + std::string(key)); + int length = dot - key; + char *ret = (char *) malloc(length + 1); + memcpy(ret, key, length); + ret[length] = '\0'; + return ret; +} + +/* * Utility function to delete a (key, value) pair. */ template @@ -148,20 +162,6 @@ #endif /* - * Utility function to parse out a type prefix from a key name. - */ -char *getType(const char *key) { - char *dot = strchr(key, '.'); - if (dot == NULL) - throw std::invalid_argument(std::string("invalid key: ") + std::string(key)); - int length = dot - key; - char *ret = (char *) malloc(length + 1); - memcpy(ret, key, length); - ret[length] = '\0'; - return ret; -} - -/* * Class: name_blackcap_exifwasher_exiv2_ExifData * Method: _erase * Signature: (Ljava/lang/String;)V