Skip to content

Commit

Permalink
Update build procedure on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
krksgbr committed Mar 10, 2020
1 parent 3922b9d commit d6ecd5d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

NODE_BIN = node_modules/.bin
OS=$(shell uname -s)

all:

ifeq ($(OS), Darwin)
all: macos
else
all: linux
endif

all: \
linux: \
clean \
backend \
node_modules
Expand All @@ -10,6 +18,20 @@ all: \
@cp backend/result/bin/gc-core dist
@$(NODE_BIN)/electron-forge make

macos: \
clean \
macos-backend \
node_modules
@mkdir -p dist
@$(NODE_BIN)/parcel build --public-url . src/index.html
@cd backend && cp `stack path --local-install-root`/bin/gc-core ../dist
@$(NODE_BIN)/electron-forge make
node ./macos/collect-backend-deps.js --exe=$(PWD)/dist/gc-core --outdir=$(PWD)/dist


macos-backend:
@cd backend && $(MAKE) macos

node_modules:
@yarn

Expand Down
5 changes: 5 additions & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

clean:
@echo "Cleaning"
@stack clean

stack2nix-output.nix: \
package.yaml \
Expand All @@ -19,3 +20,7 @@ genElm:
@stack run genElm
@sed -i 's/D\.map T\.ProjectId D\.string/D.field "contents" <| D.map T.ProjectId D.string/' ../src/elm/IPC/Decoder.elm
@sed -i 's/encodeProjectId = E\.string << T\.unProjectId/encodeProjectId pId = E.object [ ( "tag", E.string "ProjectId" ), ( "contents", E.string <| T.unProjectId pId ) ]/' ../src/elm/IPC/Encoder.elm

macos: \
clean
@stack build
9 changes: 6 additions & 3 deletions macos/collect-backend-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function getLinks(lib) {
.filter(it => !it.endsWith(":"))
.map(it => it.trim())
.map(it => it.split(" ")[0])
.filter(it => it.includes("/nix/store"));
.filter(it => it !== "")
// .filter(it => it.includes("/nix/store"));
return links;
}

Expand All @@ -44,12 +45,14 @@ function mkInstallNameCmd(link, file) {
)} ${file}`;
}

const done = [];
function gatherLibs(lib, acc = {}) {
if (acc[lib]) {
return acc;
}

const links = getLinks(lib);
done.push(lib);

const basename = path.basename(lib);
const newPath = `${outdir}/${basename}`;
Expand All @@ -63,7 +66,7 @@ function gatherLibs(lib, acc = {}) {
};

return links.reduce((acc, link) => {
const more = gatherLibs(link, acc);
const more = done.includes(link) ? [] : gatherLibs(link, acc);
return {
...acc,
...more
Expand All @@ -72,7 +75,7 @@ function gatherLibs(lib, acc = {}) {
}

const todo = Object.values(gatherLibs(exe));

function rename(link, file) {
const newLink = `@executable_path/${path.basename(link)}`;
const cmd = `install_name_tool -change ${link} ${newLink} ${file}`;
Expand Down

0 comments on commit d6ecd5d

Please sign in to comment.