diff --git a/capstone-engine/capstone/4.0.2/capstone_llar.gox b/capstone-engine/capstone/4.0.2/capstone_llar.gox new file mode 100644 index 0000000..b9e0bff --- /dev/null +++ b/capstone-engine/capstone/4.0.2/capstone_llar.gox @@ -0,0 +1,115 @@ +import ( + "os" + "path/filepath" + "strings" +) + +const consumerSource = `#include +#include +#include + +int main() { + int major = 0, minor = 0; + cs_version(&major, &minor); + printf("capstone version %d.%d\n", major, minor); + return EXIT_SUCCESS; +} +` + +id "capstone-engine/capstone" + +fromVer "4.0.2" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "use_default_alloc": "ON", +} + +filter => { + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "use_default_alloc" { + return false + } + 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" + useDefaultAlloc := target.options["use_default_alloc"][0] == "ON" + + cmakeLists := filepath.join(ctx.SourceDir, "CMakeLists.txt") + source := string(os.readFile(cmakeLists)!) + source = strings.replace(source, "cmake_policy (SET CMP0048 OLD)", "cmake_policy (SET CMP0048 NEW)", 1) + os.writeFile(cmakeLists, []byte(source), 0o644)! + + 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 "CAPSTONE_BUILD_STATIC", !shared + c.defineBool "CAPSTONE_BUILD_SHARED", shared + c.defineBool "CAPSTONE_BUILD_TESTS", false + c.defineBool "CAPSTONE_BUILD_CSTOOL", false + c.defineBool "CAPSTONE_USE_DEFAULT_ALLOC", useDefaultAlloc + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE.TXT"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE.TXT"))!, 0o644)! + + cflags := ["-I$${includedir}"] + if shared { + cflags <- "-DCAPSTONE_SHARED" + } + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := pkgconfig.new( + name = "capstone", + description = "Capstone disassembly engine", + version = "4.0.2", + libs = ["-L$${libdir}", "-lcapstone"], + cflags = cflags, + )! + out := os.create(filepath.join(pcDir, "capstone.pc"))! + pc.writeTo(out)! + out.close()! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("capstone")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "capstone.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("capstone")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! sourcePath, "-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"))! + if target.require["os"][0] == "windows" { + os.setenv("PATH", filepath.join(installDir, "bin"))! + } + } + exec! binary +} diff --git a/capstone-engine/capstone/5.0.9/capstone_llar.gox b/capstone-engine/capstone/5.0.9/capstone_llar.gox new file mode 100644 index 0000000..b8aeb21 --- /dev/null +++ b/capstone-engine/capstone/5.0.9/capstone_llar.gox @@ -0,0 +1,114 @@ +import ( + "os" + "path/filepath" +) + +const consumerSource = `#include +#include +#include + +int main() { + int major = 0, minor = 0; + cs_version(&major, &minor); + printf("capstone version %d.%d\n", major, minor); + return EXIT_SUCCESS; +} +` + +id "capstone-engine/capstone" + +fromVer "5.0.9" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "use_default_alloc": "ON", +} + +filter => { + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "use_default_alloc" { + return false + } + 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" + useDefaultAlloc := target.options["use_default_alloc"][0] == "ON" + + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "BUILD_STATIC_LIBS", !shared + c.defineBool "BUILD_STATIC_RUNTIME", shared + c.defineBool "CAPSTONE_BUILD_TESTS", false + c.defineBool "CAPSTONE_BUILD_CSTOOL", false + c.defineBool "CAPSTONE_BUILD_CSTEST", false + c.defineBool "CAPSTONE_INSTALL", true + c.defineBool "CAPSTONE_USE_DEFAULT_ALLOC", useDefaultAlloc + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + if target.require["os"][0] == "darwin" { + c.defineBool "CAPSTONE_BUILD_MACOS_THIN", true + } + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE.TXT"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE.TXT"))!, 0o644)! + + cflags := ["-I$${includedir}"] + if shared { + cflags <- "-DCAPSTONE_SHARED" + } + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := pkgconfig.new( + name = "capstone", + description = "Capstone disassembly engine", + version = "5.0.9", + libs = ["-L$${libdir}", "-lcapstone"], + cflags = cflags, + )! + out := os.create(filepath.join(pcDir, "capstone.pc"))! + pc.writeTo(out)! + out.close()! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("capstone")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "capstone.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("capstone")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! sourcePath, "-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"))! + if target.require["os"][0] == "windows" { + os.setenv("PATH", filepath.join(installDir, "bin"))! + } + } + exec! binary +} diff --git a/capstone-engine/capstone/5.0/capstone_llar.gox b/capstone-engine/capstone/5.0/capstone_llar.gox new file mode 100644 index 0000000..821a65a --- /dev/null +++ b/capstone-engine/capstone/5.0/capstone_llar.gox @@ -0,0 +1,109 @@ +import ( + "os" + "path/filepath" +) + +const consumerSource = `#include +#include +#include + +int main() { + int major = 0, minor = 0; + cs_version(&major, &minor); + printf("capstone version %d.%d\n", major, minor); + return EXIT_SUCCESS; +} +` + +id "capstone-engine/capstone" + +fromVer "5.0" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "use_default_alloc": "ON", +} + +filter => { + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "use_default_alloc" { + return false + } + 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" + useDefaultAlloc := target.options["use_default_alloc"][0] == "ON" + + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CAPSTONE_BUILD_TESTS", false + c.defineBool "CAPSTONE_BUILD_CSTOOL", false + c.defineBool "CAPSTONE_BUILD_CSTEST", false + c.defineBool "CAPSTONE_INSTALL", true + c.defineBool "CAPSTONE_USE_DEFAULT_ALLOC", useDefaultAlloc + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE.TXT"), os.readFile(filepath.join(ctx.SourceDir, "LICENSE.TXT"))!, 0o644)! + + cflags := ["-I$${includedir}"] + if shared { + cflags <- "-DCAPSTONE_SHARED" + } + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := pkgconfig.new( + name = "capstone", + description = "Capstone disassembly engine", + version = "5.0", + libs = ["-L$${libdir}", "-lcapstone"], + cflags = cflags, + )! + out := os.create(filepath.join(pcDir, "capstone.pc"))! + pc.writeTo(out)! + out.close()! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("capstone")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "capstone.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("capstone")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! sourcePath, "-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"))! + if target.require["os"][0] == "windows" { + os.setenv("PATH", filepath.join(installDir, "bin"))! + } + } + exec! binary +} diff --git a/capstone-engine/capstone/6.0.0-Alpha1/capstone_llar.gox b/capstone-engine/capstone/6.0.0-Alpha1/capstone_llar.gox new file mode 100644 index 0000000..744eab1 --- /dev/null +++ b/capstone-engine/capstone/6.0.0-Alpha1/capstone_llar.gox @@ -0,0 +1,112 @@ +import ( + "os" + "path/filepath" +) + +const consumerSource = `#include +#include +#include + +int main() { + int major = 0, minor = 0; + cs_version(&major, &minor); + printf("capstone version %d.%d\n", major, minor); + return EXIT_SUCCESS; +} +` + +id "capstone-engine/capstone" + +fromVer "6.0.0-Alpha1" + +defaults { + "shared": "OFF", + "fPIC": "ON", + "use_default_alloc": "ON", +} + +filter => { + for name, values in target.options { + if name != "shared" && name != "fPIC" && name != "use_default_alloc" { + return false + } + 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" + useDefaultAlloc := target.options["use_default_alloc"][0] == "ON" + + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.define "CMAKE_INSTALL_LIBDIR", "lib" + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CAPSTONE_BUILD_STATIC_RUNTIME", shared + c.defineBool "CAPSTONE_BUILD_CSTOOL", false + c.defineBool "CAPSTONE_BUILD_CSTEST", false + c.defineBool "CAPSTONE_INSTALL", true + c.defineBool "CAPSTONE_USE_DEFAULT_ALLOC", useDefaultAlloc + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + if target.require["os"][0] == "darwin" { + c.defineBool "CAPSTONE_BUILD_MACOS_THIN", true + } + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE.TXT"), os.readFile(filepath.join(ctx.SourceDir, "LICENSES", "LICENSE.TXT"))!, 0o644)! + + cflags := ["-I$${includedir}"] + if shared { + cflags <- "-DCAPSTONE_SHARED" + } + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := pkgconfig.new( + name = "capstone", + description = "Capstone disassembly engine", + version = "6.0.0", + libs = ["-L$${libdir}", "-lcapstone"], + cflags = cflags, + )! + out := os.create(filepath.join(pcDir, "capstone.pc"))! + pc.writeTo(out)! + out.close()! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("capstone")! +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, []byte(consumerSource), 0o644)! + + pkgconfig.use installDir + flagsFile := filepath.join(testDir, "capstone.flags") + os.writeFile(flagsFile, []byte(pkgconfig.lookup("capstone")!), 0o644)! + + binary := filepath.join(testDir, "consumer") + cc! sourcePath, "-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"))! + if target.require["os"][0] == "windows" { + os.setenv("PATH", filepath.join(installDir, "bin"))! + } + } + exec! binary +} diff --git a/capstone-engine/capstone/capstone_cmp.gox b/capstone-engine/capstone/capstone_cmp.gox new file mode 100644 index 0000000..5440a98 --- /dev/null +++ b/capstone-engine/capstone/capstone_cmp.gox @@ -0,0 +1,18 @@ +import "strings" + +func normalize(version string) string { + if version == "5.0-post1" { + return "5.0.0.1" + } + for prefix in ["2.0", "2.1", "3.0", "4.0", "5.0"] { + marker := prefix + "-" + if strings.hasPrefix(version, marker) { + return strings.replace(version, marker, prefix+".0~", 1) + } + } + return strings.replace(version, "-", "~", 1) +} + +compareVer (a, b) => { + return gnu.Compare(normalize(a.Version), normalize(b.Version)) +} diff --git a/capstone-engine/capstone/versions.json b/capstone-engine/capstone/versions.json new file mode 100644 index 0000000..4cf806f --- /dev/null +++ b/capstone-engine/capstone/versions.json @@ -0,0 +1,4 @@ +{ + "path": "capstone-engine/capstone", + "deps": {} +}