forked from dart-lang/native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathffigen.dart
More file actions
55 lines (52 loc) · 2.02 KB
/
ffigen.dart
File metadata and controls
55 lines (52 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:ffigen/ffigen.dart';
void main() {
final packageRoot = Platform.script.resolve('../');
final functions = Functions.includeSet({'gethostname'});
final FfiGenerator generator;
if (Platform.isWindows) {
generator = FfiGenerator(
headers: Headers(entryPoints: [packageRoot.resolve('src/windows.h')]),
functions: functions,
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/windows.dart'),
preamble: '''
// This file includes parts which are Copyright (c) 1982-1986 Regents
// of the University of California. All rights reserved. The
// Berkeley Software License Agreement specifies the terms and
// conditions for redistribution.
''',
),
);
} else {
generator = FfiGenerator(
headers: Headers(entryPoints: [packageRoot.resolve('src/unix.h')]),
functions: functions,
output: Output(
dartFile: packageRoot.resolve('lib/src/third_party/unix.dart'),
preamble: '''
// Copyright (C) 1991-2022 Free Software Foundation, Inc.
// This file is part of the GNU C Library.
//
// The GNU C Library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// The GNU C Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with the GNU C Library; if not, see
// <https://www.gnu.org/licenses/>.
''',
),
);
}
generator.generate();
}