Skip to content

Commit

Permalink
Stashing more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomberek committed Sep 29, 2023
1 parent 8059a61 commit 6f1cdb5
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endif
include mk/lib.mk

GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++2a -I src \
-isystem /nix/store/9x6jfl84234im3f4gsrl1js3zyqz76jd-nlohmann_json-3.11.2/include \
# -isystem /nix/store/9x6jfl84234im3f4gsrl1js3zyqz76jd-nlohmann_json-3.11.2/include \
# -isystem /nix/store/hl5lsmyf6alwj91nv8kmg2iz1lbnxym9-curl-7.86.0-dev/include \
# -isystem /nix/store/hyxa8plwvgbj16fi2rlvm2sy6idlkab1-libsodium-1.0.18-dev/include \
# -isystem /nix/store/ppqyr8qzdswkswcyb7214y9qg8cr7dnn-sqlite-3.39.4-dev/include \
Expand Down
38 changes: 24 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,8 @@
"-DSQLITE_OMIT_POPEN=1"
];
outputs = [ "out" ];
seperateDebugInfo = false;
separateDebugInfo = false;
checkPhase = ''
mkdir $debug
'';
});

Expand Down Expand Up @@ -546,10 +545,11 @@
export EM_CACHE=$(pwd)/.emscriptencache
emconfigure ./Configure linux-generic64 \
shared \
no-tests \
no-engine no-legacy no-module no-padlockeng no-ssl-trace no-ocsp no-stdio no-sm2 no-sm3 no-sm4 no-blake2 no-chacha no-poly1305 no-aria no-dtls \
--prefix=$out \
--libdir=lib \
--openssldir=etc/ssl \
no-tests
--openssldir=etc/ssl
sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
Expand All @@ -558,14 +558,13 @@
'';

buildPhase = ''
emmake make install_sw
emmake make build_sw
'';
outputs = ["out"];
installPhase = ''
emmake make install
rm -r $out/etc/ssl/misc
rm $out/bin/c_rehash
emmake make install_sw
'';
separateDebugInfo = false;
checkPhase = ''
# echo "================= testing zlib using node ================="
Expand Down Expand Up @@ -597,18 +596,18 @@

nix = stdenv.mkDerivation {
name = "emscripten-nix";
nativeBuildInputs = [ pkg-config autoconf autoreconfHook automake autoconf-archive ];
nativeBuildInputs = [ jq emscripten pkg-config autoconf autoreconfHook automake autoconf-archive ];
buildInputs = [
boost
emscripten nodejs autoconf automake pkgconfig perlPackages.DBDSQLite perl perlPackages.WWWCurl bzip2 zlib libtool bison flex curl git file
pkgconfig bzip2 zlib libtool bison flex curl git file
nlohmann_json
libsodium
lsof
lowdown-nix
editline
libarchive
brotli
jq
# openssl
openssl-wasm
sqlite-wasm
];
Expand All @@ -626,21 +625,32 @@
name = "source";
filter = path: type: ! builtins.elem path [ (self.outPath + "/flake.nix")];
};
# OPENSSL_CFLAGS="-I ${openssl.dev}/include";
# OPENSSL_LIBS="-L${openssl-wasm}/lib -lcrypto";
configurePhase = ''
HOME=$TMPDIR
mkdir -p cache/sysroot/include/bits
mkdir -p cache/sysroot/include/SDL
emconfigure ./configure \
--with-boost=$PWD/src/ports/boost_headers \
--with-boost=${boost.dev}/include \
--disable-cpuid \
--disable-seccomp-sandboxing \
--enable-gc=no \
--disable-tests \
--prefix=$PWD/outputs/out \
--prefix=$out \
--disable-doc-gen
export EMCC_CFLAGS="$NIX_CFLAGS_COMPILE"
'';
buildPhase = ''
emmake make src/nix-instantiate/nix-instantiate.html
make src/libexpr/eval.o
make -j6 src/nix-instantiate/nix-instantiate.html
'';
installPhase = ''
mkdir $out
cp src/nix-instantiate/*.{wasm,js,html} $out
'';
checkPhase = ''
'';
};
};

Expand Down
69 changes: 69 additions & 0 deletions src/nix-instantiate/local.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
programs += nix-instantiate.html

nix-instantiate.html_DIR := $(d)

nix-instantiate.html_SOURCES := \
$(wildcard src/nix-instantiate/*.cc) \
$(wildcard $(d)/*.cc) \
$(wildcard src/libexpr/*.cc) \
$(wildcard src/libexpr/value/*.cc) \
$(wildcard src/libexpr/flake/*.cc) \
$(wildcard src/libexpr/primops/*.cc) \
src/libexpr/lexer-tab.cc \
src/libexpr/parser-tab.cc

# $(wildcard $(d)/*.cc) \
# $(wildcard src/nix-build/*.cc) \
# $(wildcard src/nix-channel/*.cc) \
# $(wildcard src/nix-collect-garbage/*.cc) \
# $(wildcard src/nix-copy-closure/*.cc) \
# $(wildcard src/nix-daemon/*.cc) \
# $(wildcard src/nix-env/*.cc) \
# $(wildcard src/nix-store/*.cc) \
# $(wildcard src/build-remote/*.cc) \
nix-instantiate.html_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libexpr -I src/libmain -I src/libcmd

nix-instantiate.html_LIBS = libexpr libmain libfetchers libstore libutil libcmd

# export EM_PORTS=${PWD}/ports
# export EM_CACHE=${PWD}/cache
# -L/nix/store/0xa20qx51sr70c92sj1hlcb1ya2pxjqm-emscripten-openssl-3.0.9/lib -lcrypto
# $(shell pkg-config --libs openssl)
nix-instantiate.html_LDFLAGS = \
$(shell echo "$(NIX_LDFLAGS)" | cut -f 5- -d' ') \
-lcrypto \
-sNO_EXIT_RUNTIME=1 \
-sALLOW_MEMORY_GROWTH=1 \
-sEXPORTED_RUNTIME_METHODS=cwrap,ccall,UTF8ToString,ptrToString,allocateUTF8,UTF32ToString \
-sEXPORTED_FUNCTIONS=_processExpr,_main_nix_instantiate2
# -sUSE_SQLITE3=1 \
# -sUSE_BOOST_HEADERS=1 \
src/libexpr/parser-tab.cc src/libexpr/parser-tab.hh: src/libexpr/parser.y
$(trace-gen) bison -v -o src/libexpr/parser-tab.cc $< -d

src/libexpr/lexer-tab.cc src/libexpr/lexer-tab.hh: src/libexpr/lexer.l
$(trace-gen) flex --outfile src/libexpr/lexer-tab.cc --header-file=src/libexpr/lexer-tab.hh $<

clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh


$(foreach name, \
nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \
$(eval $(call install-symlink, nix, $(bindir)/$(name))))
$(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote))

src/nix-env/user-env.cc: src/nix-env/buildenv.nix.gen.hh

src/nix/develop.cc: src/nix/get-env.sh.gen.hh

src/nix-channel/nix-channel.cc: src/nix-channel/unpack-channel.nix.gen.hh

src/nix/main.cc: doc/manual/generate-manpage.nix.gen.hh doc/manual/utils.nix.gen.hh

src/nix/doc/files/%.md: doc/manual/src/command-ref/files/%.md
@mkdir -p $$(dirname $@)
@cp $< $@

src/nix/profile.cc: src/nix/profile.md src/nix/doc/files/profiles.md.gen.hh
4 changes: 2 additions & 2 deletions src/nix/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ nix.html_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/li

nix.html_LIBS = libexpr libmain libfetchers libstore libutil libcmd

export EM_PORTS=${PWD}/ports
export EM_CACHE=${PWD}/cache
# export EM_PORTS=${PWD}/ports
# export EM_CACHE=${PWD}/cache
nix.html_LDFLAGS = $(SODIUM_LIBS) $(EDITLINE_LIBS) $(LOWDOWN_LIBS) \
-sERROR_ON_UNDEFINED_SYMBOLS=0 \
-sUSE_SQLITE3=1 \
Expand Down

0 comments on commit 6f1cdb5

Please sign in to comment.