Skip to content

Commit

Permalink
Revert "Use pre-generated src/gen/web_assets.cc"
Browse files Browse the repository at this point in the history
This reverts commit bd461da.

This is a cheap way to get bionic deb packaging working.  It would
be nice to remove the npm build dependency, but I guess we are not
there yet.
  • Loading branch information
srh committed Mar 31, 2019
1 parent bd461da commit c07c7bc
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 402,122 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ last_tested_versions
/RethinkDB.vcxproj.filters
/RethinkDB.vcxproj.user
/RethinkDB.vcxproj.xml
/precompiled
*.xml
*.iml
/.vscode
22 changes: 19 additions & 3 deletions admin/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ web-assets-watch:
.PHONY: web-assets
web-assets: $(ALL_WEB_ASSETS)

.PHONY: generate-web-assets-cc
generate-web-assets-cc: web-assets
$(TOP)/scripts/compile-web-assets.py $(TOP)/build/web_assets > src/gen/web_assets.cc
ifeq (1,$(USE_PRECOMPILED_WEB_ASSETS))

$(BUILD_ROOT_DIR)/bundle_assets/web_assets.cc: $(PRECOMPILED_DIR)/bundle_assets/web_assets.cc | $(BUILD_ROOT_DIR)/bundle_assets/.
$P CP
cp -f $< $@

else # Don't use precompiled assets

ifeq ($(OS),Windows)
$(BUILD_ROOT_DIR)/bundle_assets/web_%.cc $(BUILD_ROOT_DIR)/bundle_assets/web_%.rc: $(TOP)/scripts/build-web-%-rc.py $(ALL_WEB_ASSETS) | $(BUILD_ROOT_DIR)/bundle_assets/.
$P GENERATE
$(TOP)/scripts/build-web-assets-rc.py $(WEB_ASSETS_BUILD_DIR) $(dir $@)
else
$(BUILD_ROOT_DIR)/bundle_assets/web_assets.cc: $(TOP)/scripts/compile-web-assets.py $(ALL_WEB_ASSETS) | $(BUILD_ROOT_DIR)/bundle_assets/.
$P GENERATE
$(TOP)/scripts/compile-web-assets.py $(WEB_ASSETS_BUILD_DIR) > $@
endif

endif
11 changes: 0 additions & 11 deletions admin/generate.sh

This file was deleted.

27 changes: 25 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ init () {
web_assets_deps="npm coffee browserify bluebird"
required_bin_deps="protoc python"
optional_bin_deps="wget curl"
bin_deps="cxx $required_bin_deps $optional_bin_deps"
bin_deps="cxx $web_assets_deps $required_bin_deps $optional_bin_deps"
all_deps="$bin_deps $all_libs boost"

default_allocator_linux=jemalloc
Expand Down Expand Up @@ -131,12 +131,17 @@ configure_unixlike () {

fi
check_cxx11
check_precompiled_web
for bin in $required_bin_deps; do
require_dep $bin
check_bin $bin
done
for bin in $web_assets_deps; do
require_dep $bin
if $enable_precompiled_web; then
optional_dep $bin
else
require_dep $bin
fi
check_bin $bin
done
check_admin_deps
Expand Down Expand Up @@ -196,6 +201,7 @@ configure_windows () {
var PTHREAD_LIBS
var CROSS_COMPILING 0
var CXX false
var USE_PRECOMPILED_WEB_ASSETS 0
for pkg in protobuf curl v8 zlib re2 openssl gtest boost; do
require_dep $pkg
fetch_lib $pkg
Expand Down Expand Up @@ -273,6 +279,7 @@ read_args () {
arg_sysconfdir=
arg_localstatedir=
custom_allocator=
enable_precompiled_web=
use_ccache=false

while [[ $# -ne 0 ]]; do
Expand Down Expand Up @@ -328,6 +335,8 @@ read_args () {
--with-tcmalloc) $no_arg; set_custom_allocator tcmalloc ;;
--with-jemalloc) $no_arg; set_custom_allocator jemalloc ;;
--with-system-malloc) $no_arg; set_custom_allocator system ;;
--enable-precompiled-web) $no_arg; enable_precompiled_web=true ;;
--disable-precompiled-web) $no_arg; enable_precompiled_web=false ;;
--ccache) $no_arg; use_ccache=true ;;
--prefix) $has_arg; arg_prefix=$arg ;;
--sysconfdir) $has_arg; arg_sysconfdir=$arg ;;
Expand Down Expand Up @@ -402,6 +411,8 @@ EOF
--with-tcmalloc Use TCMalloc
--with-jemalloc Use jemalloc (default on Linux)
--with-system-malloc Use the system malloc (default on OS X)
--enable-precompiled-web
--disable-precompiled-web Use precompiled web assets located in precompiled/web (default: autodetect)
--ccache Speed up the build using ccache
--windows-platform Windows platform: Win32 (32 bit, default) or x64 (64 bit)
EOF
Expand Down Expand Up @@ -1333,6 +1344,18 @@ check_windows_platform () {
fi
}

check_precompiled_web () {
optional "Precompiled web assets"
if [[ -z "$enable_precompiled_web" ]]; then
if test -d precompiled/bundle_assets; then
enable_precompiled_web=true
else
enable_precompiled_web=false
fi
fi
boolvar USE_PRECOMPILED_WEB_ASSETS $enable_precompiled_web
}

# The root of the source tree
root=$(dirname $0)

Expand Down
6 changes: 5 additions & 1 deletion drivers/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ include $(DRIVERS_DIR)/java/build.mk
drivers: js-driver rb-driver py-driver

.PHONY: $(DRIVERS_DIR)/all
$(DRIVERS_DIR)/all: drivers
ifeq (1,$(USE_PRECOMPILED_WEB_ASSETS))
$(DRIVERS_DIR)/all: rb-driver py-driver
else
$(DRIVERS_DIR)/all: drivers
endif
4 changes: 4 additions & 0 deletions mk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Web assets

* `make web-assets`: Build only the web assets.

* If there is a `precompiled/web` folder, the web assets will not be
rebuilt unless the `--disable-precompiled-web` flag is passed to
`./configure`

* The web assets are compiled into the executable. To speed up
development time and avoid rebuilding the executable, the
`--web-static-directory` option can be used. For example:
Expand Down
2 changes: 0 additions & 2 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,3 @@ else
all: $(TOP)/src/all $(TOP)/drivers/all
endif

.PHONY: generate
generate: generate-web-assets-cc
3 changes: 2 additions & 1 deletion mk/packaging.mk
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ $(DIST_DIR)/VERSION.OVERRIDE: FORCE | reset-dist-dir
$P ECHO "> $@"
echo -n $(RETHINKDB_CODE_VERSION) > $@

PRECOMPILED_ASSETS := $(DIST_DIR)/precompiled/proto/rdb_protocol/ql2.pb.h
PRECOMPILED_ASSETS := $(DIST_DIR)/precompiled/bundle_assets/web_assets.cc
PRECOMPILED_ASSETS += $(DIST_DIR)/precompiled/proto/rdb_protocol/ql2.pb.h
PRECOMPILED_ASSETS += $(DIST_DIR)/precompiled/proto/rdb_protocol/ql2.pb.cc

.PRECIOUS: $(PRECOMPILED_ASSETS)
Expand Down
2 changes: 2 additions & 0 deletions mk/paths.mk
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ OBJ_DIR := $(BUILD_DIR)/obj
WEB_ASSETS_DIR_NAME := web_assets
WEB_ASSETS_BUILD_DIR := $(BUILD_ROOT_DIR)/$(WEB_ASSETS_DIR_NAME)

PRECOMPILED_DIR := $(TOP)/precompiled

##### To rebuild when Makefiles change

ifeq ($(IGNORE_MAKEFILE_CHANGES),1)
Expand Down
2 changes: 2 additions & 0 deletions mk/rethinkdb.vcxproj.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@
</ItemDefinitionGroup>

<ItemGroup Condition="'$(Configuration)|$(Platform)'=='{@configuration}|{@platform}'">
<ResourceCompile Include="build\bundle_assets\web_assets.rc" />
<ClCompile Include="build\bundle_assets\web_assets.cc" />
<ClCompile Include="build\proto\rdb_protocol\ql2.pb.cc" />
<ClCompile Include="src\**\*.cc">
<xsl:choose>
Expand Down
6 changes: 4 additions & 2 deletions mk/windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ LIB_DEPS := $(foreach dep, $(FETCH_LIST), $(SUPPORT_BUILD_DIR)/$(dep)_$($(dep)_V

PROTO_DEPS := $(PROTO_DIR)/rdb_protocol/ql2.pb.h $(PROTO_DIR)/rdb_protocol/ql2.pb.cc

WEB_ASSETS_DEPS := $(BUILD_ROOT_DIR)/bundle_assets/web_assets.cc $(BUILD_ROOT_DIR)/bundle_assets/web_assets.rc

MSBUILD_FLAGS := /nologo /maxcpucount
MSBUILD_FLAGS += /p:Configuration=$(CONFIGURATION)
MSBUILD_FLAGS += /p:Platform=$(PLATFORM)
Expand All @@ -35,11 +37,11 @@ ifneq (1,$(VERBOSE))
MSBUILD_FLAGS += /verbosity:minimal
endif

$/build/$(CONFIGURATION)_$(PLATFORM)/rethinkdb.exe: $/rethinkdb.vcxproj $(SOURCES_NOUNIT) $(LIB_DEPS) $(PROTO_DEPS)
$/build/$(CONFIGURATION)_$(PLATFORM)/rethinkdb.exe: $/rethinkdb.vcxproj $(SOURCES_NOUNIT) $(LIB_DEPS) $(PROTO_DEPS) $(WEB_ASSETS_DEPS)
$P MSBUILD
"$(MSBUILD)" $(MSBUILD_FLAGS) $<

$/build/$(CONFIGURATION)_$(PLATFORM)/rethinkdb-unittest.exe: $/rethinkdb-unittest.vcxproj $(SOURCES) $(LIB_DEPS) $(PROTO_DEPS)
$/build/$(CONFIGURATION)_$(PLATFORM)/rethinkdb-unittest.exe: $/rethinkdb-unittest.vcxproj $(SOURCES) $(LIB_DEPS) $(PROTO_DEPS) $(WEB_ASSETS_DEPS)
$P MSBUILD
"$(MSBUILD)" $(MSBUILD_FLAGS) $<

Expand Down
9 changes: 7 additions & 2 deletions src/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ NAMES := $(patsubst $(SOURCE_DIR)/%.cc,%,$(SOURCES))
DEPS := $(patsubst %,$(DEP_DIR)/%$(DEPS_POSTFIX).d,$(NAMES))
OBJS := $(QL2_PROTO_OBJS) $(patsubst %,$(OBJ_DIR)/%.o,$(NAMES))

SERVER_EXEC_OBJS := $(QL2_PROTO_OBJS) $(patsubst $(SOURCE_DIR)/%.cc,$(OBJ_DIR)/%.o,$(SERVER_EXEC_SOURCES))
SERVER_EXEC_OBJS := $(OBJ_DIR)/web_assets/web_assets.o $(QL2_PROTO_OBJS) $(patsubst $(SOURCE_DIR)/%.cc,$(OBJ_DIR)/%.o,$(SERVER_EXEC_SOURCES))

SERVER_NOMAIN_OBJS := $(QL2_PROTO_OBJS) $(patsubst $(SOURCE_DIR)/%.cc,$(OBJ_DIR)/%.o,$(filter-out %/main.cc,$(SOURCES)))
SERVER_NOMAIN_OBJS := $(OBJ_DIR)/web_assets/web_assets.o $(QL2_PROTO_OBJS) $(patsubst $(SOURCE_DIR)/%.cc,$(OBJ_DIR)/%.o,$(filter-out %/main.cc,$(SOURCES)))

SERVER_UNIT_TEST_OBJS := $(SERVER_NOMAIN_OBJS) $(OBJ_DIR)/unittest/main.o

Expand Down Expand Up @@ -368,6 +368,11 @@ $(BUILD_DIR)/$(GDB_FUNCTIONS_NAME): | $(BUILD_DIR)/.
$P CP $@
cp $(SCRIPTS_DIR)/$(GDB_FUNCTIONS_NAME) $@

$(OBJ_DIR)/web_assets/web_assets.o: $(BUILD_ROOT_DIR)/bundle_assets/web_assets.cc $(MAKEFILE_DEPENDENCY)
mkdir -p $(dir $@)
$P CC
$(RT_CXX) $(RT_CXXFLAGS) -c -o $@ $<

$(OBJ_DIR)/%.pb.o: $(PROTO_DIR)/%.pb.cc $(MAKEFILE_DEPENDENCY) $(QL2_PROTO_HEADERS)
mkdir -p $(dir $@)
$P CC
Expand Down
Loading

0 comments on commit c07c7bc

Please sign in to comment.