示例#1
0
        public static string CreateArgument(ref ProjectEnvironment.ProjectModule tanner)
        {
            string arg          = "-classpath ";
            string classPaths   = "";
            ProjectEnvironment project = tanner.Project;

            foreach (ProjectEnvironment.ProjectModule module in project.ProjectModules)
            {
                classPaths += /*AppendAllSubDirectories(module.JavaBinDirectory) + */ module.JavaBinDirectory + Path.PathSeparator;
            }
            arg += classPaths.Substring(0, classPaths.Length - 1) + " -d jni ";

            Regex correctPackageSyntax = new Regex(@"^package ([a-zA-Z_]*\.*)+;");

            foreach (ProjectEnvironment.ProjectModule module in project.ProjectModules)
            {
                foreach (string entry in module.JniClasses)
                {
                    foreach (string line in File.ReadAllLines(entry))
                    {
                        string t = line.Trim().Replace("\t", "");
                        if (correctPackageSyntax.IsMatch(t))
                        {
                            Match match = correctPackageSyntax.Match(t);
                            if (match.Groups.Count > 0)
                            {
                                FileInfo currentFile = new FileInfo(entry);
                                string pckgName = match.Groups[0].ToString().Replace("package", "").Replace(";", "").Trim();
                                string fName = currentFile.Name.Replace(".java", "");
                                arg += pckgName + "." + fName + " ";
                                break;
                            }
                        }
                    }
                }
            }

            return arg;
        }
示例#2
0
        public static void JavaHBatchForProjectModule(ref ProjectEnvironment.ProjectModule tanner, ref MessageScreenScrollable mockConsole, FileInfo javaH)
        {
            string arg                  = "-classpath ";
            string classPaths           = "";
            ProjectEnvironment project  = tanner.Project;
            List<string> allClasses     = new List<string>();
            int numberOfClasses         = 0;

            foreach (ProjectEnvironment.ProjectModule module in project.ProjectModules)
            {
                classPaths += module.JavaBinDirectory + Path.PathSeparator;
                allClasses.AddRange(module.JniClasses);
            }
            arg += classPaths.Substring(0, classPaths.Length - 1) + " -d jni ";

            numberOfClasses = allClasses.Count;
            if (mockConsole != null)
            {
                mockConsole.AppendText(Environment.NewLine + "found " + numberOfClasses + " classes with native methods");
            }

            RunBatch(allClasses.ToArray(), arg, javaH.FullName, tanner.ModuleRootDirectory, ref mockConsole);
        }
示例#3
0
        // ---------------------------------------------------------------------------------------
        // ---- Internal Functions

        #region Internal Functions

        #region Initializing Project

        private void SetCurrentProject(ProjectEnvironment project)
        {
            if (!NUtilityGlobalContext.Projects.Contains(project))
            {
                NUtilityGlobalContext.Projects.Add(project);
                ProjectSelectionComboBox.Items.Clear();
                ProjectSelectionComboBox.Items.AddRange(NUtilityGlobalContext.Projects.ToArray());

                PrintMessageInMessageBox(string.Format("Added Project. Name = [{0}]", project.ProjectName));

                if (project.ProjectModules.Count > 0)
                {
                    AndroidStudioModuleComboBox.Enabled = true;
                    ModulesLabel.Visible = AndroidStudioModuleComboBox.Visible = true;
                    AndroidStudioModuleComboBox.Items.Clear();
                    AndroidStudioModuleComboBox.Items.AddRange(project.ProjectModules.Distinct().ToArray());
                    foreach (ProjectEnvironment.ProjectModule module in project.ProjectModules)
                    {
                        PrintMessageInMessageBox(string.Format("Added Module. Name = [{0}]", module.ModuleName), context: project.ProjectName);
                    }
                }
            }

            if (ProjectSelectionComboBox.Items.Count > 0 && ProjectSelectionComboBox.SelectedIndex < 0)
            {
                if (ProjectSelectionComboBox.Items.IndexOf(project) >= 0)
                {
                    ProjectSelectionComboBox.SelectedIndex = ProjectSelectionComboBox.Items.IndexOf(project);

                    if (AndroidStudioModuleComboBox.Items.Count > 0 && AndroidStudioModuleComboBox.SelectedIndex < 0)
                    {
                        AndroidStudioModuleComboBox.SelectedIndex = 0;
                    } 
                }
                else
                {
                    ProjectSelectionComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                try
                {
                    Thread bgThread = new Thread(new ThreadStart(PopulateAllFileTrees));
                    bgThread.IsBackground = true;
                    bgThread.Start();
                }
                catch (Exception ex) { }
            }
        }
示例#4
0
 // ProjectEnvironment project       :: project of which this object will be in scope
 // string[] additionalTagFilters    :: optional extra filter tags when listening to ndk-stack
 public NdkStackListener(ProjectEnvironment project, string[] additionalTagFilters=null)
 {
     AdbThreadChecker = new Thread(new ThreadStart(CheckAdbProcessExists));
     AdbThreadChecker.IsBackground = true;
     AdbThreadChecker.Start();
 }
示例#5
0
        private void CurrentDir_Click(object sender, EventArgs e)
        {
            string tempRoot = Directory.GetCurrentDirectory();
            
            // Keep going up file system tree until we reach the root
            try
            {
                while (true)
                {
                    if (ProjectEnvironment.IsValidProjectPath(tempRoot))
                    {
                        ProjectEnvironment project = new ProjectEnvironment(tempRoot);
                        SetCurrentProject(project);
                        return;
                    }
                    else
                    {
                        tempRoot = Directory.GetParent(tempRoot).FullName;
                    }
                }
            }
            catch (Exception except)
            {

            }

            MainWindow.ShowDialog("Couldn't find a native android app. Are you sure you placed the executable in the right directory?", true);
        }
示例#6
0
        // ----
        // "-s" or "--rootdirectory"    : Specify root directory
        // "-d" or "--debug"            : Specify Debug Mode, which provides more info to user through messaging
        // "--suppress-dialogs          : Suppress any alert dialogs that are not raised from severe events
        // "-define=THIS;THAT;ETC"      : Extra defines for compiler separated by semicolons

        private void HandleCommandLineArgs()
        {
            string[] startupArgs = Environment.GetCommandLineArgs();
            if (startupArgs != null)
            {
                if (startupArgs.Length > 0)
                {
                    // Do a first pass and check for certain modes
                    foreach (string arg in startupArgs)
                    {
                        if (arg == "--suppress-dialogs")
                        {
                            NUtilityGlobalContext.SuppressDialogMode    = true;
                            SuppressDialogsMenuItem.Checked             = true;
                        }
                    }

                    for (int i = 0; i < startupArgs.Length; i++)
                    {
                        string arg = startupArgs[i];

                        // ----
                        // Argument Handling

                        // Specifying root directory
                        if (arg == "-s" || arg == "--rootdirectory" && i < startupArgs.Length - 1)
                        {
                            i++;
                            string directory = startupArgs[i];
                            if (ProjectEnvironment.IsValidProjectPath(directory))
                            {
                                HasValidStartupArgs         = true;
                                HasInitialRootDirectory     = true; 
                                ProjectEnvironment project  = new ProjectEnvironment(directory);
                                SetCurrentProject(project);
                            }
                        }

                        // Debug Mode
                        else if (arg == "-d" || arg.ToLower() == "--debug")
                        {
                            NUtilityGlobalContext.DebugMode = true;
                            DebugModeMenuItem.Checked       = true;
                        }

                        // Suppress Dialogs
                        else if (arg.ToLower() == "--suppress-dialogs") {
                            NUtilityGlobalContext.SuppressDialogMode    = true;
                            SuppressDialogsMenuItem.Checked             = true;
                        }

                        // Defines
                        else if (arg.StartsWith("--define", StringComparison.InvariantCultureIgnoreCase))
                        {
                            try
                            {
                                string minusDefine = arg.Substring("--define=".Length);
                                if (minusDefine.Contains(";"))
                                {
                                    NUtilityGlobalContext.ExtraCompilerDefine = "";
                                    string[] defines = minusDefine.Split(';');
                                    foreach (string define in defines)
                                    {
                                        NUtilityGlobalContext.ExtraCompilerDefine += " -D" + define.ToUpper() + "=1";
                                    }
                                }
                                else
                                {
                                    NUtilityGlobalContext.ExtraCompilerDefine = " -D" + minusDefine.ToUpper() + "=1";
                                }

                                PrintMessageInMessageBox("Extra compiler flags found. To use in your makefile, expand the environment variable 'NUTILITY_DEFINES'", context: "nUtility Startup", severity:(int)TextSeverity.VERBOSE);
                            }
                            catch (Exception e) {
                                PrintMessageInMessageBox("Couldn't add extra compiler flags... Exception thrown: " + e.ToString(), context: "nUtility Startup", severity: (int)TextSeverity.ERROR);
                            }
                        }

                    }   // end loop iterating over cmd line args

                }
            }
        }
示例#7
0
        // --------
        // ProjectSelectionComboBox Delegates
        private void ProjectSelectionComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedProjectEnvironment = (ProjectEnvironment)ProjectSelectionComboBox.SelectedItem;

            try
            {
                Thread bgThread = new Thread(new ThreadStart(PopulateAllFileTrees));
                bgThread.IsBackground = true;
                bgThread.Start();
            }
            catch (Exception ex) { }

            AndroidStudioModuleComboBox.Items.Clear();
            AndroidStudioModuleComboBox.Items.AddRange(SelectedProjectEnvironment.ProjectModules.ToArray());

            if (AndroidStudioModuleComboBox.Items.Count == 0)
            {
                AndroidStudioModuleComboBox.Enabled = false;

                ArchBinaryList.Items.Clear();
                BinariesList.Items.Clear();

                ArchBinaryList.Enabled  = false;
                BinariesList.Enabled    = false;
                FunctionList.Enabled    = false;
            }

            RootDirectoryLabel.Text = SelectedProjectEnvironment.RootDirectory;
        }
示例#8
0
        // -----
        // -----
        // -----
        // -----
        // FROM MainWindow_internals
        // -----
        // -----
        // -----
        // -----

        #region Parsing Java files

        public string CreateJava_h_argument(ref ProjectEnvironment.ProjectModule tanner)
        {
            string arg = "";
            Regex correctPackageSyntax = new Regex(@"^package ([a-zA-Z_]*\.[a-zA-Z_]*){1,}");
            foreach (string entry in tanner.JniClasses)
            {
                foreach (string line in File.ReadAllLines(entry))
                {
                    string t = line.Trim().Replace("\t", "");
                    if (correctPackageSyntax.IsMatch(t))
                    {
                        Match match = correctPackageSyntax.Match(t);
                        if (match.Groups.Count > 0)
                        {
                            FileInfo currentFile = new FileInfo(entry);
                            string pckgName = match.Groups[0].ToString().Replace("package", "").Trim();
                            string fName = currentFile.Name.Replace(".java", "");
                            arg += pckgName + "." + fName + " ";
                            break;
                        }
                    }
                }
            }

            return arg;
        }
示例#9
0
            public ProjectModule(string root, string moduleName, ProjectEnvironment project)
            {
                Project             = project;
                ModuleRootDirectory = root;
                ModuleName          = moduleName;

                Init();

                HasAndroid_mk       = File.Exists(Path.Combine(JniDirectory, "Android.mk"));
                HasApplication_mk   = File.Exists(Path.Combine(JniDirectory, "Application.mk"));
            }
 public ProjectEnvironmentForm(ProjectEnvironment project)
 {
     Project = project;
     InitializeComponent();
 }
示例#11
0
        public static void AddProject(ProjectEnvironment rootDirectory)
        {
            if (Projects.Contains(rootDirectory))
            {
                return;
            }

            if (MainWindow.Instance.InvokeRequired)
            {
                MainWindow.Instance.Invoke(new ProjectDelegate(AddProject), new object[] { rootDirectory });
                return;
            }
            else
            {
                Projects.Add(rootDirectory);
                MainWindow.Instance.ProjectSelectionComboBox.Items.Clear();
                MainWindow.Instance.ProjectSelectionComboBox.Items.AddRange(Projects.ToArray());
                if (MainWindow.Instance.ProjectSelectionComboBox.SelectedIndex < 0 && MainWindow.Instance.ProjectSelectionComboBox.Items.Count > 0)
                {
                    MainWindow.Instance.ProjectSelectionComboBox.SelectedIndex = 0;
                }
            }
        }