Skip to content

Commit

Permalink
- Fixed C warnings on some files
Browse files Browse the repository at this point in the history
- Removed the old make_*.bat stuff
- Added build.bat and build.sh based on PHP's (build.php) and making the building system cross-system.
- ...

git-svn-id: http://pspautotests.googlecode.com/svn/trunk/pspautotests@45 998017b7-1407-6bc6-591a-4e5c7c3989f7
  • Loading branch information
soywiz committed Dec 30, 2011
1 parent 58f1363 commit ac13da9
Show file tree
Hide file tree
Showing 56 changed files with 2,084 additions and 197 deletions.
56 changes: 0 additions & 56 deletions tests/_make.bat

This file was deleted.

1 change: 1 addition & 0 deletions tests/audio/atrac/atractest.compile
@@ -0,0 +1 @@
EXTRA_LIBS=pspatrac3 pspaudio
Binary file modified tests/audio/atrac/atractest.elf
Binary file not shown.
File renamed without changes.
11 changes: 0 additions & 11 deletions tests/audio/atrac/make.bat

This file was deleted.

1 change: 0 additions & 1 deletion tests/audio/atrac/make_prepare.bat

This file was deleted.

1 change: 0 additions & 1 deletion tests/audio/sascore/make_prepare.bat

This file was deleted.

8 changes: 4 additions & 4 deletions tests/audio/sascore/sascore.c
Expand Up @@ -2,6 +2,7 @@

#include <pspkernel.h>
#include <stdio.h>
#include <pspsdk.h>
#include "sascore.h"

//PSP_MODULE_INFO("sascore test", 0, 1, 1);
Expand All @@ -15,13 +16,12 @@ typedef struct {
ByteArray loadData()
{
int n;
int length;
FILE *file;
ByteArray data = {0};
if ((file = fopen("test.vag", "rb")) != NULL) {
fseek(file, 0, SEEK_END);
data.length = ftell(file);
data.pointer = (char *)malloc(data.length);
data.pointer = (unsigned char *)malloc(data.length);
memset(data.pointer, 0, data.length);
fseek(file, 0, SEEK_SET);
fread(data.pointer, data.length, 1, file);
Expand All @@ -44,7 +44,7 @@ __attribute__((aligned(64))) short samples[256 * 2 * 16] = {0};
ByteArray data;
int result;

int sasCoreThread(int argsize, void* argdata) {
int sasCoreThread(SceSize argsize, void *argdata) {
int sasVoice = 0;
int n, m;
SasCore sasCoreInvalidAddress;
Expand All @@ -53,7 +53,7 @@ int sasCoreThread(int argsize, void* argdata) {
printf("__sceSasInit : 0x%08X\n", result = __sceSasInit(&sasCore, PSP_SAS_GRAIN_SAMPLES, PSP_SAS_VOICES_MAX, PSP_SAS_OUTPUTMODE_STEREO, 44100));
printf("__sceSasSetOutputmode: 0x%08X\n", result = __sceSasSetOutputmode(&sasCore, PSP_SAS_OUTPUTMODE_STEREO));
printf("__sceSasSetKeyOn : 0x%08X\n", result = __sceSasSetKeyOn(&sasCore, sasVoice));
printf("__sceSasSetVoice : 0x%08X\n", result = __sceSasSetVoice(&sasCore, sasVoice, data.pointer, data.length, 0));
printf("__sceSasSetVoice : 0x%08X\n", result = __sceSasSetVoice(&sasCore, sasVoice, (char *)data.pointer, data.length, 0));
printf("__sceSasSetPitch : 0x%08X\n", result = __sceSasSetPitch(&sasCore, sasVoice, 4096));
printf("__sceSasSetVolume : 0x%08X\n", result = __sceSasSetVolume(&sasCore, sasVoice, 0x1000, 0x1000));
printf("Data(%d):\n", data.length);
Expand Down
1 change: 1 addition & 0 deletions tests/audio/sascore/sascore.compile
@@ -0,0 +1 @@
EXTRA_C_FILES=sascore-imports.S
3 changes: 3 additions & 0 deletions tests/build.bat
@@ -0,0 +1,3 @@
@ECHO OFF
REM "%~dp0\..\utils\win32\php.exe" "%~dp0\build.php" %*
"c:\php\php.exe" "%~dp0\build.php" %*
90 changes: 90 additions & 0 deletions tests/build.php
@@ -0,0 +1,90 @@
<?php
// Requires PHP >= 5.3

require_once(__DIR__ . '/build_utils.php');

$pspSdk = new PspSdk();
$PSPAUTOTESTS = dirname(__DIR__);

//print_r($pspSdk);

$params = array_slice($argv, 1);

$filter = '*';
$path = __DIR__;

if (count($params) > 0) {
$param = $params[0];

if (dirname($param) == '.') {
$filter = "*{$param}*";
} else {
if (is_dir($param)) {
$path = $param;
} else {
$path = dirname($param);
}
}
}

foreach (recursive_directory_iterator($path) as $file) {
if (!endsWith($file, '.expected')) continue;

//if (!preg_match('@kirk@', $file)) continue;
//if (!preg_match('@vfpu@', $file)) continue;
//if (!preg_match('@fonttest@', $file)) continue;
if (!fnmatch($filter, $file)) continue;

$filebase = substr($file, 0, strrpos($file, '.'));
$dirbase = dirname($filebase);
$cfile = "{$filebase}.c";
$outfile = "{$filebase}.elf";
$compilefile = "{$filebase}.compile";

$libraries = array(
'pspumd', 'psppower', 'pspdebug', 'pspgum_vfpu', 'pspgu',
'pspge', 'pspdisplay', 'pspsdk', 'm', 'c', 'pspnet',
'pspnet_inet', 'pspuser', 'psprtc', 'pspctrl'
);

$sources = array(
"{$PSPAUTOTESTS}/common/common.c",
$cfile,
);

if (is_file($compilefile)) {
$info = parse_ini_string(file_get_contents($compilefile));
if (isset($info['EXTRA_C_FILES'])) {
$sources = array_merge($sources, array_map(function($name) use($dirbase) {
return "{$dirbase}/{$name}";
}, explode(' ', $info['EXTRA_C_FILES'])));
}
if (isset($info['EXTRA_LIBS'])) {
$libraries = array_merge($libraries, explode(' ', $info['EXTRA_LIBS']));
}
if (isset($info['EXTRA_LIBS_PRE'])) {
$libraries = array_merge(explode(' ', $info['EXTRA_LIBS_PRE']), $libraries);
}
}

$gcc_args = array(
'include_dirs' => array(".", "{$pspSdk->PSPSDK}/psp/sdk/include", "{$PSPAUTOTESTS}/common"),
'library_dirs' => array(".", "{$pspSdk->PSPSDK}/psp/sdk/lib", "{$PSPAUTOTESTS}/common"),
'defines' => array(
"_PSP_FW_VERSION" => $pspSdk->PSP_FW_VERSION
),
'flags' => array('-Wall', '-g', '-O0'),
'libraries' => $libraries,
'sources' => $sources,
'output' => $outfile,
);

echo "{$cfile}...";
$output = $pspSdk->gcc($gcc_args);
echo $output;
echo "Ok\n";

if (is_file($outfile)) {
touch($outfile, filemtime($cfile));
}
}
1 change: 1 addition & 0 deletions tests/build.sh
@@ -0,0 +1 @@
php build.php $@
84 changes: 84 additions & 0 deletions tests/build_utils.php
@@ -0,0 +1,84 @@
<?php
// Requires PHP 5.3

class PspSdk {
public $PSPSDK;
public $GCC;
public $FIXUP_IMPORTS;
public $MKSFO;
public $PACK_PBP;
public $EXE_PREFIX;
//public $PSP_FW_VERSION = 150;
//public $PSP_FW_VERSION = 371;
public $PSP_FW_VERSION = 500;

public function __construct() {
if (PHP_OS == 'WINNT') {
$this->EXE_PREFIX = '.exe';
} else {
$this->EXE_PREFIX = '';
}

$this->PSPSDK = $this->detect_pspsdk_path();
$this->GCC = realpath("{$this->PSPSDK}/bin/psp-gcc{$this->EXE_PREFIX}");
$this->FIXUP_IMPORTS = realpath("{$this->PSPSDK}/bin/psp-fixup-imports{$this->EXE_PREFIX}");
$this->MKSFO = realpath("{$this->PSPSDK}/bin/mksfo{$this->EXE_PREFIX}");
$this->PACK_PBP = realpath("{$this->PSPSDK}/bin/pack-pbp{$this->EXE_PREFIX}");
}

public function gcc($params) {
$args = array();

$elfoutput = $params['output'];

foreach ($params['include_dirs'] as $include_dir) $args[] = "-I{$include_dir}";
foreach ($params['library_dirs'] as $library_dir) $args[] = "-L{$library_dir}";
foreach ($params['defines'] as $key => $value) $args[] = "-D{$key}={$value}";
foreach ($params['flags'] as $flag) $args[] = $flag;
foreach ($params['sources'] as $source) $args[] = $source;
foreach ($params['libraries'] as $library) $args[] = "-l{$library}";
$args[] = '-o';
$args[] = $elfoutput;

if (is_file($elfoutput)) @unlink($elfoutput);

$gcc_cmd = $this->GCC . ' ' . implode(' ', array_map('escapeshellarg', $args));
$fixup_cmd = $this->FIXUP_IMPORTS . ' ' . escapeshellarg($elfoutput);
//echo "$cmd\n";
$gcc_out = `{$gcc_cmd}`;
$fixup_out = '';

if (is_file($elfoutput)) {
$fixup_out = `$fixup_cmd`;
}

return trim("{$gcc_out}\n{$fixup_out}");
}

static protected function detect_pspsdk_path() {
$PSPSDK = getenv('PSPSDK');

if ($PSPSDK == '') {
foreach (array('/pspsdk') as $path) {
if (is_dir($path)) {
$PSPSDK = realpath($path);
break;
}
}
}

if ($PSPSDK == '') {
throw(new Exception("Can't find the psp sdk. Please set the enviroment variable PSPSDK."));
}

return $PSPSDK;
}
}

function endsWith($str, $end) {
return (substr($str, -strlen($end)) == $end);
}

function recursive_directory_iterator($dir) {
return new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
}
1 change: 1 addition & 0 deletions tests/cpu/icache/icache.c
Expand Up @@ -5,6 +5,7 @@
#include <common.h>

#include <pspkernel.h>
#include <psputilsforkernel.h>
#include <pspthreadman.h>
#include <string.h>

Expand Down
1 change: 1 addition & 0 deletions tests/cpu/icache/icache.compile
@@ -0,0 +1 @@
EXTRA_LIBS=pspkernel
1 change: 0 additions & 1 deletion tests/cpu/vfpu/make_prepare.bat

This file was deleted.

1 change: 1 addition & 0 deletions tests/cpu/vfpu/vfpu.compile
@@ -0,0 +1 @@
EXTRA_LIBS_PRE=glut glu gl pspvfpu
1 change: 1 addition & 0 deletions tests/dmac/dmactest.compile
@@ -0,0 +1 @@
EXTRA_C_FILES=dmac-imports.S
9 changes: 0 additions & 9 deletions tests/dmac/make.bat

This file was deleted.

1 change: 0 additions & 1 deletion tests/dmac/make_prepare.bat

This file was deleted.

4 changes: 2 additions & 2 deletions tests/font/fonttest.c
Expand Up @@ -7,7 +7,7 @@
#include "libfont.h"

static void *Font_Alloc(void *data, u32 size) {
printf("Font_Alloc(%08X, %d)\n", (uint)data, size);
printf("Font_Alloc(%08X, %u)\n", (uint)data, (uint)size);
return malloc(size);
}

Expand All @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
FontHandle fontHandle;
//FontInfo fontInfo;
//int result;
u32 errorCode;
uint errorCode;
FontNewLibParams params = { NULL, 4, NULL, Font_Alloc, Font_Free, NULL, NULL, NULL, NULL, NULL, NULL };

//pspDebugScreenInit();
Expand Down
1 change: 1 addition & 0 deletions tests/font/fonttest.compile
@@ -0,0 +1 @@
EXTRA_C_FILES=libfont-imports.S
1 change: 0 additions & 1 deletion tests/font/make_prepare.bat

This file was deleted.

1 change: 1 addition & 0 deletions tests/io/iodrv/iodrv.compile
@@ -0,0 +1 @@
EXTRA_LIBS=pspkernel
1 change: 0 additions & 1 deletion tests/io/iodrv/make_prepare.bat

This file was deleted.

2 changes: 1 addition & 1 deletion tests/kirk/kirk-imports.S
Expand Up @@ -2,5 +2,5 @@

#include "pspimport.s"

IMPORT_START "semaphore",0x40010000
IMPORT_START "semaphore",0x00010011
IMPORT_FUNC "semaphore",0x4C537C72,sceUtilsBufferCopyWithRange
1 change: 1 addition & 0 deletions tests/kirk/kirk.compile
@@ -0,0 +1 @@
EXTRA_C_FILES=kirk-imports.S
1 change: 0 additions & 1 deletion tests/kirk/make_prepare.bat

This file was deleted.

3 changes: 0 additions & 3 deletions tests/make.bat

This file was deleted.

6 changes: 0 additions & 6 deletions tests/make_all.bat

This file was deleted.

0 comments on commit ac13da9

Please sign in to comment.