windows: navigator build (#485)

This commit is contained in:
Michał Majcherski 2019-04-16 10:00:58 +02:00 committed by GitHub
parent 6e7988eea0
commit f8db15856c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 47 deletions

View File

@ -26,13 +26,16 @@ function build-partial() {
//:git-revision `
//compiler/daml-lf-ast/... `
//daml-lf/interface/... `
//language-support/java/bindings/...
//language-support/java/bindings/... `
//navigator/backend/... `
//navigator/frontend/...
bazel shutdown
bazel test `
//daml-lf/interface/... `
//language-support/java/bindings/...
//language-support/java/bindings/... `
//navigator/backend/...
}
function build-full() {
@ -68,6 +71,8 @@ function build-full() {
//ledger/ledger-api-domain/... `
//ledger/ledger-api-server-example `
//ledger-api/rs-grpc-akka/... `
//navigator/backend/... `
//navigator/frontend/... `
//pipeline/samples/bazel/java/... `
//pipeline/samples/bazel/haskell/...
@ -88,6 +93,7 @@ function build-full() {
//ledger/ledger-api-client/... `
//ledger/ledger-api-common/... `
//ledger-api/rs-grpc-akka/... `
//navigator/backend/... `
//pipeline/samples/bazel/java/... `
//pipeline/samples/bazel/haskell/...
}

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@os_info//:os_info.bzl", "is_windows")
filegroup(
name = "src",
@ -42,9 +43,9 @@ nodejs_binary(
entry_point = "webpack/bin/webpack.js",
node_modules = "@navigator_frontend_deps//:node_modules",
# The webpack build step requires almost all of the node_modules dependencies
# data = [
#  ...
# ],
# data = [
# ...
# ],
)
# Builds the frontend single page application and bundles all output files
@ -69,8 +70,10 @@ genrule(
# Working directories
export IN="$$(pwd)/$(@D)/in"
export OUT="$$(pwd)/$(@D)/out"
mkdir "$$IN"
mkdir "$$OUT"
export WP_IN={WP_IN}
export WP_OUT={WP_OUT}
[ -d "$$IN" ] || mkdir "$$IN"
[ -d "$$OUT" ] || mkdir "$$OUT"
# Our tools (node.js, webpack, webpack plugins, typescript) do not work nicely
# with symbolic links and a node_modules directory that is not in the project root.
@ -83,31 +86,36 @@ genrule(
cp -L "$$(pwd)/$(execpath tslint.json)" "$$IN/tslint.json"
cp -L "$$(pwd)/$(execpath declarations.d.ts)" "$$IN/declarations.d.ts"
# Webpack needs the HOME variable to be set
# Webpack needs the HOME variable to be set
export HOME="$$IN"
# Run webpack.
# To debug, add the following options:
# -d --progress --display-error-details --verbose
# -d --progress --display-error-details --verbose
$(execpath :webpack) \
--config="$$IN/webpack.config.js" \
--env.prod \
--env.bazel_in_dir="$$IN" \
--env.bazel_out_dir="$$OUT/frontend"
--env.paths_case_check="{PATHS_CASE_CHECK}" \
--env.bazel_in_dir="$$WP_IN" \
--env.bazel_out_dir="$$WP_OUT/frontend"
# Package result (.TGZ)
# Package result (.TGZ)
# To debug, change 'czf' to 'czfv'.
echo "Packaging result from $$OUT to $(@D)/frontend.tgz"
tar czf "$(@D)/frontend.tgz" -C $$OUT .
# Package result (.JAR)
# Package result (.JAR)
echo "Packaging result from $$OUT to $(@D)/frontend.jar"
$(JAVABASE)/bin/jar c0Mf "$(@D)/frontend.jar" -C $$OUT .
""",
$(location @bazel_tools//tools/jdk:jar) c0Mf "$(@D)/frontend.jar" -C $$OUT .
""".format(
PATHS_CASE_CHECK = "false" if is_windows else "true",
WP_IN = "$$(cygpath -w $$IN)" if is_windows else "$$IN",
WP_OUT = "$$(cygpath -w $$OUT)" if is_windows else "$$OUT",
),
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
tools = [
":webpack",
"@bazel_tools//tools/jdk:current_java_runtime",
"@bazel_tools//tools/jdk:jar",
],
visibility = [
"//navigator:__subpackages__",

View File

@ -51,11 +51,12 @@ const APP_NAME = 'Navigator';
* - paths: https://www.typescriptlang.org/docs/handbook/compiler-options.html
*/
module.exports = (env) => {
const in_dir = env && env.bazel_in_dir || __dirname;
const out_dir = env && env.bazel_out_dir || path.join(__dirname, 'dist');
const build_version = env && env.bazel_version_file ? fs.readFileSync(env.bazel_version_file, 'utf8').trim() : 'HEAD';
const build_commit = env && env.bazel_commit_file ? fs.readFileSync(env.bazel_commit_file, 'utf8').trim() : 'HEAD';
const isProduction = env ? (!!env.prod || !!env.production) : false;
const paths_case_check = env && env.paths_case_check || 'true';
const in_dir = env && env.bazel_in_dir || __dirname;
const out_dir = env && env.bazel_out_dir || path.join(__dirname, 'dist');
const build_version = env && env.bazel_version_file ? fs.readFileSync(env.bazel_version_file, 'utf8').trim() : 'HEAD';
const build_commit = env && env.bazel_commit_file ? fs.readFileSync(env.bazel_commit_file, 'utf8').trim() : 'HEAD';
const isProduction = env ? (!!env.prod || !!env.production) : false;
console.log(isProduction ? 'PRODUCTION' : 'DEVELOPMENT');
const modernizr_config = path.join(in_dir, '.modernizrrc');
@ -67,8 +68,39 @@ module.exports = (env) => {
console.log(` out_dir: ${out_dir}`);
console.log(` modernizr_config: ${modernizr_config}`);
console.log(` typescript_config: ${typescript_config}`);
console.log(` paths_case_check: ${paths_case_check}`);
console.log(`============================== Webpack environment =============================`);
var plugins = [
new HtmlWebpackPlugin({
title: APP_NAME,
template: 'src/index.html'
}),
new FaviconsWebpackPlugin({
logo: './src/images/favicon.png',
prefix: 'icons-[hash]/',
inject: true, // into HtmlWebpackPlugin
background: '#fff',
title: APP_NAME,
icons: {
android: false,
appleIcon: true,
appleStartup: true,
coast: false,
favicons: true,
firefox: true,
opengraph: false,
twitter: false,
yandex: false,
windows: false
}
}),
]
if (paths_case_check === 'true') {
plugins.push(new CaseSensitivePathsPlugin())
}
return {
entry: {
browsercheck: './src/browsercheck.ts',
@ -153,32 +185,7 @@ module.exports = (env) => {
modernizr$: modernizr_config,
}
},
plugins: [
new HtmlWebpackPlugin({
title: APP_NAME,
template: 'src/index.html'
}),
new FaviconsWebpackPlugin({
logo: './src/images/favicon.png',
prefix: 'icons-[hash]/',
inject: true, // into HtmlWebpackPlugin
background: '#fff',
title: APP_NAME,
icons: {
android: false,
appleIcon: true,
appleStartup: true,
coast: false,
favicons: true,
firefox: true,
opengraph: false,
twitter: false,
yandex: false,
windows: false
}
}),
new CaseSensitivePathsPlugin(),
],
plugins: plugins,
devServer: {
port: 8000,
// host: '0.0.0.0', // enable to allow remote computers to connect