This repository was archived by the owner on Sep 20, 2026. It is now read-only.
Repository navigation
formula: anrieff/libcpuid #519
Open
MeteorsLiu
wants to merge
2
commits into
xgo-dev:main
Choose a base branch
from
MeteorsLiu:issue/243-libcpuid-luna
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- a/cpuid_tool/CMakeLists.txt | ||
| +++ b/cpuid_tool/CMakeLists.txt | ||
| @@ -5 +5 @@ | ||
| -if(WIN32) | ||
| +if(0) | ||
| --- a/libcpuid/CMakeLists.txt | ||
| +++ b/libcpuid/CMakeLists.txt | ||
| @@ -15,5 +15,5 @@ | ||
| if(UNIX) | ||
| - add_library(cpuid SHARED ${cpuid_sources}) | ||
| + add_library(cpuid ${cpuid_sources}) | ||
| else() | ||
| add_library(cpuid ${cpuid_sources}) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "libcpuid/libcpuid.h" | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| int main(void) | ||
| { | ||
| if (!cpuid_present()) { | ||
| return 1; | ||
| } | ||
|
|
||
| struct cpu_raw_data_t raw; | ||
| struct cpu_id_t data; | ||
| if (cpuid_get_raw_data(&raw) < 0) { | ||
| return 2; | ||
| } | ||
| if (cpu_identify(&raw, &data) < 0) { | ||
| return 3; | ||
| } | ||
|
|
||
| printf("%s %s\n", data.vendor_str, data.cpu_codename); | ||
| return 0; | ||
| } | ||
| ` | ||
|
|
||
| id "anrieff/libcpuid" | ||
|
|
||
| fromVer "v0.5.0" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for name, values in target.options { | ||
| if name != "shared" && name != "fPIC" { | ||
| return false | ||
| } | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return slices.contains(target.require["arch"], "amd64") | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
|
|
||
| patch := ctx.Proj.readFile("v0.5.0/0.5.0-cmake-fixes.patch")! | ||
| patchPath := filepath.join(ctx.SourceDir, "_llar_cmake-fixes.patch") | ||
| os.writeFile(patchPath, patch, 0o644)! | ||
| git! "apply", "--unidiff-zero", patchPath | ||
|
|
||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS", shared | ||
| c.defineBool "ENABLE_DOCS", false | ||
| c.configure | ||
| c.build "--target", "cpuid_tool" | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "COPYING"), os.readFile(filepath.join(ctx.SourceDir, "COPYING"))!, 0o644)! | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := pkgconfig.new( | ||
| name = "libcpuid", | ||
| description = "libcpuid provides CPU identification for x86", | ||
| version = "v0.5.0", | ||
| libs = ["-L$${libdir}", "-lcpuid"], | ||
| cflags = ["-I$${includedir}"], | ||
| )! | ||
| out := os.create(filepath.join(pcDir, "libcpuid.pc"))! | ||
| pc.writeTo(out)! | ||
| out.close()! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("libcpuid")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| consumer := filepath.join(testDir, "consumer.c") | ||
| os.writeFile(consumer, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| binary := filepath.join(testDir, "consumer") | ||
| flagsFile := filepath.join(testDir, "libcpuid.flags") | ||
| os.writeFile(flagsFile, []byte(pkgconfig.lookup("libcpuid")!), 0o644)! | ||
| cc! consumer, "-o", binary, "@"+flagsFile | ||
|
|
||
| if target.options["shared"][0] == "ON" { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| } | ||
| exec! binary | ||
| exec! filepath.join(installDir, "bin", "cpuid_tool"), "--report" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "libcpuid/libcpuid.h" | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| int main(void) | ||
| { | ||
| if (!cpuid_present()) { | ||
| return 1; | ||
| } | ||
|
|
||
| struct cpu_raw_data_t raw; | ||
| struct cpu_id_t data; | ||
| if (cpuid_get_raw_data(&raw) < 0) { | ||
| return 2; | ||
| } | ||
| if (cpu_identify(&raw, &data) < 0) { | ||
| return 3; | ||
| } | ||
|
|
||
| printf("%s %s\n", data.vendor_str, data.cpu_codename); | ||
| return 0; | ||
| } | ||
| ` | ||
|
|
||
| id "anrieff/libcpuid" | ||
|
|
||
| fromVer "v0.6.0" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for name, values in target.options { | ||
| if name != "shared" && name != "fPIC" { | ||
| return false | ||
| } | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return slices.contains(target.require["arch"], "amd64") | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS", shared | ||
| c.defineBool "ENABLE_DOCS", false | ||
| c.defineBool "LIBCPUID_TESTS", false | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "COPYING"), os.readFile(filepath.join(ctx.SourceDir, "COPYING"))!, 0o644)! | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := pkgconfig.new( | ||
| name = "libcpuid", | ||
| description = "libcpuid provides CPU identification for x86", | ||
| version = "v0.6.0", | ||
| libs = ["-L$${libdir}", "-lcpuid"], | ||
| cflags = ["-I$${includedir}"], | ||
| )! | ||
| out := os.create(filepath.join(pcDir, "libcpuid.pc"))! | ||
| pc.writeTo(out)! | ||
| out.close()! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("libcpuid")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| consumer := filepath.join(testDir, "consumer.c") | ||
| os.writeFile(consumer, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| binary := filepath.join(testDir, "consumer") | ||
| flagsFile := filepath.join(testDir, "libcpuid.flags") | ||
| os.writeFile(flagsFile, []byte(pkgconfig.lookup("libcpuid")!), 0o644)! | ||
| cc! consumer, "-o", binary, "@"+flagsFile | ||
|
|
||
| if target.options["shared"][0] == "ON" { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| } | ||
| exec! binary | ||
| exec! filepath.join(installDir, "bin", "cpuid_tool"), "--report" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "slices" | ||
| ) | ||
|
|
||
| const consumerSource = `#include "libcpuid/libcpuid.h" | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| int main(void) | ||
| { | ||
| if (!cpuid_present()) { | ||
| return 1; | ||
| } | ||
|
|
||
| struct cpu_raw_data_t raw; | ||
| struct cpu_id_t data; | ||
| if (cpuid_get_raw_data(&raw) < 0) { | ||
| return 2; | ||
| } | ||
| if (cpu_identify(&raw, &data) < 0) { | ||
| return 3; | ||
| } | ||
|
|
||
| printf("%s %s\n", data.vendor_str, data.cpu_codename); | ||
| return 0; | ||
| } | ||
| ` | ||
|
|
||
| id "anrieff/libcpuid" | ||
|
|
||
| fromVer "v0.7.0" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for name, values in target.options { | ||
| if name != "shared" && name != "fPIC" { | ||
| return false | ||
| } | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return slices.contains(target.require["arch"], "amd64") | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS", shared | ||
| c.defineBool "LIBCPUID_BUILD_DRIVERS", false | ||
| c.defineBool "LIBCPUID_ENABLE_TESTS", false | ||
| c.defineBool "LIBCPUID_ENABLE_DOCS", false | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0o755)! | ||
| os.writeFile(filepath.join(licenseDir, "COPYING"), os.readFile(filepath.join(ctx.SourceDir, "COPYING"))!, 0o644)! | ||
|
|
||
| pcDir := filepath.join(installDir, "lib", "pkgconfig") | ||
| os.mkdirAll(pcDir, 0o755)! | ||
| pc := pkgconfig.new( | ||
| name = "libcpuid", | ||
| description = "libcpuid provides CPU identification for x86", | ||
| version = "v0.7.0", | ||
| libs = ["-L$${libdir}", "-lcpuid"], | ||
| cflags = ["-I$${includedir}"], | ||
| )! | ||
| out := os.create(filepath.join(pcDir, "libcpuid.pc"))! | ||
| pc.writeTo(out)! | ||
| out.close()! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("libcpuid")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| os.mkdirAll(testDir, 0o755)! | ||
|
|
||
| consumer := filepath.join(testDir, "consumer.c") | ||
| os.writeFile(consumer, []byte(consumerSource), 0o644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| binary := filepath.join(testDir, "consumer") | ||
| flagsFile := filepath.join(testDir, "libcpuid.flags") | ||
| os.writeFile(flagsFile, []byte(pkgconfig.lookup("libcpuid")!), 0o644)! | ||
| cc! consumer, "-o", binary, "@"+flagsFile | ||
|
|
||
| if target.options["shared"][0] == "ON" { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| } | ||
| exec! binary | ||
| exec! filepath.join(installDir, "bin", "cpuid_tool"), "--report" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "anrieff/libcpuid", | ||
| "deps": {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Preserve 32-bit x86 support in the architecture filter
The Conan recipe's
validatecontract explicitly accepts bothx86andx86_64, and the upstream project publishes ix86 builds. LLAR represents 32-bit x86 as386, so this filter rejects a supported target beforeonBuildruns; the same predicate is duplicated in the v0.6.0 and v0.7.0 thresholds. Include386alongsideamd64(or otherwise mirror the recipe's x86/x86_64 matrix) so the formula does not silently drop a supported architecture.