mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-03 13:57:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
28
media/webrtc/trunk/tools/gyp/test/module/gyptest-default.py
Normal file
28
media/webrtc/trunk/tools/gyp/test/module/gyptest-default.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2012 Google Inc. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""
|
||||
Verifies simple build of a "Hello, world!" program with loadable modules. The
|
||||
default for all platforms should be to output the loadable modules to the same
|
||||
path as the executable.
|
||||
"""
|
||||
|
||||
import TestGyp
|
||||
|
||||
test = TestGyp.TestGyp()
|
||||
|
||||
test.run_gyp('module.gyp', chdir='src')
|
||||
|
||||
test.build('module.gyp', test.ALL, chdir='src')
|
||||
|
||||
expect = """\
|
||||
Hello from program.c
|
||||
Hello from lib1.c
|
||||
Hello from lib2.c
|
||||
"""
|
||||
test.run_built_executable('program', chdir='src', stdout=expect)
|
||||
|
||||
test.pass_test()
|
||||
10
media/webrtc/trunk/tools/gyp/test/module/src/lib1.c
Normal file
10
media/webrtc/trunk/tools/gyp/test/module/src/lib1.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void module_main(void)
|
||||
{
|
||||
fprintf(stdout, "Hello from lib1.c\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
10
media/webrtc/trunk/tools/gyp/test/module/src/lib2.c
Normal file
10
media/webrtc/trunk/tools/gyp/test/module/src/lib2.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void module_main(void)
|
||||
{
|
||||
fprintf(stdout, "Hello from lib2.c\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
53
media/webrtc/trunk/tools/gyp/test/module/src/module.gyp
Normal file
53
media/webrtc/trunk/tools/gyp/test/module/src/module.gyp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Copyright (c) 2009 Google Inc. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
{
|
||||
'target_defaults': {
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'defines': ['PLATFORM_WIN'],
|
||||
}],
|
||||
['OS=="mac" or OS=="ios"', {
|
||||
'defines': ['PLATFORM_MAC'],
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
'defines': ['PLATFORM_LINUX'],
|
||||
# Support 64-bit shared libs (also works fine for 32-bit).
|
||||
'cflags': ['-fPIC'],
|
||||
'libraries': ['-ldl'],
|
||||
}],
|
||||
],
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'program',
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'lib1',
|
||||
'lib2',
|
||||
],
|
||||
'sources': [
|
||||
'program.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'lib1',
|
||||
'type': 'loadable_module',
|
||||
'product_name': 'lib1',
|
||||
'product_prefix': '',
|
||||
'sources': [
|
||||
'lib1.c',
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'lib2',
|
||||
'product_name': 'lib2',
|
||||
'product_prefix': '',
|
||||
'type': 'loadable_module',
|
||||
'sources': [
|
||||
'lib2.c',
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
111
media/webrtc/trunk/tools/gyp/test/module/src/program.c
Normal file
111
media/webrtc/trunk/tools/gyp/test/module/src/program.c
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(PLATFORM_WIN)
|
||||
#include <windows.h>
|
||||
#elif defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#include <dlfcn.h>
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#define MAX_PATH PATH_MAX
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_WIN)
|
||||
#define MODULE_SUFFIX ".dll"
|
||||
#elif defined(PLATFORM_MAC)
|
||||
#define MODULE_SUFFIX ".so"
|
||||
#elif defined(PLATFORM_LINUX)
|
||||
#define MODULE_SUFFIX ".so"
|
||||
#endif
|
||||
|
||||
typedef void (*module_symbol)(void);
|
||||
char bin_path[MAX_PATH + 1];
|
||||
|
||||
|
||||
void CallModule(const char* module) {
|
||||
char module_path[MAX_PATH + 1];
|
||||
const char* module_function = "module_main";
|
||||
module_symbol funcptr;
|
||||
#if defined(PLATFORM_WIN)
|
||||
HMODULE dl;
|
||||
char drive[_MAX_DRIVE];
|
||||
char dir[_MAX_DIR];
|
||||
|
||||
if (_splitpath_s(bin_path, drive, _MAX_DRIVE, dir, _MAX_DIR,
|
||||
NULL, 0, NULL, 0)) {
|
||||
fprintf(stderr, "Failed to split executable path.\n");
|
||||
return;
|
||||
}
|
||||
if (_makepath_s(module_path, MAX_PATH, drive, dir, module, MODULE_SUFFIX)) {
|
||||
fprintf(stderr, "Failed to calculate module path.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dl = LoadLibrary(module_path);
|
||||
if (!dl) {
|
||||
fprintf(stderr, "Failed to open module: %s\n", module_path);
|
||||
return;
|
||||
}
|
||||
|
||||
funcptr = (module_symbol) GetProcAddress(dl, module_function);
|
||||
if (!funcptr) {
|
||||
fprintf(stderr, "Failed to find symbol: %s\n", module_function);
|
||||
return;
|
||||
}
|
||||
funcptr();
|
||||
|
||||
FreeLibrary(dl);
|
||||
#elif defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
void* dl;
|
||||
char* path_copy = strdup(bin_path);
|
||||
char* bin_dir = dirname(path_copy);
|
||||
int path_size = snprintf(module_path, MAX_PATH, "%s/%s%s", bin_dir, module,
|
||||
MODULE_SUFFIX);
|
||||
free(path_copy);
|
||||
if (path_size < 0 || path_size > MAX_PATH) {
|
||||
fprintf(stderr, "Failed to calculate module path.\n");
|
||||
return;
|
||||
}
|
||||
module_path[path_size] = 0;
|
||||
|
||||
dl = dlopen(module_path, RTLD_LAZY);
|
||||
if (!dl) {
|
||||
fprintf(stderr, "Failed to open module: %s\n", module_path);
|
||||
return;
|
||||
}
|
||||
|
||||
funcptr = dlsym(dl, module_function);
|
||||
if (!funcptr) {
|
||||
fprintf(stderr, "Failed to find symbol: %s\n", module_function);
|
||||
return;
|
||||
}
|
||||
funcptr();
|
||||
|
||||
dlclose(dl);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf(stdout, "Hello from program.c\n");
|
||||
fflush(stdout);
|
||||
|
||||
#if defined(PLATFORM_WIN)
|
||||
if (!GetModuleFileName(NULL, bin_path, MAX_PATH)) {
|
||||
fprintf(stderr, "Failed to determine executable path.\n");
|
||||
return 1;
|
||||
}
|
||||
#elif defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
// Using argv[0] should be OK here since we control how the tests run, and
|
||||
// can avoid exec and such issues that make it unreliable.
|
||||
if (!realpath(argv[0], bin_path)) {
|
||||
fprintf(stderr, "Failed to determine executable path (%s).\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
CallModule("lib1");
|
||||
CallModule("lib2");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue