Skip to content

Building on Gentoo Linux

mgreter edited this page Dec 24, 2014 · 1 revision

www-misc/libsass/libsass-9999.ebuild

# Copyright 2010-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4

inherit eutils git-2 autotools

DESCRIPTION="A C/C++ implementation of a Sass compiler."
HOMEPAGE="http://libsass.org/"
EGIT_PROJECT='libsass'
EGIT_REPO_URI="https://github.com/sass/libsass.git"
LICENSE="MIT"
SLOT="0"
KEYWORDS=""
IUSE=""
DEPEND=""
RDEPEND="${DEPEND}"
DEPEND="${DEPEND}"

src_prepare() {
   eautoreconf
}

www-misc/sassc/sassc-9999.ebuild

# Copyright 2010-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4

inherit eutils git-2 autotools

DESCRIPTION="Command Line Tool for libsass."
HOMEPAGE="http://libsass.org/"
EGIT_PROJECT='sassc'
EGIT_REPO_URI="https://github.com/sass/sassc.git"
LICENSE="MIT"
SLOT="0"
KEYWORDS=""
IUSE=""
DEPEND="www-misc/libsass"
RDEPEND="${DEPEND}"
DEPEND="${DEPEND}"

src_prepare() {
   eautoreconf
}

Example main.c

#include <stdio.h>
#include "sass_context.h"

int main( int argc, const char* argv[] )
{

  // get the input file from first argument or use default
  const char* input = argc > 1 ? argv[1] : "styles.scss";

  // create the file context and get all related structs
  struct Sass_File_Context* file_ctx = sass_make_file_context(input);
  struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
  struct Sass_Options* ctx_opt = sass_context_get_options(ctx);

  // configure some context options ...
  sass_option_set_precision(ctx_opt, 10);

  // context is set up, call the compile step now
  int status = sass_compile_file_context(file_ctx);

  // put the result or the error to the console (stdout)
  if (status == 0) puts(sass_context_get_output_string(ctx));
  else puts(sass_context_get_error_message(ctx));

  // release allocated memory
  sass_delete_file_context(file_ctx);

  // exit status
  return status;

}

Compile main.c

gcc -c main.c -o main.o
gcc -o sample main.o -lsass
./sample styles.scss

Sample version.c

#include <stdio.h>
#include "sass_context.h"

void main()
{
  printf("version: %s\n", libsass_version());
}

Compile version.c

gcc -c version.c -o version.o
gcc -o version version.o -lsass
./version => "version: 3.1.0-beta"