-
Notifications
You must be signed in to change notification settings - Fork 2
feat(libde265): add LLAR formula #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| ) | ||
|
|
||
| id "strukturag/libde265" | ||
|
|
||
| fromVer "v1.0.12" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| "sse": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for values in target.options { | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
| sse := target.options["sse"][0] == "ON" | ||
|
|
||
| // The Conan recipe removes this upstream assignment so its fPIC option | ||
| // controls static builds instead of being overwritten during configure. | ||
| cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") | ||
| source := string(os.readFile(cmakeLists)!) | ||
| source = strings.replace(source, "set(CMAKE_POSITION_INDEPENDENT_CODE ON)\n", "", 1) | ||
| os.writeFile(cmakeLists, []byte(source), 0644)! | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "ENABLE_SDL", false | ||
| c.defineBool "DISABLE_SSE", !sse | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0755)! | ||
| os.writeFile(filepath.join(licenseDir, "COPYING"), os.readFile(filepath.join(ctx.SourceDir, "COPYING"))!, 0644)! | ||
|
|
||
| // The upstream file embeds the install directory and keeps static runtime | ||
| // libraries private. Make the published metadata relocatable and complete | ||
| // for the static C consumer used by this Formula. | ||
| pcPath := filepath.join(installDir, "lib", "pkgconfig", "libde265.pc") | ||
| pc := string(os.readFile(pcPath)!) | ||
| pc = strings.replace(pc, "prefix="+installDir, "prefix=$${pcfiledir}/../..", 1) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fragile prefix rewrite may silently leave the absolute build path embedded. |
||
| lines := pc.split("\n") | ||
| privateLibs := "" | ||
| privateCflags := "" | ||
| for line in lines { | ||
| if line.hasPrefix("Libs.private:") { | ||
| privateLibs = line.trimPrefix("Libs.private:").trimSpace() | ||
| } | ||
| if line.hasPrefix("Cflags.private:") { | ||
| privateCflags = line.trimPrefix("Cflags.private:").trimSpace() | ||
| } | ||
| } | ||
| if !shared { | ||
| for i, line in lines { | ||
| if privateLibs != "" && line.hasPrefix("Libs:") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Folding |
||
| lines[i] = line + " " + privateLibs | ||
| } | ||
| if privateCflags != "" && line.hasPrefix("Cflags:") { | ||
| lines[i] = line + " " + privateCflags | ||
| } | ||
| } | ||
| } | ||
| os.writeFile(pcPath, []byte(strings.join(lines, "\n")), 0644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("libde265")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| testBuild := filepath.join(testDir, "_build") | ||
| consumer := filepath.join(testDir, "consumer.c") | ||
| binary := filepath.join(testBuild, "consumer") | ||
|
|
||
| os.mkdirAll(testDir, 0755)! | ||
| os.mkdirAll(testBuild, 0755)! | ||
| os.writeFile(consumer, []byte(`#include <libde265/de265.h> | ||
|
|
||
| int main(void) { | ||
| de265_decoder_context *ctx = de265_new_decoder(); | ||
| de265_free_decoder(ctx); | ||
| return 0; | ||
| } | ||
| `), 0644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| flags := pkgconfig.lookup("libde265")! | ||
| flagsFile := filepath.join(testDir, "libde265.flags") | ||
| os.writeFile(flagsFile, []byte(flags), 0644)! | ||
|
|
||
| exec "cc", "-std=c11", "@"+flagsFile, consumer, "-o", binary | ||
| lastErr! | ||
| if target.options["shared"][0] == "ON" { | ||
| os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! | ||
| } | ||
| exec binary | ||
| lastErr! | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| ) | ||
|
|
||
| id "strukturag/libde265" | ||
|
|
||
| fromVer "v1.0.17" | ||
|
|
||
| defaults { | ||
| "shared": "OFF", | ||
| "fPIC": "ON", | ||
| } | ||
|
|
||
| filter => { | ||
| for values in target.options { | ||
| for value in values { | ||
| if value != "ON" && value != "OFF" { | ||
| return false | ||
| } | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| onBuild ctx => { | ||
| installDir := ctx.outputDir | ||
| shared := target.options["shared"][0] == "ON" | ||
| fPIC := target.options["fPIC"][0] == "ON" | ||
|
|
||
| cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing rationale comments that |
||
| source := string(os.readFile(cmakeLists)!) | ||
| source = strings.replace(source, "set(CMAKE_POSITION_INDEPENDENT_CODE ON)\n", "", 1) | ||
| os.writeFile(cmakeLists, []byte(source), 0644)! | ||
|
|
||
| c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) | ||
| c.define "CMAKE_INSTALL_LIBDIR", "lib" | ||
| c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.16" | ||
| c.defineBool "BUILD_SHARED_LIBS", shared | ||
| c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC | ||
| c.defineBool "ENABLE_SDL", false | ||
| c.configure | ||
| c.build | ||
| c.install | ||
|
|
||
| licenseDir := filepath.join(installDir, "licenses") | ||
| os.mkdirAll(licenseDir, 0755)! | ||
| os.writeFile(filepath.join(licenseDir, "COPYING"), os.readFile(filepath.join(ctx.SourceDir, "COPYING"))!, 0644)! | ||
|
|
||
| pcPath := filepath.join(installDir, "lib", "pkgconfig", "libde265.pc") | ||
| pc := string(os.readFile(pcPath)!) | ||
| pc = strings.replace(pc, "prefix="+installDir, "prefix=$${pcfiledir}/../..", 1) | ||
| lines := pc.split("\n") | ||
| privateLibs := "" | ||
| privateCflags := "" | ||
| for line in lines { | ||
| if line.hasPrefix("Libs.private:") { | ||
| privateLibs = line.trimPrefix("Libs.private:").trimSpace() | ||
| } | ||
| if line.hasPrefix("Cflags.private:") { | ||
| privateCflags = line.trimPrefix("Cflags.private:").trimSpace() | ||
| } | ||
| } | ||
| if !shared { | ||
| for i, line in lines { | ||
| if privateLibs != "" && line.hasPrefix("Libs:") { | ||
| lines[i] = line + " " + privateLibs | ||
| } | ||
| if privateCflags != "" && line.hasPrefix("Cflags:") { | ||
| lines[i] = line + " " + privateCflags | ||
| } | ||
| } | ||
| } | ||
| os.writeFile(pcPath, []byte(strings.join(lines, "\n")), 0644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| ctx.setMetadata pkgconfig.lookup("libde265")! | ||
| } | ||
|
|
||
| onTest ctx => { | ||
| installDir := ctx.outputDir | ||
| testDir := filepath.join(ctx.SourceDir, "_llar_consumer") | ||
| testBuild := filepath.join(testDir, "_build") | ||
| consumer := filepath.join(testDir, "consumer.c") | ||
| binary := filepath.join(testBuild, "consumer") | ||
|
|
||
| os.mkdirAll(testDir, 0755)! | ||
| os.mkdirAll(testBuild, 0755)! | ||
| os.writeFile(consumer, []byte(`#include <libde265/de265.h> | ||
|
|
||
| int main(void) { | ||
| de265_decoder_context *ctx = de265_new_decoder(); | ||
| de265_free_decoder(ctx); | ||
| return 0; | ||
| } | ||
| `), 0644)! | ||
|
|
||
| pkgconfig.use installDir | ||
| flags := pkgconfig.lookup("libde265")! | ||
| flagsFile := filepath.join(testDir, "libde265.flags") | ||
| os.writeFile(flagsFile, []byte(flags), 0644)! | ||
|
|
||
| exec "cc", "-std=c11", "@"+flagsFile, consumer, "-o", binary | ||
| lastErr! | ||
| 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 | ||
| lastErr! | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "path": "strukturag/libde265", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation inconsistent with repo convention. All existing |
||
| "deps": {} | ||
| } | ||
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.
filteraccepts any option key, not just the known set. Unlikecglm(which validates the specificsharedkey), this loops over all oftarget.optionsand only checks values areON/OFF. A typo likeshred/Ssewould pass the filter, thentarget.options["shared"][0]etc. proceed with defaults while the intended option is silently ignored. Consider validating against the known keys (shared,fPIC,sse). Same onv1.0.17line 16.