Author Topic: Vala language  (Read 13305 times)

epsilon_da

  • Guest
Vala language
« on: April 08, 2009, 05:38:15 pm »
Hi.
I like proramming portable applications in GTK with Codeblocks and someday i would like to try Vala.
So, ¿Is there any support for Vala planned?



epsilon_da

  • Guest
Re: Vala language
« Reply #1 on: April 17, 2009, 03:32:09 am »
Vala is a new multiplatform compiler similar to C# based on GObject.
It is quickly growing and is being adopted by many GNOME projects.

It can also generate Code in C using GLib objects.

http://live.gnome.org/Vala

Sadly i cant find a way to setup it as a Compiler, because it is not a classical C compiler.
It can do many tasks:

 - Generate C/GLib Code, for libraries, clases, or the entire app, and be completely usable from C.
 - Compile the entire Vala project.
 - Compile directly without linking.
 - Handle dependencies when posible.

If i set as a C and C++ compiler "valac" then i get the next message:

"Linking stage skipped (build target has no object files to link)
Nothing to be done."

I think that CB is not calling the compiler properly.

To compile an entire Vala Project execute the next command:
  valac -o output main.vala file1.vala file2.vala ... -pkg dependency1-1.0 dependency2-1.0 ...
And this will compile the entire project. So there is not much to do more than having 3 variables:
  $output_name
  $vala_file_list
  $vala_dependency_list

then
  valac -o $output_name $vala_file_list -pkg $vala_dependency_list

But i dont know how to automate this process in codeblocks.



In a GTK project could also be useful to convert a class implemented in Vala in a .c/.h pair to be used from the C project.
  valac -C myclass.vala --directory ./myclass/ -H ./myclass/myclass.h

This can be done in "Pre build steps" but the result files, should be compiled by codeblocks, and so, added to the project before compiling, but should not be directly edited because will be overwriten by valac.


There are a few IDEs being developed for Vala. But any of them are close to CodeBlocks.
CB could make an step forward in the next version and easily add the Vala compiler and projects.


Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Vala language
« Reply #2 on: April 17, 2009, 04:48:11 am »

epsilon_da

  • Guest
Re: Vala language
« Reply #3 on: April 17, 2009, 04:48:39 pm »
Thanks dmoore.

Yes that wiki page would be what i was finding.
I always find this wikis a total mess. ^^

But i have 2 questions.

 - There isnt any macro definning a space separated list of source files. Only for objects. Vala compilates the entire project without the need to handle object files with an IDE.
The command should be like:
  $compiler $libdirs $libs -o $exe_output $sources_files
where $libdirs, is a list of paths prepended with --vapidir and $libs is a list of vala libs without writing the extension (.vapi) and prepended by --pkg , and $sources_files is a space-separated list of vala files.
That will produce the final output file, but "compiler" gets executed for each file, which is not valid in this case for vala.
I also tryed to configure it as a linker, but linker seems to require the existence of object files.
How can i tell codeblocks that it should take each $file as a $link_object on the "compiler" part.(Append each .vala to the link_objects list without generating new files)
And then use valac as a linker with all this files.

 - The second question, is that if i use valac to generate C code instead of as a compiler, i would need to change the configuration of "GNU GCC Compiler" is there a better project-portable solution?
Any way, this is the least critical part. I can just place the instructions in "pre build steps", but the generated file would need to be manually added to the project.



epsilon_da

  • Guest
Re: Vala language
« Reply #4 on: April 17, 2009, 06:01:00 pm »
Or i can make a build script:

function SetBuildOptions(base) // base = target
{

ShowMessage( base.GetOutputFilename() );

project = GetProjectManager();
GetCompilerFactory

if ( ! IO.DirectoryExists( base.GetOutputFilename() ) )
   IO.CreateDirectory( base.GetOutputFilename(), 777 );

vala_cmd <- _T("valac -o "+ base.GetOutputFilename()+" main.vala hello.vala");

Log( IO.ExecuteAndGetOutput ( vala_cmd ) );

}


The problem here is that the Output filename is not the setted in the project.
The message dialog will show "output", but the output filename is set to bin/Debug-Unix/output

I cant find any ther function to define, except for "SetBuildOptions".
Is there any other or a way to get the correct Options in the project?


Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Vala language
« Reply #5 on: April 17, 2009, 08:08:54 pm »
That will produce the final output file, but "compiler" gets executed for each file, which is not valid in this case for vala.

Are you sure Vala doesn't support per file compilation? AFAICT you can specify vala output a set .c/.h files for each source. If you tell C::B that these are generated files, C::B will take care of their compilation. This is very much like the swig example in the wiki.

Quote
- The second question, is that if i use valac to generate C code instead of as a compiler, i would need to change the configuration of "GNU GCC Compiler" is there a better project-portable solution?

I haven't looked into the portability of the custom compiler setup, but I agree that it's less useful if it can't be easily deployed.

epsilon_da

  • Guest
Re: Vala language
« Reply #6 on: April 18, 2009, 02:01:23 am »
That will produce the final output file, but "compiler" gets executed for each file, which is not valid in this case for vala.
Are you sure Vala doesn't support per file compilation? AFAICT you can specify vala output a set .c/.h files for each source. If you tell C::B that these are generated files, C::B will take care of their compilation. This is very much like the swig example in the wiki.

Yes, that could be one solution. I will try it out. But there are 2 BUTs.
Vala acts as a compiler not only a code translator.
A "Vala Project" should be a project only writen in vala code. No C at all.
The translator function should be used in C Projects, like the GTK Project (because Vala uses GLib).
I am trying to make a build script for both cases, i have to fight against the scripting language and an odd documentation.

In a ValaProject case, i may need to setup only a NULL Compiler, that is, build the project entirely with a Build script. Which for Vala is not big deal.
The first Problem is to find documentation about build scripts, because i cant find a good one in the wiki, like other functions to define. The function SetBuildOptions(base) seems to be called before to read the project configuration, because it prints an incorrect value of the output filename.

And for the translation function, i need to be able to add the generated files as "AutoGenerated" from the script. What function can do that?


epsilon_da

  • Guest
Re: Vala language
« Reply #7 on: April 18, 2009, 03:12:49 am »
That will produce the final output file, but "compiler" gets executed for each file, which is not valid in this case for vala.

Are you sure Vala doesn't support per file compilation? AFAICT you can specify vala output a set .c/.h files for each source. If you tell C::B that these are generated files, C::B will take care of their compilation. This is very much like the swig example in the wiki.

That wont work either.
If main.vala depends on mylib.vala, then the command line needs both references.
valac -C main.vala mylib.vala -H .....
If not, it will not find the symbol references.


Offline simonsunnyboy

  • Single posting newcomer
  • *
  • Posts: 2
    • Final Memory
Re: Vala language
« Reply #8 on: February 23, 2011, 06:27:26 pm »
Hello all,

has there been any further efforts for real Vala integration into Code::Blocks? E.q. installing a full project and syntax highlighting?

Thank you!
Matthias

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Vala language
« Reply #9 on: February 23, 2011, 06:50:31 pm »
Hello all,

has there been any further efforts for real Vala integration into Code::Blocks? E.q. installing a full project and syntax highlighting?

Thank you!
Matthias

For syntax highlighting you need to write an lexer for scintilla or wait for someone else to do it.
Then tell the Code::Blocks team about it; and then they can try to add it to Code::Blocks.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline simonsunnyboy

  • Single posting newcomer
  • *
  • Posts: 2
    • Final Memory
Re: Vala language
« Reply #10 on: February 23, 2011, 08:06:22 pm »
Thanks for this quick and on the mark reply!
Guess I have to wait then as I'm myself bad a writing highlighting parsers ;)

Matthias

Offline Nonenix

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Vala language
« Reply #11 on: February 28, 2012, 02:30:38 am »
http://code.google.com/p/scintillua/source/browse/lexers/vala.lua?spec=svn23fa459cef8ccdf13dbee9e011f5c230739190bc&r=23fa459cef8ccdf13dbee9e011f5c230739190bc

there is a basic lexer, a point to start.

and you can tell valac to compile files to c with -c but then you would need to do the gcc callup yourself afther that with the c files and correct librarys path ect.