Skip to content

Commit

Permalink
wip: more progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ManasJayanth committed Jun 1, 2024
1 parent 9683ef2 commit 0dd5836
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 15 deletions.
80 changes: 69 additions & 11 deletions etc/formula.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
require 'json'

def ENV.deparallelize
# After the block returns, you'd restore any environment state changes if necessary.
end


class PlaceholderPath
def initialize(path = "")
@path = path
Expand All @@ -22,6 +27,9 @@ def to_s
end

class OS
def self.linux?(*args)
false
end
def self.mac?
# TODO
false
Expand All @@ -38,10 +46,10 @@ def opt_prefix
end

class Build
def head?
def head?(*args)
false
end
def stable?
def stable?(*args)
true
end
end
Expand Down Expand Up @@ -138,7 +146,7 @@ def self.depends_on(dependency)
self.add_formula(dep, FormulaStub.new(dependency))
end

def self.uses_from_macos(dependency)
def self.uses_from_macos(dependency, *unused)
@uses_from_macos << dependency
self.add_formula(dependency, FormulaStub.new(dependency))
end
Expand Down Expand Up @@ -205,6 +213,9 @@ def system_args
@system_args
end

def std_configure_args
@system_args
end
def std_meson_args
@system_args
end
Expand All @@ -224,16 +235,63 @@ def share
PlaceholderPath.new('#{self.share}')
end

def inreplace(files, old, new, unused)
Array(files).each do |file|
content = File.read(file)
modified_content = content.gsub(old, new)
File.open(file, "w") { |f| f.puts(modified_content) }
rescue => e
# puts "Failed to replace '#{old}' with '#{new}' in #{file}: #{e}"
end
def inreplace(*unused)
""
end

def self.patch(url: nil, sha256: nil, &block)
# If a block is given, you could call it or handle it as needed
block.call if block
end
def etc
# Provide a path for binaries. Adjust the path as required for your setup.
PlaceholderPath.new('#{self.etc}')
end
def bin
# Provide a path for binaries. Adjust the path as required for your setup.
PlaceholderPath.new('#{self.bin}')
end
def doc
# Provide a path for binaries. Adjust the path as required for your setup.
PlaceholderPath.new('#{self.doc}')
end
def elisp
# Provide a path for binaries. Adjust the path as required for your setup.
PlaceholderPath.new('#{self.etc}')
end
def self.revision(_rev=nil)
""
end
def self.pour_bottle?(_rev=nil)
false
end
def self.on_linux(*args)
false
end
def self.skip_clean(*args)
false
end
def self.resource(*args)
false
end
def self.link_overwrite(*args)
false
end
def deparallelize(*args)
# This method is meant to disable parallel build processes.
# Since we're implementing a no-op version, there's nothing to do here.
end
def self.framework(*args)
""
end
def on_macos(&block)
block.call
end
def on_linux(&block)
block.call
end
def keg_only(*args)
end
end

# Define HOMEBREW_PREFIX if it's not already defined
Expand Down
5 changes: 5 additions & 0 deletions etc/language.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module Language
module Python
unless defined?(SHEBANG)
HOMEBREW_PREFIX = "/todo/shebang"
# Adjust "/path/to/your/homebrew/installation" to the appropriate path
# For example, it could be "/usr/local" or something custom.
end
def self.site_packages(unused)
return ""
end
Expand Down
18 changes: 14 additions & 4 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ export async function generate(cwd: path, pkg: string): Promise<void> {
let queue = [pkg];
while (queue.length) {
const pkg = queue.shift();
if (/^python/.test(pkg)) {
continue;
}
Log.info("Generating recipe for %s", pkg);
const generatedManifestName = `${pkg}.json`;
let npmMetaData;
Expand Down Expand Up @@ -319,7 +322,9 @@ require "${etc.print}"
name = "esy-${pkg}"
version = "0.1.0"
pkg = ${Utils.capitalizeFirstLetter(pkg)}.new
pkg = ${Utils.capitalizeFirstLetter(pkg)
.replace("@", "AT")
.replace(".", "")}.new
pkg.install
print_json(name, version, pkg)
`,
Expand All @@ -333,9 +338,14 @@ print_json(name, version, pkg)
const json = JSON.parse(jsonStr);
fs.writeFileSync(`${pkg}.json`, jsonStr);
queue = queue.concat(
(Object.keys(json.override.dependencies) || []).map((dep) =>
dep.replace("esy-", ""),
),
(Object.keys(json.override.dependencies) || [])
.map((dep) =>
dep
.replace(/{[^}]+}/, "")
// .split("@")[0]
.replace("esy-", ""),
)
.filter((a) => a !== ""),
);
} catch (e) {
console.log(e.stdout?.toString());
Expand Down

0 comments on commit 0dd5836

Please sign in to comment.