Comments (1)
In this situation, a package can ship with pre-compiled binaries and the correct shared library can be imported based on the platform.
They can be simply copied during the installation procedure which occurs before the native extension will be used.
Example you can see in the package unsafe_extension
.
// Setup
target("setup", [], (t, args) async {
print("Setup $libname.");
var compiled = pathos.join("compiled", arch, operatingSystem, libname);
if (FileUtils.testfile(compiled, "file")) {
print("Copying compiled binary '$compiled'");
new File(compiled).copySync(libname);
print("The ${t.name} successful.");
return 0;
}
var result = await Builder.current.build("build", arguments: args);
var file = new File(libname);
file.copySync(compiled);
print("The ${t.name} successful.");
}, description: "Setup '$PROJECT_NAME'");
// Before "setup"
before(["setup", "compile_link"], (t, args) {
var arg = args["bits"];
if (arg != null) {
bits = int.parse("$arg", onError: null);
}
switch (bits) {
case 32:
case 64:
break;
default:
if (bits != null) {
print("Unsupported 'bits': $bits");
return -1;
}
}
var architecture = SysInfo.processors.first.architecture;
arg = args["arch"];
// Parse argument 'arch'
if (arg != null) {
arg = "$arg".toUpperCase().trim();
switch (arg) {
case "AARCH64":
architecture = ProcessorArchitecture.AARCH64;
break;
case "ARM":
architecture = ProcessorArchitecture.ARM;
break;
case "IA64":
architecture = ProcessorArchitecture.IA64;
break;
case "MIPS":
architecture = ProcessorArchitecture.MIPS;
break;
case "X86":
architecture = ProcessorArchitecture.X86;
break;
case "X86_64":
architecture = ProcessorArchitecture.X86_64;
break;
default:
print("Unsupported 'arch': $arg");
return -1;
}
}
switch (architecture) {
case ProcessorArchitecture.X86:
switch (bits) {
case 32:
arch = "X86";
break;
case 64:
arch = "X86_64";
break;
default:
arch = "X86";
bits = 32;
}
break;
case ProcessorArchitecture.X86_64:
switch (bits) {
case 32:
arch = "X86";
break;
case 64:
arch = "X86_64";
break;
default:
arch = "X86_64";
bits = 64;
}
break;
case ProcessorArchitecture.ARM:
switch (bits) {
case 32:
case 64:
arch = "ARM";
bits = null;
break;
default:
arch = "ARM";
bits = null;
}
break;
default:
// Other platforms are not yet supported
print("Unsupported processor architecture: $architecture");
return -1;
}
});
from dep-configured-imports.
Related Issues (11)
- Slightly confusing example in syntax HOT 1
- Support implementing cross-platform interfaces HOT 17
- Less punctuation? HOT 27
- clarify interaction with analyzer HOT 9
- Allow use conditional directives at least within the section of the import/export directives HOT 5
- dart.feature.html to match `dart:html` HOT 1
- Do we need platform sniffing if we have feature detection? HOT 5
- Another approach to look on this problem (very hard) HOT 3
- Are we sure we want the library choose? HOT 7
- extending expression language to handle package versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dep-configured-imports.