diff --git a/strukturag/libde265/v1.0.12/libde265_llar.gox b/strukturag/libde265/v1.0.12/libde265_llar.gox new file mode 100644 index 0000000..134def6 --- /dev/null +++ b/strukturag/libde265/v1.0.12/libde265_llar.gox @@ -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) + 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 + +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! +} diff --git a/strukturag/libde265/v1.0.17/libde265_llar.gox b/strukturag/libde265/v1.0.17/libde265_llar.gox new file mode 100644 index 0000000..30510bb --- /dev/null +++ b/strukturag/libde265/v1.0.17/libde265_llar.gox @@ -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") + 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 + +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! +} diff --git a/strukturag/libde265/versions.json b/strukturag/libde265/versions.json new file mode 100644 index 0000000..ce92122 --- /dev/null +++ b/strukturag/libde265/versions.json @@ -0,0 +1,4 @@ +{ + "path": "strukturag/libde265", + "deps": {} +}