コード例 #1
0
ファイル: LustreCompiler.cs プロジェクト: pascalpfeil/ssharp
        public static string Compile(string lustreSource, string mainNode)
        {
            //HACK to make this thread safe
            lock (mutex)
            {
                SetupLus2Oc();

                var wslHomeDirectory = WslUtil.ExecuteCommandWithResult("echo $HOME")       // Get home directory of current wsl user
                                       .Trim();                                             // Remove trailing '\n'

                var lxssHomeDirectory = Path.Combine(
                    Environment.GetEnvironmentVariable("localappdata"),                     // Wsl filesystem is stored under
                    "lxss",                                                                 // %localappdata%/lxss
                    wslHomeDirectory.Remove(0, 1)                                           // Remove leading '/'
                    );


                // Store lustre source for lus2oc to read
                File.WriteAllText(Path.Combine(lxssHomeDirectory, $"{mainNode}.lus"), lustreSource);


                WslUtil.ExecuteCommand($"chmod 0777 {wslHomeDirectory}/{mainNode}.lus");

                // Compile .lus to wsl users home directory
                WslUtil.ExecuteCommand(
                    $"export LUSTRE_INSTALL={wslHomeDirectory}/bin/lustre-v4-III-db-linux64;" +                                     // Set environment variable
                    "source $LUSTRE_INSTALL/setenv.sh;" +                                                                           // Source setenv script
                    $"lus2oc {wslHomeDirectory}/{mainNode}.lus {mainNode} -o {wslHomeDirectory}/{mainNode}.oc"                      // Compile .lus file
                    );

                // Read and return compiled object code
                return(File.ReadAllText(Path.Combine(lxssHomeDirectory, $"{mainNode}.oc")));
            }
        }
コード例 #2
0
ファイル: LustreCompiler.cs プロジェクト: pascalpfeil/ssharp
 /// <summary>
 /// Downloads and unpacks lustre-v4 to current wsl users home directory if not yet available
 /// For more information on lus2oc visit http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/lustre-v4/distrib/lv4-html/index.html
 /// </summary>
 private static void SetupLus2Oc()
 {
     if (!WslUtil.CheckDirectory("$HOME/bin/lustre-v4-III-db-linux64/"))
     {
         Console.WriteLine("Downloading lus2oc:");
         WslUtil.ExecuteCommand($"curl -o /tmp/lustrev4.tgz http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/lustre-v4/distrib/linux64/lustre-v4-III-db-linux64.tgz");
         Console.WriteLine("Creating Directory for lus2oc:");
         WslUtil.ExecuteCommand("mkdir $HOME/bin");
         Console.WriteLine("Unpacking lus2oc:");
         WslUtil.ExecuteCommand("tar zxvf /tmp/lustrev4.tgz -C $HOME/bin/");
     }
 }