diff --git a/cli/cli.gpr b/cli/cli.gpr index d9d912ff80..93530be729 100644 --- a/cli/cli.gpr +++ b/cli/cli.gpr @@ -1,6 +1,7 @@ with "../shared"; with "../kernel/kernel_core"; +with "../python/python_core"; project CLI is diff --git a/cli/src/gps-cli.adb b/cli/src/gps-cli.adb index 642a8d316c..bc702c80d8 100644 --- a/cli/src/gps-cli.adb +++ b/cli/src/gps-cli.adb @@ -18,11 +18,13 @@ with GPS.CLI_Kernels; with GPS.Core_Kernels; +with GPS.Python_Core; procedure GPS.CLI is Kernel : aliased GPS.CLI_Kernels.CLI_Kernel; begin GPS.Core_Kernels.Initialize (Kernel'Access); + GPS.Python_Core.Register_Python (Kernel'Access); -- Destroy all GPS.Core_Kernels.Destroy (Kernel'Access); diff --git a/kernel/src_info/gps-core_kernels.adb b/kernel/src_info/gps-core_kernels.adb index 2c34f6e922..a1d658796f 100644 --- a/kernel/src_info/gps-core_kernels.adb +++ b/kernel/src_info/gps-core_kernels.adb @@ -56,6 +56,17 @@ package body GPS.Core_Kernels is GNATCOLL.Symbols.Free (Self.Symbols); end Destroy; + ----------------- + -- Get_Scripts -- + ----------------- + + function Get_Scripts + (Kernel : access Core_Kernel'Class) + return GNATCOLL.Scripts.Scripts_Repository is + begin + return Kernel.Scripts; + end Get_Scripts; + ---------------- -- Initialize -- ---------------- diff --git a/kernel/src_info/gps-core_kernels.ads b/kernel/src_info/gps-core_kernels.ads index 92378b1bc5..e15f9693c3 100644 --- a/kernel/src_info/gps-core_kernels.ads +++ b/kernel/src_info/gps-core_kernels.ads @@ -43,6 +43,10 @@ package GPS.Core_Kernels is -- Data used to store information for the scripting languages end record; + function Get_Scripts + (Kernel : access Core_Kernel'Class) + return GNATCOLL.Scripts.Scripts_Repository; + procedure Create_Registry (Self : not null access Core_Kernel) is abstract; -- Initialize Registry with kernel specific version diff --git a/python/core/gps-python_core.adb b/python/core/gps-python_core.adb new file mode 100644 index 0000000000..f9688c976b --- /dev/null +++ b/python/core/gps-python_core.adb @@ -0,0 +1,49 @@ +------------------------------------------------------------------------------ +-- G P S -- +-- -- +-- Copyright (C) 2013, AdaCore -- +-- -- +-- This is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. This software is distributed in the hope that it will be useful, -- +-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- +-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- +-- License for more details. You should have received a copy of the GNU -- +-- General Public License distributed with this software; see file -- +-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- +-- of the license. -- +------------------------------------------------------------------------------ + +with GNATCOLL.Scripts; +with GNATCOLL.Scripts.Python; use GNATCOLL.Scripts.Python; +with GNATCOLL.Utils; use GNATCOLL.Utils; + +with GNAT.OS_Lib; use GNAT.OS_Lib; +-- with GNAT.Strings; use GNAT.Strings; + +package body GPS.Python_Core is + + --------------------- + -- Register_Python -- + --------------------- + + procedure Register_Python + (Kernel : access GPS.Core_Kernels.Core_Kernel'Class) + is + Python_Home : String_Access := Getenv ("GPS_PYTHONHOME"); + begin + if Python_Home.all = "" then + Free (Python_Home); + Python_Home := new String'(Executable_Location); + end if; + + Register_Python_Scripting + (Kernel.Get_Scripts, + Module => "GPS", + Python_Home => Python_Home.all); + + Free (Python_Home); + end Register_Python; + +end GPS.Python_Core; diff --git a/python/core/gps-python_core.ads b/python/core/gps-python_core.ads new file mode 100644 index 0000000000..a9a8947597 --- /dev/null +++ b/python/core/gps-python_core.ads @@ -0,0 +1,26 @@ +------------------------------------------------------------------------------ +-- G P S -- +-- -- +-- Copyright (C) 2013, AdaCore -- +-- -- +-- This is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. This software is distributed in the hope that it will be useful, -- +-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- +-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- +-- License for more details. You should have received a copy of the GNU -- +-- General Public License distributed with this software; see file -- +-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- +-- of the license. -- +------------------------------------------------------------------------------ + +with GPS.Core_Kernels; + +package GPS.Python_Core is + + procedure Register_Python + (Kernel : access GPS.Core_Kernels.Core_Kernel'Class); + -- Register python in script registry of the Kernel + +end GPS.Python_Core; diff --git a/python/python.gpr b/python/python.gpr index 237e1ff51f..1ba1e243dc 100644 --- a/python/python.gpr +++ b/python/python.gpr @@ -2,6 +2,7 @@ with "../shared"; with "../kernel/kernel"; with "gtkada"; with "../gnatlib/src/gnatcoll"; +with "python_core"; project Python is diff --git a/python/python_core.gpr b/python/python_core.gpr new file mode 100644 index 0000000000..e4414e7486 --- /dev/null +++ b/python/python_core.gpr @@ -0,0 +1,14 @@ +with "../shared"; +with "../kernel/kernel_core"; +with "../gnatlib/src/gnatcoll"; + +project Python_Core is + + for Source_Dirs use ("core"); + for Object_Dir use Shared'Object_Dir; + for Languages use ("Ada"); + + package Compiler renames Shared.Compiler; + package IDE renames Shared.IDE; + +end Python_Core; diff --git a/python/src/python_module.adb b/python/src/python_module.adb index dd6d144434..aea28a3fa5 100644 --- a/python/src/python_module.adb +++ b/python/src/python_module.adb @@ -18,14 +18,11 @@ with Ada.Containers; with Ada.Unchecked_Conversion; -with GNAT.OS_Lib; use GNAT.OS_Lib; - with GNATCOLL.Projects; use GNATCOLL.Projects; with GNATCOLL.Python; use GNATCOLL.Python; with GNATCOLL.Scripts; use GNATCOLL.Scripts; with GNATCOLL.Scripts.Python; use GNATCOLL.Scripts.Python; with GNATCOLL.Scripts.Python.Gtkada; use GNATCOLL.Scripts.Python.Gtkada; -with GNATCOLL.Utils; use GNATCOLL.Utils; with GNATCOLL.Xref; with Basic_Types; @@ -45,6 +42,7 @@ with GPS.Kernel.Modules.UI; use GPS.Kernel.Modules.UI; with GPS.Kernel.Scripts; use GPS.Kernel.Scripts; with GPS.Kernel.Task_Manager; use GPS.Kernel.Task_Manager; with GPS.Kernel; use GPS.Kernel; +with GPS.Python_Core; with Histories; use Histories; with Interactive_Consoles; use Interactive_Consoles; with String_Utils; use String_Utils; @@ -215,19 +213,8 @@ package body Python_Module is pragma Unreferenced (Ignored, Tmp); Script : Scripting_Language; - Python_Home : String_Access := Getenv ("GPS_PYTHONHOME"); begin - if Python_Home.all = "" then - Free (Python_Home); - Python_Home := new String'(Executable_Location); - end if; - - Register_Python_Scripting - (Get_Scripts (Kernel), - Module => "GPS", - Python_Home => Python_Home.all); - - Free (Python_Home); + GPS.Python_Core.Register_Python (Kernel); Script := Lookup_Scripting_Language (Get_Scripts (Kernel), Python_Name); if Script = null then