Changeset 21b3864


Ignore:
Timestamp:
Jul 8, 2018 1:16:07 PM (23 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
2664c41, 6d0f80f
Parents:
27a0d4e
Message:

Moved some logic to C++, which will extract i2p if it's not already,
and then secondly fire up the router in a second java process when
extraction is completed. Gonna use "optional" type in C++ to make
global variables a bit less painful to use.

Location:
launchers/macosx
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/README.md

    r27a0d4e r21b3864  
    77More code will be merged in, it's just a f* mess which Meeh needs to clean up and move into repo.
    88
     9`./fullBuild.sh` triggers Ant jobs and prepare the base.zip, as well as starting the ninja build.
  • launchers/macosx/build.sbt

    r27a0d4e r21b3864  
    99lazy val bundleBuildPath = new File("./output")
    1010
    11 lazy val staticFiles = List(
    12   "blocklist.txt",
    13   "clients.config",
    14   "continents.txt",
    15   "countries.txt",
    16   "hosts.txt",
    17   "geoip.txt",
    18   "router.config",
    19   "webapps.config"
    20 )
    2111
    2212lazy val resDir = new File("./../installer/resources")
     
    2515lazy val jarsForCopy = new File(i2pBuildDir, "lib").list.filter { f => f.endsWith(".jar") }
    2616
    27 // TODO: Meeh: To be removed - logic is moved to obj-cpp
    28 def defaultOSXLauncherShellScript(javaOpts: Seq[String] = Seq.empty): Seq[String] = {
    29   val javaOptsString = javaOpts.map(_ + " ").mkString
    30   Seq(
    31     "#!/usr/bin/env sh",
    32     s"""
    33        |echo "I2P - Mac OS X Launcher starting up"
    34        |export I2P=$$HOME/Library/I2P
    35        |for jar in `ls $${I2P}/lib/*.jar`; do
    36        |  if [ ! -z $$CP ]; then
    37        |      CP=$${CP}:$${jar};
    38        |  else
    39        |      CP=$${jar}
    40        |  fi
    41        |done
    42        |export CLASSPATH=$$CP
    43        |exec java -jar $javaOptsString$$JAVA_OPTS "$$0" "$$@"""".stripMargin,
    44     "")
    45 }
    4617
    4718// Pointing the resources directory to the "installer" directory
     
    5627)
    5728
    58 assemblyOption in assembly := (assemblyOption in assembly).value.copy(
    59   prependShellScript = Some(defaultOSXLauncherShellScript(
    60     Seq(
    61       "-Xmx512M",
    62       "-Xms128m",
    63       "-Dwrapper.logfile=/tmp/router.log",
    64       "-Dwrapper.logfile.loglevel=DEBUG",
    65       "-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
    66       "-Dwrapper.console.loglevel=DEBUG",
    67       "-Di2p.dir.base=$I2P",
    68       "-Djava.library.path=$I2P"
    69     )))
    70 )
     29assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false, includeDependency = false)
    7130
    7231
    73 assemblyJarName in assembly := s"OSXLauncher"
     32assemblyJarName in assembly := s"launcher.jar"
    7433
    7534assemblyExcludedJars in assembly := {
  • launchers/macosx/obj-cpp/JavaRunner.cpp

    r27a0d4e r21b3864  
    33#include <dispatch/dispatch.h>
    44#include <subprocess.hpp>
     5#include <future>
    56
    67using namespace subprocess;
     8using namespace std::experimental;
    79
    810JavaRunner::JavaRunner(std::string javaBin, const fp_proc_t& execFn, const fp_t& cb)
     
    1214}
    1315
    14 void JavaRunner::execute()
     16optional<std::future<int> > JavaRunner::execute()
    1517{
    1618  try {
     
    2527    printf("Finished executingFn - Runs callbackFn\n");
    2628    this->exitCallbackFn();
     29    return std::async(std::launch::async, []{ return 0; });
    2730  } catch (std::exception* ex) {
    2831    printf("ERROR: %s\n", ex->what());
     32    return nullopt;
    2933  }
    3034}
  • launchers/macosx/obj-cpp/JavaRunner.h

    r27a0d4e r21b3864  
    44#include <functional>
    55#include <memory>
     6#include <string>
     7#include <list>
    68
    79#include <subprocess.hpp>
     10#include <optional.hpp>
    811
    912using namespace subprocess;
     13using namespace std::experimental;
    1014
    1115class JavaRunner;
     
    2428
    2529/**
    26  * 
     30 *
    2731 * class JavaRunner
    28  * 
     32 *
    2933 **/
    3034class JavaRunner
     
    3539  ~JavaRunner() = default;
    3640
    37   void execute();
     41  const std::list<std::string> defaultStartupFlags {
     42    "-Xmx512M",
     43    "-Xms128m",
     44    "-Djava.awt.headless=true",
     45    "-Dwrapper.logfile=/tmp/router.log",
     46    "-Dwrapper.logfile.loglevel=DEBUG",
     47    "-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
     48    "-Dwrapper.console.loglevel=DEBUG",
     49    "-Di2p.dir.base=$BASEPATH",
     50    "-Djava.library.path=$BASEPATH",
     51    "$JAVA_OPTS",
     52    "net.i2p.launchers.SimpleOSXLauncher"
     53  };
     54
     55  const std::list<std::string> defaultFlagsForExtractorJob {
     56    "-Xmx512M",
     57    "-Xms128m",
     58    "-Djava.awt.headless=true",
     59    "-Di2p.dir.base=$BASEPATH",
     60    "-Di2p.dir.zip=$ZIPPATH",
     61    "net.i2p.launchers.BaseExtractor",
     62    "extract"
     63  };
     64
     65  optional<std::future<int> > execute();
    3866  std::shared_ptr<Popen> javaProcess;
    3967  std::string javaBinaryPath;
  • launchers/macosx/obj-cpp/build.ninja

    r27a0d4e r21b3864  
    2323  command = rm -fr *.o clauncher I2PLauncher.app
    2424
     25# TODO: There must exists a cleaner way to solve this.
    2526rule bundledir
    26   command = mkdir -p I2PLauncher.app/Contents/{MacOS,Resources,Frameworks} && cp Info.plist I2PLauncher.app/Contents/Info.plist
     27  command = mkdir -p I2PLauncher.app/Contents/{MacOS,Resources,Frameworks} $
     28    && cp Info.plist I2PLauncher.app/Contents/Info.plist $
     29    && cp base.zip I2PLauncher.app/Contents/Resources/base.zip
    2730
    2831rule copytobundledir
     
    3134rule copyimgtobundle
    3235  command = cp ItoopieTransparent.png I2PLauncher.app/Contents/Resources/ItoopieTransparent.png
     36
     37rule builddir
     38  command = mkdir -p build
    3339
    3440build main.o: cxx main.mm
     
    4450
    4551build appbundle: copyimgtobundle | clauncher bundle copytobundle
    46 #build all: clauncher
     52
     53default appbundle
Note: See TracChangeset for help on using the changeset viewer.