Skip to content

Commit

Permalink
Add two test recipes for cross compilation
Browse files Browse the repository at this point in the history
One depending on the other.
  • Loading branch information
mingwandroid authored and msarahan committed Jan 3, 2017
1 parent 1046ff2 commit ef41d51
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
c_compiler: "gcc-osx-64"
target_platform: "imx351uc"
20 changes: 20 additions & 0 deletions tests/test-recipes/metadata/_cross_helloworld/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package:
name: _cross_helloworld
version: 1.0

source:
path: ./src

requirements:
build:
- {{ compiler('c') }}
- xz
host:
- _cross_libgreeting

build:
script:
- gcc helloworld.c -L${PREFIX}/lib -lgreeting -DGREETING_SUFFIX=$(xz --version | head -n 1) -o ${PREFIX}/bin/helloworld

tests:
- strings ${PREFIX}/bin/helloworld | grep "XZ Utils"
14 changes: 14 additions & 0 deletions tests/test-recipes/metadata/_cross_helloworld/src/helloworld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <libgreeting.h>
#include <stdio.h>

int main(int argc, char * argv[])
{
char * say_it = greeting(GREETING_SUFFIX);
if (say_it != NULL)
{
puts(say_it);
putc('\n');
return 0;
}
return 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
c-compiler: "gcc-osx-64"
target_platform: "imx351uc"
14 changes: 14 additions & 0 deletions tests/test-recipes/metadata/_cross_libgreeting/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package:
name: _cross_libgreeting
version: 1.0

requirements:
build:
- {{ compiler('c') }}

build:
script:
- env
- gcc -o ${LDFLAGS} ${CFLAGS} libgreeting.o libgreeting.c
- ar cru ${PREFIX}/lib/libgreeting.a libgreeting.o
- cp libgreeting.h ${PREFIX}/include
14 changes: 14 additions & 0 deletions tests/test-recipes/metadata/_cross_libgreeting/src/libgreeting.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <string.h>

#define SALUTATION "Hello World! "

char * greeting(char const * suffix)
{
char * res = malloc(strlen(SALUTATION) + strlen(suffix) + 1);
if (res == NULL)
return NULL;
res[0] = '\0';
strcat(res, SALUTATION);
strcat(res, suffix);
return res;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef LIBGREETING_H_INCLUDED
#define LIBGREETING_H_INCLUDED

char * greeting(char const * suffix);

#endif /* LIBGREETING_H_INCLUDED */

0 comments on commit ef41d51

Please sign in to comment.