Author Topic: D Programming Language Support  (Read 54515 times)

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
D Programming Language Support
« on: March 23, 2010, 12:58:11 pm »
I'am new to codeblocks and have just realized, that Codeblocks support the D programming language.
I'm interessted into improve it in this manner with the following points
- fix the current bugs related to D
- update it to the newest realeas of the dmd/gdc compiler
- make it work on more plattforms (win32/linux/freeBSD[?]/OSX[?])

so my questions are:
- is this desired?
- where can I send patches? (before all, as I know, the changed code would not be related to a plugin)

thanks and greets
nocide

-----------------------------------------------------------------------

Update: 2010-03-28
I've made a patch now!
- fixed the path for dmd1/dmd2 -> win32 only (If someone can give me the
  paths for the other OS, I will add it too!)
- fixed bugID 014301 (-g option is now added to the linkeroptions)
- d_lexer updated
- d/console project updated
- added D-Icon for codecompletion
*************************************************
update: 2010-03-29
new patch available!
- fixed a bug in common_functions.script
- added support for dmd-D1/D2 on linux/OSX/freeBSD
  [note: either install on debian-based distros the .deb package from digitalMars homepage or download, unzip and install as described on the digitalMars-page!
           -> this default paths will be assumed]
*************************************************
update: 2010-03-31
Bugfix:
- added -g option to gdc/linker for debug target
update: 2010-03-31 (evening)
- minor changes in the lexer
*************************************************
updaate: 2010-04-02
- created patchfiles for *nix and win32
- minor bugfixes
*************************************************
update: 2010-04-10
- some bugfixes (tested on linux/windows)
- now with different auto-detection for D1/D2 (gdc/dmd)
*************************************************
update-2: 2010-04-10
- recognized a bug in compilerD.cpp on windows > wxShell does not exist in windows version, replaced with wxExecute
*************************************************
update: 2010-04-12
++ uploaded the patch to patch-tracker, hopfully this patch soonly will be in the trunk
*************************************************
update: 2010-05-22
- a detailed description of the installation proccess is available on http://prowiki.org/wiki4d/wiki.cgi?EditorSupport/CodeBlocks#section6
*************************************************
update: 2010-09-29
This patch is partially applied. (see http://developer.berlios.de/patch/?func=detailpatch&patch_id=2981&group_id=5358)
So the patch in this thread is no longer needed and was removed.
« Last Edit: September 29, 2010, 09:42:47 am by nocide »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: D Programming Language Support
« Reply #1 on: March 23, 2010, 01:22:20 pm »
- is this desired?
Yes, I have seen several requests / discussion in this direction.

- where can I send patches? (before all, as I know, the changed code would not be related to a plugin)
We have a bug / patch tracker available trough our webpage. I suggest you create a forum thread related to D programming where you initially post the patches for volunteers to help (test) and if you believe they are "stable" feel free to put them on the patch tracker.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: D Programming Language Support
« Reply #2 on: March 23, 2010, 01:46:25 pm »
Ok, thats fine.
I've just checked out and will post a patch ... :)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: D Programming Language Support
« Reply #3 on: March 23, 2010, 04:34:45 pm »
I'm interested in patches for GDC/D1, not so much for DMD/D2.

Was using Code::Blocks for wxD, http://wxd.sourceforge.net/


Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: D Programming Language Support
« Reply #4 on: March 23, 2010, 04:51:08 pm »
I thought to support both: D1/D2 (since D2 is still beta!)

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: (Update: 2010-03-27) D Programming Language Support
« Reply #5 on: March 28, 2010, 01:24:25 am »
push! (see post 1)

Offline bernard

  • Single posting newcomer
  • *
  • Posts: 3
Re: (Update: 2010-03-27) D Programming Language Support
« Reply #6 on: March 29, 2010, 09:11:07 am »
Code
[codeblocks]$ patch -p0 <dprogramming.patch 
(Stripping trailing CRs from patch.)
patching file src/plugins/codecompletion/codecompletion.cpp
(Stripping trailing CRs from patch.)
patching file src/plugins/compilergcc/compilerDMD.cpp
(Stripping trailing CRs from patch.)
patching file src/plugins/compilergcc/compilerDMD.h
(Stripping trailing CRs from patch.)
patching file src/plugins/compilergcc/compilergcc.cpp
(Stripping trailing CRs from patch.)
patching file src/plugins/scriptedwizard/resources/common_functions.script
Hunk #1 FAILED at 31.
Hunk #2 FAILED at 65.
Hunk #3 FAILED at 130.
3 out of 3 hunks FAILED -- saving rejects to file src/plugins/scriptedwizard/resources/common_functions.script.rej
(Stripping trailing CRs from patch.)
patching file src/plugins/scriptedwizard/resources/d/console/hello.d
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file src/plugins/scriptedwizard/resources/d/console/hello.d.rej
(Stripping trailing CRs from patch.)
patching file src/plugins/scriptedwizard/resources/d/wizard.script
Hunk #1 FAILED at 17.
Hunk #2 FAILED at 29.
2 out of 2 hunks FAILED -- saving rejects to file src/plugins/scriptedwizard/resources/d/wizard.script.rej
(Stripping trailing CRs from patch.)
patching file src/sdk/resources/lexers/lexer_d.sample
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 14.
2 out of 2 hunks FAILED -- saving rejects to file src/sdk/resources/lexers/lexer_d.sample.rej
(Stripping trailing CRs from patch.)
patching file src/sdk/resources/lexers/lexer_d.xml
Hunk #1 FAILED at 3.
Hunk #2 FAILED at 122.
2 out of 2 hunks FAILED -- saving rejects to file src/sdk/resources/lexers/lexer_d.xml.rej

common_functions.script.rej
Code
***************
*** 31,37 ****
          base.AddCompilerOption(_T("-Wall"));
      }
      else if (   GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc*"))
-              || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd")) )
      {
          base.AddCompilerOption(_T("-w"));
      }
--- 31,37 ----
          base.AddCompilerOption(_T("-Wall"));
      }
      else if (   GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc*"))
+              || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd*")) )
      {
          base.AddCompilerOption(_T("-w"));
      }
***************
*** 65,80 ****
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("ppc*"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("cygwin"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmc"))
-              || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gdc"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("tcc")) )
      {
          base.AddCompilerOption(_T("-g"));
 
-         if  (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd")))
          {
-             base.AddCompilerOption(_T("-debug"));
          }
      }
      else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc*")))
--- 65,80 ----
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("ppc*"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("cygwin"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmc"))
+              || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd*"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gcc"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("gdc"))
               || GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("tcc")) )
      {
          base.AddCompilerOption(_T("-g"));
 
+         if  (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd*")))
          {
+             base.AddLinkerOptions(_T("-g"));
          }
      }
      else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("bcc*")))
***************
*** 130,136 ****
      {
          base.AddCompilerOption(_T("-Os"));
      }
-     else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd")))
      {
          base.AddCompilerOption(_T("-O"));
      }
--- 130,136 ----
      {
          base.AddCompilerOption(_T("-Os"));
      }
+     else if (GetCompilerFactory().CompilerInheritsFrom(compilerID, _T("dmd*")))
      {
          base.AddCompilerOption(_T("-O"));
      }

[b]/src/plugins/scriptedwizard/resources/d/console/hello.d.rej[/b]
[code]
***************
*** 1,10 ****
- version(Tango) extern (C) int printf(char *, ...);
 
- int main(char[][] args)
  {
-     printf("hello world\n");
-     printf("args.length = %d\n", args.length);
-     for (int i = 0; i < args.length; i++)
- printf("args[%d] = '%s'\n", i, cast(char *)args[i]);
-     return 0;
  }
--- 1,9 ----
+ module main;
 
+ import std.stdio;
+
+ int main(string[] args)
  {
+     writefln("Hello World\n");
+ return 0;
  }

./src/plugins/scriptedwizard/resources/d/wizard.script.rej
Code
***************
*** 17,23 ****
      // add builtin pages
      Wizard.AddInfoPage(_T("DIntro"), intro_msg); // intro
      Wizard.AddProjectPathPage(); // select project name and path
-     Wizard.AddCompilerPage(_T(""), _T("dmd;gdc"), true, true); // select compiler and configurations
      // nothing more needs to be done here
  }
 
--- 17,23 ----
      // add builtin pages
      Wizard.AddInfoPage(_T("DIntro"), intro_msg); // intro
      Wizard.AddProjectPathPage(); // select project name and path
+     Wizard.AddCompilerPage(_T(""), _T("dmd1;dmd2;gdc"), true, true); // select compiler and configurations
      // nothing more needs to be done here
  }
 
***************
*** 29,35 ****
  function SetupProject(project)
  {
      // enable compiler warnings (project-wide)
-     if (Wizard.GetCompilerID().Matches(_T("gdc")))
          WarningsOn(project, Wizard.GetCompilerID());
 
      // Debug build target
--- 29,35 ----
  function SetupProject(project)
  {
      // enable compiler warnings (project-wide)
+     if (Wizard.GetCompilerID().Matches(_T("dmd1")))
          WarningsOn(project, Wizard.GetCompilerID());
 
      // Debug build target

./src/sdk/resources/lexers/lexer_d.sample.rej
Code
***************
*** 1,13 ****
- /*
-  * Sample preview code
-  * This is a block comment
   */

- /++
- A Super Block
-  ++/
 
- import std.file;
 
  /**
    * This is a documentation comment block
--- 1,12 ----
+ /**
+  * This is a Ddoc block comment
+  * Authors: Melvin D. Nerd, melvin@mailinator.com
+  * Bugs:    Doesn't work for negative values.
+  * Date:    March 14, 2003
   */
 
+ module hello;
+ import std.stdio;
 
  /**
    * This is a documentation comment block
***************
*** 15,33 ****
    * @authr some user (this is the documentation keyword error)
    */
 
- int main(char[] args)
  {
- /// This is a documentation comment line
- int[20] numbers;
  int average = 0;
  char ch = '\n';
- for (int i = 0; i < 20; ++i) // a breakpoint is set
- {
- numbers[i] = i; // active line (during debugging)
- total += i; // error line
- }
- average = total / 20;
- printf("%d\n%d\n", numbers[0], numbers[19]);
- printf("total: %d average: %d\n", total, average);
  }
-
--- 14,65 ----
    * @authr some user (this is the documentation keyword error)
    */
 
+ void main(string[] args)
  {
+     /*
+      * Sample preview code
+      * This is a block comment
+      */
+
+     /// Deprecated: superseded by function bar().
+     void foo() {  }
+
+     int numbers[20];
  int average = 0;
  char ch = '\n';
+     int a =     /+ Nested Comment +/ 1;
+     int b = 2;  // Line Comment
+
+     writefln("Hello World, Reloaded");
+
+     // auto type inference and built-in foreach
+     foreach (argc, argv; args)
+     {
+         // Improved typesafe printf
+         writeln("argc: ", argc, " arg: ", argv);
+     }
+
+     // Nested structs and classes
+     struct specs
+     {
+         // all members automatically initialized
+         int count, allocated;
+     }
+
+     // Nested functions can refer to outer
+     // variables like args
+     specs argspecs()
+     {
+         specs* s = new specs;
+         // no need for '->'
+         s.count = args.length;        // get length of array with .length
+         s.allocated = typeof(args).sizeof; // built-in native type properties
+         foreach (argv; args)
+             s.allocated += argv.length * typeof(argv[0]).sizeof;
+         return *s;
+     }
+
+     // built-in string and common string operations
+     writefln("argc = %d, " ~ "allocated = %d",
+ argspecs().count, argspecs().allocated);
  }

./src/sdk/resources/lexers/lexer_d.xml.rej
Code
***************
*** 3,102 ****
  <CodeBlocks_lexer_properties>
  <Lexer name="D"
  index="79"
- filemasks="*.d,*.dmd,*.di">
  <Style name="Default"
  index="0"
  fg="0,0,0"
- bg="255,255,255"
  bold="0"
  italics="0"
  underlined="0"/>
- <Style name="Comment (normal)"
- index="1,2"
- fg="160,160,160"/>
  <Style name="Comment (nested)"
  index="4"
- fg="160,160,160"/>
- <Style name="Comment (documentation)"
- index="3,15"
- fg="128,128,255"
- bold="1"/>
- <Style name="Comment keyword (documentation)"
- index="16"
- fg="0,128,128"/>
- <Style name="Comment keyword error (documentation)"
- index="17"
- fg="128,0,0"/>
  <Style name="Number"
  index="5"
- fg="240,0,240"/>
- <Style name="Keyword"
- index="6,7"
- fg="0,0,160"
- bold="1"/>
- <Style name="User keyword"
  index="8"
- fg="0,160,0"
- bold="1"/>
- <Style name="Typedef"
  index="9"
- fg="0,160,0"/>
  <Style name="String"
- index="10,11"
- fg="0,0,255"/>
  <Style name="Character"
  index="12"
- fg="224,160,0"/>
  <Style name="Operator"
  index="13"
- fg="255,0,0"/>
  <Style name="Selection"
  index="-99"
- bg="192,192,192"/>
  <Style name="Active line"
  index="-98"
- bg="255,255,160"/>
  <Style name="Breakpoint line"
  index="-2"
- bg="255,160,160"/>
  <Style name="Debugger active line"
  index="-3"
- bg="160,160,255"/>
  <Style name="Compiler error line"
  index="-4"
- bg="255,128,0"/>
  <Style name="Matching brace highlight"
  index="34"
  fg="255,0,0"
- bold="1"
- underlined="1"/>
  <Style name="No matching brace highlight"
  index="35"
  bg="255,0,0"/>
  <Keywords>
- <Language index="0"
- value="abstract alias align asm assert auto
- body bool break byte
- case cast catch cdouble cent cfloat char
- class const continue creal
- dchar debug default delegate delete
- deprecated do double
- else enum export extern
- false final finally float for foreach foreach_reverse function
- goto
- idouble if ifloat import in inout int interface invariant ireal is
- lazy long
- macro mixin module
- new null out override
- package pragma private protected public
- real ref return
- scope short static struct super switch synchronized
- template this throw true try typedef typeid typeof
- ubyte ucent uint ulong union unittest ushort
- version void volatile
- wchar while with"/>
- <User index="1"/>
- <Documentation index="2"
  value="a addindex addtogroup anchor arg attention
  author b brief bug c class code date def defgroup deprecated dontinclude
  e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception
--- 3,117 ----
  <CodeBlocks_lexer_properties>
  <Lexer name="D"
  index="79"
+ filemasks="*.d,*.dd,*.di">
  <Style name="Default"
  index="0"
  fg="0,0,0"
+ bg="239,240,225"
  bold="0"
  italics="0"
  underlined="0"/>
+ <Style name="Comment"
+ index="1"
+ fg="0,128,0"/>
+ <Style name="Commentline"
+ index="2"
+ fg="0,128,0"/>
+ <Style name="Comment (doc)"
+ index="3"
+ fg="107,107,107"
+ italics="1"/>
  <Style name="Comment (nested)"
  index="4"
+ fg="107,107,107"
+ italics="1"/>
  <Style name="Number"
  index="5"
+ fg="0,100,100"/>
+ <Style name="Keyword 1"
+ index="6"
+ fg="0,0,255"/>
+ <Style name="Keyword 2"
+ index="7"
+ fg="0,0,255"/>
+ <Style name="Keyword 3"
  index="8"
+ fg="0,0,255"/>
+ <Style name="Keyword 4"
  index="9"
+ fg="0,0,255"/>
  <Style name="String"
+ index="10,11,18"
+ fg="219,0,14"/>
+ <Style name="Rawstring"
+ index="19"
+ fg="219,0,14"/>
  <Style name="Character"
  index="12"
+ fg="193,135,0"/>
  <Style name="Operator"
  index="13"
+ fg="0,0,0"/>
+ <Style name="Identifier"
+ index="14"
+ fg="0,0,0"/>
+ <Style name="Commentline (doc)"
+ index="15"
+ fg="107,107,107"
+ italics="1"/>
+ <Style name="Comment keyword (doc)"
+ index="16"
+ fg="0,128,128"
+ italics="1"/>
+ <Style name="Comment keyword error (doc)"
+ index="17"
+ fg="128,0,0"
+ italics="1"
+ bold="1"/>
+ <Style name="Keyword 5"
+ index="20"
+ fg="0,113,240"/>
+ <Style name="Keyword 6"
+ index="21"
+ fg="0,0,102"/>
+ <Style name="Keyword 7"
+ index="22"
+ fg="153,0,112"/>
  <Style name="Selection"
  index="-99"
+ bg="10,36,106"
+ fg="255,255,255"/>
  <Style name="Active line"
  index="-98"
+ bg="231,231,232"/>
  <Style name="Breakpoint line"
  index="-2"
+ bg="150,58,70"
+ fg="255,255,255"/>
  <Style name="Debugger active line"
  index="-3"
+ bg="53,61,100"
+ fg="0,0,0"/>
  <Style name="Compiler error line"
  index="-4"
+ underlined="1"/>
  <Style name="Matching brace highlight"
  index="34"
  fg="255,0,0"
+ bold="1"/>
  <Style name="No matching brace highlight"
  index="35"
  bg="255,0,0"/>
  <Keywords>
+ <Set index="0" value="void byte bool ubyte short ushort int uint long ulong cent ucent float double real ifloat
+ idouble ireal cfloat cdouble creal char wchar dchar body asm bool true false function delegate"/>
+ <Set index="1" value="public private protected with extern
+ final abstract override const debug version pragma public private deprecated protected volatile
+ class struct interface enum new this null delete invariant super union template
+
+ is import module alias typedef with cast package typeof typeid classinfo mixin
+ in out const static inout lazy ref extern export auto align scope pure"/>
+ <Set index="2"
  value="a addindex addtogroup anchor arg attention
  author b brief bug c class code date def defgroup deprecated dontinclude
  e em endcode endhtmlonly endif endlatexonly endlink endverbatim enum example exception
***************
*** 107,112 ****
  sa section see showinitializer since skip skipline struct subsection
  test throw todo typedef union until
  var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }"/>
  </Keywords>
  <SampleCode value="lexer_d.sample"
  breakpoint_line="20"
--- 122,129 ----
  sa section see showinitializer since skip skipline struct subsection
  test throw todo typedef union until
  var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }"/>
+ <Set index="3"
+ value="if for foreach while do assert return unittest try catch else throw switch case break continue default finally goto synchronized"/>
  </Keywords>
  <SampleCode value="lexer_d.sample"
  breakpoint_line="20"
[/code]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: (Update: 2010-03-27) D Programming Language Support
« Reply #7 on: March 29, 2010, 10:56:39 am »
Code
[...]
Applied just nice over here. Are you sure you are using trunk? It might be an issue with the line feeds on Linux. Take in mind that this patch was for Windows atm. Try a dos2unix at the patch file before applying it under Linux.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: (Update: 2010-03-27) D Programming Language Support
« Reply #8 on: March 29, 2010, 01:14:55 pm »
Hello bernard!

I just tried it myself and it works just fine.
It may be as Morten mentioned, that the lineendings make problems.
So I created a new patch (same content) with unix lineendigns (see post 1)

greets
nocide

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: (Update: 2010-03-27) D Programming Language Support
« Reply #9 on: March 29, 2010, 06:56:29 pm »
push (see post 1)

Offline bernard

  • Single posting newcomer
  • *
  • Posts: 3
Re: (Update: 03-29) D Programming Language Support
« Reply #10 on: March 30, 2010, 12:12:27 am »
It's still failing with the same things as before. I have no idea why, I see no real reason for the hunks to fail.

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: (Update: 03-29) D Programming Language Support
« Reply #11 on: March 30, 2010, 08:46:35 am »
Ok,
I could reproduce this failure!
Strange, with tortoiseSVN it worked perfect, but with the msys patch-tool I get the same output as you ??
I try to fix!

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: (Update: 2010-03-29) D Programming Language Support
« Reply #12 on: March 30, 2010, 02:09:03 pm »
Hello Bernard

I have created a patch with Gnu-diff (GnuWin32) tool.  (see post 1)
This worked for me to patch with TortoiseSVN and the gnu-patch tool.
Please try it out and report back

greets
nocide

Offline nocide

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: (Update: 2010-03-31) D Programming Language Support
« Reply #13 on: March 31, 2010, 10:30:11 am »
Bugfix:
- added -g option to gdc/linker for debug target

Offline bernard

  • Single posting newcomer
  • *
  • Posts: 3
Re: D Programming Language Support
« Reply #14 on: March 31, 2010, 11:29:35 pm »
Still failing, no clue why. I'm going to manually apply these bastards if I have to!

EDIT: Okay, patch manually applied (D:), compiling now.
« Last Edit: April 01, 2010, 12:24:17 am by bernard »